@univerjs-pro/collaboration-comment-service 1.0.0 → 1.0.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'](_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'](_0x32fd6e,_0x32273d){let _0x12d4c7=this['_middlewares']['get'](_0x32fd6e)??[],_0x2c2667=_0x32273d;_0x12d4c7['push'](_0x2c2667),this['_middlewares']['set'](_0x32fd6e,_0x12d4c7);let _0x2d7455=!0x1;return{'dispose':()=>{if(_0x2d7455)return;_0x2d7455=!0x0;let _0x16c4db=_0x12d4c7['indexOf'](_0x2c2667);_0x16c4db>=0x0&&_0x12d4c7['splice'](_0x16c4db,0x1);}};}async['run'](_0x3da36f,_0x324b11,_0xb4f616){let _0x5db439=[...this['_middlewares']['get'](_0x3da36f)??[]],_0x39cb32=async _0x1eb080=>{let _0x475aaf=_0x5db439[_0x1eb080];if(!_0x475aaf)return _0xb4f616();let _0x380554=!0x1,_0x2eb04f,_0x35a588=()=>{if(_0x380554)throw Error('Middleware\x20for\x20action\x20'+_0x3da36f+'\x20called\x20next()\x20more\x20than\x20once');return _0x380554=!0x0,_0x2eb04f=_0x39cb32(_0x1eb080+0x1),_0x2eb04f;};try{await _0x475aaf(_0x324b11,_0x35a588);}catch(_0x59425f){throw _0x2eb04f&&await _0x2eb04f['catch'](()=>void 0x0),_0x59425f;}if(!_0x380554)throw Error('Middleware\x20for\x20action\x20'+_0x3da36f+'\x20completed\x20without\x20calling\x20next()');await _0x2eb04f;};await _0x39cb32(0x0);}['clear'](){this['_middlewares']['clear']();}},i=class{['_middleware']=new r();['_listeners']=new Map();['_calls']=new Set();['_database'];['_userProvider'];['_state']='running';['_disposePromise'];constructor(_0x5d3dac){if(!_0x5d3dac?.['database'])throw TypeError('UniverCommentService\x20requires\x20a\x20database');this['_database']=_0x5d3dac['database'],this['_userProvider']=_0x5d3dac['userProvider'];}['use'](_0x2b131c,_0x49e006){return this['_assertRunning'](),this['_middleware']['use'](_0x2b131c,_0x49e006);}['on'](_0x42e415,_0x37d3ed){this['_assertRunning']();let _0x1b9dca=this['_listeners']['get'](_0x42e415)??new Set(),_0x5e6c9f=_0x37d3ed;_0x1b9dca['add'](_0x5e6c9f),this['_listeners']['set'](_0x42e415,_0x1b9dca);let _0x24357d=!0x1;return{'dispose':()=>{_0x24357d||(_0x24357d=!0x0,_0x1b9dca['delete'](_0x5e6c9f));}};}['addComment'](_0x45926f,_0x1fb7b9){return this['_call'](async()=>{let _0x33dfe9=s(_0x1fb7b9);m(_0x45926f['unitID']),h(_0x45926f['content']);let _0x334e52=a(_0x45926f),_0x5f0df4={..._0x33dfe9,'request':_0x334e52},_0x2768b6;return await this['_middleware']['run']('addComment',_0x5f0df4,async()=>{let _0x538cef=await this['_databaseCall'](()=>this['_database']['createRoot']({'unitID':_0x45926f['unitID'],'threadID':(0x0,e['randomUUID'])(),'authorUserID':_0x33dfe9['userID'],'content':_0x45926f['content'],'mentions':[..._0x45926f['mentions']]},_0x5f0df4));if(_0x538cef['status']==='duplicate')throw _('Comment\x20ID\x20already\x20exists');_0x2768b6=u([_0x538cef['record']]),await this['_emitWrite'](_0x33dfe9,_0x334e52,await this['_createUpdate'](n['CommentUpdateEventType']['Add'],_0x538cef['record'],_0x33dfe9,_0x334e52));}),_0x2768b6;});}['listComments'](_0x465022,_0x132652){return this['_call'](async()=>{let _0x56131e=o(_0x132652);m(_0x465022['unitID']),_0x465022['threadIDs']['forEach'](_0x5d3d03=>g('threadID',_0x5d3d03));let _0x5e0474=a(_0x465022),_0x4db116={..._0x56131e,'request':_0x5e0474},_0x366395;return await this['_middleware']['run']('listComments',_0x4db116,async()=>{let _0x56c6dc=d(await this['_databaseCall'](()=>this['_database']['listThreads']({'unitID':_0x465022['unitID'],'threadIDs':[...new Set(_0x465022['threadIDs'])]},_0x4db116))),_0x1191a1=Object['values'](_0x56c6dc)['flatMap'](_0xb5c34d=>_0xb5c34d['replies']['map'](_0x322adf=>_0x322adf['userId']));_0x366395={'comments':_0x56c6dc,'users':await this['_resolveUsers'](_0x1191a1,_0x56131e,_0x5e0474)};}),_0x366395;});}['replyComment'](_0x35becb,_0x48fc11){return this['_call'](async()=>{let _0x2030c2=s(_0x48fc11);m(_0x35becb['unitID']),g('threadID',_0x35becb['threadID']),h(_0x35becb['content']);let _0x1996b6=a(_0x35becb),_0x26f6bf={..._0x2030c2,'request':_0x1996b6},_0x1579fb;return await this['_middleware']['run']('replyComment',_0x26f6bf,async()=>{let _0x374d3b=await this['_databaseCall'](()=>this['_database']['createReply']({'unitID':_0x35becb['unitID'],'threadID':_0x35becb['threadID'],'replyID':(0x0,e['randomUUID'])(),'authorUserID':_0x2030c2['userID'],'content':_0x35becb['content'],'mentions':[..._0x35becb['mentions']]},_0x26f6bf));if(_0x374d3b['status']==='not-found'||_0x374d3b['status']==='closed')throw v('Open\x20Comment\x20thread\x20was\x20not\x20found');if(_0x374d3b['status']==='duplicate')throw _('Comment\x20ID\x20already\x20exists');_0x1579fb=l(_0x374d3b['record']),await this['_emitWrite'](_0x2030c2,_0x1996b6,await this['_createUpdate'](n['CommentUpdateEventType']['Reply'],_0x374d3b['record'],_0x2030c2,_0x1996b6));}),_0x1579fb;});}['editComment'](_0x47c317,_0x264546){return this['_call'](async()=>{let _0x1967d1=s(_0x264546);p(_0x47c317),h(_0x47c317['content']);let _0x7d36f9=a(_0x47c317),_0x418df6={..._0x1967d1,'request':_0x7d36f9};await this['_middleware']['run']('editComment',_0x418df6,async()=>{let _0x21eb14=await this['_databaseCall'](()=>this['_database']['editComment']({'unitID':_0x47c317['unitID'],'threadID':_0x47c317['threadID'],'replyID':_0x47c317['replyID'],'expectedAuthorUserID':_0x1967d1['userID'],'content':_0x47c317['content'],'mentions':[..._0x47c317['mentions']]},_0x418df6));if(_0x21eb14['status']==='author-mismatch')throw y('Only\x20the\x20Comment\x20author\x20can\x20edit\x20it');if(_0x21eb14['status']==='not-found'||_0x21eb14['status']==='closed')throw v('Open\x20Comment\x20was\x20not\x20found');_0x21eb14['status']==='edited'&&await this['_emitWrite'](_0x1967d1,_0x7d36f9,f(n['CommentUpdateEventType']['Edit'],_0x21eb14['record'],_0x1967d1));});});}['setThreadSolved'](_0x4ef47f,_0x34a028){return this['_call'](async()=>{let _0xf95b9e=s(_0x34a028);if(m(_0x4ef47f['unitID']),g('threadID',_0x4ef47f['threadID']),_0x4ef47f['solved']!==n['CommentSolvedStatus']['OpenOrReOpen']&&_0x4ef47f['solved']!==n['CommentSolvedStatus']['Solved'])throw _('solved\x20must\x20be\x20OpenOrReOpen\x20or\x20Solved');let _0x23fa5b=a(_0x4ef47f),_0xd3978a={..._0xf95b9e,'request':_0x23fa5b};await this['_middleware']['run']('setThreadSolved',_0xd3978a,async()=>{let _0x39639d=await this['_databaseCall'](()=>this['_database']['setThreadSolved'](_0x4ef47f,_0xd3978a));if(_0x39639d['status']==='not-found')throw v('Comment\x20thread\x20was\x20not\x20found');_0x39639d['status']==='updated'&&await this['_emitWrite'](_0xf95b9e,_0x23fa5b,{'memberId':_0xf95b9e['memberID'],'userId':_0xf95b9e['userID'],'unitId':_0x4ef47f['unitID'],'threadId':_0x4ef47f['threadID'],'type':n['CommentUpdateEventType']['Solve'],'solved':_0x4ef47f['solved']});});});}['deleteComment'](_0x533b5c,_0x41de56){return this['_call'](async()=>{let _0x1405b5=s(_0x41de56);m(_0x533b5c['unitID']),g('threadID',_0x533b5c['threadID']),_0x533b5c['replyID']!==void 0x0&&g('replyID',_0x533b5c['replyID']);let _0x106d98=_0x533b5c['replyID']===_0x533b5c['threadID']?void 0x0:_0x533b5c['replyID'],_0x3fc157=a({'unitID':_0x533b5c['unitID'],'threadID':_0x533b5c['threadID'],..._0x106d98===void 0x0?{}:{'replyID':_0x106d98}}),_0x3f1aee={..._0x1405b5,'request':_0x3fc157},_0x1555ed=await this['_databaseCall'](()=>this['_database']['getComment']({'unitID':_0x533b5c['unitID'],'threadID':_0x533b5c['threadID'],'replyID':_0x106d98??_0x533b5c['threadID']},_0x3f1aee));if(!_0x1555ed)throw v('Comment\x20was\x20not\x20found');await this['_middleware']['run']('deleteComment',{..._0x3f1aee,'request':_0x3fc157,'target':{'kind':_0x106d98===void 0x0?'root':'reply','threadID':_0x1555ed['threadID'],'replyID':_0x1555ed['replyID'],'authorUserID':_0x1555ed['authorUserID'],'generation':_0x1555ed['generation']}},async()=>{let _0x563d6c=await this['_databaseCall'](()=>this['_database']['deleteComment']({'unitID':_0x533b5c['unitID'],'threadID':_0x533b5c['threadID'],..._0x106d98===void 0x0?{}:{'replyID':_0x106d98},'expectedGeneration':_0x1555ed['generation']},_0x3f1aee));if(_0x563d6c['status']==='not-found')throw v('Comment\x20was\x20not\x20found');if(_0x563d6c['status']==='generation-mismatch')throw _('Comment\x20changed\x20before\x20deletion');await this['_emitWrite'](_0x1405b5,_0x3fc157,{'memberId':_0x1405b5['memberID'],'userId':_0x1405b5['userID'],'unitId':_0x533b5c['unitID'],'threadId':_0x533b5c['threadID'],'type':n['CommentUpdateEventType']['Delete'],..._0x106d98===void 0x0?{}:{'replyId':_0x106d98}});});});}['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'](_0x2f2637,_0x449197,_0x4bfee9,_0xb979c3){let _0x5d43c5=await this['_resolveUsers']([_0x449197['authorUserID']],_0x4bfee9,_0xb979c3);return{...f(_0x2f2637,_0x449197,_0x4bfee9),..._0x5d43c5[_0x449197['authorUserID']]?{'user':_0x5d43c5[_0x449197['authorUserID']]}:{}};}async['_resolveUsers'](_0x10ddb8,_0x1a41ff,_0x24c070){let _0x4d4961=[...new Set(_0x10ddb8['filter'](Boolean))];if(!this['_userProvider']||_0x4d4961['length']===0x0)return{};let _0x484c7b;try{_0x484c7b=await this['_userProvider']['getUsers'](_0x4d4961,{..._0x1a41ff,'request':_0x24c070});}catch{return{};}let _0x23f96e=new Set(_0x4d4961),_0x54f388={};for(let _0x5d83c4 of _0x484c7b)_0x5d83c4?.['userID']&&_0x23f96e['has'](_0x5d83c4['userID'])&&(_0x54f388[_0x5d83c4['userID']]=_0x5d83c4);return _0x54f388;}async['_emitWrite'](_0x25ef00,_0x13dfd9,_0x589c66){let _0x3f18f4={'userID':_0x25ef00['userID'],'memberID':_0x25ef00['memberID'],'customData':_0x25ef00['customData'],'request':_0x13dfd9,'update':_0x589c66,'committedAt':Date['now']()};for(let _0x5ef2c9 of[...this['_listeners']['get']('commentCommitted')??[]])try{await _0x5ef2c9(_0x3f18f4);}catch{}}['_call'](_0x3f3b2d){this['_assertRunning']();let _0x5f1d13=_0x3f3b2d();return this['_calls']['add'](_0x5f1d13),_0x5f1d13['finally'](()=>this['_calls']['delete'](_0x5f1d13))['catch'](()=>void 0x0),_0x5f1d13;}async['_databaseCall'](_0x2c46c0){try{return await _0x2c46c0();}catch(_0x2e6a96){throw _0x2e6a96 instanceof t['CollabError']?_0x2e6a96:new t['CollabError']('ADAPTER_FAILURE','Comment\x20Database\x20Adapter\x20failed',{'retryable':!0x0,'cause':_0x2e6a96});}}['_assertRunning'](){if(this['_state']!=='running')throw new t['CollabError']('INTERNAL_ERROR','Comment\x20Service\x20is\x20'+this['_state'],{'retryable':!0x0});}};function a(_0x13e2d6){return{..._0x13e2d6};}function o(_0x14821f){return c(_0x14821f),{'userID':_0x14821f['userID'],'customData':_0x14821f['customData']??Object['create'](null)};}function s(_0x2078eb){return c(_0x2078eb),g('memberID',_0x2078eb['memberID']),{'userID':_0x2078eb['userID'],'memberID':_0x2078eb['memberID'],'customData':_0x2078eb['customData']??Object['create'](null)};}function c(_0x36d66b){if(!_0x36d66b||typeof _0x36d66b!='object')throw _('context\x20must\x20be\x20an\x20object');if(g('userID',_0x36d66b['userID']),_0x36d66b['customData']!==void 0x0&&(_0x36d66b['customData']===null||typeof _0x36d66b['customData']!='object'||Array['isArray'](_0x36d66b['customData'])))throw _('customData\x20must\x20be\x20an\x20object');}function l(_0x5048e3){return{'threadId':_0x5048e3['threadID'],'replyId':_0x5048e3['replyID'],'content':_0x5048e3['content'],'userId':_0x5048e3['authorUserID'],'createTimestamp':_0x5048e3['createdAt']};}function u(_0x1a715c){let _0x18ae3e=_0x1a715c['find'](_0xc5e620=>_0xc5e620['replyID']===_0xc5e620['threadID']);return{'threadId':_0x18ae3e['threadID'],'solved':_0x18ae3e['solved'],'replies':_0x1a715c['map'](l)};}function d(_0x3c1d4d){let _0x7f47e9=new Map();for(let _0x5e74a6 of _0x3c1d4d){let _0x444148=_0x7f47e9['get'](_0x5e74a6['threadID'])??[];_0x444148['push'](_0x5e74a6),_0x7f47e9['set'](_0x5e74a6['threadID'],_0x444148);}let _0x2617e5={};for(let [_0x45aa7e,_0x39d699]of _0x7f47e9)_0x39d699['find'](_0x4d8961=>_0x4d8961['replyID']===_0x45aa7e)&&(_0x2617e5[_0x45aa7e]=u([..._0x39d699]['sort']((_0x4903f9,_0x4dbf18)=>_0x4903f9['replyID']===_0x45aa7e?-0x1:_0x4dbf18['replyID']===_0x45aa7e?0x1:_0x4903f9['createdAt']-_0x4dbf18['createdAt']||_0x4903f9['replyID']['localeCompare'](_0x4dbf18['replyID']))));return _0x2617e5;}function f(_0x2bbd2f,_0x3ef1c0,_0x30720e){return{'memberId':_0x30720e['memberID'],'userId':_0x30720e['userID'],'unitId':_0x3ef1c0['unitID'],'threadId':_0x3ef1c0['threadID'],'type':_0x2bbd2f,'replyId':_0x3ef1c0['replyID'],'content':_0x3ef1c0['content'],'createTimestamp':String(_0x3ef1c0['createdAt'])};}function p(_0x36f15e){m(_0x36f15e['unitID']),g('threadID',_0x36f15e['threadID']),g('replyID',_0x36f15e['replyID']);}function m(_0x1fb40b){g('unitID',_0x1fb40b);}function h(_0x32838b){if(typeof _0x32838b!='string'||_0x32838b['length']===0x0)throw _('content\x20must\x20be\x20a\x20non-empty\x20string');}function g(_0x1cbbdc,_0x36cb2a){if(typeof _0x36cb2a!='string'||_0x36cb2a['length']===0x0)throw _(_0x1cbbdc+'\x20must\x20be\x20a\x20non-empty\x20string');}function _(_0x18a67a){return new t['CollabError']('INVALID_REQUEST',_0x18a67a);}function v(_0x139978){return new t['CollabError']('UNIT_NOT_FOUND',_0x139978);}function y(_0x4eeb5e){return new t['CollabError']('PERMISSION_DENIED',_0x4eeb5e);}exports['UniverCommentService']=i;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0xfc26a0,_0x382116){const _0x1c11c3=_0x2421,_0x43fea3=_0xfc26a0();while(!![]){try{const _0x184ab7=parseInt(_0x1c11c3(0x165))/0x1+parseInt(_0x1c11c3(0x168))/0x2+-parseInt(_0x1c11c3(0x166))/0x3*(-parseInt(_0x1c11c3(0x167))/0x4)+parseInt(_0x1c11c3(0x16d))/0x5+-parseInt(_0x1c11c3(0x16c))/0x6*(-parseInt(_0x1c11c3(0x169))/0x7)+parseInt(_0x1c11c3(0x16b))/0x8+-parseInt(_0x1c11c3(0x16a))/0x9*(parseInt(_0x1c11c3(0x16e))/0xa);if(_0x184ab7===_0x382116)break;else _0x43fea3['push'](_0x43fea3['shift']());}catch(_0x1dbedf){_0x43fea3['push'](_0x43fea3['shift']());}}}(_0x15d3,0x55890));function _0x15d3(){const _0x17da2c=['1406200qQFlIA','1280orcZFF','267368bKAZgO','3XbcpaY','384044omTjsZ','407028jvGwmZ','12180UWgtLk','59544YnaYsU','941176aayKsE','798TUYvKS'];_0x15d3=function(){return _0x17da2c;};return _0x15d3();}import _0x311bb8 from'./index.cjs';function _0x2421(_0x35adcb,_0x477d9d){_0x35adcb=_0x35adcb-0x165;const _0x15d3e9=_0x15d3();let _0x2421d9=_0x15d3e9[_0x35adcb];return _0x2421d9;}const facadeExport0=_0x311bb8['UniverCommentService'];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.
|
|
4
|
+
"version": "1.0.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.0.
|
|
20
|
-
"@univerjs/protocol": "1.0.
|
|
19
|
+
"@univerjs-pro/collaboration-service": "1.0.2",
|
|
20
|
+
"@univerjs/protocol": "1.0.2"
|
|
21
21
|
}
|
|
22
22
|
}
|