@univerjs-pro/collaboration-comment-service 1.0.2 → 1.0.3
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'](_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;
|
|
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;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
function _0x2159(){const _0xfdbf9b=['2553279DwVUNT','1593788gaKfRQ','262150FYQEBr','24ENMoFY','36rfVqtY','2BWZSlM','4RhDqSs','UniverCommentService','1065907WUPNxP','4866990FixFTk','44275550YXRZBG','7438832gkxxLO'];_0x2159=function(){return _0xfdbf9b;};return _0x2159();}function _0x43aa(_0x1f7900,_0x714fae){_0x1f7900=_0x1f7900-0x9c;const _0x215958=_0x2159();let _0x43aa21=_0x215958[_0x1f7900];return _0x43aa21;}const _0x5bdb8f=_0x43aa;(function(_0x59875b,_0x2fd327){const _0x5a805e=_0x43aa,_0x12a5fd=_0x59875b();while(!![]){try{const _0x1d483b=parseInt(_0x5a805e(0x9f))/0x1*(parseInt(_0x5a805e(0x9c))/0x2)+parseInt(_0x5a805e(0xa3))/0x3*(parseInt(_0x5a805e(0x9d))/0x4)+parseInt(_0x5a805e(0xa0))/0x5+parseInt(_0x5a805e(0xa6))/0x6*(parseInt(_0x5a805e(0xa4))/0x7)+parseInt(_0x5a805e(0xa2))/0x8+-parseInt(_0x5a805e(0xa7))/0x9*(parseInt(_0x5a805e(0xa5))/0xa)+-parseInt(_0x5a805e(0xa1))/0xb;if(_0x1d483b===_0x2fd327)break;else _0x12a5fd['push'](_0x12a5fd['shift']());}catch(_0x346380){_0x12a5fd['push'](_0x12a5fd['shift']());}}}(_0x2159,0x92bf6));import _0x58234b from'./index.cjs';const facadeExport0=_0x58234b[_0x5bdb8f(0x9e)];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.3",
|
|
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.3",
|
|
20
|
+
"@univerjs/protocol": "1.0.3"
|
|
21
21
|
}
|
|
22
22
|
}
|