@univerjs-pro/collaboration-comment-service 1.0.0 → 1.0.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 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'](_0x2e3295,_0x506066){let _0x2152ff=this['_middlewares']['get'](_0x2e3295)??[],_0x1b5e83=_0x506066;_0x2152ff['push'](_0x1b5e83),this['_middlewares']['set'](_0x2e3295,_0x2152ff);let _0x4db7e4=!0x1;return{'dispose':()=>{if(_0x4db7e4)return;_0x4db7e4=!0x0;let _0x40ac1e=_0x2152ff['indexOf'](_0x1b5e83);_0x40ac1e>=0x0&&_0x2152ff['splice'](_0x40ac1e,0x1);}};}async['run'](_0x4223b4,_0x187a2c,_0xe2a530){let _0xab0f03=[...this['_middlewares']['get'](_0x4223b4)??[]],_0x92ce69=async _0x290077=>{let _0x128564=_0xab0f03[_0x290077];if(!_0x128564)return _0xe2a530();let _0x1ab58b=!0x1,_0x4ffdc7,_0x5eb2f1=()=>{if(_0x1ab58b)throw Error('Middleware\x20for\x20action\x20'+_0x4223b4+'\x20called\x20next()\x20more\x20than\x20once');return _0x1ab58b=!0x0,_0x4ffdc7=_0x92ce69(_0x290077+0x1),_0x4ffdc7;};try{await _0x128564(_0x187a2c,_0x5eb2f1);}catch(_0x307815){throw _0x4ffdc7&&await _0x4ffdc7['catch'](()=>void 0x0),_0x307815;}if(!_0x1ab58b)throw Error('Middleware\x20for\x20action\x20'+_0x4223b4+'\x20completed\x20without\x20calling\x20next()');await _0x4ffdc7;};await _0x92ce69(0x0);}['clear'](){this['_middlewares']['clear']();}},i=class{['_middleware']=new r();['_listeners']=new Map();['_calls']=new Set();['_database'];['_userProvider'];['_state']='running';['_disposePromise'];constructor(_0x1adaf0){if(!_0x1adaf0?.['database'])throw TypeError('UniverCommentService\x20requires\x20a\x20database');this['_database']=_0x1adaf0['database'],this['_userProvider']=_0x1adaf0['userProvider'];}['use'](_0x29f5a4,_0x175941){return this['_assertRunning'](),this['_middleware']['use'](_0x29f5a4,_0x175941);}['on'](_0x37b9ab,_0x16584c){this['_assertRunning']();let _0x646ae9=this['_listeners']['get'](_0x37b9ab)??new Set(),_0x5e985e=_0x16584c;_0x646ae9['add'](_0x5e985e),this['_listeners']['set'](_0x37b9ab,_0x646ae9);let _0x449dc7=!0x1;return{'dispose':()=>{_0x449dc7||(_0x449dc7=!0x0,_0x646ae9['delete'](_0x5e985e));}};}['addComment'](_0x132029,_0xb65d24){return this['_call'](async()=>{let _0x144ed3=s(_0xb65d24);m(_0x132029['unitID']),h(_0x132029['content']);let _0x1ce073=a(_0x132029),_0x244698={..._0x144ed3,'request':_0x1ce073},_0x19dd6d;return await this['_middleware']['run']('addComment',_0x244698,async()=>{let _0x560207=await this['_databaseCall'](()=>this['_database']['createRoot']({'unitID':_0x132029['unitID'],'threadID':(0x0,e['randomUUID'])(),'authorUserID':_0x144ed3['userID'],'content':_0x132029['content'],'mentions':[..._0x132029['mentions']]},_0x244698));if(_0x560207['status']==='duplicate')throw _('Comment\x20ID\x20already\x20exists');_0x19dd6d=u([_0x560207['record']]),await this['_emitWrite'](_0x144ed3,_0x1ce073,await this['_createUpdate'](n['CommentUpdateEventType']['Add'],_0x560207['record'],_0x144ed3,_0x1ce073));}),_0x19dd6d;});}['listComments'](_0x5a2065,_0x432178){return this['_call'](async()=>{let _0x70add4=o(_0x432178);m(_0x5a2065['unitID']),_0x5a2065['threadIDs']['forEach'](_0x4e7ff4=>g('threadID',_0x4e7ff4));let _0x701ae9=a(_0x5a2065),_0x5ea83e={..._0x70add4,'request':_0x701ae9},_0x182d79;return await this['_middleware']['run']('listComments',_0x5ea83e,async()=>{let _0x43a029=d(await this['_databaseCall'](()=>this['_database']['listThreads']({'unitID':_0x5a2065['unitID'],'threadIDs':[...new Set(_0x5a2065['threadIDs'])]},_0x5ea83e))),_0x152e09=Object['values'](_0x43a029)['flatMap'](_0x4c3ca4=>_0x4c3ca4['replies']['map'](_0x559c32=>_0x559c32['userId']));_0x182d79={'comments':_0x43a029,'users':await this['_resolveUsers'](_0x152e09,_0x70add4,_0x701ae9)};}),_0x182d79;});}['replyComment'](_0x18f464,_0x4495cd){return this['_call'](async()=>{let _0x5cc5f6=s(_0x4495cd);m(_0x18f464['unitID']),g('threadID',_0x18f464['threadID']),h(_0x18f464['content']);let _0x1891de=a(_0x18f464),_0x1a9e2c={..._0x5cc5f6,'request':_0x1891de},_0x55cb05;return await this['_middleware']['run']('replyComment',_0x1a9e2c,async()=>{let _0x3a0713=await this['_databaseCall'](()=>this['_database']['createReply']({'unitID':_0x18f464['unitID'],'threadID':_0x18f464['threadID'],'replyID':(0x0,e['randomUUID'])(),'authorUserID':_0x5cc5f6['userID'],'content':_0x18f464['content'],'mentions':[..._0x18f464['mentions']]},_0x1a9e2c));if(_0x3a0713['status']==='not-found'||_0x3a0713['status']==='closed')throw v('Open\x20Comment\x20thread\x20was\x20not\x20found');if(_0x3a0713['status']==='duplicate')throw _('Comment\x20ID\x20already\x20exists');_0x55cb05=l(_0x3a0713['record']),await this['_emitWrite'](_0x5cc5f6,_0x1891de,await this['_createUpdate'](n['CommentUpdateEventType']['Reply'],_0x3a0713['record'],_0x5cc5f6,_0x1891de));}),_0x55cb05;});}['editComment'](_0x341d39,_0x20490e){return this['_call'](async()=>{let _0x2a99b2=s(_0x20490e);p(_0x341d39),h(_0x341d39['content']);let _0xd5dde2=a(_0x341d39),_0x3cab1d={..._0x2a99b2,'request':_0xd5dde2};await this['_middleware']['run']('editComment',_0x3cab1d,async()=>{let _0x44540a=await this['_databaseCall'](()=>this['_database']['editComment']({'unitID':_0x341d39['unitID'],'threadID':_0x341d39['threadID'],'replyID':_0x341d39['replyID'],'expectedAuthorUserID':_0x2a99b2['userID'],'content':_0x341d39['content'],'mentions':[..._0x341d39['mentions']]},_0x3cab1d));if(_0x44540a['status']==='author-mismatch')throw y('Only\x20the\x20Comment\x20author\x20can\x20edit\x20it');if(_0x44540a['status']==='not-found'||_0x44540a['status']==='closed')throw v('Open\x20Comment\x20was\x20not\x20found');_0x44540a['status']==='edited'&&await this['_emitWrite'](_0x2a99b2,_0xd5dde2,f(n['CommentUpdateEventType']['Edit'],_0x44540a['record'],_0x2a99b2));});});}['setThreadSolved'](_0x29fd1d,_0x194c10){return this['_call'](async()=>{let _0x265a4b=s(_0x194c10);if(m(_0x29fd1d['unitID']),g('threadID',_0x29fd1d['threadID']),_0x29fd1d['solved']!==n['CommentSolvedStatus']['OpenOrReOpen']&&_0x29fd1d['solved']!==n['CommentSolvedStatus']['Solved'])throw _('solved\x20must\x20be\x20OpenOrReOpen\x20or\x20Solved');let _0x4fc997=a(_0x29fd1d),_0x4e60b4={..._0x265a4b,'request':_0x4fc997};await this['_middleware']['run']('setThreadSolved',_0x4e60b4,async()=>{let _0x3bd5e3=await this['_databaseCall'](()=>this['_database']['setThreadSolved'](_0x29fd1d,_0x4e60b4));if(_0x3bd5e3['status']==='not-found')throw v('Comment\x20thread\x20was\x20not\x20found');_0x3bd5e3['status']==='updated'&&await this['_emitWrite'](_0x265a4b,_0x4fc997,{'memberId':_0x265a4b['memberID'],'userId':_0x265a4b['userID'],'unitId':_0x29fd1d['unitID'],'threadId':_0x29fd1d['threadID'],'type':n['CommentUpdateEventType']['Solve'],'solved':_0x29fd1d['solved']});});});}['deleteComment'](_0x2e108f,_0x1c8a33){return this['_call'](async()=>{let _0x139361=s(_0x1c8a33);m(_0x2e108f['unitID']),g('threadID',_0x2e108f['threadID']),_0x2e108f['replyID']!==void 0x0&&g('replyID',_0x2e108f['replyID']);let _0x3a3f92=_0x2e108f['replyID']===_0x2e108f['threadID']?void 0x0:_0x2e108f['replyID'],_0x3f212f=a({'unitID':_0x2e108f['unitID'],'threadID':_0x2e108f['threadID'],..._0x3a3f92===void 0x0?{}:{'replyID':_0x3a3f92}}),_0x66999c={..._0x139361,'request':_0x3f212f},_0x33770c=await this['_databaseCall'](()=>this['_database']['getComment']({'unitID':_0x2e108f['unitID'],'threadID':_0x2e108f['threadID'],'replyID':_0x3a3f92??_0x2e108f['threadID']},_0x66999c));if(!_0x33770c)throw v('Comment\x20was\x20not\x20found');await this['_middleware']['run']('deleteComment',{..._0x66999c,'request':_0x3f212f,'target':{'kind':_0x3a3f92===void 0x0?'root':'reply','threadID':_0x33770c['threadID'],'replyID':_0x33770c['replyID'],'authorUserID':_0x33770c['authorUserID'],'generation':_0x33770c['generation']}},async()=>{let _0x4fdb4d=await this['_databaseCall'](()=>this['_database']['deleteComment']({'unitID':_0x2e108f['unitID'],'threadID':_0x2e108f['threadID'],..._0x3a3f92===void 0x0?{}:{'replyID':_0x3a3f92},'expectedGeneration':_0x33770c['generation']},_0x66999c));if(_0x4fdb4d['status']==='not-found')throw v('Comment\x20was\x20not\x20found');if(_0x4fdb4d['status']==='generation-mismatch')throw _('Comment\x20changed\x20before\x20deletion');await this['_emitWrite'](_0x139361,_0x3f212f,{'memberId':_0x139361['memberID'],'userId':_0x139361['userID'],'unitId':_0x2e108f['unitID'],'threadId':_0x2e108f['threadID'],'type':n['CommentUpdateEventType']['Delete'],..._0x3a3f92===void 0x0?{}:{'replyId':_0x3a3f92}});});});}['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'](_0xbe0f9a,_0x2f5b70,_0x5625cf,_0x533c84){let _0x4fd385=await this['_resolveUsers']([_0x2f5b70['authorUserID']],_0x5625cf,_0x533c84);return{...f(_0xbe0f9a,_0x2f5b70,_0x5625cf),..._0x4fd385[_0x2f5b70['authorUserID']]?{'user':_0x4fd385[_0x2f5b70['authorUserID']]}:{}};}async['_resolveUsers'](_0x3833b4,_0x466645,_0x420835){let _0xeb044a=[...new Set(_0x3833b4['filter'](Boolean))];if(!this['_userProvider']||_0xeb044a['length']===0x0)return{};let _0x459d58;try{_0x459d58=await this['_userProvider']['getUsers'](_0xeb044a,{..._0x466645,'request':_0x420835});}catch{return{};}let _0x2fec93=new Set(_0xeb044a),_0x1d1d3c={};for(let _0x31bd8c of _0x459d58)_0x31bd8c?.['userID']&&_0x2fec93['has'](_0x31bd8c['userID'])&&(_0x1d1d3c[_0x31bd8c['userID']]=_0x31bd8c);return _0x1d1d3c;}async['_emitWrite'](_0x3f0b11,_0xc80e09,_0x1c6e21){let _0x1ea856={'userID':_0x3f0b11['userID'],'memberID':_0x3f0b11['memberID'],'customData':_0x3f0b11['customData'],'request':_0xc80e09,'update':_0x1c6e21,'committedAt':Date['now']()};for(let _0x5e8f57 of[...this['_listeners']['get']('commentCommitted')??[]])try{await _0x5e8f57(_0x1ea856);}catch{}}['_call'](_0x25686f){this['_assertRunning']();let _0x4238c3=_0x25686f();return this['_calls']['add'](_0x4238c3),_0x4238c3['finally'](()=>this['_calls']['delete'](_0x4238c3))['catch'](()=>void 0x0),_0x4238c3;}async['_databaseCall'](_0xba1d){try{return await _0xba1d();}catch(_0x3edfa9){throw _0x3edfa9 instanceof t['CollabError']?_0x3edfa9:new t['CollabError']('ADAPTER_FAILURE','Comment\x20Database\x20Adapter\x20failed',{'retryable':!0x0,'cause':_0x3edfa9});}}['_assertRunning'](){if(this['_state']!=='running')throw new t['CollabError']('INTERNAL_ERROR','Comment\x20Service\x20is\x20'+this['_state'],{'retryable':!0x0});}};function a(_0x44396d){return{..._0x44396d};}function o(_0x1516e6){return c(_0x1516e6),{'userID':_0x1516e6['userID'],'customData':_0x1516e6['customData']??Object['create'](null)};}function s(_0x4b6825){return c(_0x4b6825),g('memberID',_0x4b6825['memberID']),{'userID':_0x4b6825['userID'],'memberID':_0x4b6825['memberID'],'customData':_0x4b6825['customData']??Object['create'](null)};}function c(_0x22ff90){if(!_0x22ff90||typeof _0x22ff90!='object')throw _('context\x20must\x20be\x20an\x20object');if(g('userID',_0x22ff90['userID']),_0x22ff90['customData']!==void 0x0&&(_0x22ff90['customData']===null||typeof _0x22ff90['customData']!='object'||Array['isArray'](_0x22ff90['customData'])))throw _('customData\x20must\x20be\x20an\x20object');}function l(_0x196aa2){return{'threadId':_0x196aa2['threadID'],'replyId':_0x196aa2['replyID'],'content':_0x196aa2['content'],'userId':_0x196aa2['authorUserID'],'createTimestamp':_0x196aa2['createdAt']};}function u(_0x516884){let _0x2116c7=_0x516884['find'](_0x4b1c47=>_0x4b1c47['replyID']===_0x4b1c47['threadID']);return{'threadId':_0x2116c7['threadID'],'solved':_0x2116c7['solved'],'replies':_0x516884['map'](l)};}function d(_0x366a64){let _0x2e2119=new Map();for(let _0x2f1e4d of _0x366a64){let _0x36ff57=_0x2e2119['get'](_0x2f1e4d['threadID'])??[];_0x36ff57['push'](_0x2f1e4d),_0x2e2119['set'](_0x2f1e4d['threadID'],_0x36ff57);}let _0x3a1ee3={};for(let [_0x42e63c,_0x4a426d]of _0x2e2119)_0x4a426d['find'](_0x325e4c=>_0x325e4c['replyID']===_0x42e63c)&&(_0x3a1ee3[_0x42e63c]=u([..._0x4a426d]['sort']((_0x34ba28,_0x41d93c)=>_0x34ba28['replyID']===_0x42e63c?-0x1:_0x41d93c['replyID']===_0x42e63c?0x1:_0x34ba28['createdAt']-_0x41d93c['createdAt']||_0x34ba28['replyID']['localeCompare'](_0x41d93c['replyID']))));return _0x3a1ee3;}function f(_0x24d783,_0x30c908,_0x27b6c1){return{'memberId':_0x27b6c1['memberID'],'userId':_0x27b6c1['userID'],'unitId':_0x30c908['unitID'],'threadId':_0x30c908['threadID'],'type':_0x24d783,'replyId':_0x30c908['replyID'],'content':_0x30c908['content'],'createTimestamp':String(_0x30c908['createdAt'])};}function p(_0x315797){m(_0x315797['unitID']),g('threadID',_0x315797['threadID']),g('replyID',_0x315797['replyID']);}function m(_0x65c9f2){g('unitID',_0x65c9f2);}function h(_0xadc376){if(typeof _0xadc376!='string'||_0xadc376['length']===0x0)throw _('content\x20must\x20be\x20a\x20non-empty\x20string');}function g(_0x365a07,_0xcc24e7){if(typeof _0xcc24e7!='string'||_0xcc24e7['length']===0x0)throw _(_0x365a07+'\x20must\x20be\x20a\x20non-empty\x20string');}function _(_0x39f3ca){return new t['CollabError']('INVALID_REQUEST',_0x39f3ca);}function v(_0x5ef0a5){return new t['CollabError']('UNIT_NOT_FOUND',_0x5ef0a5);}function y(_0x2b7a3c){return new t['CollabError']('PERMISSION_DENIED',_0x2b7a3c);}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'](_0x23b718,_0x2deb03){let _0x5f124b=this['_middlewares']['get'](_0x23b718)??[],_0x392acd=_0x2deb03;_0x5f124b['push'](_0x392acd),this['_middlewares']['set'](_0x23b718,_0x5f124b);let _0x2fbedf=!0x1;return{'dispose':()=>{if(_0x2fbedf)return;_0x2fbedf=!0x0;let _0x24ebef=_0x5f124b['indexOf'](_0x392acd);_0x24ebef>=0x0&&_0x5f124b['splice'](_0x24ebef,0x1);}};}async['run'](_0x36fcfa,_0xe0883e,_0x132eed){let _0x2ca3a2=[...this['_middlewares']['get'](_0x36fcfa)??[]],_0xfd2d69=async _0x4318d9=>{let _0x588442=_0x2ca3a2[_0x4318d9];if(!_0x588442)return _0x132eed();let _0x1cdd7f=!0x1,_0x340dfe,_0x1d6f3e=()=>{if(_0x1cdd7f)throw Error('Middleware\x20for\x20action\x20'+_0x36fcfa+'\x20called\x20next()\x20more\x20than\x20once');return _0x1cdd7f=!0x0,_0x340dfe=_0xfd2d69(_0x4318d9+0x1),_0x340dfe;};try{await _0x588442(_0xe0883e,_0x1d6f3e);}catch(_0x3fa3b8){throw _0x340dfe&&await _0x340dfe['catch'](()=>void 0x0),_0x3fa3b8;}if(!_0x1cdd7f)throw Error('Middleware\x20for\x20action\x20'+_0x36fcfa+'\x20completed\x20without\x20calling\x20next()');await _0x340dfe;};await _0xfd2d69(0x0);}['clear'](){this['_middlewares']['clear']();}},i=class{['_middleware']=new r();['_listeners']=new Map();['_calls']=new Set();['_database'];['_userProvider'];['_state']='running';['_disposePromise'];constructor(_0x160e71){if(!_0x160e71?.['database'])throw TypeError('UniverCommentService\x20requires\x20a\x20database');this['_database']=_0x160e71['database'],this['_userProvider']=_0x160e71['userProvider'];}['use'](_0x4955e9,_0x197b0d){return this['_assertRunning'](),this['_middleware']['use'](_0x4955e9,_0x197b0d);}['on'](_0x395ee7,_0x49100f){this['_assertRunning']();let _0x4eb96f=this['_listeners']['get'](_0x395ee7)??new Set(),_0x4e8b9f=_0x49100f;_0x4eb96f['add'](_0x4e8b9f),this['_listeners']['set'](_0x395ee7,_0x4eb96f);let _0x433f5d=!0x1;return{'dispose':()=>{_0x433f5d||(_0x433f5d=!0x0,_0x4eb96f['delete'](_0x4e8b9f));}};}['addComment'](_0x26c24f,_0x45fe29){return this['_call'](async()=>{let _0x540616=s(_0x45fe29);m(_0x26c24f['unitID']),h(_0x26c24f['content']);let _0x28bc68=a(_0x26c24f),_0x36cc14={..._0x540616,'request':_0x28bc68},_0x2ea1b1;return await this['_middleware']['run']('addComment',_0x36cc14,async()=>{let _0xee26d1=await this['_databaseCall'](()=>this['_database']['createRoot']({'unitID':_0x26c24f['unitID'],'threadID':(0x0,e['randomUUID'])(),'authorUserID':_0x540616['userID'],'content':_0x26c24f['content'],'mentions':[..._0x26c24f['mentions']]},_0x36cc14));if(_0xee26d1['status']==='duplicate')throw _('Comment\x20ID\x20already\x20exists');_0x2ea1b1=u([_0xee26d1['record']]),await this['_emitWrite'](_0x540616,_0x28bc68,await this['_createUpdate'](n['CommentUpdateEventType']['Add'],_0xee26d1['record'],_0x540616,_0x28bc68));}),_0x2ea1b1;});}['listComments'](_0x4de927,_0x10f4e7){return this['_call'](async()=>{let _0x27f0af=o(_0x10f4e7);m(_0x4de927['unitID']),_0x4de927['threadIDs']['forEach'](_0x4ecb3e=>g('threadID',_0x4ecb3e));let _0x22fa65=a(_0x4de927),_0x53493d={..._0x27f0af,'request':_0x22fa65},_0x486482;return await this['_middleware']['run']('listComments',_0x53493d,async()=>{let _0x50fd40=d(await this['_databaseCall'](()=>this['_database']['listThreads']({'unitID':_0x4de927['unitID'],'threadIDs':[...new Set(_0x4de927['threadIDs'])]},_0x53493d))),_0x9c0593=Object['values'](_0x50fd40)['flatMap'](_0x5f2c11=>_0x5f2c11['replies']['map'](_0x3d7141=>_0x3d7141['userId']));_0x486482={'comments':_0x50fd40,'users':await this['_resolveUsers'](_0x9c0593,_0x27f0af,_0x22fa65)};}),_0x486482;});}['replyComment'](_0x2335df,_0x2bbc6c){return this['_call'](async()=>{let _0x5d555b=s(_0x2bbc6c);m(_0x2335df['unitID']),g('threadID',_0x2335df['threadID']),h(_0x2335df['content']);let _0x5342ee=a(_0x2335df),_0x1ca144={..._0x5d555b,'request':_0x5342ee},_0xc7d597;return await this['_middleware']['run']('replyComment',_0x1ca144,async()=>{let _0x52b9e1=await this['_databaseCall'](()=>this['_database']['createReply']({'unitID':_0x2335df['unitID'],'threadID':_0x2335df['threadID'],'replyID':(0x0,e['randomUUID'])(),'authorUserID':_0x5d555b['userID'],'content':_0x2335df['content'],'mentions':[..._0x2335df['mentions']]},_0x1ca144));if(_0x52b9e1['status']==='not-found'||_0x52b9e1['status']==='closed')throw v('Open\x20Comment\x20thread\x20was\x20not\x20found');if(_0x52b9e1['status']==='duplicate')throw _('Comment\x20ID\x20already\x20exists');_0xc7d597=l(_0x52b9e1['record']),await this['_emitWrite'](_0x5d555b,_0x5342ee,await this['_createUpdate'](n['CommentUpdateEventType']['Reply'],_0x52b9e1['record'],_0x5d555b,_0x5342ee));}),_0xc7d597;});}['editComment'](_0x241fe4,_0x4bd132){return this['_call'](async()=>{let _0x440bdf=s(_0x4bd132);p(_0x241fe4),h(_0x241fe4['content']);let _0x5098cb=a(_0x241fe4),_0x562b9d={..._0x440bdf,'request':_0x5098cb};await this['_middleware']['run']('editComment',_0x562b9d,async()=>{let _0x45b9e3=await this['_databaseCall'](()=>this['_database']['editComment']({'unitID':_0x241fe4['unitID'],'threadID':_0x241fe4['threadID'],'replyID':_0x241fe4['replyID'],'expectedAuthorUserID':_0x440bdf['userID'],'content':_0x241fe4['content'],'mentions':[..._0x241fe4['mentions']]},_0x562b9d));if(_0x45b9e3['status']==='author-mismatch')throw y('Only\x20the\x20Comment\x20author\x20can\x20edit\x20it');if(_0x45b9e3['status']==='not-found'||_0x45b9e3['status']==='closed')throw v('Open\x20Comment\x20was\x20not\x20found');_0x45b9e3['status']==='edited'&&await this['_emitWrite'](_0x440bdf,_0x5098cb,f(n['CommentUpdateEventType']['Edit'],_0x45b9e3['record'],_0x440bdf));});});}['setThreadSolved'](_0x2ace1c,_0x560559){return this['_call'](async()=>{let _0x44ea5a=s(_0x560559);if(m(_0x2ace1c['unitID']),g('threadID',_0x2ace1c['threadID']),_0x2ace1c['solved']!==n['CommentSolvedStatus']['OpenOrReOpen']&&_0x2ace1c['solved']!==n['CommentSolvedStatus']['Solved'])throw _('solved\x20must\x20be\x20OpenOrReOpen\x20or\x20Solved');let _0x357317=a(_0x2ace1c),_0xe4a706={..._0x44ea5a,'request':_0x357317};await this['_middleware']['run']('setThreadSolved',_0xe4a706,async()=>{let _0x446f02=await this['_databaseCall'](()=>this['_database']['setThreadSolved'](_0x2ace1c,_0xe4a706));if(_0x446f02['status']==='not-found')throw v('Comment\x20thread\x20was\x20not\x20found');_0x446f02['status']==='updated'&&await this['_emitWrite'](_0x44ea5a,_0x357317,{'memberId':_0x44ea5a['memberID'],'userId':_0x44ea5a['userID'],'unitId':_0x2ace1c['unitID'],'threadId':_0x2ace1c['threadID'],'type':n['CommentUpdateEventType']['Solve'],'solved':_0x2ace1c['solved']});});});}['deleteComment'](_0xcf4ecd,_0x4bec53){return this['_call'](async()=>{let _0x2c56d6=s(_0x4bec53);m(_0xcf4ecd['unitID']),g('threadID',_0xcf4ecd['threadID']),_0xcf4ecd['replyID']!==void 0x0&&g('replyID',_0xcf4ecd['replyID']);let _0x3b0468=_0xcf4ecd['replyID']===_0xcf4ecd['threadID']?void 0x0:_0xcf4ecd['replyID'],_0x59283b=a({'unitID':_0xcf4ecd['unitID'],'threadID':_0xcf4ecd['threadID'],..._0x3b0468===void 0x0?{}:{'replyID':_0x3b0468}}),_0x1ddb0d={..._0x2c56d6,'request':_0x59283b},_0xe185b3=await this['_databaseCall'](()=>this['_database']['getComment']({'unitID':_0xcf4ecd['unitID'],'threadID':_0xcf4ecd['threadID'],'replyID':_0x3b0468??_0xcf4ecd['threadID']},_0x1ddb0d));if(!_0xe185b3)throw v('Comment\x20was\x20not\x20found');await this['_middleware']['run']('deleteComment',{..._0x1ddb0d,'request':_0x59283b,'target':{'kind':_0x3b0468===void 0x0?'root':'reply','threadID':_0xe185b3['threadID'],'replyID':_0xe185b3['replyID'],'authorUserID':_0xe185b3['authorUserID'],'generation':_0xe185b3['generation']}},async()=>{let _0x16670e=await this['_databaseCall'](()=>this['_database']['deleteComment']({'unitID':_0xcf4ecd['unitID'],'threadID':_0xcf4ecd['threadID'],..._0x3b0468===void 0x0?{}:{'replyID':_0x3b0468},'expectedGeneration':_0xe185b3['generation']},_0x1ddb0d));if(_0x16670e['status']==='not-found')throw v('Comment\x20was\x20not\x20found');if(_0x16670e['status']==='generation-mismatch')throw _('Comment\x20changed\x20before\x20deletion');await this['_emitWrite'](_0x2c56d6,_0x59283b,{'memberId':_0x2c56d6['memberID'],'userId':_0x2c56d6['userID'],'unitId':_0xcf4ecd['unitID'],'threadId':_0xcf4ecd['threadID'],'type':n['CommentUpdateEventType']['Delete'],..._0x3b0468===void 0x0?{}:{'replyId':_0x3b0468}});});});}['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'](_0x25ed2d,_0xe4bc77,_0x4622e8,_0x5955ce){let _0x15df11=await this['_resolveUsers']([_0xe4bc77['authorUserID']],_0x4622e8,_0x5955ce);return{...f(_0x25ed2d,_0xe4bc77,_0x4622e8),..._0x15df11[_0xe4bc77['authorUserID']]?{'user':_0x15df11[_0xe4bc77['authorUserID']]}:{}};}async['_resolveUsers'](_0x2458ab,_0x4d977c,_0x479032){let _0x320150=[...new Set(_0x2458ab['filter'](Boolean))];if(!this['_userProvider']||_0x320150['length']===0x0)return{};let _0x197efd;try{_0x197efd=await this['_userProvider']['getUsers'](_0x320150,{..._0x4d977c,'request':_0x479032});}catch{return{};}let _0x187f99=new Set(_0x320150),_0x5d446a={};for(let _0x14257c of _0x197efd)_0x14257c?.['userID']&&_0x187f99['has'](_0x14257c['userID'])&&(_0x5d446a[_0x14257c['userID']]=_0x14257c);return _0x5d446a;}async['_emitWrite'](_0x3bda81,_0x3ed26c,_0x19d106){let _0x316455={'userID':_0x3bda81['userID'],'memberID':_0x3bda81['memberID'],'customData':_0x3bda81['customData'],'request':_0x3ed26c,'update':_0x19d106,'committedAt':Date['now']()};for(let _0x15f4b7 of[...this['_listeners']['get']('commentCommitted')??[]])try{await _0x15f4b7(_0x316455);}catch{}}['_call'](_0x34fee1){this['_assertRunning']();let _0x4d8a25=_0x34fee1();return this['_calls']['add'](_0x4d8a25),_0x4d8a25['finally'](()=>this['_calls']['delete'](_0x4d8a25))['catch'](()=>void 0x0),_0x4d8a25;}async['_databaseCall'](_0x4d04e3){try{return await _0x4d04e3();}catch(_0x29d4ae){throw _0x29d4ae instanceof t['CollabError']?_0x29d4ae:new t['CollabError']('ADAPTER_FAILURE','Comment\x20Database\x20Adapter\x20failed',{'retryable':!0x0,'cause':_0x29d4ae});}}['_assertRunning'](){if(this['_state']!=='running')throw new t['CollabError']('INTERNAL_ERROR','Comment\x20Service\x20is\x20'+this['_state'],{'retryable':!0x0});}};function a(_0x479f47){return{..._0x479f47};}function o(_0x3a4b0d){return c(_0x3a4b0d),{'userID':_0x3a4b0d['userID'],'customData':_0x3a4b0d['customData']??Object['create'](null)};}function s(_0x6e3a9a){return c(_0x6e3a9a),g('memberID',_0x6e3a9a['memberID']),{'userID':_0x6e3a9a['userID'],'memberID':_0x6e3a9a['memberID'],'customData':_0x6e3a9a['customData']??Object['create'](null)};}function c(_0xfc5e5c){if(!_0xfc5e5c||typeof _0xfc5e5c!='object')throw _('context\x20must\x20be\x20an\x20object');if(g('userID',_0xfc5e5c['userID']),_0xfc5e5c['customData']!==void 0x0&&(_0xfc5e5c['customData']===null||typeof _0xfc5e5c['customData']!='object'||Array['isArray'](_0xfc5e5c['customData'])))throw _('customData\x20must\x20be\x20an\x20object');}function l(_0x2ca3f3){return{'threadId':_0x2ca3f3['threadID'],'replyId':_0x2ca3f3['replyID'],'content':_0x2ca3f3['content'],'userId':_0x2ca3f3['authorUserID'],'createTimestamp':_0x2ca3f3['createdAt']};}function u(_0x588b6e){let _0x4cd960=_0x588b6e['find'](_0x229a76=>_0x229a76['replyID']===_0x229a76['threadID']);return{'threadId':_0x4cd960['threadID'],'solved':_0x4cd960['solved'],'replies':_0x588b6e['map'](l)};}function d(_0x2d9d6d){let _0x26d174=new Map();for(let _0x79071b of _0x2d9d6d){let _0x2813d2=_0x26d174['get'](_0x79071b['threadID'])??[];_0x2813d2['push'](_0x79071b),_0x26d174['set'](_0x79071b['threadID'],_0x2813d2);}let _0x3c31e1={};for(let [_0x5d8160,_0x206b17]of _0x26d174)_0x206b17['find'](_0x3308e4=>_0x3308e4['replyID']===_0x5d8160)&&(_0x3c31e1[_0x5d8160]=u([..._0x206b17]['sort']((_0x27f32b,_0x65809f)=>_0x27f32b['replyID']===_0x5d8160?-0x1:_0x65809f['replyID']===_0x5d8160?0x1:_0x27f32b['createdAt']-_0x65809f['createdAt']||_0x27f32b['replyID']['localeCompare'](_0x65809f['replyID']))));return _0x3c31e1;}function f(_0x339c5c,_0x444235,_0x1c5ed5){return{'memberId':_0x1c5ed5['memberID'],'userId':_0x1c5ed5['userID'],'unitId':_0x444235['unitID'],'threadId':_0x444235['threadID'],'type':_0x339c5c,'replyId':_0x444235['replyID'],'content':_0x444235['content'],'createTimestamp':String(_0x444235['createdAt'])};}function p(_0x1ec2a7){m(_0x1ec2a7['unitID']),g('threadID',_0x1ec2a7['threadID']),g('replyID',_0x1ec2a7['replyID']);}function m(_0x50871b){g('unitID',_0x50871b);}function h(_0x235412){if(typeof _0x235412!='string'||_0x235412['length']===0x0)throw _('content\x20must\x20be\x20a\x20non-empty\x20string');}function g(_0x49a8f3,_0x183d46){if(typeof _0x183d46!='string'||_0x183d46['length']===0x0)throw _(_0x49a8f3+'\x20must\x20be\x20a\x20non-empty\x20string');}function _(_0x40e074){return new t['CollabError']('INVALID_REQUEST',_0x40e074);}function v(_0x16e4a9){return new t['CollabError']('UNIT_NOT_FOUND',_0x16e4a9);}function y(_0xfc0b20){return new t['CollabError']('PERMISSION_DENIED',_0xfc0b20);}exports['UniverCommentService']=i;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- (function(_0x22162e,_0x2d5c04){const _0x30490d=_0x2a4f,_0x421220=_0x22162e();while(!![]){try{const _0x3c3e82=parseInt(_0x30490d(0x1a4))/0x1*(-parseInt(_0x30490d(0x1a3))/0x2)+parseInt(_0x30490d(0x1a7))/0x3*(-parseInt(_0x30490d(0x1aa))/0x4)+-parseInt(_0x30490d(0x1a5))/0x5+parseInt(_0x30490d(0x1a6))/0x6+parseInt(_0x30490d(0x1ab))/0x7*(parseInt(_0x30490d(0x1ad))/0x8)+-parseInt(_0x30490d(0x1a8))/0x9*(parseInt(_0x30490d(0x1ac))/0xa)+parseInt(_0x30490d(0x1a9))/0xb;if(_0x3c3e82===_0x2d5c04)break;else _0x421220['push'](_0x421220['shift']());}catch(_0x14cd3a){_0x421220['push'](_0x421220['shift']());}}}(_0x12ab,0x72d31));function _0x12ab(){const _0x3164c5=['12471811TAaqzC','940kyFqiR','408331RWWswt','190KdQorI','104ynKxzl','512938ELWrpq','3scIgGZ','3429330zYtWOd','4932474ouVEHx','1173qcaYDh','330030pMlmPx'];_0x12ab=function(){return _0x3164c5;};return _0x12ab();}import _0x5476a5 from'./index.cjs';const facadeExport0=_0x5476a5['UniverCommentService'];function _0x2a4f(_0x344496,_0x5e8397){_0x344496=_0x344496-0x1a3;const _0x12ab14=_0x12ab();let _0x2a4f44=_0x12ab14[_0x344496];return _0x2a4f44;}export{facadeExport0 as UniverCommentService};
1
+ const _0x410b96=_0x2620;function _0x2620(_0x4b62f6,_0x4928bd){_0x4b62f6=_0x4b62f6-0x1c3;const _0x2ced5b=_0x2ced();let _0x2620ac=_0x2ced5b[_0x4b62f6];return _0x2620ac;}(function(_0x51321e,_0x59b28f){const _0x21bc27=_0x2620,_0x449b23=_0x51321e();while(!![]){try{const _0xe356c6=-parseInt(_0x21bc27(0x1cc))/0x1+parseInt(_0x21bc27(0x1cd))/0x2+parseInt(_0x21bc27(0x1ca))/0x3+parseInt(_0x21bc27(0x1c4))/0x4*(-parseInt(_0x21bc27(0x1c8))/0x5)+-parseInt(_0x21bc27(0x1c6))/0x6*(-parseInt(_0x21bc27(0x1cb))/0x7)+parseInt(_0x21bc27(0x1c9))/0x8*(parseInt(_0x21bc27(0x1c7))/0x9)+parseInt(_0x21bc27(0x1ce))/0xa*(-parseInt(_0x21bc27(0x1c3))/0xb);if(_0xe356c6===_0x59b28f)break;else _0x449b23['push'](_0x449b23['shift']());}catch(_0x29c782){_0x449b23['push'](_0x449b23['shift']());}}}(_0x2ced,0x38fde));function _0x2ced(){const _0x2274c5=['18rooUFt','9FAOchE','910045OFERaU','3494552bEgiYZ','458784aMPgmG','1080247cirVnQ','324098uvnkKN','727388IGphqJ','6768590Rokquz','11shizcd','4ZrLwKs','UniverCommentService'];_0x2ced=function(){return _0x2274c5;};return _0x2ced();}import _0x554b58 from'./index.cjs';const facadeExport0=_0x554b58[_0x410b96(0x1c5)];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.0.0",
4
+ "version": "1.0.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.0.0",
20
- "@univerjs/protocol": "1.0.0"
19
+ "@univerjs-pro/collaboration-service": "1.0.1",
20
+ "@univerjs/protocol": "1.0.1"
21
21
  }
22
22
  }