@univerjs-pro/collaboration-comment-service 1.6.1 → 1.7.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs 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'](_0x5106ef,_0x17fc29){let _0x313d74=this['_middlewares']['get'](_0x5106ef)??[],_0x8c1a17=_0x17fc29;_0x313d74['push'](_0x8c1a17),this['_middlewares']['set'](_0x5106ef,_0x313d74);let _0x2db741=!0x1;return{'dispose':()=>{if(_0x2db741)return;_0x2db741=!0x0;let _0x818ab1=_0x313d74['indexOf'](_0x8c1a17);_0x818ab1>=0x0&&_0x313d74['splice'](_0x818ab1,0x1);}};}async['run'](_0x523dc6,_0x533b41,_0x300933){let _0x5397e0=[...this['_middlewares']['get'](_0x523dc6)??[]],_0x456dbb=async _0x4704ef=>{let _0x4b158c=_0x5397e0[_0x4704ef];if(!_0x4b158c)return _0x300933();let _0xe673a5=!0x1,_0x71fbfa,_0xa13f4f=()=>{if(_0xe673a5)throw Error('Middleware\x20for\x20action\x20'+_0x523dc6+'\x20called\x20next()\x20more\x20than\x20once');return _0xe673a5=!0x0,_0x71fbfa=_0x456dbb(_0x4704ef+0x1),_0x71fbfa;};try{await _0x4b158c(_0x533b41,_0xa13f4f);}catch(_0x76228a){throw _0x71fbfa&&await _0x71fbfa['catch'](()=>void 0x0),_0x76228a;}if(!_0xe673a5)throw Error('Middleware\x20for\x20action\x20'+_0x523dc6+'\x20completed\x20without\x20calling\x20next()');await _0x71fbfa;};await _0x456dbb(0x0);}['clear'](){this['_middlewares']['clear']();}},i=class{['_middleware']=new r();['_listeners']=new Map();['_calls']=new Set();['_database'];['_userProvider'];['_state']='running';['_disposePromise'];constructor(_0x35b2ba){if(!_0x35b2ba?.['database'])throw TypeError('UniverCommentService\x20requires\x20a\x20database');this['_database']=_0x35b2ba['database'],this['_userProvider']=_0x35b2ba['userProvider'];}['use'](_0x1f177f,_0x4464c4){return this['_assertRunning'](),this['_middleware']['use'](_0x1f177f,_0x4464c4);}['on'](_0x571684,_0x62e745){this['_assertRunning']();let _0x156e1d=this['_listeners']['get'](_0x571684)??new Set(),_0xbd5c61=_0x62e745;_0x156e1d['add'](_0xbd5c61),this['_listeners']['set'](_0x571684,_0x156e1d);let _0x79c200=!0x1;return{'dispose':()=>{_0x79c200||(_0x79c200=!0x0,_0x156e1d['delete'](_0xbd5c61));}};}['addComment'](_0x4c3e75,_0x46662f){return this['_call'](async()=>{let _0x3521f7=s(_0x46662f);m(_0x4c3e75['unitID']),h(_0x4c3e75['content']);let _0x5c796e=a(_0x4c3e75),_0x372c3b={..._0x3521f7,'request':_0x5c796e},_0x1fcc0b;return await this['_middleware']['run']('addComment',_0x372c3b,async()=>{let _0x2aa008=await this['_databaseCall'](()=>this['_database']['createRoot']({'unitID':_0x4c3e75['unitID'],'threadID':(0x0,e['randomUUID'])(),'authorUserID':_0x3521f7['userID'],'content':_0x4c3e75['content'],'mentions':[..._0x4c3e75['mentions']]},_0x372c3b));if(_0x2aa008['status']==='duplicate')throw _('Comment\x20ID\x20already\x20exists');_0x1fcc0b=u([_0x2aa008['record']]),await this['_emitWrite'](_0x3521f7,_0x5c796e,await this['_createUpdate'](n['CommentUpdateEventType']['Add'],_0x2aa008['record'],_0x3521f7,_0x5c796e));}),_0x1fcc0b;});}['listComments'](_0x4a060e,_0x52e4df){return this['_call'](async()=>{let _0x165fd9=o(_0x52e4df);m(_0x4a060e['unitID']),_0x4a060e['threadIDs']['forEach'](_0xe49b91=>g('threadID',_0xe49b91));let _0x152991=a(_0x4a060e),_0x48de9f={..._0x165fd9,'request':_0x152991},_0x4cde62;return await this['_middleware']['run']('listComments',_0x48de9f,async()=>{let _0x1a57b0=d(await this['_databaseCall'](()=>this['_database']['listThreads']({'unitID':_0x4a060e['unitID'],'threadIDs':[...new Set(_0x4a060e['threadIDs'])]},_0x48de9f))),_0x477516=Object['values'](_0x1a57b0)['flatMap'](_0x6297e=>_0x6297e['replies']['map'](_0x2a3d7d=>_0x2a3d7d['userId']));_0x4cde62={'comments':_0x1a57b0,'users':await this['_resolveUsers'](_0x477516,_0x165fd9,_0x152991)};}),_0x4cde62;});}['replyComment'](_0x7ddc13,_0x3b3296){return this['_call'](async()=>{let _0x2898d8=s(_0x3b3296);m(_0x7ddc13['unitID']),g('threadID',_0x7ddc13['threadID']),h(_0x7ddc13['content']);let _0x5962d5=a(_0x7ddc13),_0x26c7c3={..._0x2898d8,'request':_0x5962d5},_0x834123;return await this['_middleware']['run']('replyComment',_0x26c7c3,async()=>{let _0x17b72a=await this['_databaseCall'](()=>this['_database']['createReply']({'unitID':_0x7ddc13['unitID'],'threadID':_0x7ddc13['threadID'],'replyID':(0x0,e['randomUUID'])(),'authorUserID':_0x2898d8['userID'],'content':_0x7ddc13['content'],'mentions':[..._0x7ddc13['mentions']]},_0x26c7c3));if(_0x17b72a['status']==='not-found'||_0x17b72a['status']==='closed')throw v('Open\x20Comment\x20thread\x20was\x20not\x20found');if(_0x17b72a['status']==='duplicate')throw _('Comment\x20ID\x20already\x20exists');_0x834123=l(_0x17b72a['record']),await this['_emitWrite'](_0x2898d8,_0x5962d5,await this['_createUpdate'](n['CommentUpdateEventType']['Reply'],_0x17b72a['record'],_0x2898d8,_0x5962d5));}),_0x834123;});}['editComment'](_0x1e1ff0,_0x3616ba){return this['_call'](async()=>{let _0x5877f9=s(_0x3616ba);p(_0x1e1ff0),h(_0x1e1ff0['content']);let _0x59795a=a(_0x1e1ff0),_0x29cee6={..._0x5877f9,'request':_0x59795a};await this['_middleware']['run']('editComment',_0x29cee6,async()=>{let _0x34fbbd=await this['_databaseCall'](()=>this['_database']['editComment']({'unitID':_0x1e1ff0['unitID'],'threadID':_0x1e1ff0['threadID'],'replyID':_0x1e1ff0['replyID'],'expectedAuthorUserID':_0x5877f9['userID'],'content':_0x1e1ff0['content'],'mentions':[..._0x1e1ff0['mentions']]},_0x29cee6));if(_0x34fbbd['status']==='author-mismatch')throw y('Only\x20the\x20Comment\x20author\x20can\x20edit\x20it');if(_0x34fbbd['status']==='not-found'||_0x34fbbd['status']==='closed')throw v('Open\x20Comment\x20was\x20not\x20found');_0x34fbbd['status']==='edited'&&await this['_emitWrite'](_0x5877f9,_0x59795a,f(n['CommentUpdateEventType']['Edit'],_0x34fbbd['record'],_0x5877f9));});});}['setThreadSolved'](_0xb7229,_0x1e2bf9){return this['_call'](async()=>{let _0x56eadc=s(_0x1e2bf9);if(m(_0xb7229['unitID']),g('threadID',_0xb7229['threadID']),_0xb7229['solved']!==n['CommentSolvedStatus']['OpenOrReOpen']&&_0xb7229['solved']!==n['CommentSolvedStatus']['Solved'])throw _('solved\x20must\x20be\x20OpenOrReOpen\x20or\x20Solved');let _0x33d7e8=a(_0xb7229),_0x1fc6d8={..._0x56eadc,'request':_0x33d7e8};await this['_middleware']['run']('setThreadSolved',_0x1fc6d8,async()=>{let _0xb57160=await this['_databaseCall'](()=>this['_database']['setThreadSolved'](_0xb7229,_0x1fc6d8));if(_0xb57160['status']==='not-found')throw v('Comment\x20thread\x20was\x20not\x20found');_0xb57160['status']==='updated'&&await this['_emitWrite'](_0x56eadc,_0x33d7e8,{'memberId':_0x56eadc['memberID'],'userId':_0x56eadc['userID'],'unitId':_0xb7229['unitID'],'threadId':_0xb7229['threadID'],'type':n['CommentUpdateEventType']['Solve'],'solved':_0xb7229['solved']});});});}['deleteComment'](_0x4d339a,_0x41b86d){return this['_call'](async()=>{let _0x34eaa4=s(_0x41b86d);m(_0x4d339a['unitID']),g('threadID',_0x4d339a['threadID']),_0x4d339a['replyID']!==void 0x0&&g('replyID',_0x4d339a['replyID']);let _0x577e95=_0x4d339a['replyID']===_0x4d339a['threadID']?void 0x0:_0x4d339a['replyID'],_0x37b534=a({'unitID':_0x4d339a['unitID'],'threadID':_0x4d339a['threadID'],..._0x577e95===void 0x0?{}:{'replyID':_0x577e95}}),_0x437f2c={..._0x34eaa4,'request':_0x37b534},_0x2da67f=await this['_databaseCall'](()=>this['_database']['getComment']({'unitID':_0x4d339a['unitID'],'threadID':_0x4d339a['threadID'],'replyID':_0x577e95??_0x4d339a['threadID']},_0x437f2c));if(!_0x2da67f)throw v('Comment\x20was\x20not\x20found');await this['_middleware']['run']('deleteComment',{..._0x437f2c,'request':_0x37b534,'target':{'kind':_0x577e95===void 0x0?'root':'reply','threadID':_0x2da67f['threadID'],'replyID':_0x2da67f['replyID'],'authorUserID':_0x2da67f['authorUserID'],'generation':_0x2da67f['generation']}},async()=>{let _0x4a9466=await this['_databaseCall'](()=>this['_database']['deleteComment']({'unitID':_0x4d339a['unitID'],'threadID':_0x4d339a['threadID'],..._0x577e95===void 0x0?{}:{'replyID':_0x577e95},'expectedGeneration':_0x2da67f['generation']},_0x437f2c));if(_0x4a9466['status']==='not-found')throw v('Comment\x20was\x20not\x20found');if(_0x4a9466['status']==='generation-mismatch')throw _('Comment\x20changed\x20before\x20deletion');await this['_emitWrite'](_0x34eaa4,_0x37b534,{'memberId':_0x34eaa4['memberID'],'userId':_0x34eaa4['userID'],'unitId':_0x4d339a['unitID'],'threadId':_0x4d339a['threadID'],'type':n['CommentUpdateEventType']['Delete'],..._0x577e95===void 0x0?{}:{'replyId':_0x577e95}});});});}['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'](_0x3a9796,_0x469693,_0x233c3b,_0x5d7fa5){let _0x5dc11d=await this['_resolveUsers']([_0x469693['authorUserID']],_0x233c3b,_0x5d7fa5);return{...f(_0x3a9796,_0x469693,_0x233c3b),..._0x5dc11d[_0x469693['authorUserID']]?{'user':_0x5dc11d[_0x469693['authorUserID']]}:{}};}async['_resolveUsers'](_0x456d8f,_0x4a91f0,_0xda1ee1){let _0x3bc7db=[...new Set(_0x456d8f['filter'](Boolean))];if(!this['_userProvider']||_0x3bc7db['length']===0x0)return{};let _0x464e8f;try{_0x464e8f=await this['_userProvider']['getUsers'](_0x3bc7db,{..._0x4a91f0,'request':_0xda1ee1});}catch{return{};}let _0x583ecc=new Set(_0x3bc7db),_0x26db9c={};for(let _0x239ce0 of _0x464e8f)_0x239ce0?.['userID']&&_0x583ecc['has'](_0x239ce0['userID'])&&(_0x26db9c[_0x239ce0['userID']]=_0x239ce0);return _0x26db9c;}async['_emitWrite'](_0x3fd19c,_0x3eb971,_0x1bcf79){let _0xb4eed8={'userID':_0x3fd19c['userID'],'memberID':_0x3fd19c['memberID'],'customData':_0x3fd19c['customData'],'request':_0x3eb971,'update':_0x1bcf79,'committedAt':Date['now']()};for(let _0x1a2709 of[...this['_listeners']['get']('commentCommitted')??[]])try{await _0x1a2709(_0xb4eed8);}catch{}}['_call'](_0x1e24b2){this['_assertRunning']();let _0x15d720=_0x1e24b2();return this['_calls']['add'](_0x15d720),_0x15d720['finally'](()=>this['_calls']['delete'](_0x15d720))['catch'](()=>void 0x0),_0x15d720;}async['_databaseCall'](_0x332d34){try{return await _0x332d34();}catch(_0x7587b4){throw _0x7587b4 instanceof t['CollabError']?_0x7587b4:new t['CollabError']('ADAPTER_FAILURE','Comment\x20Database\x20Adapter\x20failed',{'retryable':!0x0,'cause':_0x7587b4});}}['_assertRunning'](){if(this['_state']!=='running')throw new t['CollabError']('INTERNAL_ERROR','Comment\x20Service\x20is\x20'+this['_state'],{'retryable':!0x0});}};function a(_0x44e097){return{..._0x44e097};}function o(_0x5899dc){return c(_0x5899dc),{'userID':_0x5899dc['userID'],'customData':_0x5899dc['customData']??Object['create'](null)};}function s(_0x3ffc86){return c(_0x3ffc86),g('memberID',_0x3ffc86['memberID']),{'userID':_0x3ffc86['userID'],'memberID':_0x3ffc86['memberID'],'customData':_0x3ffc86['customData']??Object['create'](null)};}function c(_0x2a3239){if(!_0x2a3239||typeof _0x2a3239!='object')throw _('context\x20must\x20be\x20an\x20object');if(g('userID',_0x2a3239['userID']),_0x2a3239['customData']!==void 0x0&&(_0x2a3239['customData']===null||typeof _0x2a3239['customData']!='object'||Array['isArray'](_0x2a3239['customData'])))throw _('customData\x20must\x20be\x20an\x20object');}function l(_0x5e73e8){return{'threadId':_0x5e73e8['threadID'],'replyId':_0x5e73e8['replyID'],'content':_0x5e73e8['content'],'userId':_0x5e73e8['authorUserID'],'createTimestamp':_0x5e73e8['createdAt']};}function u(_0x17b7c0){let _0x41f08e=_0x17b7c0['find'](_0x4244fb=>_0x4244fb['replyID']===_0x4244fb['threadID']);return{'threadId':_0x41f08e['threadID'],'solved':_0x41f08e['solved'],'replies':_0x17b7c0['map'](l)};}function d(_0x164fbc){let _0x22989a=new Map();for(let _0x513fd6 of _0x164fbc){let _0x155910=_0x22989a['get'](_0x513fd6['threadID'])??[];_0x155910['push'](_0x513fd6),_0x22989a['set'](_0x513fd6['threadID'],_0x155910);}let _0x25d6bb={};for(let [_0x33a58,_0x3d6958]of _0x22989a)_0x3d6958['find'](_0xaefb0a=>_0xaefb0a['replyID']===_0x33a58)&&(_0x25d6bb[_0x33a58]=u([..._0x3d6958]['sort']((_0xc6bf67,_0xdc4296)=>_0xc6bf67['replyID']===_0x33a58?-0x1:_0xdc4296['replyID']===_0x33a58?0x1:_0xc6bf67['createdAt']-_0xdc4296['createdAt']||_0xc6bf67['replyID']['localeCompare'](_0xdc4296['replyID']))));return _0x25d6bb;}function f(_0x380dff,_0x52e8f7,_0xcb337b){return{'memberId':_0xcb337b['memberID'],'userId':_0xcb337b['userID'],'unitId':_0x52e8f7['unitID'],'threadId':_0x52e8f7['threadID'],'type':_0x380dff,'replyId':_0x52e8f7['replyID'],'content':_0x52e8f7['content'],'createTimestamp':String(_0x52e8f7['createdAt'])};}function p(_0x1cd2e3){m(_0x1cd2e3['unitID']),g('threadID',_0x1cd2e3['threadID']),g('replyID',_0x1cd2e3['replyID']);}function m(_0x4ac6ac){g('unitID',_0x4ac6ac);}function h(_0xb0df2f){if(typeof _0xb0df2f!='string'||_0xb0df2f['length']===0x0)throw _('content\x20must\x20be\x20a\x20non-empty\x20string');}function g(_0x41b27f,_0x3f087e){if(typeof _0x3f087e!='string'||_0x3f087e['length']===0x0)throw _(_0x41b27f+'\x20must\x20be\x20a\x20non-empty\x20string');}function _(_0x1e52bc){return new t['CollabError']('INVALID_REQUEST',_0x1e52bc);}function v(_0x442278){return new t['CollabError']('UNIT_NOT_FOUND',_0x442278);}function y(_0x4a72d3){return new t['CollabError']('PERMISSION_DENIED',_0x4a72d3);}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
+ function _0x2cdb(_0x4378cc,_0x2e396b){_0x4378cc=_0x4378cc-0x1d3;const _0x3446f0=_0x3446();let _0x2cdbc2=_0x3446f0[_0x4378cc];return _0x2cdbc2;}const _0x3dbdd6=_0x2cdb;(function(_0x82cae6,_0x231083){const _0x13f726=_0x2cdb,_0x202a5a=_0x82cae6();while(!![]){try{const _0x4cbd0f=-parseInt(_0x13f726(0x1d5))/0x1+-parseInt(_0x13f726(0x1d6))/0x2+-parseInt(_0x13f726(0x1db))/0x3+parseInt(_0x13f726(0x1d4))/0x4+parseInt(_0x13f726(0x1d7))/0x5+parseInt(_0x13f726(0x1d8))/0x6*(-parseInt(_0x13f726(0x1da))/0x7)+parseInt(_0x13f726(0x1d3))/0x8;if(_0x4cbd0f===_0x231083)break;else _0x202a5a['push'](_0x202a5a['shift']());}catch(_0x11145d){_0x202a5a['push'](_0x202a5a['shift']());}}}(_0x3446,0xef09a));import _0x3cbf25 from'./index.cjs';const facadeExport0=_0x3cbf25[_0x3dbdd6(0x1d9)];function _0x3446(){const _0x49580f=['3095136aWcvGs','68520WTbOyQ','3908590Hnlwgk','5239675NIkMQr','96762pgbCsL','UniverCommentService','126LbSKAS','4047804wGkhjA','22557984IZaCYb'];_0x3446=function(){return _0x49580f;};return _0x3446();}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.7.0-alpha.0",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
7
7
  "types": "./dist/index.d.ts",
@@ -16,7 +16,7 @@
16
16
  "dist"
17
17
  ],
18
18
  "dependencies": {
19
- "@univerjs-pro/collaboration-service": "1.6.1",
20
- "@univerjs/protocol": "1.6.1"
19
+ "@univerjs-pro/collaboration-service": "1.7.0-alpha.0",
20
+ "@univerjs/protocol": "1.7.0-alpha.0"
21
21
  }
22
22
  }