@univerjs-pro/collaboration-comment-service 1.6.1 → 1.6.3

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 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'](_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;
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'](_0x5da568,_0x583c90){let _0x3bef0d=this['_middlewares']['get'](_0x5da568)??[],_0x5ce586=_0x583c90;_0x3bef0d['push'](_0x5ce586),this['_middlewares']['set'](_0x5da568,_0x3bef0d);let _0x5908bc=!0x1;return{'dispose':()=>{if(_0x5908bc)return;_0x5908bc=!0x0;let _0x1bd209=_0x3bef0d['indexOf'](_0x5ce586);_0x1bd209>=0x0&&_0x3bef0d['splice'](_0x1bd209,0x1);}};}async['run'](_0x784c97,_0x3e65f1,_0x171ab2){let _0x65fba8=[...this['_middlewares']['get'](_0x784c97)??[]],_0x1e6306=async _0x5780c3=>{let _0x5fcfdb=_0x65fba8[_0x5780c3];if(!_0x5fcfdb)return _0x171ab2();let _0x4c95f4=!0x1,_0x237ee4,_0x55ee0c=()=>{if(_0x4c95f4)throw Error('Middleware\x20for\x20action\x20'+_0x784c97+'\x20called\x20next()\x20more\x20than\x20once');return _0x4c95f4=!0x0,_0x237ee4=_0x1e6306(_0x5780c3+0x1),_0x237ee4;};try{await _0x5fcfdb(_0x3e65f1,_0x55ee0c);}catch(_0x18229b){throw _0x237ee4&&await _0x237ee4['catch'](()=>void 0x0),_0x18229b;}if(!_0x4c95f4)throw Error('Middleware\x20for\x20action\x20'+_0x784c97+'\x20completed\x20without\x20calling\x20next()');await _0x237ee4;};await _0x1e6306(0x0);}['clear'](){this['_middlewares']['clear']();}},i=class{['_middleware']=new r();['_listeners']=new Map();['_calls']=new Set();['_database'];['_userProvider'];['_state']='running';['_disposePromise'];constructor(_0x365cb1){if(!_0x365cb1?.['database'])throw TypeError('UniverCommentService\x20requires\x20a\x20database');this['_database']=_0x365cb1['database'],this['_userProvider']=_0x365cb1['userProvider'];}['use'](_0x508047,_0x11305f){return this['_assertRunning'](),this['_middleware']['use'](_0x508047,_0x11305f);}['on'](_0x435b18,_0x55dfa9){this['_assertRunning']();let _0x41cf62=this['_listeners']['get'](_0x435b18)??new Set(),_0x1a6a9b=_0x55dfa9;_0x41cf62['add'](_0x1a6a9b),this['_listeners']['set'](_0x435b18,_0x41cf62);let _0x1464ff=!0x1;return{'dispose':()=>{_0x1464ff||(_0x1464ff=!0x0,_0x41cf62['delete'](_0x1a6a9b));}};}['addComment'](_0x868514,_0x53f733){return this['_call'](async()=>{let _0x38b709=s(_0x53f733);m(_0x868514['unitID']),h(_0x868514['content']);let _0x419c41=a(_0x868514),_0x1821b3={..._0x38b709,'request':_0x419c41},_0x43f80d;return await this['_middleware']['run']('addComment',_0x1821b3,async()=>{let _0xf47ecc=await this['_databaseCall'](()=>this['_database']['createRoot']({'unitID':_0x868514['unitID'],'threadID':(0x0,e['randomUUID'])(),'authorUserID':_0x38b709['userID'],'content':_0x868514['content'],'mentions':[..._0x868514['mentions']]},_0x1821b3));if(_0xf47ecc['status']==='duplicate')throw _('Comment\x20ID\x20already\x20exists');_0x43f80d=u([_0xf47ecc['record']]),await this['_emitWrite'](_0x38b709,_0x419c41,await this['_createUpdate'](n['CommentUpdateEventType']['Add'],_0xf47ecc['record'],_0x38b709,_0x419c41));}),_0x43f80d;});}['listComments'](_0x158460,_0x1811d0){return this['_call'](async()=>{let _0x3f722f=o(_0x1811d0);m(_0x158460['unitID']),_0x158460['threadIDs']['forEach'](_0x5ec801=>g('threadID',_0x5ec801));let _0x460126=a(_0x158460),_0x22c5f6={..._0x3f722f,'request':_0x460126},_0x5ec463;return await this['_middleware']['run']('listComments',_0x22c5f6,async()=>{let _0xd04056=d(await this['_databaseCall'](()=>this['_database']['listThreads']({'unitID':_0x158460['unitID'],'threadIDs':[...new Set(_0x158460['threadIDs'])]},_0x22c5f6))),_0x27e674=Object['values'](_0xd04056)['flatMap'](_0x2971dd=>_0x2971dd['replies']['map'](_0x2928c3=>_0x2928c3['userId']));_0x5ec463={'comments':_0xd04056,'users':await this['_resolveUsers'](_0x27e674,_0x3f722f,_0x460126)};}),_0x5ec463;});}['replyComment'](_0x51f33b,_0x5304bc){return this['_call'](async()=>{let _0x42e0fd=s(_0x5304bc);m(_0x51f33b['unitID']),g('threadID',_0x51f33b['threadID']),h(_0x51f33b['content']);let _0xd97fb7=a(_0x51f33b),_0x37e97f={..._0x42e0fd,'request':_0xd97fb7},_0x3b35d1;return await this['_middleware']['run']('replyComment',_0x37e97f,async()=>{let _0x5cea11=await this['_databaseCall'](()=>this['_database']['createReply']({'unitID':_0x51f33b['unitID'],'threadID':_0x51f33b['threadID'],'replyID':(0x0,e['randomUUID'])(),'authorUserID':_0x42e0fd['userID'],'content':_0x51f33b['content'],'mentions':[..._0x51f33b['mentions']]},_0x37e97f));if(_0x5cea11['status']==='not-found'||_0x5cea11['status']==='closed')throw v('Open\x20Comment\x20thread\x20was\x20not\x20found');if(_0x5cea11['status']==='duplicate')throw _('Comment\x20ID\x20already\x20exists');_0x3b35d1=l(_0x5cea11['record']),await this['_emitWrite'](_0x42e0fd,_0xd97fb7,await this['_createUpdate'](n['CommentUpdateEventType']['Reply'],_0x5cea11['record'],_0x42e0fd,_0xd97fb7));}),_0x3b35d1;});}['editComment'](_0x2dc533,_0x4077f9){return this['_call'](async()=>{let _0x2d3ff8=s(_0x4077f9);p(_0x2dc533),h(_0x2dc533['content']);let _0x522a60=a(_0x2dc533),_0x1be0c1={..._0x2d3ff8,'request':_0x522a60};await this['_middleware']['run']('editComment',_0x1be0c1,async()=>{let _0x5c1b93=await this['_databaseCall'](()=>this['_database']['editComment']({'unitID':_0x2dc533['unitID'],'threadID':_0x2dc533['threadID'],'replyID':_0x2dc533['replyID'],'expectedAuthorUserID':_0x2d3ff8['userID'],'content':_0x2dc533['content'],'mentions':[..._0x2dc533['mentions']]},_0x1be0c1));if(_0x5c1b93['status']==='author-mismatch')throw y('Only\x20the\x20Comment\x20author\x20can\x20edit\x20it');if(_0x5c1b93['status']==='not-found'||_0x5c1b93['status']==='closed')throw v('Open\x20Comment\x20was\x20not\x20found');_0x5c1b93['status']==='edited'&&await this['_emitWrite'](_0x2d3ff8,_0x522a60,f(n['CommentUpdateEventType']['Edit'],_0x5c1b93['record'],_0x2d3ff8));});});}['setThreadSolved'](_0x1d7e06,_0x7b3335){return this['_call'](async()=>{let _0x51d775=s(_0x7b3335);if(m(_0x1d7e06['unitID']),g('threadID',_0x1d7e06['threadID']),_0x1d7e06['solved']!==n['CommentSolvedStatus']['OpenOrReOpen']&&_0x1d7e06['solved']!==n['CommentSolvedStatus']['Solved'])throw _('solved\x20must\x20be\x20OpenOrReOpen\x20or\x20Solved');let _0x21d058=a(_0x1d7e06),_0x59b4bd={..._0x51d775,'request':_0x21d058};await this['_middleware']['run']('setThreadSolved',_0x59b4bd,async()=>{let _0x1c2135=await this['_databaseCall'](()=>this['_database']['setThreadSolved'](_0x1d7e06,_0x59b4bd));if(_0x1c2135['status']==='not-found')throw v('Comment\x20thread\x20was\x20not\x20found');_0x1c2135['status']==='updated'&&await this['_emitWrite'](_0x51d775,_0x21d058,{'memberId':_0x51d775['memberID'],'userId':_0x51d775['userID'],'unitId':_0x1d7e06['unitID'],'threadId':_0x1d7e06['threadID'],'type':n['CommentUpdateEventType']['Solve'],'solved':_0x1d7e06['solved']});});});}['deleteComment'](_0x2275a4,_0x1f2bad){return this['_call'](async()=>{let _0x2805ae=s(_0x1f2bad);m(_0x2275a4['unitID']),g('threadID',_0x2275a4['threadID']),_0x2275a4['replyID']!==void 0x0&&g('replyID',_0x2275a4['replyID']);let _0x19a4b7=_0x2275a4['replyID']===_0x2275a4['threadID']?void 0x0:_0x2275a4['replyID'],_0x272a3f=a({'unitID':_0x2275a4['unitID'],'threadID':_0x2275a4['threadID'],..._0x19a4b7===void 0x0?{}:{'replyID':_0x19a4b7}}),_0x4f212d={..._0x2805ae,'request':_0x272a3f},_0x3c4b34=await this['_databaseCall'](()=>this['_database']['getComment']({'unitID':_0x2275a4['unitID'],'threadID':_0x2275a4['threadID'],'replyID':_0x19a4b7??_0x2275a4['threadID']},_0x4f212d));if(!_0x3c4b34)throw v('Comment\x20was\x20not\x20found');await this['_middleware']['run']('deleteComment',{..._0x4f212d,'request':_0x272a3f,'target':{'kind':_0x19a4b7===void 0x0?'root':'reply','threadID':_0x3c4b34['threadID'],'replyID':_0x3c4b34['replyID'],'authorUserID':_0x3c4b34['authorUserID'],'generation':_0x3c4b34['generation']}},async()=>{let _0x583923=await this['_databaseCall'](()=>this['_database']['deleteComment']({'unitID':_0x2275a4['unitID'],'threadID':_0x2275a4['threadID'],..._0x19a4b7===void 0x0?{}:{'replyID':_0x19a4b7},'expectedGeneration':_0x3c4b34['generation']},_0x4f212d));if(_0x583923['status']==='not-found')throw v('Comment\x20was\x20not\x20found');if(_0x583923['status']==='generation-mismatch')throw _('Comment\x20changed\x20before\x20deletion');await this['_emitWrite'](_0x2805ae,_0x272a3f,{'memberId':_0x2805ae['memberID'],'userId':_0x2805ae['userID'],'unitId':_0x2275a4['unitID'],'threadId':_0x2275a4['threadID'],'type':n['CommentUpdateEventType']['Delete'],..._0x19a4b7===void 0x0?{}:{'replyId':_0x19a4b7}});});});}['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'](_0x19f68c,_0x218408,_0x1c0e23,_0x5c8618){let _0x40afac=await this['_resolveUsers']([_0x218408['authorUserID']],_0x1c0e23,_0x5c8618);return{...f(_0x19f68c,_0x218408,_0x1c0e23),..._0x40afac[_0x218408['authorUserID']]?{'user':_0x40afac[_0x218408['authorUserID']]}:{}};}async['_resolveUsers'](_0x2e703d,_0x3a6813,_0xf6c823){let _0x37c7e7=[...new Set(_0x2e703d['filter'](Boolean))];if(!this['_userProvider']||_0x37c7e7['length']===0x0)return{};let _0x55d27b;try{_0x55d27b=await this['_userProvider']['getUsers'](_0x37c7e7,{..._0x3a6813,'request':_0xf6c823});}catch{return{};}let _0xb7886c=new Set(_0x37c7e7),_0x10dfff={};for(let _0xfec6df of _0x55d27b)_0xfec6df?.['userID']&&_0xb7886c['has'](_0xfec6df['userID'])&&(_0x10dfff[_0xfec6df['userID']]=_0xfec6df);return _0x10dfff;}async['_emitWrite'](_0x1e913c,_0x1b116f,_0x3068ab){let _0x12cb4d={'userID':_0x1e913c['userID'],'memberID':_0x1e913c['memberID'],'customData':_0x1e913c['customData'],'request':_0x1b116f,'update':_0x3068ab,'committedAt':Date['now']()};for(let _0x678e56 of[...this['_listeners']['get']('commentCommitted')??[]])try{await _0x678e56(_0x12cb4d);}catch{}}['_call'](_0x21f32b){this['_assertRunning']();let _0x31f2d0=_0x21f32b();return this['_calls']['add'](_0x31f2d0),_0x31f2d0['finally'](()=>this['_calls']['delete'](_0x31f2d0))['catch'](()=>void 0x0),_0x31f2d0;}async['_databaseCall'](_0x14b01c){try{return await _0x14b01c();}catch(_0x464e17){throw _0x464e17 instanceof t['CollabError']?_0x464e17:new t['CollabError']('ADAPTER_FAILURE','Comment\x20Database\x20Adapter\x20failed',{'retryable':!0x0,'cause':_0x464e17});}}['_assertRunning'](){if(this['_state']!=='running')throw new t['CollabError']('INTERNAL_ERROR','Comment\x20Service\x20is\x20'+this['_state'],{'retryable':!0x0});}};function a(_0x216eab){return{..._0x216eab};}function o(_0xd4c7c0){return c(_0xd4c7c0),{'userID':_0xd4c7c0['userID'],'customData':_0xd4c7c0['customData']??Object['create'](null)};}function s(_0x59f371){return c(_0x59f371),g('memberID',_0x59f371['memberID']),{'userID':_0x59f371['userID'],'memberID':_0x59f371['memberID'],'customData':_0x59f371['customData']??Object['create'](null)};}function c(_0x2c22e8){if(!_0x2c22e8||typeof _0x2c22e8!='object')throw _('context\x20must\x20be\x20an\x20object');if(g('userID',_0x2c22e8['userID']),_0x2c22e8['customData']!==void 0x0&&(_0x2c22e8['customData']===null||typeof _0x2c22e8['customData']!='object'||Array['isArray'](_0x2c22e8['customData'])))throw _('customData\x20must\x20be\x20an\x20object');}function l(_0x1fe8a8){return{'threadId':_0x1fe8a8['threadID'],'replyId':_0x1fe8a8['replyID'],'content':_0x1fe8a8['content'],'userId':_0x1fe8a8['authorUserID'],'createTimestamp':_0x1fe8a8['createdAt']};}function u(_0x11f12c){let _0xdb6e13=_0x11f12c['find'](_0x5de0f0=>_0x5de0f0['replyID']===_0x5de0f0['threadID']);return{'threadId':_0xdb6e13['threadID'],'solved':_0xdb6e13['solved'],'replies':_0x11f12c['map'](l)};}function d(_0x5a44e6){let _0x1e7bb5=new Map();for(let _0x5c42c6 of _0x5a44e6){let _0x40e191=_0x1e7bb5['get'](_0x5c42c6['threadID'])??[];_0x40e191['push'](_0x5c42c6),_0x1e7bb5['set'](_0x5c42c6['threadID'],_0x40e191);}let _0x2b9794={};for(let [_0x3abc7a,_0x4e9312]of _0x1e7bb5)_0x4e9312['find'](_0x4ad003=>_0x4ad003['replyID']===_0x3abc7a)&&(_0x2b9794[_0x3abc7a]=u([..._0x4e9312]['sort']((_0x3aa2af,_0x330903)=>_0x3aa2af['replyID']===_0x3abc7a?-0x1:_0x330903['replyID']===_0x3abc7a?0x1:_0x3aa2af['createdAt']-_0x330903['createdAt']||_0x3aa2af['replyID']['localeCompare'](_0x330903['replyID']))));return _0x2b9794;}function f(_0x4a91fd,_0x3827f2,_0xb488b5){return{'memberId':_0xb488b5['memberID'],'userId':_0xb488b5['userID'],'unitId':_0x3827f2['unitID'],'threadId':_0x3827f2['threadID'],'type':_0x4a91fd,'replyId':_0x3827f2['replyID'],'content':_0x3827f2['content'],'createTimestamp':String(_0x3827f2['createdAt'])};}function p(_0xe39242){m(_0xe39242['unitID']),g('threadID',_0xe39242['threadID']),g('replyID',_0xe39242['replyID']);}function m(_0x31827c){g('unitID',_0x31827c);}function h(_0x245591){if(typeof _0x245591!='string'||_0x245591['length']===0x0)throw _('content\x20must\x20be\x20a\x20non-empty\x20string');}function g(_0x2fb5de,_0x76762b){if(typeof _0x76762b!='string'||_0x76762b['length']===0x0)throw _(_0x2fb5de+'\x20must\x20be\x20a\x20non-empty\x20string');}function _(_0x5af901){return new t['CollabError']('INVALID_REQUEST',_0x5af901);}function v(_0x5de22e){return new t['CollabError']('UNIT_NOT_FOUND',_0x5de22e);}function y(_0x35c6ac){return new t['CollabError']('PERMISSION_DENIED',_0x35c6ac);}exports['UniverCommentService']=i;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
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};
1
+ const _0x2881d8=_0x713e;(function(_0x1b6f2d,_0x59f1f8){const _0x508bde=_0x713e,_0x5f15b1=_0x1b6f2d();while(!![]){try{const _0x12a3e3=parseInt(_0x508bde(0x1ea))/0x1+parseInt(_0x508bde(0x1e5))/0x2*(parseInt(_0x508bde(0x1ed))/0x3)+-parseInt(_0x508bde(0x1e8))/0x4*(parseInt(_0x508bde(0x1eb))/0x5)+-parseInt(_0x508bde(0x1f0))/0x6*(parseInt(_0x508bde(0x1e6))/0x7)+-parseInt(_0x508bde(0x1ec))/0x8+parseInt(_0x508bde(0x1ee))/0x9+-parseInt(_0x508bde(0x1e7))/0xa*(-parseInt(_0x508bde(0x1e9))/0xb);if(_0x12a3e3===_0x59f1f8)break;else _0x5f15b1['push'](_0x5f15b1['shift']());}catch(_0x5443ba){_0x5f15b1['push'](_0x5f15b1['shift']());}}}(_0x4147,0x4a431));import _0x1cab5a from'./index.cjs';function _0x4147(){const _0x2ad618=['192521epkYgk','10DjbFaD','2327160IjVxpL','3cxDYjH','3099213MTnmih','UniverCommentService','18RHbvHE','765002pgxHSo','1050903LqGrtm','60VQQIFJ','585836ShPlKR','768163wZQnSQ'];_0x4147=function(){return _0x2ad618;};return _0x4147();}function _0x713e(_0x4c4185,_0xae5c4a){_0x4c4185=_0x4c4185-0x1e5;const _0x414765=_0x4147();let _0x713e08=_0x414765[_0x4c4185];return _0x713e08;}const facadeExport0=_0x1cab5a[_0x2881d8(0x1ef)];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.6.1",
4
+ "version": "1.6.3",
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.6.1",
20
- "@univerjs/protocol": "1.6.1"
19
+ "@univerjs-pro/collaboration-service": "1.6.3",
20
+ "@univerjs/protocol": "1.6.3"
21
21
  }
22
22
  }