@univerjs-pro/collaboration-comment-service 1.0.0-rc.0 → 1.0.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'](_0x40f78d,_0x28173f){let _0xb00391=this['_middlewares']['get'](_0x40f78d)??[],_0x20abbe=_0x28173f;_0xb00391['push'](_0x20abbe),this['_middlewares']['set'](_0x40f78d,_0xb00391);let _0x19f1b8=!0x1;return{'dispose':()=>{if(_0x19f1b8)return;_0x19f1b8=!0x0;let _0x4b48ec=_0xb00391['indexOf'](_0x20abbe);_0x4b48ec>=0x0&&_0xb00391['splice'](_0x4b48ec,0x1);}};}async['run'](_0x49ba31,_0x13740a,_0x7b3ccf){let _0x1db6d0=[...this['_middlewares']['get'](_0x49ba31)??[]],_0x3205da=async _0x48d959=>{let _0xa46d44=_0x1db6d0[_0x48d959];if(!_0xa46d44)return _0x7b3ccf();let _0x21731f=!0x1,_0x53e505,_0x383559=()=>{if(_0x21731f)throw Error('Middleware\x20for\x20action\x20'+_0x49ba31+'\x20called\x20next()\x20more\x20than\x20once');return _0x21731f=!0x0,_0x53e505=_0x3205da(_0x48d959+0x1),_0x53e505;};try{await _0xa46d44(_0x13740a,_0x383559);}catch(_0x5c8aef){throw _0x53e505&&await _0x53e505['catch'](()=>void 0x0),_0x5c8aef;}if(!_0x21731f)throw Error('Middleware\x20for\x20action\x20'+_0x49ba31+'\x20completed\x20without\x20calling\x20next()');await _0x53e505;};await _0x3205da(0x0);}['clear'](){this['_middlewares']['clear']();}},i=class{['_middleware']=new r();['_listeners']=new Map();['_calls']=new Set();['_database'];['_userProvider'];['_state']='running';['_disposePromise'];constructor(_0x173001){if(!_0x173001?.['database'])throw TypeError('UniverCommentService\x20requires\x20a\x20database');this['_database']=_0x173001['database'],this['_userProvider']=_0x173001['userProvider'];}['use'](_0x23af8e,_0x29b583){return this['_assertRunning'](),this['_middleware']['use'](_0x23af8e,_0x29b583);}['on'](_0x316c00,_0xd68e31){this['_assertRunning']();let _0x2183f3=this['_listeners']['get'](_0x316c00)??new Set(),_0xdebea3=_0xd68e31;_0x2183f3['add'](_0xdebea3),this['_listeners']['set'](_0x316c00,_0x2183f3);let _0x5a2de3=!0x1;return{'dispose':()=>{_0x5a2de3||(_0x5a2de3=!0x0,_0x2183f3['delete'](_0xdebea3));}};}['addComment'](_0x11da28,_0x13258b){return this['_call'](async()=>{let _0x2cef51=s(_0x13258b);m(_0x11da28['unitID']),h(_0x11da28['content']);let _0x5c66b7=a(_0x11da28),_0x52480e={..._0x2cef51,'request':_0x5c66b7},_0xe0f881;return await this['_middleware']['run']('addComment',_0x52480e,async()=>{let _0x470c3c=await this['_databaseCall'](()=>this['_database']['createRoot']({'unitID':_0x11da28['unitID'],'threadID':(0x0,e['randomUUID'])(),'authorUserID':_0x2cef51['userID'],'content':_0x11da28['content'],'mentions':[..._0x11da28['mentions']]},_0x52480e));if(_0x470c3c['status']==='duplicate')throw _('Comment\x20ID\x20already\x20exists');_0xe0f881=u([_0x470c3c['record']]),await this['_emitWrite'](_0x2cef51,_0x5c66b7,await this['_createUpdate'](n['CommentUpdateEventType']['Add'],_0x470c3c['record'],_0x2cef51,_0x5c66b7));}),_0xe0f881;});}['listComments'](_0x23ed2d,_0x3bc176){return this['_call'](async()=>{let _0x84b10d=o(_0x3bc176);m(_0x23ed2d['unitID']),_0x23ed2d['threadIDs']['forEach'](_0x48a40c=>g('threadID',_0x48a40c));let _0xa512bf=a(_0x23ed2d),_0x289bce={..._0x84b10d,'request':_0xa512bf},_0x5e932f;return await this['_middleware']['run']('listComments',_0x289bce,async()=>{let _0x35f8bb=d(await this['_databaseCall'](()=>this['_database']['listThreads']({'unitID':_0x23ed2d['unitID'],'threadIDs':[...new Set(_0x23ed2d['threadIDs'])]},_0x289bce))),_0x348e11=Object['values'](_0x35f8bb)['flatMap'](_0x4af35f=>_0x4af35f['replies']['map'](_0x5b37ef=>_0x5b37ef['userId']));_0x5e932f={'comments':_0x35f8bb,'users':await this['_resolveUsers'](_0x348e11,_0x84b10d,_0xa512bf)};}),_0x5e932f;});}['replyComment'](_0x14aabd,_0x42471a){return this['_call'](async()=>{let _0x3b8776=s(_0x42471a);m(_0x14aabd['unitID']),g('threadID',_0x14aabd['threadID']),h(_0x14aabd['content']);let _0x432147=a(_0x14aabd),_0x376e0b={..._0x3b8776,'request':_0x432147},_0x1f9867;return await this['_middleware']['run']('replyComment',_0x376e0b,async()=>{let _0x29b079=await this['_databaseCall'](()=>this['_database']['createReply']({'unitID':_0x14aabd['unitID'],'threadID':_0x14aabd['threadID'],'replyID':(0x0,e['randomUUID'])(),'authorUserID':_0x3b8776['userID'],'content':_0x14aabd['content'],'mentions':[..._0x14aabd['mentions']]},_0x376e0b));if(_0x29b079['status']==='not-found'||_0x29b079['status']==='closed')throw v('Open\x20Comment\x20thread\x20was\x20not\x20found');if(_0x29b079['status']==='duplicate')throw _('Comment\x20ID\x20already\x20exists');_0x1f9867=l(_0x29b079['record']),await this['_emitWrite'](_0x3b8776,_0x432147,await this['_createUpdate'](n['CommentUpdateEventType']['Reply'],_0x29b079['record'],_0x3b8776,_0x432147));}),_0x1f9867;});}['editComment'](_0x984632,_0x4cd054){return this['_call'](async()=>{let _0x5f10e3=s(_0x4cd054);p(_0x984632),h(_0x984632['content']);let _0x439b8a=a(_0x984632),_0x2deb6f={..._0x5f10e3,'request':_0x439b8a};await this['_middleware']['run']('editComment',_0x2deb6f,async()=>{let _0x37b656=await this['_databaseCall'](()=>this['_database']['editComment']({'unitID':_0x984632['unitID'],'threadID':_0x984632['threadID'],'replyID':_0x984632['replyID'],'expectedAuthorUserID':_0x5f10e3['userID'],'content':_0x984632['content'],'mentions':[..._0x984632['mentions']]},_0x2deb6f));if(_0x37b656['status']==='author-mismatch')throw y('Only\x20the\x20Comment\x20author\x20can\x20edit\x20it');if(_0x37b656['status']==='not-found'||_0x37b656['status']==='closed')throw v('Open\x20Comment\x20was\x20not\x20found');_0x37b656['status']==='edited'&&await this['_emitWrite'](_0x5f10e3,_0x439b8a,f(n['CommentUpdateEventType']['Edit'],_0x37b656['record'],_0x5f10e3));});});}['setThreadSolved'](_0x8d47e2,_0x59ddca){return this['_call'](async()=>{let _0x4ccc09=s(_0x59ddca);if(m(_0x8d47e2['unitID']),g('threadID',_0x8d47e2['threadID']),_0x8d47e2['solved']!==n['CommentSolvedStatus']['OpenOrReOpen']&&_0x8d47e2['solved']!==n['CommentSolvedStatus']['Solved'])throw _('solved\x20must\x20be\x20OpenOrReOpen\x20or\x20Solved');let _0x320877=a(_0x8d47e2),_0x55eca6={..._0x4ccc09,'request':_0x320877};await this['_middleware']['run']('setThreadSolved',_0x55eca6,async()=>{let _0x229870=await this['_databaseCall'](()=>this['_database']['setThreadSolved'](_0x8d47e2,_0x55eca6));if(_0x229870['status']==='not-found')throw v('Comment\x20thread\x20was\x20not\x20found');_0x229870['status']==='updated'&&await this['_emitWrite'](_0x4ccc09,_0x320877,{'memberId':_0x4ccc09['memberID'],'userId':_0x4ccc09['userID'],'unitId':_0x8d47e2['unitID'],'threadId':_0x8d47e2['threadID'],'type':n['CommentUpdateEventType']['Solve'],'solved':_0x8d47e2['solved']});});});}['deleteComment'](_0x7773b0,_0x412c7b){return this['_call'](async()=>{let _0x1f718d=s(_0x412c7b);m(_0x7773b0['unitID']),g('threadID',_0x7773b0['threadID']),_0x7773b0['replyID']!==void 0x0&&g('replyID',_0x7773b0['replyID']);let _0x433fd2=_0x7773b0['replyID']===_0x7773b0['threadID']?void 0x0:_0x7773b0['replyID'],_0x2f6d50=a({'unitID':_0x7773b0['unitID'],'threadID':_0x7773b0['threadID'],..._0x433fd2===void 0x0?{}:{'replyID':_0x433fd2}}),_0x516a17={..._0x1f718d,'request':_0x2f6d50},_0x17461c=await this['_databaseCall'](()=>this['_database']['getComment']({'unitID':_0x7773b0['unitID'],'threadID':_0x7773b0['threadID'],'replyID':_0x433fd2??_0x7773b0['threadID']},_0x516a17));if(!_0x17461c)throw v('Comment\x20was\x20not\x20found');await this['_middleware']['run']('deleteComment',{..._0x516a17,'request':_0x2f6d50,'target':{'kind':_0x433fd2===void 0x0?'root':'reply','threadID':_0x17461c['threadID'],'replyID':_0x17461c['replyID'],'authorUserID':_0x17461c['authorUserID'],'generation':_0x17461c['generation']}},async()=>{let _0x204987=await this['_databaseCall'](()=>this['_database']['deleteComment']({'unitID':_0x7773b0['unitID'],'threadID':_0x7773b0['threadID'],..._0x433fd2===void 0x0?{}:{'replyID':_0x433fd2},'expectedGeneration':_0x17461c['generation']},_0x516a17));if(_0x204987['status']==='not-found')throw v('Comment\x20was\x20not\x20found');if(_0x204987['status']==='generation-mismatch')throw _('Comment\x20changed\x20before\x20deletion');await this['_emitWrite'](_0x1f718d,_0x2f6d50,{'memberId':_0x1f718d['memberID'],'userId':_0x1f718d['userID'],'unitId':_0x7773b0['unitID'],'threadId':_0x7773b0['threadID'],'type':n['CommentUpdateEventType']['Delete'],..._0x433fd2===void 0x0?{}:{'replyId':_0x433fd2}});});});}['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'](_0x1dfeeb,_0x2bcd9a,_0x3d10d2,_0x5bfa11){let _0x54f092=await this['_resolveUsers']([_0x2bcd9a['authorUserID']],_0x3d10d2,_0x5bfa11);return{...f(_0x1dfeeb,_0x2bcd9a,_0x3d10d2),..._0x54f092[_0x2bcd9a['authorUserID']]?{'user':_0x54f092[_0x2bcd9a['authorUserID']]}:{}};}async['_resolveUsers'](_0x49b522,_0x3c4067,_0x1d1a71){let _0x51ca96=[...new Set(_0x49b522['filter'](Boolean))];if(!this['_userProvider']||_0x51ca96['length']===0x0)return{};let _0x35e10a;try{_0x35e10a=await this['_userProvider']['getUsers'](_0x51ca96,{..._0x3c4067,'request':_0x1d1a71});}catch{return{};}let _0x4e99d7=new Set(_0x51ca96),_0x4bf11e={};for(let _0x3c67a6 of _0x35e10a)_0x3c67a6?.['userID']&&_0x4e99d7['has'](_0x3c67a6['userID'])&&(_0x4bf11e[_0x3c67a6['userID']]=_0x3c67a6);return _0x4bf11e;}async['_emitWrite'](_0x3aa095,_0x17d16d,_0x1f56fc){let _0x370a74={'userID':_0x3aa095['userID'],'memberID':_0x3aa095['memberID'],'customData':_0x3aa095['customData'],'request':_0x17d16d,'update':_0x1f56fc,'committedAt':Date['now']()};for(let _0xbcd3b4 of[...this['_listeners']['get']('commentCommitted')??[]])try{await _0xbcd3b4(_0x370a74);}catch{}}['_call'](_0x177c76){this['_assertRunning']();let _0x13d8db=_0x177c76();return this['_calls']['add'](_0x13d8db),_0x13d8db['finally'](()=>this['_calls']['delete'](_0x13d8db))['catch'](()=>void 0x0),_0x13d8db;}async['_databaseCall'](_0xcf8e61){try{return await _0xcf8e61();}catch(_0x4bb10f){throw _0x4bb10f instanceof t['CollabError']?_0x4bb10f:new t['CollabError']('ADAPTER_FAILURE','Comment\x20Database\x20Adapter\x20failed',{'retryable':!0x0,'cause':_0x4bb10f});}}['_assertRunning'](){if(this['_state']!=='running')throw new t['CollabError']('INTERNAL_ERROR','Comment\x20Service\x20is\x20'+this['_state'],{'retryable':!0x0});}};function a(_0x490bc6){return{..._0x490bc6};}function o(_0x3656ae){return c(_0x3656ae),{'userID':_0x3656ae['userID'],'customData':_0x3656ae['customData']??Object['create'](null)};}function s(_0x264a0c){return c(_0x264a0c),g('memberID',_0x264a0c['memberID']),{'userID':_0x264a0c['userID'],'memberID':_0x264a0c['memberID'],'customData':_0x264a0c['customData']??Object['create'](null)};}function c(_0x91ad41){if(!_0x91ad41||typeof _0x91ad41!='object')throw _('context\x20must\x20be\x20an\x20object');if(g('userID',_0x91ad41['userID']),_0x91ad41['customData']!==void 0x0&&(_0x91ad41['customData']===null||typeof _0x91ad41['customData']!='object'||Array['isArray'](_0x91ad41['customData'])))throw _('customData\x20must\x20be\x20an\x20object');}function l(_0x76f2b5){return{'threadId':_0x76f2b5['threadID'],'replyId':_0x76f2b5['replyID'],'content':_0x76f2b5['content'],'userId':_0x76f2b5['authorUserID'],'createTimestamp':_0x76f2b5['createdAt']};}function u(_0x552752){let _0x38ec5a=_0x552752['find'](_0xe29900=>_0xe29900['replyID']===_0xe29900['threadID']);return{'threadId':_0x38ec5a['threadID'],'solved':_0x38ec5a['solved'],'replies':_0x552752['map'](l)};}function d(_0x4d9781){let _0x3bfa14=new Map();for(let _0x5f72b of _0x4d9781){let _0xf8899e=_0x3bfa14['get'](_0x5f72b['threadID'])??[];_0xf8899e['push'](_0x5f72b),_0x3bfa14['set'](_0x5f72b['threadID'],_0xf8899e);}let _0x1db00e={};for(let [_0x239d8f,_0x5cbed3]of _0x3bfa14)_0x5cbed3['find'](_0xb759f3=>_0xb759f3['replyID']===_0x239d8f)&&(_0x1db00e[_0x239d8f]=u([..._0x5cbed3]['sort']((_0x280b02,_0x495017)=>_0x280b02['replyID']===_0x239d8f?-0x1:_0x495017['replyID']===_0x239d8f?0x1:_0x280b02['createdAt']-_0x495017['createdAt']||_0x280b02['replyID']['localeCompare'](_0x495017['replyID']))));return _0x1db00e;}function f(_0x5317b3,_0x98f4f5,_0x5cf041){return{'memberId':_0x5cf041['memberID'],'userId':_0x5cf041['userID'],'unitId':_0x98f4f5['unitID'],'threadId':_0x98f4f5['threadID'],'type':_0x5317b3,'replyId':_0x98f4f5['replyID'],'content':_0x98f4f5['content'],'createTimestamp':String(_0x98f4f5['createdAt'])};}function p(_0x3b8a46){m(_0x3b8a46['unitID']),g('threadID',_0x3b8a46['threadID']),g('replyID',_0x3b8a46['replyID']);}function m(_0x5dd7eb){g('unitID',_0x5dd7eb);}function h(_0x473e64){if(typeof _0x473e64!='string'||_0x473e64['length']===0x0)throw _('content\x20must\x20be\x20a\x20non-empty\x20string');}function g(_0x4bb847,_0x374158){if(typeof _0x374158!='string'||_0x374158['length']===0x0)throw _(_0x4bb847+'\x20must\x20be\x20a\x20non-empty\x20string');}function _(_0x156e78){return new t['CollabError']('INVALID_REQUEST',_0x156e78);}function v(_0x323fc7){return new t['CollabError']('UNIT_NOT_FOUND',_0x323fc7);}function y(_0x2b8470){return new t['CollabError']('PERMISSION_DENIED',_0x2b8470);}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'](_0x2e3295,_0x506066){let _0x2152ff=this['_middlewares']['get'](_0x2e3295)??[],_0x1b5e83=_0x506066;_0x2152ff['push'](_0x1b5e83),this['_middlewares']['set'](_0x2e3295,_0x2152ff);let _0x4db7e4=!0x1;return{'dispose':()=>{if(_0x4db7e4)return;_0x4db7e4=!0x0;let _0x40ac1e=_0x2152ff['indexOf'](_0x1b5e83);_0x40ac1e>=0x0&&_0x2152ff['splice'](_0x40ac1e,0x1);}};}async['run'](_0x4223b4,_0x187a2c,_0xe2a530){let _0xab0f03=[...this['_middlewares']['get'](_0x4223b4)??[]],_0x92ce69=async _0x290077=>{let _0x128564=_0xab0f03[_0x290077];if(!_0x128564)return _0xe2a530();let _0x1ab58b=!0x1,_0x4ffdc7,_0x5eb2f1=()=>{if(_0x1ab58b)throw Error('Middleware\x20for\x20action\x20'+_0x4223b4+'\x20called\x20next()\x20more\x20than\x20once');return _0x1ab58b=!0x0,_0x4ffdc7=_0x92ce69(_0x290077+0x1),_0x4ffdc7;};try{await _0x128564(_0x187a2c,_0x5eb2f1);}catch(_0x307815){throw _0x4ffdc7&&await _0x4ffdc7['catch'](()=>void 0x0),_0x307815;}if(!_0x1ab58b)throw Error('Middleware\x20for\x20action\x20'+_0x4223b4+'\x20completed\x20without\x20calling\x20next()');await _0x4ffdc7;};await _0x92ce69(0x0);}['clear'](){this['_middlewares']['clear']();}},i=class{['_middleware']=new r();['_listeners']=new Map();['_calls']=new Set();['_database'];['_userProvider'];['_state']='running';['_disposePromise'];constructor(_0x1adaf0){if(!_0x1adaf0?.['database'])throw TypeError('UniverCommentService\x20requires\x20a\x20database');this['_database']=_0x1adaf0['database'],this['_userProvider']=_0x1adaf0['userProvider'];}['use'](_0x29f5a4,_0x175941){return this['_assertRunning'](),this['_middleware']['use'](_0x29f5a4,_0x175941);}['on'](_0x37b9ab,_0x16584c){this['_assertRunning']();let _0x646ae9=this['_listeners']['get'](_0x37b9ab)??new Set(),_0x5e985e=_0x16584c;_0x646ae9['add'](_0x5e985e),this['_listeners']['set'](_0x37b9ab,_0x646ae9);let _0x449dc7=!0x1;return{'dispose':()=>{_0x449dc7||(_0x449dc7=!0x0,_0x646ae9['delete'](_0x5e985e));}};}['addComment'](_0x132029,_0xb65d24){return this['_call'](async()=>{let _0x144ed3=s(_0xb65d24);m(_0x132029['unitID']),h(_0x132029['content']);let _0x1ce073=a(_0x132029),_0x244698={..._0x144ed3,'request':_0x1ce073},_0x19dd6d;return await this['_middleware']['run']('addComment',_0x244698,async()=>{let _0x560207=await this['_databaseCall'](()=>this['_database']['createRoot']({'unitID':_0x132029['unitID'],'threadID':(0x0,e['randomUUID'])(),'authorUserID':_0x144ed3['userID'],'content':_0x132029['content'],'mentions':[..._0x132029['mentions']]},_0x244698));if(_0x560207['status']==='duplicate')throw _('Comment\x20ID\x20already\x20exists');_0x19dd6d=u([_0x560207['record']]),await this['_emitWrite'](_0x144ed3,_0x1ce073,await this['_createUpdate'](n['CommentUpdateEventType']['Add'],_0x560207['record'],_0x144ed3,_0x1ce073));}),_0x19dd6d;});}['listComments'](_0x5a2065,_0x432178){return this['_call'](async()=>{let _0x70add4=o(_0x432178);m(_0x5a2065['unitID']),_0x5a2065['threadIDs']['forEach'](_0x4e7ff4=>g('threadID',_0x4e7ff4));let _0x701ae9=a(_0x5a2065),_0x5ea83e={..._0x70add4,'request':_0x701ae9},_0x182d79;return await this['_middleware']['run']('listComments',_0x5ea83e,async()=>{let _0x43a029=d(await this['_databaseCall'](()=>this['_database']['listThreads']({'unitID':_0x5a2065['unitID'],'threadIDs':[...new Set(_0x5a2065['threadIDs'])]},_0x5ea83e))),_0x152e09=Object['values'](_0x43a029)['flatMap'](_0x4c3ca4=>_0x4c3ca4['replies']['map'](_0x559c32=>_0x559c32['userId']));_0x182d79={'comments':_0x43a029,'users':await this['_resolveUsers'](_0x152e09,_0x70add4,_0x701ae9)};}),_0x182d79;});}['replyComment'](_0x18f464,_0x4495cd){return this['_call'](async()=>{let _0x5cc5f6=s(_0x4495cd);m(_0x18f464['unitID']),g('threadID',_0x18f464['threadID']),h(_0x18f464['content']);let _0x1891de=a(_0x18f464),_0x1a9e2c={..._0x5cc5f6,'request':_0x1891de},_0x55cb05;return await this['_middleware']['run']('replyComment',_0x1a9e2c,async()=>{let _0x3a0713=await this['_databaseCall'](()=>this['_database']['createReply']({'unitID':_0x18f464['unitID'],'threadID':_0x18f464['threadID'],'replyID':(0x0,e['randomUUID'])(),'authorUserID':_0x5cc5f6['userID'],'content':_0x18f464['content'],'mentions':[..._0x18f464['mentions']]},_0x1a9e2c));if(_0x3a0713['status']==='not-found'||_0x3a0713['status']==='closed')throw v('Open\x20Comment\x20thread\x20was\x20not\x20found');if(_0x3a0713['status']==='duplicate')throw _('Comment\x20ID\x20already\x20exists');_0x55cb05=l(_0x3a0713['record']),await this['_emitWrite'](_0x5cc5f6,_0x1891de,await this['_createUpdate'](n['CommentUpdateEventType']['Reply'],_0x3a0713['record'],_0x5cc5f6,_0x1891de));}),_0x55cb05;});}['editComment'](_0x341d39,_0x20490e){return this['_call'](async()=>{let _0x2a99b2=s(_0x20490e);p(_0x341d39),h(_0x341d39['content']);let _0xd5dde2=a(_0x341d39),_0x3cab1d={..._0x2a99b2,'request':_0xd5dde2};await this['_middleware']['run']('editComment',_0x3cab1d,async()=>{let _0x44540a=await this['_databaseCall'](()=>this['_database']['editComment']({'unitID':_0x341d39['unitID'],'threadID':_0x341d39['threadID'],'replyID':_0x341d39['replyID'],'expectedAuthorUserID':_0x2a99b2['userID'],'content':_0x341d39['content'],'mentions':[..._0x341d39['mentions']]},_0x3cab1d));if(_0x44540a['status']==='author-mismatch')throw y('Only\x20the\x20Comment\x20author\x20can\x20edit\x20it');if(_0x44540a['status']==='not-found'||_0x44540a['status']==='closed')throw v('Open\x20Comment\x20was\x20not\x20found');_0x44540a['status']==='edited'&&await this['_emitWrite'](_0x2a99b2,_0xd5dde2,f(n['CommentUpdateEventType']['Edit'],_0x44540a['record'],_0x2a99b2));});});}['setThreadSolved'](_0x29fd1d,_0x194c10){return this['_call'](async()=>{let _0x265a4b=s(_0x194c10);if(m(_0x29fd1d['unitID']),g('threadID',_0x29fd1d['threadID']),_0x29fd1d['solved']!==n['CommentSolvedStatus']['OpenOrReOpen']&&_0x29fd1d['solved']!==n['CommentSolvedStatus']['Solved'])throw _('solved\x20must\x20be\x20OpenOrReOpen\x20or\x20Solved');let _0x4fc997=a(_0x29fd1d),_0x4e60b4={..._0x265a4b,'request':_0x4fc997};await this['_middleware']['run']('setThreadSolved',_0x4e60b4,async()=>{let _0x3bd5e3=await this['_databaseCall'](()=>this['_database']['setThreadSolved'](_0x29fd1d,_0x4e60b4));if(_0x3bd5e3['status']==='not-found')throw v('Comment\x20thread\x20was\x20not\x20found');_0x3bd5e3['status']==='updated'&&await this['_emitWrite'](_0x265a4b,_0x4fc997,{'memberId':_0x265a4b['memberID'],'userId':_0x265a4b['userID'],'unitId':_0x29fd1d['unitID'],'threadId':_0x29fd1d['threadID'],'type':n['CommentUpdateEventType']['Solve'],'solved':_0x29fd1d['solved']});});});}['deleteComment'](_0x2e108f,_0x1c8a33){return this['_call'](async()=>{let _0x139361=s(_0x1c8a33);m(_0x2e108f['unitID']),g('threadID',_0x2e108f['threadID']),_0x2e108f['replyID']!==void 0x0&&g('replyID',_0x2e108f['replyID']);let _0x3a3f92=_0x2e108f['replyID']===_0x2e108f['threadID']?void 0x0:_0x2e108f['replyID'],_0x3f212f=a({'unitID':_0x2e108f['unitID'],'threadID':_0x2e108f['threadID'],..._0x3a3f92===void 0x0?{}:{'replyID':_0x3a3f92}}),_0x66999c={..._0x139361,'request':_0x3f212f},_0x33770c=await this['_databaseCall'](()=>this['_database']['getComment']({'unitID':_0x2e108f['unitID'],'threadID':_0x2e108f['threadID'],'replyID':_0x3a3f92??_0x2e108f['threadID']},_0x66999c));if(!_0x33770c)throw v('Comment\x20was\x20not\x20found');await this['_middleware']['run']('deleteComment',{..._0x66999c,'request':_0x3f212f,'target':{'kind':_0x3a3f92===void 0x0?'root':'reply','threadID':_0x33770c['threadID'],'replyID':_0x33770c['replyID'],'authorUserID':_0x33770c['authorUserID'],'generation':_0x33770c['generation']}},async()=>{let _0x4fdb4d=await this['_databaseCall'](()=>this['_database']['deleteComment']({'unitID':_0x2e108f['unitID'],'threadID':_0x2e108f['threadID'],..._0x3a3f92===void 0x0?{}:{'replyID':_0x3a3f92},'expectedGeneration':_0x33770c['generation']},_0x66999c));if(_0x4fdb4d['status']==='not-found')throw v('Comment\x20was\x20not\x20found');if(_0x4fdb4d['status']==='generation-mismatch')throw _('Comment\x20changed\x20before\x20deletion');await this['_emitWrite'](_0x139361,_0x3f212f,{'memberId':_0x139361['memberID'],'userId':_0x139361['userID'],'unitId':_0x2e108f['unitID'],'threadId':_0x2e108f['threadID'],'type':n['CommentUpdateEventType']['Delete'],..._0x3a3f92===void 0x0?{}:{'replyId':_0x3a3f92}});});});}['dispose'](){return this['_disposePromise']?this['_disposePromise']:(this['_state']='disposing',this['_disposePromise']=((async()=>{await Promise['allSettled']([...this['_calls']]),this['_middleware']['clear'](),this['_listeners']['clear'](),this['_state']='disposed';})()),this['_disposePromise']);}async['_createUpdate'](_0xbe0f9a,_0x2f5b70,_0x5625cf,_0x533c84){let _0x4fd385=await this['_resolveUsers']([_0x2f5b70['authorUserID']],_0x5625cf,_0x533c84);return{...f(_0xbe0f9a,_0x2f5b70,_0x5625cf),..._0x4fd385[_0x2f5b70['authorUserID']]?{'user':_0x4fd385[_0x2f5b70['authorUserID']]}:{}};}async['_resolveUsers'](_0x3833b4,_0x466645,_0x420835){let _0xeb044a=[...new Set(_0x3833b4['filter'](Boolean))];if(!this['_userProvider']||_0xeb044a['length']===0x0)return{};let _0x459d58;try{_0x459d58=await this['_userProvider']['getUsers'](_0xeb044a,{..._0x466645,'request':_0x420835});}catch{return{};}let _0x2fec93=new Set(_0xeb044a),_0x1d1d3c={};for(let _0x31bd8c of _0x459d58)_0x31bd8c?.['userID']&&_0x2fec93['has'](_0x31bd8c['userID'])&&(_0x1d1d3c[_0x31bd8c['userID']]=_0x31bd8c);return _0x1d1d3c;}async['_emitWrite'](_0x3f0b11,_0xc80e09,_0x1c6e21){let _0x1ea856={'userID':_0x3f0b11['userID'],'memberID':_0x3f0b11['memberID'],'customData':_0x3f0b11['customData'],'request':_0xc80e09,'update':_0x1c6e21,'committedAt':Date['now']()};for(let _0x5e8f57 of[...this['_listeners']['get']('commentCommitted')??[]])try{await _0x5e8f57(_0x1ea856);}catch{}}['_call'](_0x25686f){this['_assertRunning']();let _0x4238c3=_0x25686f();return this['_calls']['add'](_0x4238c3),_0x4238c3['finally'](()=>this['_calls']['delete'](_0x4238c3))['catch'](()=>void 0x0),_0x4238c3;}async['_databaseCall'](_0xba1d){try{return await _0xba1d();}catch(_0x3edfa9){throw _0x3edfa9 instanceof t['CollabError']?_0x3edfa9:new t['CollabError']('ADAPTER_FAILURE','Comment\x20Database\x20Adapter\x20failed',{'retryable':!0x0,'cause':_0x3edfa9});}}['_assertRunning'](){if(this['_state']!=='running')throw new t['CollabError']('INTERNAL_ERROR','Comment\x20Service\x20is\x20'+this['_state'],{'retryable':!0x0});}};function a(_0x44396d){return{..._0x44396d};}function o(_0x1516e6){return c(_0x1516e6),{'userID':_0x1516e6['userID'],'customData':_0x1516e6['customData']??Object['create'](null)};}function s(_0x4b6825){return c(_0x4b6825),g('memberID',_0x4b6825['memberID']),{'userID':_0x4b6825['userID'],'memberID':_0x4b6825['memberID'],'customData':_0x4b6825['customData']??Object['create'](null)};}function c(_0x22ff90){if(!_0x22ff90||typeof _0x22ff90!='object')throw _('context\x20must\x20be\x20an\x20object');if(g('userID',_0x22ff90['userID']),_0x22ff90['customData']!==void 0x0&&(_0x22ff90['customData']===null||typeof _0x22ff90['customData']!='object'||Array['isArray'](_0x22ff90['customData'])))throw _('customData\x20must\x20be\x20an\x20object');}function l(_0x196aa2){return{'threadId':_0x196aa2['threadID'],'replyId':_0x196aa2['replyID'],'content':_0x196aa2['content'],'userId':_0x196aa2['authorUserID'],'createTimestamp':_0x196aa2['createdAt']};}function u(_0x516884){let _0x2116c7=_0x516884['find'](_0x4b1c47=>_0x4b1c47['replyID']===_0x4b1c47['threadID']);return{'threadId':_0x2116c7['threadID'],'solved':_0x2116c7['solved'],'replies':_0x516884['map'](l)};}function d(_0x366a64){let _0x2e2119=new Map();for(let _0x2f1e4d of _0x366a64){let _0x36ff57=_0x2e2119['get'](_0x2f1e4d['threadID'])??[];_0x36ff57['push'](_0x2f1e4d),_0x2e2119['set'](_0x2f1e4d['threadID'],_0x36ff57);}let _0x3a1ee3={};for(let [_0x42e63c,_0x4a426d]of _0x2e2119)_0x4a426d['find'](_0x325e4c=>_0x325e4c['replyID']===_0x42e63c)&&(_0x3a1ee3[_0x42e63c]=u([..._0x4a426d]['sort']((_0x34ba28,_0x41d93c)=>_0x34ba28['replyID']===_0x42e63c?-0x1:_0x41d93c['replyID']===_0x42e63c?0x1:_0x34ba28['createdAt']-_0x41d93c['createdAt']||_0x34ba28['replyID']['localeCompare'](_0x41d93c['replyID']))));return _0x3a1ee3;}function f(_0x24d783,_0x30c908,_0x27b6c1){return{'memberId':_0x27b6c1['memberID'],'userId':_0x27b6c1['userID'],'unitId':_0x30c908['unitID'],'threadId':_0x30c908['threadID'],'type':_0x24d783,'replyId':_0x30c908['replyID'],'content':_0x30c908['content'],'createTimestamp':String(_0x30c908['createdAt'])};}function p(_0x315797){m(_0x315797['unitID']),g('threadID',_0x315797['threadID']),g('replyID',_0x315797['replyID']);}function m(_0x65c9f2){g('unitID',_0x65c9f2);}function h(_0xadc376){if(typeof _0xadc376!='string'||_0xadc376['length']===0x0)throw _('content\x20must\x20be\x20a\x20non-empty\x20string');}function g(_0x365a07,_0xcc24e7){if(typeof _0xcc24e7!='string'||_0xcc24e7['length']===0x0)throw _(_0x365a07+'\x20must\x20be\x20a\x20non-empty\x20string');}function _(_0x39f3ca){return new t['CollabError']('INVALID_REQUEST',_0x39f3ca);}function v(_0x5ef0a5){return new t['CollabError']('UNIT_NOT_FOUND',_0x5ef0a5);}function y(_0x2b7a3c){return new t['CollabError']('PERMISSION_DENIED',_0x2b7a3c);}exports['UniverCommentService']=i;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
(function(_0x22162e,_0x2d5c04){const _0x30490d=_0x2a4f,_0x421220=_0x22162e();while(!![]){try{const _0x3c3e82=parseInt(_0x30490d(0x1a4))/0x1*(-parseInt(_0x30490d(0x1a3))/0x2)+parseInt(_0x30490d(0x1a7))/0x3*(-parseInt(_0x30490d(0x1aa))/0x4)+-parseInt(_0x30490d(0x1a5))/0x5+parseInt(_0x30490d(0x1a6))/0x6+parseInt(_0x30490d(0x1ab))/0x7*(parseInt(_0x30490d(0x1ad))/0x8)+-parseInt(_0x30490d(0x1a8))/0x9*(parseInt(_0x30490d(0x1ac))/0xa)+parseInt(_0x30490d(0x1a9))/0xb;if(_0x3c3e82===_0x2d5c04)break;else _0x421220['push'](_0x421220['shift']());}catch(_0x14cd3a){_0x421220['push'](_0x421220['shift']());}}}(_0x12ab,0x72d31));function _0x12ab(){const _0x3164c5=['12471811TAaqzC','940kyFqiR','408331RWWswt','190KdQorI','104ynKxzl','512938ELWrpq','3scIgGZ','3429330zYtWOd','4932474ouVEHx','1173qcaYDh','330030pMlmPx'];_0x12ab=function(){return _0x3164c5;};return _0x12ab();}import _0x5476a5 from'./index.cjs';const facadeExport0=_0x5476a5['UniverCommentService'];function _0x2a4f(_0x344496,_0x5e8397){_0x344496=_0x344496-0x1a3;const _0x12ab14=_0x12ab();let _0x2a4f44=_0x12ab14[_0x344496];return _0x2a4f44;}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.0
|
|
4
|
+
"version": "1.0.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.0
|
|
20
|
-
"@univerjs/protocol": "1.0.0
|
|
19
|
+
"@univerjs-pro/collaboration-service": "1.0.0",
|
|
20
|
+
"@univerjs/protocol": "1.0.0"
|
|
21
21
|
}
|
|
22
22
|
}
|