@univerjs-pro/collaboration-comment-service 1.0.4 → 1.2.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.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'](_0x14a493,_0x2a42aa){let _0x8fd75c=this['_middlewares']['get'](_0x14a493)??[],_0x3e9f1c=_0x2a42aa;_0x8fd75c['push'](_0x3e9f1c),this['_middlewares']['set'](_0x14a493,_0x8fd75c);let _0x5bbed2=!0x1;return{'dispose':()=>{if(_0x5bbed2)return;_0x5bbed2=!0x0;let _0x45dd4c=_0x8fd75c['indexOf'](_0x3e9f1c);_0x45dd4c>=0x0&&_0x8fd75c['splice'](_0x45dd4c,0x1);}};}async['run'](_0x4ce709,_0x31ebf6,_0x46b085){let _0x1f887e=[...this['_middlewares']['get'](_0x4ce709)??[]],_0x2752dc=async _0x55ea03=>{let _0x4ee448=_0x1f887e[_0x55ea03];if(!_0x4ee448)return _0x46b085();let _0x5f4987=!0x1,_0x5729eb,_0x4bb919=()=>{if(_0x5f4987)throw Error('Middleware\x20for\x20action\x20'+_0x4ce709+'\x20called\x20next()\x20more\x20than\x20once');return _0x5f4987=!0x0,_0x5729eb=_0x2752dc(_0x55ea03+0x1),_0x5729eb;};try{await _0x4ee448(_0x31ebf6,_0x4bb919);}catch(_0x105635){throw _0x5729eb&&await _0x5729eb['catch'](()=>void 0x0),_0x105635;}if(!_0x5f4987)throw Error('Middleware\x20for\x20action\x20'+_0x4ce709+'\x20completed\x20without\x20calling\x20next()');await _0x5729eb;};await _0x2752dc(0x0);}['clear'](){this['_middlewares']['clear']();}},i=class{['_middleware']=new r();['_listeners']=new Map();['_calls']=new Set();['_database'];['_userProvider'];['_state']='running';['_disposePromise'];constructor(_0x4ad693){if(!_0x4ad693?.['database'])throw TypeError('UniverCommentService\x20requires\x20a\x20database');this['_database']=_0x4ad693['database'],this['_userProvider']=_0x4ad693['userProvider'];}['use'](_0x436cf9,_0x54cf6d){return this['_assertRunning'](),this['_middleware']['use'](_0x436cf9,_0x54cf6d);}['on'](_0x5d40fa,_0x10c198){this['_assertRunning']();let _0x15b29f=this['_listeners']['get'](_0x5d40fa)??new Set(),_0x1097ef=_0x10c198;_0x15b29f['add'](_0x1097ef),this['_listeners']['set'](_0x5d40fa,_0x15b29f);let _0x90dbd2=!0x1;return{'dispose':()=>{_0x90dbd2||(_0x90dbd2=!0x0,_0x15b29f['delete'](_0x1097ef));}};}['addComment'](_0x218dab,_0x137ed5){return this['_call'](async()=>{let _0x31d0a5=s(_0x137ed5);m(_0x218dab['unitID']),h(_0x218dab['content']);let _0xe78963=a(_0x218dab),_0x3fe1f6={..._0x31d0a5,'request':_0xe78963},_0x13211a;return await this['_middleware']['run']('addComment',_0x3fe1f6,async()=>{let _0x55a30a=await this['_databaseCall'](()=>this['_database']['createRoot']({'unitID':_0x218dab['unitID'],'threadID':(0x0,e['randomUUID'])(),'authorUserID':_0x31d0a5['userID'],'content':_0x218dab['content'],'mentions':[..._0x218dab['mentions']]},_0x3fe1f6));if(_0x55a30a['status']==='duplicate')throw _('Comment\x20ID\x20already\x20exists');_0x13211a=u([_0x55a30a['record']]),await this['_emitWrite'](_0x31d0a5,_0xe78963,await this['_createUpdate'](n['CommentUpdateEventType']['Add'],_0x55a30a['record'],_0x31d0a5,_0xe78963));}),_0x13211a;});}['listComments'](_0x5b3760,_0x2e462e){return this['_call'](async()=>{let _0x439a55=o(_0x2e462e);m(_0x5b3760['unitID']),_0x5b3760['threadIDs']['forEach'](_0x22a679=>g('threadID',_0x22a679));let _0x10cfb9=a(_0x5b3760),_0x7f942e={..._0x439a55,'request':_0x10cfb9},_0x3f7f9a;return await this['_middleware']['run']('listComments',_0x7f942e,async()=>{let _0x4da7d7=d(await this['_databaseCall'](()=>this['_database']['listThreads']({'unitID':_0x5b3760['unitID'],'threadIDs':[...new Set(_0x5b3760['threadIDs'])]},_0x7f942e))),_0xa05278=Object['values'](_0x4da7d7)['flatMap'](_0x3a6a89=>_0x3a6a89['replies']['map'](_0x23cf6f=>_0x23cf6f['userId']));_0x3f7f9a={'comments':_0x4da7d7,'users':await this['_resolveUsers'](_0xa05278,_0x439a55,_0x10cfb9)};}),_0x3f7f9a;});}['replyComment'](_0x160038,_0x5dd243){return this['_call'](async()=>{let _0x3e886a=s(_0x5dd243);m(_0x160038['unitID']),g('threadID',_0x160038['threadID']),h(_0x160038['content']);let _0xe9c82f=a(_0x160038),_0x4eac0a={..._0x3e886a,'request':_0xe9c82f},_0x514b41;return await this['_middleware']['run']('replyComment',_0x4eac0a,async()=>{let _0x2a64ec=await this['_databaseCall'](()=>this['_database']['createReply']({'unitID':_0x160038['unitID'],'threadID':_0x160038['threadID'],'replyID':(0x0,e['randomUUID'])(),'authorUserID':_0x3e886a['userID'],'content':_0x160038['content'],'mentions':[..._0x160038['mentions']]},_0x4eac0a));if(_0x2a64ec['status']==='not-found'||_0x2a64ec['status']==='closed')throw v('Open\x20Comment\x20thread\x20was\x20not\x20found');if(_0x2a64ec['status']==='duplicate')throw _('Comment\x20ID\x20already\x20exists');_0x514b41=l(_0x2a64ec['record']),await this['_emitWrite'](_0x3e886a,_0xe9c82f,await this['_createUpdate'](n['CommentUpdateEventType']['Reply'],_0x2a64ec['record'],_0x3e886a,_0xe9c82f));}),_0x514b41;});}['editComment'](_0x9a76c0,_0x3d5ed9){return this['_call'](async()=>{let _0x268dbc=s(_0x3d5ed9);p(_0x9a76c0),h(_0x9a76c0['content']);let _0x21f3f5=a(_0x9a76c0),_0x4164b8={..._0x268dbc,'request':_0x21f3f5};await this['_middleware']['run']('editComment',_0x4164b8,async()=>{let _0x11020e=await this['_databaseCall'](()=>this['_database']['editComment']({'unitID':_0x9a76c0['unitID'],'threadID':_0x9a76c0['threadID'],'replyID':_0x9a76c0['replyID'],'expectedAuthorUserID':_0x268dbc['userID'],'content':_0x9a76c0['content'],'mentions':[..._0x9a76c0['mentions']]},_0x4164b8));if(_0x11020e['status']==='author-mismatch')throw y('Only\x20the\x20Comment\x20author\x20can\x20edit\x20it');if(_0x11020e['status']==='not-found'||_0x11020e['status']==='closed')throw v('Open\x20Comment\x20was\x20not\x20found');_0x11020e['status']==='edited'&&await this['_emitWrite'](_0x268dbc,_0x21f3f5,f(n['CommentUpdateEventType']['Edit'],_0x11020e['record'],_0x268dbc));});});}['setThreadSolved'](_0x1247bd,_0x12fe77){return this['_call'](async()=>{let _0x2e5bb5=s(_0x12fe77);if(m(_0x1247bd['unitID']),g('threadID',_0x1247bd['threadID']),_0x1247bd['solved']!==n['CommentSolvedStatus']['OpenOrReOpen']&&_0x1247bd['solved']!==n['CommentSolvedStatus']['Solved'])throw _('solved\x20must\x20be\x20OpenOrReOpen\x20or\x20Solved');let _0xa13af3=a(_0x1247bd),_0x353783={..._0x2e5bb5,'request':_0xa13af3};await this['_middleware']['run']('setThreadSolved',_0x353783,async()=>{let _0x4f278f=await this['_databaseCall'](()=>this['_database']['setThreadSolved'](_0x1247bd,_0x353783));if(_0x4f278f['status']==='not-found')throw v('Comment\x20thread\x20was\x20not\x20found');_0x4f278f['status']==='updated'&&await this['_emitWrite'](_0x2e5bb5,_0xa13af3,{'memberId':_0x2e5bb5['memberID'],'userId':_0x2e5bb5['userID'],'unitId':_0x1247bd['unitID'],'threadId':_0x1247bd['threadID'],'type':n['CommentUpdateEventType']['Solve'],'solved':_0x1247bd['solved']});});});}['deleteComment'](_0x2830fa,_0x55298a){return this['_call'](async()=>{let _0x376c38=s(_0x55298a);m(_0x2830fa['unitID']),g('threadID',_0x2830fa['threadID']),_0x2830fa['replyID']!==void 0x0&&g('replyID',_0x2830fa['replyID']);let _0x130a81=_0x2830fa['replyID']===_0x2830fa['threadID']?void 0x0:_0x2830fa['replyID'],_0x2673f1=a({'unitID':_0x2830fa['unitID'],'threadID':_0x2830fa['threadID'],..._0x130a81===void 0x0?{}:{'replyID':_0x130a81}}),_0x258c77={..._0x376c38,'request':_0x2673f1},_0x50e76d=await this['_databaseCall'](()=>this['_database']['getComment']({'unitID':_0x2830fa['unitID'],'threadID':_0x2830fa['threadID'],'replyID':_0x130a81??_0x2830fa['threadID']},_0x258c77));if(!_0x50e76d)throw v('Comment\x20was\x20not\x20found');await this['_middleware']['run']('deleteComment',{..._0x258c77,'request':_0x2673f1,'target':{'kind':_0x130a81===void 0x0?'root':'reply','threadID':_0x50e76d['threadID'],'replyID':_0x50e76d['replyID'],'authorUserID':_0x50e76d['authorUserID'],'generation':_0x50e76d['generation']}},async()=>{let _0x4205cc=await this['_databaseCall'](()=>this['_database']['deleteComment']({'unitID':_0x2830fa['unitID'],'threadID':_0x2830fa['threadID'],..._0x130a81===void 0x0?{}:{'replyID':_0x130a81},'expectedGeneration':_0x50e76d['generation']},_0x258c77));if(_0x4205cc['status']==='not-found')throw v('Comment\x20was\x20not\x20found');if(_0x4205cc['status']==='generation-mismatch')throw _('Comment\x20changed\x20before\x20deletion');await this['_emitWrite'](_0x376c38,_0x2673f1,{'memberId':_0x376c38['memberID'],'userId':_0x376c38['userID'],'unitId':_0x2830fa['unitID'],'threadId':_0x2830fa['threadID'],'type':n['CommentUpdateEventType']['Delete'],..._0x130a81===void 0x0?{}:{'replyId':_0x130a81}});});});}['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'](_0x3812db,_0x41cee1,_0x122af2,_0x594eb1){let _0x3d2129=await this['_resolveUsers']([_0x41cee1['authorUserID']],_0x122af2,_0x594eb1);return{...f(_0x3812db,_0x41cee1,_0x122af2),..._0x3d2129[_0x41cee1['authorUserID']]?{'user':_0x3d2129[_0x41cee1['authorUserID']]}:{}};}async['_resolveUsers'](_0x347249,_0x3f3bda,_0x5ae994){let _0x54e3dc=[...new Set(_0x347249['filter'](Boolean))];if(!this['_userProvider']||_0x54e3dc['length']===0x0)return{};let _0x5b6d1e;try{_0x5b6d1e=await this['_userProvider']['getUsers'](_0x54e3dc,{..._0x3f3bda,'request':_0x5ae994});}catch{return{};}let _0x1e7824=new Set(_0x54e3dc),_0x1810fd={};for(let _0x896b00 of _0x5b6d1e)_0x896b00?.['userID']&&_0x1e7824['has'](_0x896b00['userID'])&&(_0x1810fd[_0x896b00['userID']]=_0x896b00);return _0x1810fd;}async['_emitWrite'](_0x54608a,_0x36bc21,_0x5a6500){let _0x2f11a3={'userID':_0x54608a['userID'],'memberID':_0x54608a['memberID'],'customData':_0x54608a['customData'],'request':_0x36bc21,'update':_0x5a6500,'committedAt':Date['now']()};for(let _0x2f504a of[...this['_listeners']['get']('commentCommitted')??[]])try{await _0x2f504a(_0x2f11a3);}catch{}}['_call'](_0x1b29e6){this['_assertRunning']();let _0x28c003=_0x1b29e6();return this['_calls']['add'](_0x28c003),_0x28c003['finally'](()=>this['_calls']['delete'](_0x28c003))['catch'](()=>void 0x0),_0x28c003;}async['_databaseCall'](_0x222ca3){try{return await _0x222ca3();}catch(_0x894050){throw _0x894050 instanceof t['CollabError']?_0x894050:new t['CollabError']('ADAPTER_FAILURE','Comment\x20Database\x20Adapter\x20failed',{'retryable':!0x0,'cause':_0x894050});}}['_assertRunning'](){if(this['_state']!=='running')throw new t['CollabError']('INTERNAL_ERROR','Comment\x20Service\x20is\x20'+this['_state'],{'retryable':!0x0});}};function a(_0x5db3f2){return{..._0x5db3f2};}function o(_0x27cd50){return c(_0x27cd50),{'userID':_0x27cd50['userID'],'customData':_0x27cd50['customData']??Object['create'](null)};}function s(_0x958cc7){return c(_0x958cc7),g('memberID',_0x958cc7['memberID']),{'userID':_0x958cc7['userID'],'memberID':_0x958cc7['memberID'],'customData':_0x958cc7['customData']??Object['create'](null)};}function c(_0x3ec838){if(!_0x3ec838||typeof _0x3ec838!='object')throw _('context\x20must\x20be\x20an\x20object');if(g('userID',_0x3ec838['userID']),_0x3ec838['customData']!==void 0x0&&(_0x3ec838['customData']===null||typeof _0x3ec838['customData']!='object'||Array['isArray'](_0x3ec838['customData'])))throw _('customData\x20must\x20be\x20an\x20object');}function l(_0x4dfcca){return{'threadId':_0x4dfcca['threadID'],'replyId':_0x4dfcca['replyID'],'content':_0x4dfcca['content'],'userId':_0x4dfcca['authorUserID'],'createTimestamp':_0x4dfcca['createdAt']};}function u(_0x4269f5){let _0x5ba9e8=_0x4269f5['find'](_0x1d10fa=>_0x1d10fa['replyID']===_0x1d10fa['threadID']);return{'threadId':_0x5ba9e8['threadID'],'solved':_0x5ba9e8['solved'],'replies':_0x4269f5['map'](l)};}function d(_0x4d49a2){let _0x26b75a=new Map();for(let _0x5d3d2f of _0x4d49a2){let _0x283db6=_0x26b75a['get'](_0x5d3d2f['threadID'])??[];_0x283db6['push'](_0x5d3d2f),_0x26b75a['set'](_0x5d3d2f['threadID'],_0x283db6);}let _0x40e068={};for(let [_0x4db95b,_0x5d4ff1]of _0x26b75a)_0x5d4ff1['find'](_0x27a56c=>_0x27a56c['replyID']===_0x4db95b)&&(_0x40e068[_0x4db95b]=u([..._0x5d4ff1]['sort']((_0x1305ea,_0x4f11a6)=>_0x1305ea['replyID']===_0x4db95b?-0x1:_0x4f11a6['replyID']===_0x4db95b?0x1:_0x1305ea['createdAt']-_0x4f11a6['createdAt']||_0x1305ea['replyID']['localeCompare'](_0x4f11a6['replyID']))));return _0x40e068;}function f(_0x1c8b88,_0xa01901,_0x22bb19){return{'memberId':_0x22bb19['memberID'],'userId':_0x22bb19['userID'],'unitId':_0xa01901['unitID'],'threadId':_0xa01901['threadID'],'type':_0x1c8b88,'replyId':_0xa01901['replyID'],'content':_0xa01901['content'],'createTimestamp':String(_0xa01901['createdAt'])};}function p(_0x3cbbad){m(_0x3cbbad['unitID']),g('threadID',_0x3cbbad['threadID']),g('replyID',_0x3cbbad['replyID']);}function m(_0x3a00b4){g('unitID',_0x3a00b4);}function h(_0x3ea3d1){if(typeof _0x3ea3d1!='string'||_0x3ea3d1['length']===0x0)throw _('content\x20must\x20be\x20a\x20non-empty\x20string');}function g(_0x331f1d,_0x4af4f8){if(typeof _0x4af4f8!='string'||_0x4af4f8['length']===0x0)throw _(_0x331f1d+'\x20must\x20be\x20a\x20non-empty\x20string');}function _(_0x56f40f){return new t['CollabError']('INVALID_REQUEST',_0x56f40f);}function v(_0xbfdf41){return new t['CollabError']('UNIT_NOT_FOUND',_0xbfdf41);}function y(_0x59abfa){return new t['CollabError']('PERMISSION_DENIED',_0x59abfa);}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'](_0x4303ec,_0x3a5f3b){let _0x26ab46=this['_middlewares']['get'](_0x4303ec)??[],_0x1c00aa=_0x3a5f3b;_0x26ab46['push'](_0x1c00aa),this['_middlewares']['set'](_0x4303ec,_0x26ab46);let _0x2af98e=!0x1;return{'dispose':()=>{if(_0x2af98e)return;_0x2af98e=!0x0;let _0x136b85=_0x26ab46['indexOf'](_0x1c00aa);_0x136b85>=0x0&&_0x26ab46['splice'](_0x136b85,0x1);}};}async['run'](_0x1ddfef,_0x1b312d,_0x4d933a){let _0x1aafe7=[...this['_middlewares']['get'](_0x1ddfef)??[]],_0x1beb5f=async _0x36f831=>{let _0x3675fd=_0x1aafe7[_0x36f831];if(!_0x3675fd)return _0x4d933a();let _0x5432f9=!0x1,_0x532052,_0xad249c=()=>{if(_0x5432f9)throw Error('Middleware\x20for\x20action\x20'+_0x1ddfef+'\x20called\x20next()\x20more\x20than\x20once');return _0x5432f9=!0x0,_0x532052=_0x1beb5f(_0x36f831+0x1),_0x532052;};try{await _0x3675fd(_0x1b312d,_0xad249c);}catch(_0x474bdb){throw _0x532052&&await _0x532052['catch'](()=>void 0x0),_0x474bdb;}if(!_0x5432f9)throw Error('Middleware\x20for\x20action\x20'+_0x1ddfef+'\x20completed\x20without\x20calling\x20next()');await _0x532052;};await _0x1beb5f(0x0);}['clear'](){this['_middlewares']['clear']();}},i=class{['_middleware']=new r();['_listeners']=new Map();['_calls']=new Set();['_database'];['_userProvider'];['_state']='running';['_disposePromise'];constructor(_0x153d68){if(!_0x153d68?.['database'])throw TypeError('UniverCommentService\x20requires\x20a\x20database');this['_database']=_0x153d68['database'],this['_userProvider']=_0x153d68['userProvider'];}['use'](_0x5a612d,_0xfac928){return this['_assertRunning'](),this['_middleware']['use'](_0x5a612d,_0xfac928);}['on'](_0xb80ac1,_0x193b79){this['_assertRunning']();let _0x59eb18=this['_listeners']['get'](_0xb80ac1)??new Set(),_0x3f2431=_0x193b79;_0x59eb18['add'](_0x3f2431),this['_listeners']['set'](_0xb80ac1,_0x59eb18);let _0x4ca523=!0x1;return{'dispose':()=>{_0x4ca523||(_0x4ca523=!0x0,_0x59eb18['delete'](_0x3f2431));}};}['addComment'](_0x4a51d1,_0x56a8cc){return this['_call'](async()=>{let _0x57e9b8=s(_0x56a8cc);m(_0x4a51d1['unitID']),h(_0x4a51d1['content']);let _0x584e34=a(_0x4a51d1),_0x429118={..._0x57e9b8,'request':_0x584e34},_0x930c3;return await this['_middleware']['run']('addComment',_0x429118,async()=>{let _0x2d2378=await this['_databaseCall'](()=>this['_database']['createRoot']({'unitID':_0x4a51d1['unitID'],'threadID':(0x0,e['randomUUID'])(),'authorUserID':_0x57e9b8['userID'],'content':_0x4a51d1['content'],'mentions':[..._0x4a51d1['mentions']]},_0x429118));if(_0x2d2378['status']==='duplicate')throw _('Comment\x20ID\x20already\x20exists');_0x930c3=u([_0x2d2378['record']]),await this['_emitWrite'](_0x57e9b8,_0x584e34,await this['_createUpdate'](n['CommentUpdateEventType']['Add'],_0x2d2378['record'],_0x57e9b8,_0x584e34));}),_0x930c3;});}['listComments'](_0x27c261,_0x3a38cd){return this['_call'](async()=>{let _0x4f216b=o(_0x3a38cd);m(_0x27c261['unitID']),_0x27c261['threadIDs']['forEach'](_0x487e57=>g('threadID',_0x487e57));let _0x8a1c3=a(_0x27c261),_0x408c35={..._0x4f216b,'request':_0x8a1c3},_0x46229d;return await this['_middleware']['run']('listComments',_0x408c35,async()=>{let _0x39b7a4=d(await this['_databaseCall'](()=>this['_database']['listThreads']({'unitID':_0x27c261['unitID'],'threadIDs':[...new Set(_0x27c261['threadIDs'])]},_0x408c35))),_0x3b9465=Object['values'](_0x39b7a4)['flatMap'](_0x13e34a=>_0x13e34a['replies']['map'](_0x1b25b2=>_0x1b25b2['userId']));_0x46229d={'comments':_0x39b7a4,'users':await this['_resolveUsers'](_0x3b9465,_0x4f216b,_0x8a1c3)};}),_0x46229d;});}['replyComment'](_0x4e7a89,_0x313cf7){return this['_call'](async()=>{let _0xf1125=s(_0x313cf7);m(_0x4e7a89['unitID']),g('threadID',_0x4e7a89['threadID']),h(_0x4e7a89['content']);let _0x464fbd=a(_0x4e7a89),_0x18fc10={..._0xf1125,'request':_0x464fbd},_0x37b649;return await this['_middleware']['run']('replyComment',_0x18fc10,async()=>{let _0x238daf=await this['_databaseCall'](()=>this['_database']['createReply']({'unitID':_0x4e7a89['unitID'],'threadID':_0x4e7a89['threadID'],'replyID':(0x0,e['randomUUID'])(),'authorUserID':_0xf1125['userID'],'content':_0x4e7a89['content'],'mentions':[..._0x4e7a89['mentions']]},_0x18fc10));if(_0x238daf['status']==='not-found'||_0x238daf['status']==='closed')throw v('Open\x20Comment\x20thread\x20was\x20not\x20found');if(_0x238daf['status']==='duplicate')throw _('Comment\x20ID\x20already\x20exists');_0x37b649=l(_0x238daf['record']),await this['_emitWrite'](_0xf1125,_0x464fbd,await this['_createUpdate'](n['CommentUpdateEventType']['Reply'],_0x238daf['record'],_0xf1125,_0x464fbd));}),_0x37b649;});}['editComment'](_0x15b0ff,_0x56a159){return this['_call'](async()=>{let _0x10adb0=s(_0x56a159);p(_0x15b0ff),h(_0x15b0ff['content']);let _0x295aa1=a(_0x15b0ff),_0x1069dd={..._0x10adb0,'request':_0x295aa1};await this['_middleware']['run']('editComment',_0x1069dd,async()=>{let _0x30dd44=await this['_databaseCall'](()=>this['_database']['editComment']({'unitID':_0x15b0ff['unitID'],'threadID':_0x15b0ff['threadID'],'replyID':_0x15b0ff['replyID'],'expectedAuthorUserID':_0x10adb0['userID'],'content':_0x15b0ff['content'],'mentions':[..._0x15b0ff['mentions']]},_0x1069dd));if(_0x30dd44['status']==='author-mismatch')throw y('Only\x20the\x20Comment\x20author\x20can\x20edit\x20it');if(_0x30dd44['status']==='not-found'||_0x30dd44['status']==='closed')throw v('Open\x20Comment\x20was\x20not\x20found');_0x30dd44['status']==='edited'&&await this['_emitWrite'](_0x10adb0,_0x295aa1,f(n['CommentUpdateEventType']['Edit'],_0x30dd44['record'],_0x10adb0));});});}['setThreadSolved'](_0xa95fb4,_0x22dafe){return this['_call'](async()=>{let _0xc96553=s(_0x22dafe);if(m(_0xa95fb4['unitID']),g('threadID',_0xa95fb4['threadID']),_0xa95fb4['solved']!==n['CommentSolvedStatus']['OpenOrReOpen']&&_0xa95fb4['solved']!==n['CommentSolvedStatus']['Solved'])throw _('solved\x20must\x20be\x20OpenOrReOpen\x20or\x20Solved');let _0x5013f9=a(_0xa95fb4),_0x5aefe4={..._0xc96553,'request':_0x5013f9};await this['_middleware']['run']('setThreadSolved',_0x5aefe4,async()=>{let _0x36a741=await this['_databaseCall'](()=>this['_database']['setThreadSolved'](_0xa95fb4,_0x5aefe4));if(_0x36a741['status']==='not-found')throw v('Comment\x20thread\x20was\x20not\x20found');_0x36a741['status']==='updated'&&await this['_emitWrite'](_0xc96553,_0x5013f9,{'memberId':_0xc96553['memberID'],'userId':_0xc96553['userID'],'unitId':_0xa95fb4['unitID'],'threadId':_0xa95fb4['threadID'],'type':n['CommentUpdateEventType']['Solve'],'solved':_0xa95fb4['solved']});});});}['deleteComment'](_0x3512aa,_0x47f3f1){return this['_call'](async()=>{let _0x4d4ea6=s(_0x47f3f1);m(_0x3512aa['unitID']),g('threadID',_0x3512aa['threadID']),_0x3512aa['replyID']!==void 0x0&&g('replyID',_0x3512aa['replyID']);let _0x34e629=_0x3512aa['replyID']===_0x3512aa['threadID']?void 0x0:_0x3512aa['replyID'],_0x386577=a({'unitID':_0x3512aa['unitID'],'threadID':_0x3512aa['threadID'],..._0x34e629===void 0x0?{}:{'replyID':_0x34e629}}),_0x23f4af={..._0x4d4ea6,'request':_0x386577},_0x4d3399=await this['_databaseCall'](()=>this['_database']['getComment']({'unitID':_0x3512aa['unitID'],'threadID':_0x3512aa['threadID'],'replyID':_0x34e629??_0x3512aa['threadID']},_0x23f4af));if(!_0x4d3399)throw v('Comment\x20was\x20not\x20found');await this['_middleware']['run']('deleteComment',{..._0x23f4af,'request':_0x386577,'target':{'kind':_0x34e629===void 0x0?'root':'reply','threadID':_0x4d3399['threadID'],'replyID':_0x4d3399['replyID'],'authorUserID':_0x4d3399['authorUserID'],'generation':_0x4d3399['generation']}},async()=>{let _0x34c039=await this['_databaseCall'](()=>this['_database']['deleteComment']({'unitID':_0x3512aa['unitID'],'threadID':_0x3512aa['threadID'],..._0x34e629===void 0x0?{}:{'replyID':_0x34e629},'expectedGeneration':_0x4d3399['generation']},_0x23f4af));if(_0x34c039['status']==='not-found')throw v('Comment\x20was\x20not\x20found');if(_0x34c039['status']==='generation-mismatch')throw _('Comment\x20changed\x20before\x20deletion');await this['_emitWrite'](_0x4d4ea6,_0x386577,{'memberId':_0x4d4ea6['memberID'],'userId':_0x4d4ea6['userID'],'unitId':_0x3512aa['unitID'],'threadId':_0x3512aa['threadID'],'type':n['CommentUpdateEventType']['Delete'],..._0x34e629===void 0x0?{}:{'replyId':_0x34e629}});});});}['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'](_0x1cff07,_0x55c636,_0x2b5964,_0x1a47cb){let _0x1dac9a=await this['_resolveUsers']([_0x55c636['authorUserID']],_0x2b5964,_0x1a47cb);return{...f(_0x1cff07,_0x55c636,_0x2b5964),..._0x1dac9a[_0x55c636['authorUserID']]?{'user':_0x1dac9a[_0x55c636['authorUserID']]}:{}};}async['_resolveUsers'](_0x4c40d4,_0x1c51c4,_0x10ad6a){let _0x16fc60=[...new Set(_0x4c40d4['filter'](Boolean))];if(!this['_userProvider']||_0x16fc60['length']===0x0)return{};let _0x5219ac;try{_0x5219ac=await this['_userProvider']['getUsers'](_0x16fc60,{..._0x1c51c4,'request':_0x10ad6a});}catch{return{};}let _0x242a8d=new Set(_0x16fc60),_0x285fc2={};for(let _0x1d8023 of _0x5219ac)_0x1d8023?.['userID']&&_0x242a8d['has'](_0x1d8023['userID'])&&(_0x285fc2[_0x1d8023['userID']]=_0x1d8023);return _0x285fc2;}async['_emitWrite'](_0x41d720,_0x45ba93,_0x1dd801){let _0xe3648c={'userID':_0x41d720['userID'],'memberID':_0x41d720['memberID'],'customData':_0x41d720['customData'],'request':_0x45ba93,'update':_0x1dd801,'committedAt':Date['now']()};for(let _0x408a7e of[...this['_listeners']['get']('commentCommitted')??[]])try{await _0x408a7e(_0xe3648c);}catch{}}['_call'](_0x324d90){this['_assertRunning']();let _0x4bb17c=_0x324d90();return this['_calls']['add'](_0x4bb17c),_0x4bb17c['finally'](()=>this['_calls']['delete'](_0x4bb17c))['catch'](()=>void 0x0),_0x4bb17c;}async['_databaseCall'](_0x12600b){try{return await _0x12600b();}catch(_0x174a6d){throw _0x174a6d instanceof t['CollabError']?_0x174a6d:new t['CollabError']('ADAPTER_FAILURE','Comment\x20Database\x20Adapter\x20failed',{'retryable':!0x0,'cause':_0x174a6d});}}['_assertRunning'](){if(this['_state']!=='running')throw new t['CollabError']('INTERNAL_ERROR','Comment\x20Service\x20is\x20'+this['_state'],{'retryable':!0x0});}};function a(_0x18f174){return{..._0x18f174};}function o(_0x55d8d0){return c(_0x55d8d0),{'userID':_0x55d8d0['userID'],'customData':_0x55d8d0['customData']??Object['create'](null)};}function s(_0x365a07){return c(_0x365a07),g('memberID',_0x365a07['memberID']),{'userID':_0x365a07['userID'],'memberID':_0x365a07['memberID'],'customData':_0x365a07['customData']??Object['create'](null)};}function c(_0x1284fc){if(!_0x1284fc||typeof _0x1284fc!='object')throw _('context\x20must\x20be\x20an\x20object');if(g('userID',_0x1284fc['userID']),_0x1284fc['customData']!==void 0x0&&(_0x1284fc['customData']===null||typeof _0x1284fc['customData']!='object'||Array['isArray'](_0x1284fc['customData'])))throw _('customData\x20must\x20be\x20an\x20object');}function l(_0xf84e14){return{'threadId':_0xf84e14['threadID'],'replyId':_0xf84e14['replyID'],'content':_0xf84e14['content'],'userId':_0xf84e14['authorUserID'],'createTimestamp':_0xf84e14['createdAt']};}function u(_0x327337){let _0x4282a8=_0x327337['find'](_0x471d76=>_0x471d76['replyID']===_0x471d76['threadID']);return{'threadId':_0x4282a8['threadID'],'solved':_0x4282a8['solved'],'replies':_0x327337['map'](l)};}function d(_0x2de636){let _0x20127a=new Map();for(let _0x2aa4e4 of _0x2de636){let _0x367dd3=_0x20127a['get'](_0x2aa4e4['threadID'])??[];_0x367dd3['push'](_0x2aa4e4),_0x20127a['set'](_0x2aa4e4['threadID'],_0x367dd3);}let _0x2ed389={};for(let [_0x7298cf,_0x1e338c]of _0x20127a)_0x1e338c['find'](_0xf442e=>_0xf442e['replyID']===_0x7298cf)&&(_0x2ed389[_0x7298cf]=u([..._0x1e338c]['sort']((_0x599eaf,_0x41f615)=>_0x599eaf['replyID']===_0x7298cf?-0x1:_0x41f615['replyID']===_0x7298cf?0x1:_0x599eaf['createdAt']-_0x41f615['createdAt']||_0x599eaf['replyID']['localeCompare'](_0x41f615['replyID']))));return _0x2ed389;}function f(_0x4152c9,_0x301f43,_0x3c7ebb){return{'memberId':_0x3c7ebb['memberID'],'userId':_0x3c7ebb['userID'],'unitId':_0x301f43['unitID'],'threadId':_0x301f43['threadID'],'type':_0x4152c9,'replyId':_0x301f43['replyID'],'content':_0x301f43['content'],'createTimestamp':String(_0x301f43['createdAt'])};}function p(_0x547b1a){m(_0x547b1a['unitID']),g('threadID',_0x547b1a['threadID']),g('replyID',_0x547b1a['replyID']);}function m(_0x52ffe2){g('unitID',_0x52ffe2);}function h(_0x4317da){if(typeof _0x4317da!='string'||_0x4317da['length']===0x0)throw _('content\x20must\x20be\x20a\x20non-empty\x20string');}function g(_0x5811c2,_0x5dcb4c){if(typeof _0x5dcb4c!='string'||_0x5dcb4c['length']===0x0)throw _(_0x5811c2+'\x20must\x20be\x20a\x20non-empty\x20string');}function _(_0x57ee2f){return new t['CollabError']('INVALID_REQUEST',_0x57ee2f);}function v(_0x5f3750){return new t['CollabError']('UNIT_NOT_FOUND',_0x5f3750);}function y(_0xa890a1){return new t['CollabError']('PERMISSION_DENIED',_0xa890a1);}exports['UniverCommentService']=i;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const _0x2cb468=_0x169c;(function(_0x3c1d3a,_0x320a7e){const _0xf43cca=_0x169c,_0x1945ac=_0x3c1d3a();while(!![]){try{const _0x5b1182=parseInt(_0xf43cca(0x1bc))/0x1+-parseInt(_0xf43cca(0x1c3))/0x2*(parseInt(_0xf43cca(0x1bb))/0x3)+parseInt(_0xf43cca(0x1bf))/0x4+-parseInt(_0xf43cca(0x1bd))/0x5+parseInt(_0xf43cca(0x1c2))/0x6*(parseInt(_0xf43cca(0x1c0))/0x7)+-parseInt(_0xf43cca(0x1be))/0x8+parseInt(_0xf43cca(0x1c1))/0x9;if(_0x5b1182===_0x320a7e)break;else _0x1945ac['push'](_0x1945ac['shift']());}catch(_0x448572){_0x1945ac['push'](_0x1945ac['shift']());}}}(_0x4a96,0x5ea09));import _0x1e60f7 from'./index.cjs';function _0x4a96(){const _0x582596=['2940648XJdmSK','288604eGwORi','1092GnHkkC','374175HgOYAR','27312yITbCs','10mSgMWQ','UniverCommentService','397401jUsJbO','719643ZOJsCr','629860glKbxB'];_0x4a96=function(){return _0x582596;};return _0x4a96();}const facadeExport0=_0x1e60f7[_0x2cb468(0x1c4)];function _0x169c(_0x12df2c,_0x2a1da3){_0x12df2c=_0x12df2c-0x1bb;const _0x4a96a5=_0x4a96();let _0x169c32=_0x4a96a5[_0x12df2c];return _0x169c32;}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.2.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.0
|
|
20
|
-
"@univerjs/protocol": "1.0
|
|
19
|
+
"@univerjs-pro/collaboration-service": "1.2.0",
|
|
20
|
+
"@univerjs/protocol": "1.2.0"
|
|
21
21
|
}
|
|
22
22
|
}
|