@univerjs-pro/collaboration-comment-service 1.4.0 → 1.6.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 +1 -1
- package/dist/index.d.ts +1 -8
- 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'](_0x378e00,_0x853a1f){let _0x18702e=this['_middlewares']['get'](_0x378e00)??[],_0x43109c=_0x853a1f;_0x18702e['push'](_0x43109c),this['_middlewares']['set'](_0x378e00,_0x18702e);let _0x440ff0=!0x1;return{'dispose':()=>{if(_0x440ff0)return;_0x440ff0=!0x0;let _0x1aff6b=_0x18702e['indexOf'](_0x43109c);_0x1aff6b>=0x0&&_0x18702e['splice'](_0x1aff6b,0x1);}};}async['run'](_0x26304e,_0x3f8c21,_0x2c58fe){let _0x32d234=[...this['_middlewares']['get'](_0x26304e)??[]],_0x4c4bc2=async _0x53e4c2=>{let _0x59009d=_0x32d234[_0x53e4c2];if(!_0x59009d)return _0x2c58fe();let _0x2f1671=!0x1,_0x66d331,_0x3d76ba=()=>{if(_0x2f1671)throw Error('Middleware\x20for\x20action\x20'+_0x26304e+'\x20called\x20next()\x20more\x20than\x20once');return _0x2f1671=!0x0,_0x66d331=_0x4c4bc2(_0x53e4c2+0x1),_0x66d331;};try{await _0x59009d(_0x3f8c21,_0x3d76ba);}catch(_0x14f72c){throw _0x66d331&&await _0x66d331['catch'](()=>void 0x0),_0x14f72c;}if(!_0x2f1671)throw Error('Middleware\x20for\x20action\x20'+_0x26304e+'\x20completed\x20without\x20calling\x20next()');await _0x66d331;};await _0x4c4bc2(0x0);}['clear'](){this['_middlewares']['clear']();}},i=class{['_middleware']=new r();['_listeners']=new Map();['_calls']=new Set();['_database'];['_userProvider'];['_state']='running';['_disposePromise'];constructor(_0x2ebad0){if(!_0x2ebad0?.['database'])throw TypeError('UniverCommentService\x20requires\x20a\x20database');this['_database']=_0x2ebad0['database'],this['_userProvider']=_0x2ebad0['userProvider'];}['use'](_0x2724fb,_0x95fa9b){return this['_assertRunning'](),this['_middleware']['use'](_0x2724fb,_0x95fa9b);}['on'](_0x2e67ef,_0xa7a61a){this['_assertRunning']();let _0x16c4c9=this['_listeners']['get'](_0x2e67ef)??new Set(),_0x45bc60=_0xa7a61a;_0x16c4c9['add'](_0x45bc60),this['_listeners']['set'](_0x2e67ef,_0x16c4c9);let _0x5354f2=!0x1;return{'dispose':()=>{_0x5354f2||(_0x5354f2=!0x0,_0x16c4c9['delete'](_0x45bc60));}};}['addComment'](_0x2d31bf,_0x40db82){return this['_call'](async()=>{let _0x2ee180=s(_0x40db82);m(_0x2d31bf['unitID']),h(_0x2d31bf['content']);let _0x4a56a5=a(_0x2d31bf),_0x31e885={..._0x2ee180,'request':_0x4a56a5},_0x5c9de3;return await this['_middleware']['run']('addComment',_0x31e885,async()=>{let _0xa7db92=await this['_databaseCall'](()=>this['_database']['createRoot']({'unitID':_0x2d31bf['unitID'],'threadID':(0x0,e['randomUUID'])(),'authorUserID':_0x2ee180['userID'],'content':_0x2d31bf['content'],'mentions':[..._0x2d31bf['mentions']]},_0x31e885));if(_0xa7db92['status']==='duplicate')throw _('Comment\x20ID\x20already\x20exists');_0x5c9de3=u([_0xa7db92['record']]),await this['_emitWrite'](_0x2ee180,_0x4a56a5,await this['_createUpdate'](n['CommentUpdateEventType']['Add'],_0xa7db92['record'],_0x2ee180,_0x4a56a5));}),_0x5c9de3;});}['listComments'](_0x2f4b82,_0x530f67){return this['_call'](async()=>{let _0x105424=o(_0x530f67);m(_0x2f4b82['unitID']),_0x2f4b82['threadIDs']['forEach'](_0x26fd84=>g('threadID',_0x26fd84));let _0x5aeff5=a(_0x2f4b82),_0x38ba71={..._0x105424,'request':_0x5aeff5},_0x3b224b;return await this['_middleware']['run']('listComments',_0x38ba71,async()=>{let _0x2f62d7=d(await this['_databaseCall'](()=>this['_database']['listThreads']({'unitID':_0x2f4b82['unitID'],'threadIDs':[...new Set(_0x2f4b82['threadIDs'])]},_0x38ba71))),_0x24d0b7=Object['values'](_0x2f62d7)['flatMap'](_0x4c6c03=>_0x4c6c03['replies']['map'](_0xca2cb1=>_0xca2cb1['userId']));_0x3b224b={'comments':_0x2f62d7,'users':await this['_resolveUsers'](_0x24d0b7,_0x105424,_0x5aeff5)};}),_0x3b224b;});}['replyComment'](_0x20b7f4,_0x12f182){return this['_call'](async()=>{let _0x5df7ed=s(_0x12f182);m(_0x20b7f4['unitID']),g('threadID',_0x20b7f4['threadID']),h(_0x20b7f4['content']);let _0x35da43=a(_0x20b7f4),_0x197839={..._0x5df7ed,'request':_0x35da43},_0x3d63a8;return await this['_middleware']['run']('replyComment',_0x197839,async()=>{let _0x2f882f=await this['_databaseCall'](()=>this['_database']['createReply']({'unitID':_0x20b7f4['unitID'],'threadID':_0x20b7f4['threadID'],'replyID':(0x0,e['randomUUID'])(),'authorUserID':_0x5df7ed['userID'],'content':_0x20b7f4['content'],'mentions':[..._0x20b7f4['mentions']]},_0x197839));if(_0x2f882f['status']==='not-found'||_0x2f882f['status']==='closed')throw v('Open\x20Comment\x20thread\x20was\x20not\x20found');if(_0x2f882f['status']==='duplicate')throw _('Comment\x20ID\x20already\x20exists');_0x3d63a8=l(_0x2f882f['record']),await this['_emitWrite'](_0x5df7ed,_0x35da43,await this['_createUpdate'](n['CommentUpdateEventType']['Reply'],_0x2f882f['record'],_0x5df7ed,_0x35da43));}),_0x3d63a8;});}['editComment'](_0xc34965,_0x5de3dd){return this['_call'](async()=>{let _0x5a8dce=s(_0x5de3dd);p(_0xc34965),h(_0xc34965['content']);let _0x39c340=a(_0xc34965),_0x520119={..._0x5a8dce,'request':_0x39c340};await this['_middleware']['run']('editComment',_0x520119,async()=>{let _0x584a7a=await this['_databaseCall'](()=>this['_database']['editComment']({'unitID':_0xc34965['unitID'],'threadID':_0xc34965['threadID'],'replyID':_0xc34965['replyID'],'expectedAuthorUserID':_0x5a8dce['userID'],'content':_0xc34965['content'],'mentions':[..._0xc34965['mentions']]},_0x520119));if(_0x584a7a['status']==='author-mismatch')throw y('Only\x20the\x20Comment\x20author\x20can\x20edit\x20it');if(_0x584a7a['status']==='not-found'||_0x584a7a['status']==='closed')throw v('Open\x20Comment\x20was\x20not\x20found');_0x584a7a['status']==='edited'&&await this['_emitWrite'](_0x5a8dce,_0x39c340,f(n['CommentUpdateEventType']['Edit'],_0x584a7a['record'],_0x5a8dce));});});}['setThreadSolved'](_0x4d8022,_0x4fcf41){return this['_call'](async()=>{let _0xb1073e=s(_0x4fcf41);if(m(_0x4d8022['unitID']),g('threadID',_0x4d8022['threadID']),_0x4d8022['solved']!==n['CommentSolvedStatus']['OpenOrReOpen']&&_0x4d8022['solved']!==n['CommentSolvedStatus']['Solved'])throw _('solved\x20must\x20be\x20OpenOrReOpen\x20or\x20Solved');let _0x584381=a(_0x4d8022),_0x4a37ce={..._0xb1073e,'request':_0x584381};await this['_middleware']['run']('setThreadSolved',_0x4a37ce,async()=>{let _0x484bb1=await this['_databaseCall'](()=>this['_database']['setThreadSolved'](_0x4d8022,_0x4a37ce));if(_0x484bb1['status']==='not-found')throw v('Comment\x20thread\x20was\x20not\x20found');_0x484bb1['status']==='updated'&&await this['_emitWrite'](_0xb1073e,_0x584381,{'memberId':_0xb1073e['memberID'],'userId':_0xb1073e['userID'],'unitId':_0x4d8022['unitID'],'threadId':_0x4d8022['threadID'],'type':n['CommentUpdateEventType']['Solve'],'solved':_0x4d8022['solved']});});});}['deleteComment'](_0xbfcba,_0xc68dec){return this['_call'](async()=>{let _0x4d11a0=s(_0xc68dec);m(_0xbfcba['unitID']),g('threadID',_0xbfcba['threadID']),_0xbfcba['replyID']!==void 0x0&&g('replyID',_0xbfcba['replyID']);let _0x89193b=_0xbfcba['replyID']===_0xbfcba['threadID']?void 0x0:_0xbfcba['replyID'],_0x45534f=a({'unitID':_0xbfcba['unitID'],'threadID':_0xbfcba['threadID'],..._0x89193b===void 0x0?{}:{'replyID':_0x89193b}}),_0x3df622={..._0x4d11a0,'request':_0x45534f},_0x2b4d7e=await this['_databaseCall'](()=>this['_database']['getComment']({'unitID':_0xbfcba['unitID'],'threadID':_0xbfcba['threadID'],'replyID':_0x89193b??_0xbfcba['threadID']},_0x3df622));if(!_0x2b4d7e)throw v('Comment\x20was\x20not\x20found');await this['_middleware']['run']('deleteComment',{..._0x3df622,'request':_0x45534f,'target':{'kind':_0x89193b===void 0x0?'root':'reply','threadID':_0x2b4d7e['threadID'],'replyID':_0x2b4d7e['replyID'],'authorUserID':_0x2b4d7e['authorUserID'],'generation':_0x2b4d7e['generation']}},async()=>{let _0x242e91=await this['_databaseCall'](()=>this['_database']['deleteComment']({'unitID':_0xbfcba['unitID'],'threadID':_0xbfcba['threadID'],..._0x89193b===void 0x0?{}:{'replyID':_0x89193b},'expectedGeneration':_0x2b4d7e['generation']},_0x3df622));if(_0x242e91['status']==='not-found')throw v('Comment\x20was\x20not\x20found');if(_0x242e91['status']==='generation-mismatch')throw _('Comment\x20changed\x20before\x20deletion');await this['_emitWrite'](_0x4d11a0,_0x45534f,{'memberId':_0x4d11a0['memberID'],'userId':_0x4d11a0['userID'],'unitId':_0xbfcba['unitID'],'threadId':_0xbfcba['threadID'],'type':n['CommentUpdateEventType']['Delete'],..._0x89193b===void 0x0?{}:{'replyId':_0x89193b}});});});}['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'](_0xb0c6f,_0x1d0f7d,_0x313a60,_0x1f0a98){let _0x4bba8a=await this['_resolveUsers']([_0x1d0f7d['authorUserID']],_0x313a60,_0x1f0a98);return{...f(_0xb0c6f,_0x1d0f7d,_0x313a60),..._0x4bba8a[_0x1d0f7d['authorUserID']]?{'user':_0x4bba8a[_0x1d0f7d['authorUserID']]}:{}};}async['_resolveUsers'](_0x3d7452,_0x51e6f8,_0x1ffa2f){let _0x47eafe=[...new Set(_0x3d7452['filter'](Boolean))];if(!this['_userProvider']||_0x47eafe['length']===0x0)return{};let _0x21ef96;try{_0x21ef96=await this['_userProvider']['getUsers'](_0x47eafe,{..._0x51e6f8,'request':_0x1ffa2f});}catch{return{};}let _0x103824=new Set(_0x47eafe),_0x2c40cc={};for(let _0x5716ca of _0x21ef96)_0x5716ca?.['userID']&&_0x103824['has'](_0x5716ca['userID'])&&(_0x2c40cc[_0x5716ca['userID']]=_0x5716ca);return _0x2c40cc;}async['_emitWrite'](_0x4c4949,_0x2dced8,_0x3cf1c8){let _0x524cbe={'userID':_0x4c4949['userID'],'memberID':_0x4c4949['memberID'],'customData':_0x4c4949['customData'],'request':_0x2dced8,'update':_0x3cf1c8,'committedAt':Date['now']()};for(let _0x2e7691 of[...this['_listeners']['get']('commentCommitted')??[]])try{await _0x2e7691(_0x524cbe);}catch{}}['_call'](_0x1ea404){this['_assertRunning']();let _0x4298cf=_0x1ea404();return this['_calls']['add'](_0x4298cf),_0x4298cf['finally'](()=>this['_calls']['delete'](_0x4298cf))['catch'](()=>void 0x0),_0x4298cf;}async['_databaseCall'](_0x373fe9){try{return await _0x373fe9();}catch(_0x40d18e){throw _0x40d18e instanceof t['CollabError']?_0x40d18e:new t['CollabError']('ADAPTER_FAILURE','Comment\x20Database\x20Adapter\x20failed',{'retryable':!0x0,'cause':_0x40d18e});}}['_assertRunning'](){if(this['_state']!=='running')throw new t['CollabError']('INTERNAL_ERROR','Comment\x20Service\x20is\x20'+this['_state'],{'retryable':!0x0});}};function a(_0x3ae8eb){return{..._0x3ae8eb};}function o(_0x5f451e){return c(_0x5f451e),{'userID':_0x5f451e['userID'],'customData':_0x5f451e['customData']??Object['create'](null)};}function s(_0x5e53b8){return c(_0x5e53b8),g('memberID',_0x5e53b8['memberID']),{'userID':_0x5e53b8['userID'],'memberID':_0x5e53b8['memberID'],'customData':_0x5e53b8['customData']??Object['create'](null)};}function c(_0x478bff){if(!_0x478bff||typeof _0x478bff!='object')throw _('context\x20must\x20be\x20an\x20object');if(g('userID',_0x478bff['userID']),_0x478bff['customData']!==void 0x0&&(_0x478bff['customData']===null||typeof _0x478bff['customData']!='object'||Array['isArray'](_0x478bff['customData'])))throw _('customData\x20must\x20be\x20an\x20object');}function l(_0x1763e2){return{'threadId':_0x1763e2['threadID'],'replyId':_0x1763e2['replyID'],'content':_0x1763e2['content'],'userId':_0x1763e2['authorUserID'],'createTimestamp':_0x1763e2['createdAt']};}function u(_0x1524af){let _0x5cebff=_0x1524af['find'](_0x3e27dd=>_0x3e27dd['replyID']===_0x3e27dd['threadID']);return{'threadId':_0x5cebff['threadID'],'solved':_0x5cebff['solved'],'replies':_0x1524af['map'](l)};}function d(_0x15dd39){let _0x43cba7=new Map();for(let _0x267b4a of _0x15dd39){let _0x78c31b=_0x43cba7['get'](_0x267b4a['threadID'])??[];_0x78c31b['push'](_0x267b4a),_0x43cba7['set'](_0x267b4a['threadID'],_0x78c31b);}let _0x1cbcc7={};for(let [_0x2b0244,_0x366e38]of _0x43cba7)_0x366e38['find'](_0x255a14=>_0x255a14['replyID']===_0x2b0244)&&(_0x1cbcc7[_0x2b0244]=u([..._0x366e38]['sort']((_0x41bc08,_0x2b9925)=>_0x41bc08['replyID']===_0x2b0244?-0x1:_0x2b9925['replyID']===_0x2b0244?0x1:_0x41bc08['createdAt']-_0x2b9925['createdAt']||_0x41bc08['replyID']['localeCompare'](_0x2b9925['replyID']))));return _0x1cbcc7;}function f(_0x4af2bf,_0x198a08,_0x448f6c){return{'memberId':_0x448f6c['memberID'],'userId':_0x448f6c['userID'],'unitId':_0x198a08['unitID'],'threadId':_0x198a08['threadID'],'type':_0x4af2bf,'replyId':_0x198a08['replyID'],'content':_0x198a08['content'],'createTimestamp':String(_0x198a08['createdAt'])};}function p(_0x8783f){m(_0x8783f['unitID']),g('threadID',_0x8783f['threadID']),g('replyID',_0x8783f['replyID']);}function m(_0x4d2a10){g('unitID',_0x4d2a10);}function h(_0x4348a9){if(typeof _0x4348a9!='string'||_0x4348a9['length']===0x0)throw _('content\x20must\x20be\x20a\x20non-empty\x20string');}function g(_0x3d7cb0,_0x326837){if(typeof _0x326837!='string'||_0x326837['length']===0x0)throw _(_0x3d7cb0+'\x20must\x20be\x20a\x20non-empty\x20string');}function _(_0x6736f6){return new t['CollabError']('INVALID_REQUEST',_0x6736f6);}function v(_0x55da11){return new t['CollabError']('UNIT_NOT_FOUND',_0x55da11);}function y(_0x330889){return new t['CollabError']('PERMISSION_DENIED',_0x330889);}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'](_0x29a139,_0x1154f4){let _0xaf6a10=this['_middlewares']['get'](_0x29a139)??[],_0x8428c=_0x1154f4;_0xaf6a10['push'](_0x8428c),this['_middlewares']['set'](_0x29a139,_0xaf6a10);let _0x12cc37=!0x1;return{'dispose':()=>{if(_0x12cc37)return;_0x12cc37=!0x0;let _0x25aebb=_0xaf6a10['indexOf'](_0x8428c);_0x25aebb>=0x0&&_0xaf6a10['splice'](_0x25aebb,0x1);}};}async['run'](_0x53f923,_0x852a8b,_0x29e8d1){let _0x4768c9=[...this['_middlewares']['get'](_0x53f923)??[]],_0x56209e=async _0x1877d5=>{let _0x257f85=_0x4768c9[_0x1877d5];if(!_0x257f85)return _0x29e8d1();let _0x541a79=!0x1,_0x55c948,_0x2cd6ca=()=>{if(_0x541a79)throw Error('Middleware\x20for\x20action\x20'+_0x53f923+'\x20called\x20next()\x20more\x20than\x20once');return _0x541a79=!0x0,_0x55c948=_0x56209e(_0x1877d5+0x1),_0x55c948;};try{await _0x257f85(_0x852a8b,_0x2cd6ca);}catch(_0x2cbadc){throw _0x55c948&&await _0x55c948['catch'](()=>void 0x0),_0x2cbadc;}if(!_0x541a79)throw Error('Middleware\x20for\x20action\x20'+_0x53f923+'\x20completed\x20without\x20calling\x20next()');await _0x55c948;};await _0x56209e(0x0);}['clear'](){this['_middlewares']['clear']();}},i=class{['_middleware']=new r();['_listeners']=new Map();['_calls']=new Set();['_database'];['_userProvider'];['_state']='running';['_disposePromise'];constructor(_0x31f1d1){if(!_0x31f1d1?.['database'])throw TypeError('UniverCommentService\x20requires\x20a\x20database');this['_database']=_0x31f1d1['database'],this['_userProvider']=_0x31f1d1['userProvider'];}['use'](_0x8b4e4f,_0x267fdf){return this['_assertRunning'](),this['_middleware']['use'](_0x8b4e4f,_0x267fdf);}['on'](_0x6f53cc,_0x273bca){this['_assertRunning']();let _0x5b9471=this['_listeners']['get'](_0x6f53cc)??new Set(),_0x39ccf4=_0x273bca;_0x5b9471['add'](_0x39ccf4),this['_listeners']['set'](_0x6f53cc,_0x5b9471);let _0x6623e2=!0x1;return{'dispose':()=>{_0x6623e2||(_0x6623e2=!0x0,_0x5b9471['delete'](_0x39ccf4));}};}['addComment'](_0x262acd,_0x36a696){return this['_call'](async()=>{let _0x3b2b88=s(_0x36a696);m(_0x262acd['unitID']),h(_0x262acd['content']);let _0x390e3e=a(_0x262acd),_0x1e4a30={..._0x3b2b88,'request':_0x390e3e},_0x3ffd0e;return await this['_middleware']['run']('addComment',_0x1e4a30,async()=>{let _0x31b92b=await this['_databaseCall'](()=>this['_database']['createRoot']({'unitID':_0x262acd['unitID'],'threadID':(0x0,e['randomUUID'])(),'authorUserID':_0x3b2b88['userID'],'content':_0x262acd['content'],'mentions':[..._0x262acd['mentions']]},_0x1e4a30));if(_0x31b92b['status']==='duplicate')throw _('Comment\x20ID\x20already\x20exists');_0x3ffd0e=u([_0x31b92b['record']]),await this['_emitWrite'](_0x3b2b88,_0x390e3e,await this['_createUpdate'](n['CommentUpdateEventType']['Add'],_0x31b92b['record'],_0x3b2b88,_0x390e3e));}),_0x3ffd0e;});}['listComments'](_0x575091,_0x5a6b7a){return this['_call'](async()=>{let _0x1bac24=o(_0x5a6b7a);m(_0x575091['unitID']),_0x575091['threadIDs']['forEach'](_0x30cb94=>g('threadID',_0x30cb94));let _0x5a7463=a(_0x575091),_0x489149={..._0x1bac24,'request':_0x5a7463},_0x2874dd;return await this['_middleware']['run']('listComments',_0x489149,async()=>{let _0x1ee280=d(await this['_databaseCall'](()=>this['_database']['listThreads']({'unitID':_0x575091['unitID'],'threadIDs':[...new Set(_0x575091['threadIDs'])]},_0x489149))),_0x28858f=Object['values'](_0x1ee280)['flatMap'](_0x2b7c9d=>_0x2b7c9d['replies']['map'](_0x1b11a1=>_0x1b11a1['userId']));_0x2874dd={'comments':_0x1ee280,'users':await this['_resolveUsers'](_0x28858f,_0x1bac24,_0x5a7463)};}),_0x2874dd;});}['replyComment'](_0x23153b,_0x2fc32c){return this['_call'](async()=>{let _0x333ea9=s(_0x2fc32c);m(_0x23153b['unitID']),g('threadID',_0x23153b['threadID']),h(_0x23153b['content']);let _0x5aec3e=a(_0x23153b),_0x13f053={..._0x333ea9,'request':_0x5aec3e},_0x5e3a49;return await this['_middleware']['run']('replyComment',_0x13f053,async()=>{let _0x3e1c9f=await this['_databaseCall'](()=>this['_database']['createReply']({'unitID':_0x23153b['unitID'],'threadID':_0x23153b['threadID'],'replyID':(0x0,e['randomUUID'])(),'authorUserID':_0x333ea9['userID'],'content':_0x23153b['content'],'mentions':[..._0x23153b['mentions']]},_0x13f053));if(_0x3e1c9f['status']==='not-found'||_0x3e1c9f['status']==='closed')throw v('Open\x20Comment\x20thread\x20was\x20not\x20found');if(_0x3e1c9f['status']==='duplicate')throw _('Comment\x20ID\x20already\x20exists');_0x5e3a49=l(_0x3e1c9f['record']),await this['_emitWrite'](_0x333ea9,_0x5aec3e,await this['_createUpdate'](n['CommentUpdateEventType']['Reply'],_0x3e1c9f['record'],_0x333ea9,_0x5aec3e));}),_0x5e3a49;});}['editComment'](_0x5528b5,_0xa3c2e6){return this['_call'](async()=>{let _0x646e53=s(_0xa3c2e6);p(_0x5528b5),h(_0x5528b5['content']);let _0x42b260=a(_0x5528b5),_0x47a075={..._0x646e53,'request':_0x42b260};await this['_middleware']['run']('editComment',_0x47a075,async()=>{let _0x26cef5=await this['_databaseCall'](()=>this['_database']['editComment']({'unitID':_0x5528b5['unitID'],'threadID':_0x5528b5['threadID'],'replyID':_0x5528b5['replyID'],'expectedAuthorUserID':_0x646e53['userID'],'content':_0x5528b5['content'],'mentions':[..._0x5528b5['mentions']]},_0x47a075));if(_0x26cef5['status']==='author-mismatch')throw y('Only\x20the\x20Comment\x20author\x20can\x20edit\x20it');if(_0x26cef5['status']==='not-found'||_0x26cef5['status']==='closed')throw v('Open\x20Comment\x20was\x20not\x20found');_0x26cef5['status']==='edited'&&await this['_emitWrite'](_0x646e53,_0x42b260,f(n['CommentUpdateEventType']['Edit'],_0x26cef5['record'],_0x646e53));});});}['setThreadSolved'](_0x5a5909,_0x530802){return this['_call'](async()=>{let _0x54f79e=s(_0x530802);if(m(_0x5a5909['unitID']),g('threadID',_0x5a5909['threadID']),_0x5a5909['solved']!==n['CommentSolvedStatus']['OpenOrReOpen']&&_0x5a5909['solved']!==n['CommentSolvedStatus']['Solved'])throw _('solved\x20must\x20be\x20OpenOrReOpen\x20or\x20Solved');let _0x29bcb1=a(_0x5a5909),_0x26a5a2={..._0x54f79e,'request':_0x29bcb1};await this['_middleware']['run']('setThreadSolved',_0x26a5a2,async()=>{let _0x4fda01=await this['_databaseCall'](()=>this['_database']['setThreadSolved'](_0x5a5909,_0x26a5a2));if(_0x4fda01['status']==='not-found')throw v('Comment\x20thread\x20was\x20not\x20found');_0x4fda01['status']==='updated'&&await this['_emitWrite'](_0x54f79e,_0x29bcb1,{'memberId':_0x54f79e['memberID'],'userId':_0x54f79e['userID'],'unitId':_0x5a5909['unitID'],'threadId':_0x5a5909['threadID'],'type':n['CommentUpdateEventType']['Solve'],'solved':_0x5a5909['solved']});});});}['deleteComment'](_0x51fe5d,_0xb59749){return this['_call'](async()=>{let _0x44b2a0=s(_0xb59749);m(_0x51fe5d['unitID']),g('threadID',_0x51fe5d['threadID']),_0x51fe5d['replyID']!==void 0x0&&g('replyID',_0x51fe5d['replyID']);let _0x405a87=_0x51fe5d['replyID']===_0x51fe5d['threadID']?void 0x0:_0x51fe5d['replyID'],_0xb0c1dd=a({'unitID':_0x51fe5d['unitID'],'threadID':_0x51fe5d['threadID'],..._0x405a87===void 0x0?{}:{'replyID':_0x405a87}}),_0x410539={..._0x44b2a0,'request':_0xb0c1dd},_0x246475=await this['_databaseCall'](()=>this['_database']['getComment']({'unitID':_0x51fe5d['unitID'],'threadID':_0x51fe5d['threadID'],'replyID':_0x405a87??_0x51fe5d['threadID']},_0x410539));if(!_0x246475)throw v('Comment\x20was\x20not\x20found');await this['_middleware']['run']('deleteComment',{..._0x410539,'request':_0xb0c1dd,'target':{'kind':_0x405a87===void 0x0?'root':'reply','threadID':_0x246475['threadID'],'replyID':_0x246475['replyID'],'authorUserID':_0x246475['authorUserID'],'generation':_0x246475['generation']}},async()=>{let _0x454de0=await this['_databaseCall'](()=>this['_database']['deleteComment']({'unitID':_0x51fe5d['unitID'],'threadID':_0x51fe5d['threadID'],..._0x405a87===void 0x0?{}:{'replyID':_0x405a87},'expectedGeneration':_0x246475['generation']},_0x410539));if(_0x454de0['status']==='not-found')throw v('Comment\x20was\x20not\x20found');if(_0x454de0['status']==='generation-mismatch')throw _('Comment\x20changed\x20before\x20deletion');await this['_emitWrite'](_0x44b2a0,_0xb0c1dd,{'memberId':_0x44b2a0['memberID'],'userId':_0x44b2a0['userID'],'unitId':_0x51fe5d['unitID'],'threadId':_0x51fe5d['threadID'],'type':n['CommentUpdateEventType']['Delete'],..._0x405a87===void 0x0?{}:{'replyId':_0x405a87}});});});}['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'](_0x40dac3,_0x2e71ba,_0x4871a3,_0x54e1aa){let _0x1396f9=await this['_resolveUsers']([_0x2e71ba['authorUserID']],_0x4871a3,_0x54e1aa);return{...f(_0x40dac3,_0x2e71ba,_0x4871a3),..._0x1396f9[_0x2e71ba['authorUserID']]?{'user':_0x1396f9[_0x2e71ba['authorUserID']]}:{}};}async['_resolveUsers'](_0x4534db,_0x2a50b8,_0x4addfd){let _0x3c58be=[...new Set(_0x4534db['filter'](Boolean))];if(!this['_userProvider']||_0x3c58be['length']===0x0)return{};let _0x199246;try{_0x199246=await this['_userProvider']['getUsers'](_0x3c58be,{..._0x2a50b8,'request':_0x4addfd});}catch{return{};}let _0x44d2a8=new Set(_0x3c58be),_0x32f342={};for(let _0x2d924b of _0x199246)_0x2d924b?.['userID']&&_0x44d2a8['has'](_0x2d924b['userID'])&&(_0x32f342[_0x2d924b['userID']]=_0x2d924b);return _0x32f342;}async['_emitWrite'](_0x54a454,_0x1dfc82,_0x1c32c3){let _0x3b48ed={'userID':_0x54a454['userID'],'memberID':_0x54a454['memberID'],'customData':_0x54a454['customData'],'request':_0x1dfc82,'update':_0x1c32c3,'committedAt':Date['now']()};for(let _0x325a86 of[...this['_listeners']['get']('commentCommitted')??[]])try{await _0x325a86(_0x3b48ed);}catch{}}['_call'](_0x5180f7){this['_assertRunning']();let _0x4e1231=_0x5180f7();return this['_calls']['add'](_0x4e1231),_0x4e1231['finally'](()=>this['_calls']['delete'](_0x4e1231))['catch'](()=>void 0x0),_0x4e1231;}async['_databaseCall'](_0xf6aa06){try{return await _0xf6aa06();}catch(_0x570f6a){throw _0x570f6a instanceof t['CollabError']?_0x570f6a:new t['CollabError']('ADAPTER_FAILURE','Comment\x20Database\x20Adapter\x20failed',{'retryable':!0x0,'cause':_0x570f6a});}}['_assertRunning'](){if(this['_state']!=='running')throw new t['CollabError']('INTERNAL_ERROR','Comment\x20Service\x20is\x20'+this['_state'],{'retryable':!0x0});}};function a(_0x52d991){return{..._0x52d991};}function o(_0x551589){return c(_0x551589),{'userID':_0x551589['userID'],'customData':_0x551589['customData']??Object['create'](null)};}function s(_0xce223c){return c(_0xce223c),g('memberID',_0xce223c['memberID']),{'userID':_0xce223c['userID'],'memberID':_0xce223c['memberID'],'customData':_0xce223c['customData']??Object['create'](null)};}function c(_0x332a4c){if(!_0x332a4c||typeof _0x332a4c!='object')throw _('context\x20must\x20be\x20an\x20object');if(g('userID',_0x332a4c['userID']),_0x332a4c['customData']!==void 0x0&&(_0x332a4c['customData']===null||typeof _0x332a4c['customData']!='object'||Array['isArray'](_0x332a4c['customData'])))throw _('customData\x20must\x20be\x20an\x20object');}function l(_0x449aa7){return{'threadId':_0x449aa7['threadID'],'replyId':_0x449aa7['replyID'],'content':_0x449aa7['content'],'userId':_0x449aa7['authorUserID'],'createTimestamp':_0x449aa7['createdAt']};}function u(_0x270025){let _0x1553c6=_0x270025['find'](_0x158015=>_0x158015['replyID']===_0x158015['threadID']);return{'threadId':_0x1553c6['threadID'],'solved':_0x1553c6['solved'],'replies':_0x270025['map'](l)};}function d(_0x4bef4b){let _0x41edb0=new Map();for(let _0x958e92 of _0x4bef4b){let _0x10f5b9=_0x41edb0['get'](_0x958e92['threadID'])??[];_0x10f5b9['push'](_0x958e92),_0x41edb0['set'](_0x958e92['threadID'],_0x10f5b9);}let _0x149c02={};for(let [_0x562bd3,_0x2df231]of _0x41edb0)_0x2df231['find'](_0x44b238=>_0x44b238['replyID']===_0x562bd3)&&(_0x149c02[_0x562bd3]=u([..._0x2df231]['sort']((_0x14d8d4,_0x4abf65)=>_0x14d8d4['replyID']===_0x562bd3?-0x1:_0x4abf65['replyID']===_0x562bd3?0x1:_0x14d8d4['createdAt']-_0x4abf65['createdAt']||_0x14d8d4['replyID']['localeCompare'](_0x4abf65['replyID']))));return _0x149c02;}function f(_0xbde230,_0x84931a,_0x4c177a){return{'memberId':_0x4c177a['memberID'],'userId':_0x4c177a['userID'],'unitId':_0x84931a['unitID'],'threadId':_0x84931a['threadID'],'type':_0xbde230,'replyId':_0x84931a['replyID'],'content':_0x84931a['content'],'createTimestamp':String(_0x84931a['createdAt'])};}function p(_0x5e0a71){m(_0x5e0a71['unitID']),g('threadID',_0x5e0a71['threadID']),g('replyID',_0x5e0a71['replyID']);}function m(_0x1f6316){g('unitID',_0x1f6316);}function h(_0x153398){if(typeof _0x153398!='string'||_0x153398['length']===0x0)throw _('content\x20must\x20be\x20a\x20non-empty\x20string');}function g(_0x385dad,_0x5c0735){if(typeof _0x5c0735!='string'||_0x5c0735['length']===0x0)throw _(_0x385dad+'\x20must\x20be\x20a\x20non-empty\x20string');}function _(_0x21a7d9){return new t['CollabError']('INVALID_REQUEST',_0x21a7d9);}function v(_0x39cfa2){return new t['CollabError']('UNIT_NOT_FOUND',_0x39cfa2);}function y(_0x51e020){return new t['CollabError']('PERMISSION_DENIED',_0x51e020);}exports['UniverCommentService']=i;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CollabContext, CollabMemberContext, CustomData, Disposable } from "@univerjs-pro/collaboration-service";
|
|
2
2
|
import { CommentSolvedStatus, ICommentUpdate, IReply, IThread, IUser } from "@univerjs/protocol";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/middleware.d.ts
|
|
5
5
|
interface DeleteCommentMiddlewareTarget {
|
|
6
6
|
readonly kind: "root" | "reply";
|
|
7
7
|
readonly threadID: string;
|
|
@@ -36,8 +36,6 @@ interface CommentMiddlewareMap {
|
|
|
36
36
|
readonly editComment: CommentMiddleware<EditCommentMiddlewareContext>;
|
|
37
37
|
readonly deleteComment: CommentMiddleware<DeleteCommentMiddlewareContext>;
|
|
38
38
|
}
|
|
39
|
-
//#endregion
|
|
40
|
-
//#region src/types.d.ts
|
|
41
39
|
interface AddCommentInput {
|
|
42
40
|
readonly unitID: string;
|
|
43
41
|
readonly content: string;
|
|
@@ -113,8 +111,6 @@ interface IUniverCommentService {
|
|
|
113
111
|
on<K extends keyof CommentServiceEventMap>(event: K, listener: CommentServiceListener<K>): Disposable;
|
|
114
112
|
dispose(): Promise<void>;
|
|
115
113
|
}
|
|
116
|
-
//#endregion
|
|
117
|
-
//#region src/database-adapter.d.ts
|
|
118
114
|
interface CommentRecord {
|
|
119
115
|
readonly unitID: string;
|
|
120
116
|
readonly threadID: string;
|
|
@@ -218,8 +214,6 @@ interface ICommentDatabaseAdapter {
|
|
|
218
214
|
deleteComment(input: DeleteCommentDatabaseInput, context: CommentMemberDatabaseContext): Promise<DeleteCommentDatabaseResult>;
|
|
219
215
|
dispose(): Promise<void>;
|
|
220
216
|
}
|
|
221
|
-
//#endregion
|
|
222
|
-
//#region src/service.d.ts
|
|
223
217
|
interface UniverCommentServiceOptions {
|
|
224
218
|
readonly database: ICommentDatabaseAdapter;
|
|
225
219
|
readonly userProvider?: ICommentUserProvider;
|
|
@@ -249,5 +243,4 @@ declare class UniverCommentService implements IUniverCommentService {
|
|
|
249
243
|
private _databaseCall;
|
|
250
244
|
private _assertRunning;
|
|
251
245
|
}
|
|
252
|
-
//#endregion
|
|
253
246
|
export { type AddCommentInput, type AddCommentMiddlewareContext, type AddCommentRequest, type CommentCommittedEvent, type CommentDatabaseContext, type CommentListResult, type CommentMemberDatabaseContext, type CommentMiddleware, type CommentMiddlewareAction, type CommentMiddlewareMap, type CommentMiddlewareNext, type CommentRecord, type CommentRequest, type CommentServiceEventMap, type CommentUserProviderContext, type CommentWriteRequest, type CreateCommentDatabaseResult, type CreateReplyDatabaseInput, type CreateReplyDatabaseResult, type CreateRootDatabaseInput, type DeleteCommentDatabaseInput, type DeleteCommentDatabaseResult, type DeleteCommentInput, type DeleteCommentMiddlewareContext, type DeleteCommentMiddlewareTarget, type DeleteCommentRequest, type EditCommentDatabaseInput, type EditCommentDatabaseResult, type EditCommentInput, type EditCommentMiddlewareContext, type EditCommentRequest, type GetCommentDatabaseInput, type ICommentDatabaseAdapter, type ICommentUserProvider, type IUniverCommentService, type ListCommentsInput, type ListCommentsMiddlewareContext, type ListCommentsRequest, type ListThreadsDatabaseInput, type ReplyCommentInput, type ReplyCommentMiddlewareContext, type ReplyCommentRequest, type SetThreadSolvedDatabaseInput, type SetThreadSolvedDatabaseResult, type SetThreadSolvedInput, type SetThreadSolvedMiddlewareContext, type SetThreadSolvedRequest, UniverCommentService, type UniverCommentServiceOptions };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const _0x370e2d=_0x17da;(function(_0x4fb26f,_0x2f5a49){const _0x28cbad=_0x17da,_0x5d5066=_0x4fb26f();while(!![]){try{const _0x95b035=parseInt(_0x28cbad(0x1e1))/0x1*(parseInt(_0x28cbad(0x1da))/0x2)+parseInt(_0x28cbad(0x1de))/0x3+parseInt(_0x28cbad(0x1db))/0x4*(-parseInt(_0x28cbad(0x1e0))/0x5)+parseInt(_0x28cbad(0x1d7))/0x6+-parseInt(_0x28cbad(0x1d8))/0x7+parseInt(_0x28cbad(0x1d9))/0x8+parseInt(_0x28cbad(0x1dc))/0x9*(-parseInt(_0x28cbad(0x1dd))/0xa);if(_0x95b035===_0x2f5a49)break;else _0x5d5066['push'](_0x5d5066['shift']());}catch(_0x5adbe8){_0x5d5066['push'](_0x5d5066['shift']());}}}(_0x4659,0x507b3));import _0xe4a0d1 from'./index.cjs';function _0x17da(_0x9ec0e9,_0x5f2a0d){_0x9ec0e9=_0x9ec0e9-0x1d7;const _0x4659b6=_0x4659();let _0x17da35=_0x4659b6[_0x9ec0e9];return _0x17da35;}function _0x4659(){const _0x220125=['17110fEdqqk','659559gwvPew','UniverCommentService','306975aAyiOh','4pxtuvN','1326738HzKbcK','939071hwDtxQ','4987272raJXKW','139336xyctKP','4nMAUUg','4302xRqMxL'];_0x4659=function(){return _0x220125;};return _0x4659();}const facadeExport0=_0xe4a0d1[_0x370e2d(0x1df)];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.
|
|
4
|
+
"version": "1.6.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.
|
|
20
|
-
"@univerjs/protocol": "1.
|
|
19
|
+
"@univerjs-pro/collaboration-service": "1.6.0",
|
|
20
|
+
"@univerjs/protocol": "1.6.0"
|
|
21
21
|
}
|
|
22
22
|
}
|