@univerjs-pro/collaboration-comment-service 1.6.1 → 1.6.2
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'](_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'](_0x118b6e,_0x5e62e1){let _0x563dc0=this['_middlewares']['get'](_0x118b6e)??[],_0x4e7edc=_0x5e62e1;_0x563dc0['push'](_0x4e7edc),this['_middlewares']['set'](_0x118b6e,_0x563dc0);let _0x5ec6fb=!0x1;return{'dispose':()=>{if(_0x5ec6fb)return;_0x5ec6fb=!0x0;let _0x3770fa=_0x563dc0['indexOf'](_0x4e7edc);_0x3770fa>=0x0&&_0x563dc0['splice'](_0x3770fa,0x1);}};}async['run'](_0x1324a7,_0x2895c8,_0x2f1965){let _0x4b4b4b=[...this['_middlewares']['get'](_0x1324a7)??[]],_0x5e0dc4=async _0x1b7d0e=>{let _0x3d3e8b=_0x4b4b4b[_0x1b7d0e];if(!_0x3d3e8b)return _0x2f1965();let _0x1ed93a=!0x1,_0x5cbbe9,_0x3c2454=()=>{if(_0x1ed93a)throw Error('Middleware\x20for\x20action\x20'+_0x1324a7+'\x20called\x20next()\x20more\x20than\x20once');return _0x1ed93a=!0x0,_0x5cbbe9=_0x5e0dc4(_0x1b7d0e+0x1),_0x5cbbe9;};try{await _0x3d3e8b(_0x2895c8,_0x3c2454);}catch(_0x5c3757){throw _0x5cbbe9&&await _0x5cbbe9['catch'](()=>void 0x0),_0x5c3757;}if(!_0x1ed93a)throw Error('Middleware\x20for\x20action\x20'+_0x1324a7+'\x20completed\x20without\x20calling\x20next()');await _0x5cbbe9;};await _0x5e0dc4(0x0);}['clear'](){this['_middlewares']['clear']();}},i=class{['_middleware']=new r();['_listeners']=new Map();['_calls']=new Set();['_database'];['_userProvider'];['_state']='running';['_disposePromise'];constructor(_0x5b1363){if(!_0x5b1363?.['database'])throw TypeError('UniverCommentService\x20requires\x20a\x20database');this['_database']=_0x5b1363['database'],this['_userProvider']=_0x5b1363['userProvider'];}['use'](_0x3cbccf,_0x5c6a39){return this['_assertRunning'](),this['_middleware']['use'](_0x3cbccf,_0x5c6a39);}['on'](_0x22a703,_0x82a2e4){this['_assertRunning']();let _0x8fd86d=this['_listeners']['get'](_0x22a703)??new Set(),_0x516d22=_0x82a2e4;_0x8fd86d['add'](_0x516d22),this['_listeners']['set'](_0x22a703,_0x8fd86d);let _0x4153a0=!0x1;return{'dispose':()=>{_0x4153a0||(_0x4153a0=!0x0,_0x8fd86d['delete'](_0x516d22));}};}['addComment'](_0x2b1009,_0x2747e1){return this['_call'](async()=>{let _0x590dac=s(_0x2747e1);m(_0x2b1009['unitID']),h(_0x2b1009['content']);let _0x24f6b2=a(_0x2b1009),_0x16e912={..._0x590dac,'request':_0x24f6b2},_0x398d33;return await this['_middleware']['run']('addComment',_0x16e912,async()=>{let _0x276edf=await this['_databaseCall'](()=>this['_database']['createRoot']({'unitID':_0x2b1009['unitID'],'threadID':(0x0,e['randomUUID'])(),'authorUserID':_0x590dac['userID'],'content':_0x2b1009['content'],'mentions':[..._0x2b1009['mentions']]},_0x16e912));if(_0x276edf['status']==='duplicate')throw _('Comment\x20ID\x20already\x20exists');_0x398d33=u([_0x276edf['record']]),await this['_emitWrite'](_0x590dac,_0x24f6b2,await this['_createUpdate'](n['CommentUpdateEventType']['Add'],_0x276edf['record'],_0x590dac,_0x24f6b2));}),_0x398d33;});}['listComments'](_0x4b97f9,_0x548df6){return this['_call'](async()=>{let _0xf3f32f=o(_0x548df6);m(_0x4b97f9['unitID']),_0x4b97f9['threadIDs']['forEach'](_0x11f238=>g('threadID',_0x11f238));let _0x1d4188=a(_0x4b97f9),_0x212ed1={..._0xf3f32f,'request':_0x1d4188},_0x3625db;return await this['_middleware']['run']('listComments',_0x212ed1,async()=>{let _0x50c663=d(await this['_databaseCall'](()=>this['_database']['listThreads']({'unitID':_0x4b97f9['unitID'],'threadIDs':[...new Set(_0x4b97f9['threadIDs'])]},_0x212ed1))),_0x273b35=Object['values'](_0x50c663)['flatMap'](_0x244100=>_0x244100['replies']['map'](_0x16aa0e=>_0x16aa0e['userId']));_0x3625db={'comments':_0x50c663,'users':await this['_resolveUsers'](_0x273b35,_0xf3f32f,_0x1d4188)};}),_0x3625db;});}['replyComment'](_0x24b681,_0x54da21){return this['_call'](async()=>{let _0x50a1c1=s(_0x54da21);m(_0x24b681['unitID']),g('threadID',_0x24b681['threadID']),h(_0x24b681['content']);let _0x1b2e92=a(_0x24b681),_0x46a5fa={..._0x50a1c1,'request':_0x1b2e92},_0x10b92c;return await this['_middleware']['run']('replyComment',_0x46a5fa,async()=>{let _0x5c3f27=await this['_databaseCall'](()=>this['_database']['createReply']({'unitID':_0x24b681['unitID'],'threadID':_0x24b681['threadID'],'replyID':(0x0,e['randomUUID'])(),'authorUserID':_0x50a1c1['userID'],'content':_0x24b681['content'],'mentions':[..._0x24b681['mentions']]},_0x46a5fa));if(_0x5c3f27['status']==='not-found'||_0x5c3f27['status']==='closed')throw v('Open\x20Comment\x20thread\x20was\x20not\x20found');if(_0x5c3f27['status']==='duplicate')throw _('Comment\x20ID\x20already\x20exists');_0x10b92c=l(_0x5c3f27['record']),await this['_emitWrite'](_0x50a1c1,_0x1b2e92,await this['_createUpdate'](n['CommentUpdateEventType']['Reply'],_0x5c3f27['record'],_0x50a1c1,_0x1b2e92));}),_0x10b92c;});}['editComment'](_0x15fa53,_0x3f88f3){return this['_call'](async()=>{let _0x38ba0a=s(_0x3f88f3);p(_0x15fa53),h(_0x15fa53['content']);let _0x19922d=a(_0x15fa53),_0x9a6f3b={..._0x38ba0a,'request':_0x19922d};await this['_middleware']['run']('editComment',_0x9a6f3b,async()=>{let _0x31bd8f=await this['_databaseCall'](()=>this['_database']['editComment']({'unitID':_0x15fa53['unitID'],'threadID':_0x15fa53['threadID'],'replyID':_0x15fa53['replyID'],'expectedAuthorUserID':_0x38ba0a['userID'],'content':_0x15fa53['content'],'mentions':[..._0x15fa53['mentions']]},_0x9a6f3b));if(_0x31bd8f['status']==='author-mismatch')throw y('Only\x20the\x20Comment\x20author\x20can\x20edit\x20it');if(_0x31bd8f['status']==='not-found'||_0x31bd8f['status']==='closed')throw v('Open\x20Comment\x20was\x20not\x20found');_0x31bd8f['status']==='edited'&&await this['_emitWrite'](_0x38ba0a,_0x19922d,f(n['CommentUpdateEventType']['Edit'],_0x31bd8f['record'],_0x38ba0a));});});}['setThreadSolved'](_0xd1a475,_0x1db4d8){return this['_call'](async()=>{let _0x478fe8=s(_0x1db4d8);if(m(_0xd1a475['unitID']),g('threadID',_0xd1a475['threadID']),_0xd1a475['solved']!==n['CommentSolvedStatus']['OpenOrReOpen']&&_0xd1a475['solved']!==n['CommentSolvedStatus']['Solved'])throw _('solved\x20must\x20be\x20OpenOrReOpen\x20or\x20Solved');let _0xac696b=a(_0xd1a475),_0x57e627={..._0x478fe8,'request':_0xac696b};await this['_middleware']['run']('setThreadSolved',_0x57e627,async()=>{let _0x11607c=await this['_databaseCall'](()=>this['_database']['setThreadSolved'](_0xd1a475,_0x57e627));if(_0x11607c['status']==='not-found')throw v('Comment\x20thread\x20was\x20not\x20found');_0x11607c['status']==='updated'&&await this['_emitWrite'](_0x478fe8,_0xac696b,{'memberId':_0x478fe8['memberID'],'userId':_0x478fe8['userID'],'unitId':_0xd1a475['unitID'],'threadId':_0xd1a475['threadID'],'type':n['CommentUpdateEventType']['Solve'],'solved':_0xd1a475['solved']});});});}['deleteComment'](_0x4c206e,_0xdca9c5){return this['_call'](async()=>{let _0x381939=s(_0xdca9c5);m(_0x4c206e['unitID']),g('threadID',_0x4c206e['threadID']),_0x4c206e['replyID']!==void 0x0&&g('replyID',_0x4c206e['replyID']);let _0x2567a7=_0x4c206e['replyID']===_0x4c206e['threadID']?void 0x0:_0x4c206e['replyID'],_0x1717e3=a({'unitID':_0x4c206e['unitID'],'threadID':_0x4c206e['threadID'],..._0x2567a7===void 0x0?{}:{'replyID':_0x2567a7}}),_0x159409={..._0x381939,'request':_0x1717e3},_0x220627=await this['_databaseCall'](()=>this['_database']['getComment']({'unitID':_0x4c206e['unitID'],'threadID':_0x4c206e['threadID'],'replyID':_0x2567a7??_0x4c206e['threadID']},_0x159409));if(!_0x220627)throw v('Comment\x20was\x20not\x20found');await this['_middleware']['run']('deleteComment',{..._0x159409,'request':_0x1717e3,'target':{'kind':_0x2567a7===void 0x0?'root':'reply','threadID':_0x220627['threadID'],'replyID':_0x220627['replyID'],'authorUserID':_0x220627['authorUserID'],'generation':_0x220627['generation']}},async()=>{let _0x12c2b5=await this['_databaseCall'](()=>this['_database']['deleteComment']({'unitID':_0x4c206e['unitID'],'threadID':_0x4c206e['threadID'],..._0x2567a7===void 0x0?{}:{'replyID':_0x2567a7},'expectedGeneration':_0x220627['generation']},_0x159409));if(_0x12c2b5['status']==='not-found')throw v('Comment\x20was\x20not\x20found');if(_0x12c2b5['status']==='generation-mismatch')throw _('Comment\x20changed\x20before\x20deletion');await this['_emitWrite'](_0x381939,_0x1717e3,{'memberId':_0x381939['memberID'],'userId':_0x381939['userID'],'unitId':_0x4c206e['unitID'],'threadId':_0x4c206e['threadID'],'type':n['CommentUpdateEventType']['Delete'],..._0x2567a7===void 0x0?{}:{'replyId':_0x2567a7}});});});}['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'](_0x19ae7b,_0x12ab30,_0x33fa80,_0x163f9d){let _0x180a23=await this['_resolveUsers']([_0x12ab30['authorUserID']],_0x33fa80,_0x163f9d);return{...f(_0x19ae7b,_0x12ab30,_0x33fa80),..._0x180a23[_0x12ab30['authorUserID']]?{'user':_0x180a23[_0x12ab30['authorUserID']]}:{}};}async['_resolveUsers'](_0x7f9ff0,_0x781ba2,_0x58fba1){let _0x34ef33=[...new Set(_0x7f9ff0['filter'](Boolean))];if(!this['_userProvider']||_0x34ef33['length']===0x0)return{};let _0x1258d2;try{_0x1258d2=await this['_userProvider']['getUsers'](_0x34ef33,{..._0x781ba2,'request':_0x58fba1});}catch{return{};}let _0x2ddf97=new Set(_0x34ef33),_0x50d40c={};for(let _0x17db8e of _0x1258d2)_0x17db8e?.['userID']&&_0x2ddf97['has'](_0x17db8e['userID'])&&(_0x50d40c[_0x17db8e['userID']]=_0x17db8e);return _0x50d40c;}async['_emitWrite'](_0x1d2c46,_0xa89444,_0x9aac19){let _0x3fab9b={'userID':_0x1d2c46['userID'],'memberID':_0x1d2c46['memberID'],'customData':_0x1d2c46['customData'],'request':_0xa89444,'update':_0x9aac19,'committedAt':Date['now']()};for(let _0x49cd8b of[...this['_listeners']['get']('commentCommitted')??[]])try{await _0x49cd8b(_0x3fab9b);}catch{}}['_call'](_0x1e9d55){this['_assertRunning']();let _0x59cd17=_0x1e9d55();return this['_calls']['add'](_0x59cd17),_0x59cd17['finally'](()=>this['_calls']['delete'](_0x59cd17))['catch'](()=>void 0x0),_0x59cd17;}async['_databaseCall'](_0x1e4e31){try{return await _0x1e4e31();}catch(_0x3380a3){throw _0x3380a3 instanceof t['CollabError']?_0x3380a3:new t['CollabError']('ADAPTER_FAILURE','Comment\x20Database\x20Adapter\x20failed',{'retryable':!0x0,'cause':_0x3380a3});}}['_assertRunning'](){if(this['_state']!=='running')throw new t['CollabError']('INTERNAL_ERROR','Comment\x20Service\x20is\x20'+this['_state'],{'retryable':!0x0});}};function a(_0x36f964){return{..._0x36f964};}function o(_0x45ae87){return c(_0x45ae87),{'userID':_0x45ae87['userID'],'customData':_0x45ae87['customData']??Object['create'](null)};}function s(_0x3cd97b){return c(_0x3cd97b),g('memberID',_0x3cd97b['memberID']),{'userID':_0x3cd97b['userID'],'memberID':_0x3cd97b['memberID'],'customData':_0x3cd97b['customData']??Object['create'](null)};}function c(_0x2a2c30){if(!_0x2a2c30||typeof _0x2a2c30!='object')throw _('context\x20must\x20be\x20an\x20object');if(g('userID',_0x2a2c30['userID']),_0x2a2c30['customData']!==void 0x0&&(_0x2a2c30['customData']===null||typeof _0x2a2c30['customData']!='object'||Array['isArray'](_0x2a2c30['customData'])))throw _('customData\x20must\x20be\x20an\x20object');}function l(_0xc4599f){return{'threadId':_0xc4599f['threadID'],'replyId':_0xc4599f['replyID'],'content':_0xc4599f['content'],'userId':_0xc4599f['authorUserID'],'createTimestamp':_0xc4599f['createdAt']};}function u(_0x25de55){let _0x5daea4=_0x25de55['find'](_0x2a590a=>_0x2a590a['replyID']===_0x2a590a['threadID']);return{'threadId':_0x5daea4['threadID'],'solved':_0x5daea4['solved'],'replies':_0x25de55['map'](l)};}function d(_0x517063){let _0x38d07a=new Map();for(let _0x528591 of _0x517063){let _0x232c7c=_0x38d07a['get'](_0x528591['threadID'])??[];_0x232c7c['push'](_0x528591),_0x38d07a['set'](_0x528591['threadID'],_0x232c7c);}let _0x15901c={};for(let [_0xf714f,_0x2e1b05]of _0x38d07a)_0x2e1b05['find'](_0x5e34be=>_0x5e34be['replyID']===_0xf714f)&&(_0x15901c[_0xf714f]=u([..._0x2e1b05]['sort']((_0x1f97a8,_0x423850)=>_0x1f97a8['replyID']===_0xf714f?-0x1:_0x423850['replyID']===_0xf714f?0x1:_0x1f97a8['createdAt']-_0x423850['createdAt']||_0x1f97a8['replyID']['localeCompare'](_0x423850['replyID']))));return _0x15901c;}function f(_0x2b32eb,_0x15df21,_0x9132e1){return{'memberId':_0x9132e1['memberID'],'userId':_0x9132e1['userID'],'unitId':_0x15df21['unitID'],'threadId':_0x15df21['threadID'],'type':_0x2b32eb,'replyId':_0x15df21['replyID'],'content':_0x15df21['content'],'createTimestamp':String(_0x15df21['createdAt'])};}function p(_0x2ccf0d){m(_0x2ccf0d['unitID']),g('threadID',_0x2ccf0d['threadID']),g('replyID',_0x2ccf0d['replyID']);}function m(_0x303031){g('unitID',_0x303031);}function h(_0x15bf33){if(typeof _0x15bf33!='string'||_0x15bf33['length']===0x0)throw _('content\x20must\x20be\x20a\x20non-empty\x20string');}function g(_0x408acf,_0x2fcb76){if(typeof _0x2fcb76!='string'||_0x2fcb76['length']===0x0)throw _(_0x408acf+'\x20must\x20be\x20a\x20non-empty\x20string');}function _(_0x4b2aea){return new t['CollabError']('INVALID_REQUEST',_0x4b2aea);}function v(_0x51a7b8){return new t['CollabError']('UNIT_NOT_FOUND',_0x51a7b8);}function y(_0x377cbc){return new t['CollabError']('PERMISSION_DENIED',_0x377cbc);}exports['UniverCommentService']=i;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
(function(_0x24d798,_0x513aa9){const _0x58f7ff=_0xf7f4,_0x4eb6c4=_0x24d798();while(!![]){try{const _0x39c58c=-parseInt(_0x58f7ff(0xaf))/0x1+parseInt(_0x58f7ff(0xb0))/0x2*(-parseInt(_0x58f7ff(0xb2))/0x3)+-parseInt(_0x58f7ff(0xb3))/0x4+-parseInt(_0x58f7ff(0xb1))/0x5*(-parseInt(_0x58f7ff(0xae))/0x6)+-parseInt(_0x58f7ff(0xb5))/0x7+-parseInt(_0x58f7ff(0xad))/0x8+parseInt(_0x58f7ff(0xb4))/0x9;if(_0x39c58c===_0x513aa9)break;else _0x4eb6c4['push'](_0x4eb6c4['shift']());}catch(_0x2d2f85){_0x4eb6c4['push'](_0x4eb6c4['shift']());}}}(_0x3904,0x9dd69));function _0xf7f4(_0x1161a9,_0x1cde04){_0x1161a9=_0x1161a9-0xad;const _0x3904ac=_0x3904();let _0xf7f483=_0x3904ac[_0x1161a9];return _0xf7f483;}import _0x452725 from'./index.cjs';const facadeExport0=_0x452725['UniverCommentService'];function _0x3904(){const _0x9e1b87=['30CtQSXJ','6555OCpgcc','70479YiyvMQ','4195928nyLgPH','25650207ClVUha','1704094iaHzBQ','8438632cBmBTI','3966owkBMc','370441tTCUcE'];_0x3904=function(){return _0x9e1b87;};return _0x3904();}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.
|
|
4
|
+
"version": "1.6.2",
|
|
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.
|
|
20
|
-
"@univerjs/protocol": "1.6.
|
|
19
|
+
"@univerjs-pro/collaboration-service": "1.6.2",
|
|
20
|
+
"@univerjs/protocol": "1.6.2"
|
|
21
21
|
}
|
|
22
22
|
}
|