@univerjs-pro/collaboration-comment-service 1.0.3 → 1.1.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'](_0x296fc1,_0x257818){let _0x5d5295=this['_middlewares']['get'](_0x296fc1)??[],_0x1bd56f=_0x257818;_0x5d5295['push'](_0x1bd56f),this['_middlewares']['set'](_0x296fc1,_0x5d5295);let _0x4df17d=!0x1;return{'dispose':()=>{if(_0x4df17d)return;_0x4df17d=!0x0;let _0x243a4e=_0x5d5295['indexOf'](_0x1bd56f);_0x243a4e>=0x0&&_0x5d5295['splice'](_0x243a4e,0x1);}};}async['run'](_0x3ad7ab,_0x42a201,_0x39fc72){let _0x52d679=[...this['_middlewares']['get'](_0x3ad7ab)??[]],_0x211738=async _0x1cd5b4=>{let _0x4d2501=_0x52d679[_0x1cd5b4];if(!_0x4d2501)return _0x39fc72();let _0x4668e1=!0x1,_0x914632,_0x5bb101=()=>{if(_0x4668e1)throw Error('Middleware\x20for\x20action\x20'+_0x3ad7ab+'\x20called\x20next()\x20more\x20than\x20once');return _0x4668e1=!0x0,_0x914632=_0x211738(_0x1cd5b4+0x1),_0x914632;};try{await _0x4d2501(_0x42a201,_0x5bb101);}catch(_0x4d227b){throw _0x914632&&await _0x914632['catch'](()=>void 0x0),_0x4d227b;}if(!_0x4668e1)throw Error('Middleware\x20for\x20action\x20'+_0x3ad7ab+'\x20completed\x20without\x20calling\x20next()');await _0x914632;};await _0x211738(0x0);}['clear'](){this['_middlewares']['clear']();}},i=class{['_middleware']=new r();['_listeners']=new Map();['_calls']=new Set();['_database'];['_userProvider'];['_state']='running';['_disposePromise'];constructor(_0x49ea74){if(!_0x49ea74?.['database'])throw TypeError('UniverCommentService\x20requires\x20a\x20database');this['_database']=_0x49ea74['database'],this['_userProvider']=_0x49ea74['userProvider'];}['use'](_0xc2992c,_0x4c9a04){return this['_assertRunning'](),this['_middleware']['use'](_0xc2992c,_0x4c9a04);}['on'](_0x1c9f37,_0x34c364){this['_assertRunning']();let _0x21a44a=this['_listeners']['get'](_0x1c9f37)??new Set(),_0x161368=_0x34c364;_0x21a44a['add'](_0x161368),this['_listeners']['set'](_0x1c9f37,_0x21a44a);let _0x4c711c=!0x1;return{'dispose':()=>{_0x4c711c||(_0x4c711c=!0x0,_0x21a44a['delete'](_0x161368));}};}['addComment'](_0xaecbd9,_0x4ca599){return this['_call'](async()=>{let _0x4e31e6=s(_0x4ca599);m(_0xaecbd9['unitID']),h(_0xaecbd9['content']);let _0x5d7f08=a(_0xaecbd9),_0x743dc7={..._0x4e31e6,'request':_0x5d7f08},_0x11dba9;return await this['_middleware']['run']('addComment',_0x743dc7,async()=>{let _0x12b544=await this['_databaseCall'](()=>this['_database']['createRoot']({'unitID':_0xaecbd9['unitID'],'threadID':(0x0,e['randomUUID'])(),'authorUserID':_0x4e31e6['userID'],'content':_0xaecbd9['content'],'mentions':[..._0xaecbd9['mentions']]},_0x743dc7));if(_0x12b544['status']==='duplicate')throw _('Comment\x20ID\x20already\x20exists');_0x11dba9=u([_0x12b544['record']]),await this['_emitWrite'](_0x4e31e6,_0x5d7f08,await this['_createUpdate'](n['CommentUpdateEventType']['Add'],_0x12b544['record'],_0x4e31e6,_0x5d7f08));}),_0x11dba9;});}['listComments'](_0x55c455,_0x282db2){return this['_call'](async()=>{let _0x586e0f=o(_0x282db2);m(_0x55c455['unitID']),_0x55c455['threadIDs']['forEach'](_0x570da4=>g('threadID',_0x570da4));let _0x55571b=a(_0x55c455),_0x3bd23e={..._0x586e0f,'request':_0x55571b},_0x53fae9;return await this['_middleware']['run']('listComments',_0x3bd23e,async()=>{let _0x799e3f=d(await this['_databaseCall'](()=>this['_database']['listThreads']({'unitID':_0x55c455['unitID'],'threadIDs':[...new Set(_0x55c455['threadIDs'])]},_0x3bd23e))),_0x2b15e1=Object['values'](_0x799e3f)['flatMap'](_0x749f20=>_0x749f20['replies']['map'](_0xacbb40=>_0xacbb40['userId']));_0x53fae9={'comments':_0x799e3f,'users':await this['_resolveUsers'](_0x2b15e1,_0x586e0f,_0x55571b)};}),_0x53fae9;});}['replyComment'](_0x11946b,_0x7d24b7){return this['_call'](async()=>{let _0x42cc27=s(_0x7d24b7);m(_0x11946b['unitID']),g('threadID',_0x11946b['threadID']),h(_0x11946b['content']);let _0x4edc09=a(_0x11946b),_0x1762e1={..._0x42cc27,'request':_0x4edc09},_0x429881;return await this['_middleware']['run']('replyComment',_0x1762e1,async()=>{let _0x5ecbe4=await this['_databaseCall'](()=>this['_database']['createReply']({'unitID':_0x11946b['unitID'],'threadID':_0x11946b['threadID'],'replyID':(0x0,e['randomUUID'])(),'authorUserID':_0x42cc27['userID'],'content':_0x11946b['content'],'mentions':[..._0x11946b['mentions']]},_0x1762e1));if(_0x5ecbe4['status']==='not-found'||_0x5ecbe4['status']==='closed')throw v('Open\x20Comment\x20thread\x20was\x20not\x20found');if(_0x5ecbe4['status']==='duplicate')throw _('Comment\x20ID\x20already\x20exists');_0x429881=l(_0x5ecbe4['record']),await this['_emitWrite'](_0x42cc27,_0x4edc09,await this['_createUpdate'](n['CommentUpdateEventType']['Reply'],_0x5ecbe4['record'],_0x42cc27,_0x4edc09));}),_0x429881;});}['editComment'](_0x2d2099,_0x3a51a7){return this['_call'](async()=>{let _0x50d101=s(_0x3a51a7);p(_0x2d2099),h(_0x2d2099['content']);let _0x25685e=a(_0x2d2099),_0x5f1b96={..._0x50d101,'request':_0x25685e};await this['_middleware']['run']('editComment',_0x5f1b96,async()=>{let _0x4cc5ef=await this['_databaseCall'](()=>this['_database']['editComment']({'unitID':_0x2d2099['unitID'],'threadID':_0x2d2099['threadID'],'replyID':_0x2d2099['replyID'],'expectedAuthorUserID':_0x50d101['userID'],'content':_0x2d2099['content'],'mentions':[..._0x2d2099['mentions']]},_0x5f1b96));if(_0x4cc5ef['status']==='author-mismatch')throw y('Only\x20the\x20Comment\x20author\x20can\x20edit\x20it');if(_0x4cc5ef['status']==='not-found'||_0x4cc5ef['status']==='closed')throw v('Open\x20Comment\x20was\x20not\x20found');_0x4cc5ef['status']==='edited'&&await this['_emitWrite'](_0x50d101,_0x25685e,f(n['CommentUpdateEventType']['Edit'],_0x4cc5ef['record'],_0x50d101));});});}['setThreadSolved'](_0x29e478,_0x5c2e20){return this['_call'](async()=>{let _0xb02597=s(_0x5c2e20);if(m(_0x29e478['unitID']),g('threadID',_0x29e478['threadID']),_0x29e478['solved']!==n['CommentSolvedStatus']['OpenOrReOpen']&&_0x29e478['solved']!==n['CommentSolvedStatus']['Solved'])throw _('solved\x20must\x20be\x20OpenOrReOpen\x20or\x20Solved');let _0x20306b=a(_0x29e478),_0x465c2a={..._0xb02597,'request':_0x20306b};await this['_middleware']['run']('setThreadSolved',_0x465c2a,async()=>{let _0x580228=await this['_databaseCall'](()=>this['_database']['setThreadSolved'](_0x29e478,_0x465c2a));if(_0x580228['status']==='not-found')throw v('Comment\x20thread\x20was\x20not\x20found');_0x580228['status']==='updated'&&await this['_emitWrite'](_0xb02597,_0x20306b,{'memberId':_0xb02597['memberID'],'userId':_0xb02597['userID'],'unitId':_0x29e478['unitID'],'threadId':_0x29e478['threadID'],'type':n['CommentUpdateEventType']['Solve'],'solved':_0x29e478['solved']});});});}['deleteComment'](_0x23be77,_0x3b68b4){return this['_call'](async()=>{let _0x3023a9=s(_0x3b68b4);m(_0x23be77['unitID']),g('threadID',_0x23be77['threadID']),_0x23be77['replyID']!==void 0x0&&g('replyID',_0x23be77['replyID']);let _0x83614a=_0x23be77['replyID']===_0x23be77['threadID']?void 0x0:_0x23be77['replyID'],_0x166a5b=a({'unitID':_0x23be77['unitID'],'threadID':_0x23be77['threadID'],..._0x83614a===void 0x0?{}:{'replyID':_0x83614a}}),_0x4444dd={..._0x3023a9,'request':_0x166a5b},_0x3b0a5c=await this['_databaseCall'](()=>this['_database']['getComment']({'unitID':_0x23be77['unitID'],'threadID':_0x23be77['threadID'],'replyID':_0x83614a??_0x23be77['threadID']},_0x4444dd));if(!_0x3b0a5c)throw v('Comment\x20was\x20not\x20found');await this['_middleware']['run']('deleteComment',{..._0x4444dd,'request':_0x166a5b,'target':{'kind':_0x83614a===void 0x0?'root':'reply','threadID':_0x3b0a5c['threadID'],'replyID':_0x3b0a5c['replyID'],'authorUserID':_0x3b0a5c['authorUserID'],'generation':_0x3b0a5c['generation']}},async()=>{let _0x2902f8=await this['_databaseCall'](()=>this['_database']['deleteComment']({'unitID':_0x23be77['unitID'],'threadID':_0x23be77['threadID'],..._0x83614a===void 0x0?{}:{'replyID':_0x83614a},'expectedGeneration':_0x3b0a5c['generation']},_0x4444dd));if(_0x2902f8['status']==='not-found')throw v('Comment\x20was\x20not\x20found');if(_0x2902f8['status']==='generation-mismatch')throw _('Comment\x20changed\x20before\x20deletion');await this['_emitWrite'](_0x3023a9,_0x166a5b,{'memberId':_0x3023a9['memberID'],'userId':_0x3023a9['userID'],'unitId':_0x23be77['unitID'],'threadId':_0x23be77['threadID'],'type':n['CommentUpdateEventType']['Delete'],..._0x83614a===void 0x0?{}:{'replyId':_0x83614a}});});});}['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'](_0x57bac8,_0x596c25,_0x1f046a,_0x46bbd4){let _0x40c03a=await this['_resolveUsers']([_0x596c25['authorUserID']],_0x1f046a,_0x46bbd4);return{...f(_0x57bac8,_0x596c25,_0x1f046a),..._0x40c03a[_0x596c25['authorUserID']]?{'user':_0x40c03a[_0x596c25['authorUserID']]}:{}};}async['_resolveUsers'](_0x1d8d70,_0x54eac0,_0x11c686){let _0xa3c667=[...new Set(_0x1d8d70['filter'](Boolean))];if(!this['_userProvider']||_0xa3c667['length']===0x0)return{};let _0x5a5a5a;try{_0x5a5a5a=await this['_userProvider']['getUsers'](_0xa3c667,{..._0x54eac0,'request':_0x11c686});}catch{return{};}let _0x56bea1=new Set(_0xa3c667),_0x1874ee={};for(let _0x5aab21 of _0x5a5a5a)_0x5aab21?.['userID']&&_0x56bea1['has'](_0x5aab21['userID'])&&(_0x1874ee[_0x5aab21['userID']]=_0x5aab21);return _0x1874ee;}async['_emitWrite'](_0x2781de,_0x5b85a3,_0x4fa2aa){let _0xdfb40b={'userID':_0x2781de['userID'],'memberID':_0x2781de['memberID'],'customData':_0x2781de['customData'],'request':_0x5b85a3,'update':_0x4fa2aa,'committedAt':Date['now']()};for(let _0x1bc8bf of[...this['_listeners']['get']('commentCommitted')??[]])try{await _0x1bc8bf(_0xdfb40b);}catch{}}['_call'](_0x44309c){this['_assertRunning']();let _0x1b8c9f=_0x44309c();return this['_calls']['add'](_0x1b8c9f),_0x1b8c9f['finally'](()=>this['_calls']['delete'](_0x1b8c9f))['catch'](()=>void 0x0),_0x1b8c9f;}async['_databaseCall'](_0xfaddb9){try{return await _0xfaddb9();}catch(_0x64bf9a){throw _0x64bf9a instanceof t['CollabError']?_0x64bf9a:new t['CollabError']('ADAPTER_FAILURE','Comment\x20Database\x20Adapter\x20failed',{'retryable':!0x0,'cause':_0x64bf9a});}}['_assertRunning'](){if(this['_state']!=='running')throw new t['CollabError']('INTERNAL_ERROR','Comment\x20Service\x20is\x20'+this['_state'],{'retryable':!0x0});}};function a(_0x4f5f8c){return{..._0x4f5f8c};}function o(_0x57ead8){return c(_0x57ead8),{'userID':_0x57ead8['userID'],'customData':_0x57ead8['customData']??Object['create'](null)};}function s(_0x38531a){return c(_0x38531a),g('memberID',_0x38531a['memberID']),{'userID':_0x38531a['userID'],'memberID':_0x38531a['memberID'],'customData':_0x38531a['customData']??Object['create'](null)};}function c(_0x11884b){if(!_0x11884b||typeof _0x11884b!='object')throw _('context\x20must\x20be\x20an\x20object');if(g('userID',_0x11884b['userID']),_0x11884b['customData']!==void 0x0&&(_0x11884b['customData']===null||typeof _0x11884b['customData']!='object'||Array['isArray'](_0x11884b['customData'])))throw _('customData\x20must\x20be\x20an\x20object');}function l(_0x1f1b1d){return{'threadId':_0x1f1b1d['threadID'],'replyId':_0x1f1b1d['replyID'],'content':_0x1f1b1d['content'],'userId':_0x1f1b1d['authorUserID'],'createTimestamp':_0x1f1b1d['createdAt']};}function u(_0x76f2ad){let _0x2dba25=_0x76f2ad['find'](_0x2a56c4=>_0x2a56c4['replyID']===_0x2a56c4['threadID']);return{'threadId':_0x2dba25['threadID'],'solved':_0x2dba25['solved'],'replies':_0x76f2ad['map'](l)};}function d(_0x211022){let _0x581b30=new Map();for(let _0x1bbada of _0x211022){let _0x37be69=_0x581b30['get'](_0x1bbada['threadID'])??[];_0x37be69['push'](_0x1bbada),_0x581b30['set'](_0x1bbada['threadID'],_0x37be69);}let _0x1358a6={};for(let [_0x515752,_0x39d61a]of _0x581b30)_0x39d61a['find'](_0xf0d0b0=>_0xf0d0b0['replyID']===_0x515752)&&(_0x1358a6[_0x515752]=u([..._0x39d61a]['sort']((_0xf853cc,_0x26364d)=>_0xf853cc['replyID']===_0x515752?-0x1:_0x26364d['replyID']===_0x515752?0x1:_0xf853cc['createdAt']-_0x26364d['createdAt']||_0xf853cc['replyID']['localeCompare'](_0x26364d['replyID']))));return _0x1358a6;}function f(_0x3fef8f,_0x492a66,_0x569f19){return{'memberId':_0x569f19['memberID'],'userId':_0x569f19['userID'],'unitId':_0x492a66['unitID'],'threadId':_0x492a66['threadID'],'type':_0x3fef8f,'replyId':_0x492a66['replyID'],'content':_0x492a66['content'],'createTimestamp':String(_0x492a66['createdAt'])};}function p(_0x58dd7b){m(_0x58dd7b['unitID']),g('threadID',_0x58dd7b['threadID']),g('replyID',_0x58dd7b['replyID']);}function m(_0xe01481){g('unitID',_0xe01481);}function h(_0x13e6e5){if(typeof _0x13e6e5!='string'||_0x13e6e5['length']===0x0)throw _('content\x20must\x20be\x20a\x20non-empty\x20string');}function g(_0x377a6a,_0x34a9c2){if(typeof _0x34a9c2!='string'||_0x34a9c2['length']===0x0)throw _(_0x377a6a+'\x20must\x20be\x20a\x20non-empty\x20string');}function _(_0x4a3037){return new t['CollabError']('INVALID_REQUEST',_0x4a3037);}function v(_0x2f7db6){return new t['CollabError']('UNIT_NOT_FOUND',_0x2f7db6);}function y(_0x431052){return new t['CollabError']('PERMISSION_DENIED',_0x431052);}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'](_0x19ede3,_0x46c656){let _0x4d7633=this['_middlewares']['get'](_0x19ede3)??[],_0x261672=_0x46c656;_0x4d7633['push'](_0x261672),this['_middlewares']['set'](_0x19ede3,_0x4d7633);let _0x122203=!0x1;return{'dispose':()=>{if(_0x122203)return;_0x122203=!0x0;let _0x3735b4=_0x4d7633['indexOf'](_0x261672);_0x3735b4>=0x0&&_0x4d7633['splice'](_0x3735b4,0x1);}};}async['run'](_0x2eaec8,_0x565700,_0xa6e3ac){let _0x1d9b48=[...this['_middlewares']['get'](_0x2eaec8)??[]],_0x365eb7=async _0x125047=>{let _0x75174e=_0x1d9b48[_0x125047];if(!_0x75174e)return _0xa6e3ac();let _0x5b2d25=!0x1,_0xef6c2f,_0x4f102c=()=>{if(_0x5b2d25)throw Error('Middleware\x20for\x20action\x20'+_0x2eaec8+'\x20called\x20next()\x20more\x20than\x20once');return _0x5b2d25=!0x0,_0xef6c2f=_0x365eb7(_0x125047+0x1),_0xef6c2f;};try{await _0x75174e(_0x565700,_0x4f102c);}catch(_0x545fb6){throw _0xef6c2f&&await _0xef6c2f['catch'](()=>void 0x0),_0x545fb6;}if(!_0x5b2d25)throw Error('Middleware\x20for\x20action\x20'+_0x2eaec8+'\x20completed\x20without\x20calling\x20next()');await _0xef6c2f;};await _0x365eb7(0x0);}['clear'](){this['_middlewares']['clear']();}},i=class{['_middleware']=new r();['_listeners']=new Map();['_calls']=new Set();['_database'];['_userProvider'];['_state']='running';['_disposePromise'];constructor(_0x43e39d){if(!_0x43e39d?.['database'])throw TypeError('UniverCommentService\x20requires\x20a\x20database');this['_database']=_0x43e39d['database'],this['_userProvider']=_0x43e39d['userProvider'];}['use'](_0x4077fd,_0x26595c){return this['_assertRunning'](),this['_middleware']['use'](_0x4077fd,_0x26595c);}['on'](_0x3b8882,_0x1b7f91){this['_assertRunning']();let _0x4211da=this['_listeners']['get'](_0x3b8882)??new Set(),_0xe8905e=_0x1b7f91;_0x4211da['add'](_0xe8905e),this['_listeners']['set'](_0x3b8882,_0x4211da);let _0x2fc574=!0x1;return{'dispose':()=>{_0x2fc574||(_0x2fc574=!0x0,_0x4211da['delete'](_0xe8905e));}};}['addComment'](_0xc8f877,_0x4141a9){return this['_call'](async()=>{let _0x259652=s(_0x4141a9);m(_0xc8f877['unitID']),h(_0xc8f877['content']);let _0xe06779=a(_0xc8f877),_0x52abe0={..._0x259652,'request':_0xe06779},_0x561db3;return await this['_middleware']['run']('addComment',_0x52abe0,async()=>{let _0x56af9f=await this['_databaseCall'](()=>this['_database']['createRoot']({'unitID':_0xc8f877['unitID'],'threadID':(0x0,e['randomUUID'])(),'authorUserID':_0x259652['userID'],'content':_0xc8f877['content'],'mentions':[..._0xc8f877['mentions']]},_0x52abe0));if(_0x56af9f['status']==='duplicate')throw _('Comment\x20ID\x20already\x20exists');_0x561db3=u([_0x56af9f['record']]),await this['_emitWrite'](_0x259652,_0xe06779,await this['_createUpdate'](n['CommentUpdateEventType']['Add'],_0x56af9f['record'],_0x259652,_0xe06779));}),_0x561db3;});}['listComments'](_0x19a1db,_0x17c2b0){return this['_call'](async()=>{let _0x3782a9=o(_0x17c2b0);m(_0x19a1db['unitID']),_0x19a1db['threadIDs']['forEach'](_0x4893bd=>g('threadID',_0x4893bd));let _0x152d89=a(_0x19a1db),_0x3f1d48={..._0x3782a9,'request':_0x152d89},_0xa9ba25;return await this['_middleware']['run']('listComments',_0x3f1d48,async()=>{let _0x3f7e77=d(await this['_databaseCall'](()=>this['_database']['listThreads']({'unitID':_0x19a1db['unitID'],'threadIDs':[...new Set(_0x19a1db['threadIDs'])]},_0x3f1d48))),_0x275538=Object['values'](_0x3f7e77)['flatMap'](_0x10c5a9=>_0x10c5a9['replies']['map'](_0x143da2=>_0x143da2['userId']));_0xa9ba25={'comments':_0x3f7e77,'users':await this['_resolveUsers'](_0x275538,_0x3782a9,_0x152d89)};}),_0xa9ba25;});}['replyComment'](_0x35b707,_0x5cdda2){return this['_call'](async()=>{let _0x2e5bff=s(_0x5cdda2);m(_0x35b707['unitID']),g('threadID',_0x35b707['threadID']),h(_0x35b707['content']);let _0xdf9871=a(_0x35b707),_0x1bc82a={..._0x2e5bff,'request':_0xdf9871},_0x235594;return await this['_middleware']['run']('replyComment',_0x1bc82a,async()=>{let _0x3716b8=await this['_databaseCall'](()=>this['_database']['createReply']({'unitID':_0x35b707['unitID'],'threadID':_0x35b707['threadID'],'replyID':(0x0,e['randomUUID'])(),'authorUserID':_0x2e5bff['userID'],'content':_0x35b707['content'],'mentions':[..._0x35b707['mentions']]},_0x1bc82a));if(_0x3716b8['status']==='not-found'||_0x3716b8['status']==='closed')throw v('Open\x20Comment\x20thread\x20was\x20not\x20found');if(_0x3716b8['status']==='duplicate')throw _('Comment\x20ID\x20already\x20exists');_0x235594=l(_0x3716b8['record']),await this['_emitWrite'](_0x2e5bff,_0xdf9871,await this['_createUpdate'](n['CommentUpdateEventType']['Reply'],_0x3716b8['record'],_0x2e5bff,_0xdf9871));}),_0x235594;});}['editComment'](_0x3c904b,_0x14d329){return this['_call'](async()=>{let _0x4e0599=s(_0x14d329);p(_0x3c904b),h(_0x3c904b['content']);let _0x483828=a(_0x3c904b),_0x267740={..._0x4e0599,'request':_0x483828};await this['_middleware']['run']('editComment',_0x267740,async()=>{let _0x11795f=await this['_databaseCall'](()=>this['_database']['editComment']({'unitID':_0x3c904b['unitID'],'threadID':_0x3c904b['threadID'],'replyID':_0x3c904b['replyID'],'expectedAuthorUserID':_0x4e0599['userID'],'content':_0x3c904b['content'],'mentions':[..._0x3c904b['mentions']]},_0x267740));if(_0x11795f['status']==='author-mismatch')throw y('Only\x20the\x20Comment\x20author\x20can\x20edit\x20it');if(_0x11795f['status']==='not-found'||_0x11795f['status']==='closed')throw v('Open\x20Comment\x20was\x20not\x20found');_0x11795f['status']==='edited'&&await this['_emitWrite'](_0x4e0599,_0x483828,f(n['CommentUpdateEventType']['Edit'],_0x11795f['record'],_0x4e0599));});});}['setThreadSolved'](_0xa84fc2,_0x48414d){return this['_call'](async()=>{let _0x36132d=s(_0x48414d);if(m(_0xa84fc2['unitID']),g('threadID',_0xa84fc2['threadID']),_0xa84fc2['solved']!==n['CommentSolvedStatus']['OpenOrReOpen']&&_0xa84fc2['solved']!==n['CommentSolvedStatus']['Solved'])throw _('solved\x20must\x20be\x20OpenOrReOpen\x20or\x20Solved');let _0x17eb63=a(_0xa84fc2),_0x597953={..._0x36132d,'request':_0x17eb63};await this['_middleware']['run']('setThreadSolved',_0x597953,async()=>{let _0x4e6993=await this['_databaseCall'](()=>this['_database']['setThreadSolved'](_0xa84fc2,_0x597953));if(_0x4e6993['status']==='not-found')throw v('Comment\x20thread\x20was\x20not\x20found');_0x4e6993['status']==='updated'&&await this['_emitWrite'](_0x36132d,_0x17eb63,{'memberId':_0x36132d['memberID'],'userId':_0x36132d['userID'],'unitId':_0xa84fc2['unitID'],'threadId':_0xa84fc2['threadID'],'type':n['CommentUpdateEventType']['Solve'],'solved':_0xa84fc2['solved']});});});}['deleteComment'](_0x53c394,_0x28f584){return this['_call'](async()=>{let _0x1540ae=s(_0x28f584);m(_0x53c394['unitID']),g('threadID',_0x53c394['threadID']),_0x53c394['replyID']!==void 0x0&&g('replyID',_0x53c394['replyID']);let _0x51af80=_0x53c394['replyID']===_0x53c394['threadID']?void 0x0:_0x53c394['replyID'],_0x5e82f6=a({'unitID':_0x53c394['unitID'],'threadID':_0x53c394['threadID'],..._0x51af80===void 0x0?{}:{'replyID':_0x51af80}}),_0x29b401={..._0x1540ae,'request':_0x5e82f6},_0x2166da=await this['_databaseCall'](()=>this['_database']['getComment']({'unitID':_0x53c394['unitID'],'threadID':_0x53c394['threadID'],'replyID':_0x51af80??_0x53c394['threadID']},_0x29b401));if(!_0x2166da)throw v('Comment\x20was\x20not\x20found');await this['_middleware']['run']('deleteComment',{..._0x29b401,'request':_0x5e82f6,'target':{'kind':_0x51af80===void 0x0?'root':'reply','threadID':_0x2166da['threadID'],'replyID':_0x2166da['replyID'],'authorUserID':_0x2166da['authorUserID'],'generation':_0x2166da['generation']}},async()=>{let _0x53452c=await this['_databaseCall'](()=>this['_database']['deleteComment']({'unitID':_0x53c394['unitID'],'threadID':_0x53c394['threadID'],..._0x51af80===void 0x0?{}:{'replyID':_0x51af80},'expectedGeneration':_0x2166da['generation']},_0x29b401));if(_0x53452c['status']==='not-found')throw v('Comment\x20was\x20not\x20found');if(_0x53452c['status']==='generation-mismatch')throw _('Comment\x20changed\x20before\x20deletion');await this['_emitWrite'](_0x1540ae,_0x5e82f6,{'memberId':_0x1540ae['memberID'],'userId':_0x1540ae['userID'],'unitId':_0x53c394['unitID'],'threadId':_0x53c394['threadID'],'type':n['CommentUpdateEventType']['Delete'],..._0x51af80===void 0x0?{}:{'replyId':_0x51af80}});});});}['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'](_0x445c1a,_0x463934,_0x465e0c,_0x1877c5){let _0x2aadec=await this['_resolveUsers']([_0x463934['authorUserID']],_0x465e0c,_0x1877c5);return{...f(_0x445c1a,_0x463934,_0x465e0c),..._0x2aadec[_0x463934['authorUserID']]?{'user':_0x2aadec[_0x463934['authorUserID']]}:{}};}async['_resolveUsers'](_0x1b30d0,_0x2a7bf3,_0x39f2e3){let _0x22da6e=[...new Set(_0x1b30d0['filter'](Boolean))];if(!this['_userProvider']||_0x22da6e['length']===0x0)return{};let _0x28f497;try{_0x28f497=await this['_userProvider']['getUsers'](_0x22da6e,{..._0x2a7bf3,'request':_0x39f2e3});}catch{return{};}let _0x2e3fba=new Set(_0x22da6e),_0x53446f={};for(let _0xa89407 of _0x28f497)_0xa89407?.['userID']&&_0x2e3fba['has'](_0xa89407['userID'])&&(_0x53446f[_0xa89407['userID']]=_0xa89407);return _0x53446f;}async['_emitWrite'](_0x2e8a27,_0x2629de,_0x45a23e){let _0x42a34f={'userID':_0x2e8a27['userID'],'memberID':_0x2e8a27['memberID'],'customData':_0x2e8a27['customData'],'request':_0x2629de,'update':_0x45a23e,'committedAt':Date['now']()};for(let _0x7189d3 of[...this['_listeners']['get']('commentCommitted')??[]])try{await _0x7189d3(_0x42a34f);}catch{}}['_call'](_0xa0241a){this['_assertRunning']();let _0xcf32fb=_0xa0241a();return this['_calls']['add'](_0xcf32fb),_0xcf32fb['finally'](()=>this['_calls']['delete'](_0xcf32fb))['catch'](()=>void 0x0),_0xcf32fb;}async['_databaseCall'](_0x3ec9d9){try{return await _0x3ec9d9();}catch(_0x416610){throw _0x416610 instanceof t['CollabError']?_0x416610:new t['CollabError']('ADAPTER_FAILURE','Comment\x20Database\x20Adapter\x20failed',{'retryable':!0x0,'cause':_0x416610});}}['_assertRunning'](){if(this['_state']!=='running')throw new t['CollabError']('INTERNAL_ERROR','Comment\x20Service\x20is\x20'+this['_state'],{'retryable':!0x0});}};function a(_0x1437fe){return{..._0x1437fe};}function o(_0x155b1d){return c(_0x155b1d),{'userID':_0x155b1d['userID'],'customData':_0x155b1d['customData']??Object['create'](null)};}function s(_0x121d1f){return c(_0x121d1f),g('memberID',_0x121d1f['memberID']),{'userID':_0x121d1f['userID'],'memberID':_0x121d1f['memberID'],'customData':_0x121d1f['customData']??Object['create'](null)};}function c(_0x3f9a8d){if(!_0x3f9a8d||typeof _0x3f9a8d!='object')throw _('context\x20must\x20be\x20an\x20object');if(g('userID',_0x3f9a8d['userID']),_0x3f9a8d['customData']!==void 0x0&&(_0x3f9a8d['customData']===null||typeof _0x3f9a8d['customData']!='object'||Array['isArray'](_0x3f9a8d['customData'])))throw _('customData\x20must\x20be\x20an\x20object');}function l(_0x57c40f){return{'threadId':_0x57c40f['threadID'],'replyId':_0x57c40f['replyID'],'content':_0x57c40f['content'],'userId':_0x57c40f['authorUserID'],'createTimestamp':_0x57c40f['createdAt']};}function u(_0x1632e1){let _0x5dfec7=_0x1632e1['find'](_0x4193f1=>_0x4193f1['replyID']===_0x4193f1['threadID']);return{'threadId':_0x5dfec7['threadID'],'solved':_0x5dfec7['solved'],'replies':_0x1632e1['map'](l)};}function d(_0xc24e61){let _0x1619a9=new Map();for(let _0x514a55 of _0xc24e61){let _0x10f1e5=_0x1619a9['get'](_0x514a55['threadID'])??[];_0x10f1e5['push'](_0x514a55),_0x1619a9['set'](_0x514a55['threadID'],_0x10f1e5);}let _0x52ef0f={};for(let [_0x40381e,_0x8bf3c6]of _0x1619a9)_0x8bf3c6['find'](_0xc62c9b=>_0xc62c9b['replyID']===_0x40381e)&&(_0x52ef0f[_0x40381e]=u([..._0x8bf3c6]['sort']((_0x5bb36a,_0x512050)=>_0x5bb36a['replyID']===_0x40381e?-0x1:_0x512050['replyID']===_0x40381e?0x1:_0x5bb36a['createdAt']-_0x512050['createdAt']||_0x5bb36a['replyID']['localeCompare'](_0x512050['replyID']))));return _0x52ef0f;}function f(_0x4fb689,_0x5cf331,_0x6f5fce){return{'memberId':_0x6f5fce['memberID'],'userId':_0x6f5fce['userID'],'unitId':_0x5cf331['unitID'],'threadId':_0x5cf331['threadID'],'type':_0x4fb689,'replyId':_0x5cf331['replyID'],'content':_0x5cf331['content'],'createTimestamp':String(_0x5cf331['createdAt'])};}function p(_0x2b26dd){m(_0x2b26dd['unitID']),g('threadID',_0x2b26dd['threadID']),g('replyID',_0x2b26dd['replyID']);}function m(_0x3cc9d1){g('unitID',_0x3cc9d1);}function h(_0x1fe2a3){if(typeof _0x1fe2a3!='string'||_0x1fe2a3['length']===0x0)throw _('content\x20must\x20be\x20a\x20non-empty\x20string');}function g(_0x4d999e,_0x4bb6b8){if(typeof _0x4bb6b8!='string'||_0x4bb6b8['length']===0x0)throw _(_0x4d999e+'\x20must\x20be\x20a\x20non-empty\x20string');}function _(_0x158172){return new t['CollabError']('INVALID_REQUEST',_0x158172);}function v(_0x383cd5){return new t['CollabError']('UNIT_NOT_FOUND',_0x383cd5);}function y(_0x2c0aa3){return new t['CollabError']('PERMISSION_DENIED',_0x2c0aa3);}exports['UniverCommentService']=i;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const _0x369176=_0x2995;(function(_0x2ae7b1,_0x511a93){const _0x2e2839=_0x2995,_0x5a1301=_0x2ae7b1();while(!![]){try{const _0x4937bc=-parseInt(_0x2e2839(0x8c))/0x1+-parseInt(_0x2e2839(0x87))/0x2+-parseInt(_0x2e2839(0x88))/0x3+parseInt(_0x2e2839(0x86))/0x4*(-parseInt(_0x2e2839(0x83))/0x5)+-parseInt(_0x2e2839(0x8a))/0x6*(parseInt(_0x2e2839(0x84))/0x7)+-parseInt(_0x2e2839(0x81))/0x8*(-parseInt(_0x2e2839(0x82))/0x9)+-parseInt(_0x2e2839(0x89))/0xa*(-parseInt(_0x2e2839(0x8b))/0xb);if(_0x4937bc===_0x511a93)break;else _0x5a1301['push'](_0x5a1301['shift']());}catch(_0x1aa1f){_0x5a1301['push'](_0x5a1301['shift']());}}}(_0x14fd,0x597da));import _0x1742ba from'./index.cjs';const facadeExport0=_0x1742ba[_0x369176(0x85)];function _0x2995(_0x3ecc26,_0x38e990){_0x3ecc26=_0x3ecc26-0x81;const _0x14fdd5=_0x14fd();let _0x29954d=_0x14fdd5[_0x3ecc26];return _0x29954d;}function _0x14fd(){const _0x491659=['1141acwttP','UniverCommentService','4hsVeZk','1263774HmiaIO','739002OgoEJR','11278330ssdycC','5334AxqAlF','22eiuyDK','476338zvftfq','1149352pmbdzZ','18QMZhuV','3384920lOdLtb'];_0x14fd=function(){return _0x491659;};return _0x14fd();}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.1.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.1.0",
|
|
20
|
+
"@univerjs/protocol": "1.1.0"
|
|
21
21
|
}
|
|
22
22
|
}
|