@univerjs-pro/collaboration-comment-database-sqlite 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 CHANGED
@@ -1 +1 @@
1
- Object['defineProperty'](exports,Symbol['toStringTag'],{'value':'Module'});var e=Object['create'],t=Object['defineProperty'],n=Object['getOwnPropertyDescriptor'],r=Object['getOwnPropertyNames'],i=Object['getPrototypeOf'],a=Object['prototype']['hasOwnProperty'],o=(_0x2e4b8f,_0x24b5f4,_0x5acf91,_0x2e9c4b)=>{if(_0x24b5f4&&typeof _0x24b5f4=='object'||typeof _0x24b5f4=='function'){for(var _0x1fb9ce=r(_0x24b5f4),_0x3267b7=0x0,_0x487dca=_0x1fb9ce['length'],_0x5616e7;_0x3267b7<_0x487dca;_0x3267b7++)_0x5616e7=_0x1fb9ce[_0x3267b7],!a['call'](_0x2e4b8f,_0x5616e7)&&_0x5616e7!==_0x5acf91&&t(_0x2e4b8f,_0x5616e7,{'get':(_0x43fd10=>_0x24b5f4[_0x43fd10])['bind'](null,_0x5616e7),'enumerable':!(_0x2e9c4b=n(_0x24b5f4,_0x5616e7))||_0x2e9c4b['enumerable']});}return _0x2e4b8f;},s=(_0x1f4d7d,_0x3d44bf,_0x3ad4eb)=>(_0x3ad4eb=_0x1f4d7d==null?{}:e(i(_0x1f4d7d)),o(_0x3d44bf||!_0x1f4d7d||!_0x1f4d7d['__esModule']?t(_0x3ad4eb,'default',{'value':_0x1f4d7d,'enumerable':!0x0}):_0x3ad4eb,_0x1f4d7d));let c=require('node:crypto'),l=require('libsql');l=s(l,0x1);let u=require('@univerjs/protocol');var d=0x1388,f='comment',p=0x1,m=['collaboration_comments'],h=class{['_database'];['_disposed']=!0x1;constructor(_0x157bad){b(_0x157bad),this['_database']=new l['default'](_0x157bad['filename'],{'timeout':_0x157bad['busyTimeoutMs']??d});try{this['_database']['exec']('PRAGMA\x20busy_timeout\x20=\x20'+(_0x157bad['busyTimeoutMs']??d)+';'),this['_initializeSchema']();}catch(_0x30e528){throw this['_database']['close'](),_0x30e528;}}async['createRoot'](_0x22aae8,_0x375bc2){return this['_assertOpen'](),this['_transaction'](()=>{if(this['_getByReply'](_0x22aae8['unitID'],_0x22aae8['threadID']))return{'status':'duplicate'};let _0x17c22b=Date['now']();return this['_insert']({..._0x22aae8,'replyID':_0x22aae8['threadID'],'solved':u['CommentSolvedStatus']['OpenOrReOpen'],'createdAt':_0x17c22b,'updatedAt':_0x17c22b,'generation':(0x0,c['randomUUID'])()}),{'status':'created','record':this['_require'](_0x22aae8['unitID'],_0x22aae8['threadID'])};});}async['createReply'](_0x516e38,_0xeda11c){return this['_assertOpen'](),this['_transaction'](()=>{if(this['_getByReply'](_0x516e38['unitID'],_0x516e38['replyID']))return{'status':'duplicate'};let _0x59a179=this['_getByReply'](_0x516e38['unitID'],_0x516e38['threadID']);if(!_0x59a179||_0x59a179['threadID']!==_0x59a179['replyID'])return{'status':'not-found'};if(_0x59a179['solved']!==u['CommentSolvedStatus']['OpenOrReOpen'])return{'status':'closed'};let _0x36389b=Date['now']();return this['_insert']({..._0x516e38,'solved':_0x59a179['solved'],'createdAt':_0x36389b,'updatedAt':_0x36389b,'generation':(0x0,c['randomUUID'])()}),{'status':'created','record':this['_require'](_0x516e38['unitID'],_0x516e38['replyID'])};});}async['getComment'](_0x308b93,_0x1a15ab){this['_assertOpen']();let _0xc791ff=this['_getByReply'](_0x308b93['unitID'],_0x308b93['replyID']);return _0xc791ff?.['threadID']===_0x308b93['threadID']?_0xc791ff:null;}async['listThreads'](_0x1f633a,_0x492c27){this['_assertOpen']();let _0x136023=[...new Set(_0x1f633a['threadIDs'])];return(_0x136023['length']===0x0?this['_database']['prepare'](g+'\x20WHERE\x20unit_id\x20=\x20?')['all'](_0x1f633a['unitID']):this['_database']['prepare'](g+'\x20WHERE\x20unit_id\x20=\x20?\x20AND\x20thread_id\x20IN\x20('+_0x136023['map'](()=>'?')['join'](',')+')')['all'](_0x1f633a['unitID'],..._0x136023))['map'](_)['sort'](v);}async['editComment'](_0x5af051,_0x10e755){return this['_assertOpen'](),this['_transaction'](()=>{let _0x5bbb7e=this['_getByReply'](_0x5af051['unitID'],_0x5af051['replyID']),_0x2574d0=this['_getByReply'](_0x5af051['unitID'],_0x5af051['threadID']);return!_0x5bbb7e||_0x5bbb7e['threadID']!==_0x5af051['threadID']||!_0x2574d0?{'status':'not-found'}:_0x2574d0['solved']===u['CommentSolvedStatus']['OpenOrReOpen']?_0x5bbb7e['authorUserID']===_0x5af051['expectedAuthorUserID']?_0x5bbb7e['content']===_0x5af051['content']&&y(_0x5bbb7e['mentions'],_0x5af051['mentions'])?{'status':'unchanged','record':_0x5bbb7e}:(this['_database']['prepare']('UPDATE\x20collaboration_comments\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20SET\x20content\x20=\x20?,\x20mentions_json\x20=\x20?,\x20updated_at\x20=\x20?\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20unit_id\x20=\x20?\x20AND\x20thread_id\x20=\x20?\x20AND\x20reply_id\x20=\x20?')['run'](_0x5af051['content'],JSON['stringify'](_0x5af051['mentions']),Math['max'](Date['now'](),_0x5bbb7e['updatedAt']+0x1),_0x5af051['unitID'],_0x5af051['threadID'],_0x5af051['replyID']),{'status':'edited','record':this['_require'](_0x5af051['unitID'],_0x5af051['replyID'])}):{'status':'author-mismatch'}:{'status':'closed'};});}async['setThreadSolved'](_0x4b9aa3,_0x11ec3e){return this['_assertOpen'](),this['_transaction'](()=>{let _0x42ba31=this['_getByReply'](_0x4b9aa3['unitID'],_0x4b9aa3['threadID']);return!_0x42ba31||_0x42ba31['threadID']!==_0x42ba31['replyID']?{'status':'not-found'}:_0x42ba31['solved']===_0x4b9aa3['solved']?{'status':'unchanged'}:(this['_database']['prepare']('UPDATE\x20collaboration_comments\x20SET\x20solved\x20=\x20?,\x20updated_at\x20=\x20?\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20unit_id\x20=\x20?\x20AND\x20reply_id\x20=\x20?')['run'](_0x4b9aa3['solved'],Math['max'](Date['now'](),_0x42ba31['updatedAt']+0x1),_0x4b9aa3['unitID'],_0x4b9aa3['threadID']),{'status':'updated'});});}async['deleteComment'](_0x408c9e,_0x4ccba1){return this['_assertOpen'](),this['_transaction'](()=>{let _0x4563c5=_0x408c9e['replyID']??_0x408c9e['threadID'],_0x53364d=this['_getByReply'](_0x408c9e['unitID'],_0x4563c5);return!_0x53364d||_0x53364d['threadID']!==_0x408c9e['threadID']?{'status':'not-found'}:_0x53364d['generation']===_0x408c9e['expectedGeneration']?(_0x408c9e['replyID']===void 0x0?this['_database']['prepare']('DELETE\x20FROM\x20collaboration_comments\x20WHERE\x20unit_id\x20=\x20?\x20AND\x20thread_id\x20=\x20?')['run'](_0x408c9e['unitID'],_0x408c9e['threadID']):this['_database']['prepare']('DELETE\x20FROM\x20collaboration_comments\x20WHERE\x20unit_id\x20=\x20?\x20AND\x20thread_id\x20=\x20?\x20AND\x20reply_id\x20=\x20?\x20AND\x20generation\x20=\x20?')['run'](_0x408c9e['unitID'],_0x408c9e['threadID'],_0x408c9e['replyID'],_0x408c9e['expectedGeneration']),{'status':'deleted'}):{'status':'generation-mismatch'};});}async['dispose'](){this['_disposed']||(this['_disposed']=!0x0,this['_database']['close']());}['_initializeSchema'](){this['_transaction'](()=>{if(!this['_hasTable']('collaboration_schema_versions')){if(this['_hasAnyOwnedTable']())throw x('SQLite\x20Comment\x20tables\x20exist\x20without\x20a\x20schema\x20version');this['_database']['exec']('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20CREATE\x20TABLE\x20collaboration_schema_versions\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20component\x20TEXT\x20PRIMARY\x20KEY,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20version\x20INTEGER\x20NOT\x20NULL\x20CHECK\x20(version\x20>=\x201)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20);\x0a\x20\x20\x20\x20\x20\x20\x20\x20');}let _0x2d7192=this['_database']['prepare']('SELECT\x20version\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20collaboration_schema_versions\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20component\x20=\x20?')['get'](f);if(_0x2d7192){if(_0x2d7192['version']!==p)throw x('SQLite\x20Comment\x20schema\x20version\x20'+_0x2d7192['version']+'\x20is\x20not\x20supported');let _0x3901ed=m['filter'](_0x47ecea=>!this['_hasTable'](_0x47ecea));if(_0x3901ed['length']>0x0)throw x('SQLite\x20Comment\x20schema\x20v1\x20is\x20incomplete:\x20missing\x20'+_0x3901ed['join'](',\x20'));return;}if(this['_hasAnyOwnedTable']())throw x('SQLite\x20Comment\x20tables\x20exist\x20without\x20a\x20schema\x20version');this['_database']['exec']('\x0a\x20\x20\x20\x20\x20\x20\x20\x20CREATE\x20TABLE\x20collaboration_comments\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20unit_id\x20TEXT\x20NOT\x20NULL,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20thread_id\x20TEXT\x20NOT\x20NULL,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20reply_id\x20TEXT\x20NOT\x20NULL,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20author_user_id\x20TEXT\x20NOT\x20NULL,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20content\x20TEXT\x20NOT\x20NULL,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20mentions_json\x20TEXT\x20NOT\x20NULL,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20solved\x20INTEGER\x20NOT\x20NULL,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20created_at\x20INTEGER\x20NOT\x20NULL,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20updated_at\x20INTEGER\x20NOT\x20NULL,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20generation\x20TEXT\x20NOT\x20NULL,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20PRIMARY\x20KEY\x20(unit_id,\x20reply_id)\x0a\x20\x20\x20\x20\x20\x20\x20\x20);\x0a\x0a\x20\x20\x20\x20\x20\x20\x20\x20CREATE\x20INDEX\x20collaboration_comments_thread_lookup\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ON\x20collaboration_comments(unit_id,\x20thread_id,\x20created_at,\x20reply_id);\x0a\x0a\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20collaboration_schema_versions\x20(component,\x20version)\x0a\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20(\x27comment\x27,\x201);\x0a\x20\x20\x20\x20\x20\x20');});}['_hasTable'](_0x45faef){return!!this['_database']['prepare']('SELECT\x201\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20sqlite_schema\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20type\x20=\x20\x27table\x27\x20AND\x20name\x20=\x20?')['get'](_0x45faef);}['_hasAnyOwnedTable'](){return m['some'](_0x5e8283=>this['_hasTable'](_0x5e8283));}['_insert'](_0x15dabd){this['_database']['prepare']('INSERT\x20INTO\x20collaboration_comments\x0a\x20\x20\x20\x20\x20\x20\x20(unit_id,\x20thread_id,\x20reply_id,\x20author_user_id,\x20content,\x20mentions_json,\x0a\x20\x20\x20\x20\x20\x20\x20\x20solved,\x20created_at,\x20updated_at,\x20generation)\x0a\x20\x20\x20\x20\x20\x20\x20VALUES\x20(?,\x20?,\x20?,\x20?,\x20?,\x20?,\x20?,\x20?,\x20?,\x20?)')['run'](_0x15dabd['unitID'],_0x15dabd['threadID'],_0x15dabd['replyID'],_0x15dabd['authorUserID'],_0x15dabd['content'],JSON['stringify'](_0x15dabd['mentions']),_0x15dabd['solved'],_0x15dabd['createdAt'],_0x15dabd['updatedAt'],_0x15dabd['generation']);}['_getByReply'](_0x94c274,_0x85e8d6){let _0x4986fc=this['_database']['prepare'](g+'\x20WHERE\x20unit_id\x20=\x20?\x20AND\x20reply_id\x20=\x20?')['get'](_0x94c274,_0x85e8d6);return _0x4986fc?_(_0x4986fc):null;}['_require'](_0x405685,_0x2b0a4a){let _0x21f3c1=this['_getByReply'](_0x405685,_0x2b0a4a);if(!_0x21f3c1)throw Error('SQLite\x20Comment\x20write\x20did\x20not\x20persist\x20its\x20record');return _0x21f3c1;}['_transaction'](_0x4bece4){this['_database']['exec']('BEGIN\x20IMMEDIATE;');try{let _0xd8da34=_0x4bece4();return this['_database']['exec']('COMMIT;'),_0xd8da34;}catch(_0x3b5e78){try{this['_database']['exec']('ROLLBACK;');}catch{}throw _0x3b5e78;}}['_assertOpen'](){if(this['_disposed'])throw Error('SQLite\x20Comment\x20Database\x20Adapter\x20is\x20disposed');}},g='SELECT\x20unit_id,\x20thread_id,\x20reply_id,\x20author_user_id,\x0a\x20\x20content,\x20mentions_json,\x20solved,\x20created_at,\x20updated_at,\x20generation\x0a\x20\x20FROM\x20collaboration_comments';function _(_0x1585bd){let _0x18d012=JSON['parse'](_0x1585bd['mentions_json']);if(!Array['isArray'](_0x18d012)||_0x18d012['some'](_0x152e95=>typeof _0x152e95!='string'))throw Error('SQLite\x20Comment\x20contains\x20invalid\x20mentions');if(_0x1585bd['solved']!==u['CommentSolvedStatus']['OpenOrReOpen']&&_0x1585bd['solved']!==u['CommentSolvedStatus']['Solved'])throw Error('SQLite\x20Comment\x20contains\x20invalid\x20solved\x20status');return{'unitID':_0x1585bd['unit_id'],'threadID':_0x1585bd['thread_id'],'replyID':_0x1585bd['reply_id'],'authorUserID':_0x1585bd['author_user_id'],'content':_0x1585bd['content'],'mentions':_0x18d012,'solved':_0x1585bd['solved'],'createdAt':_0x1585bd['created_at'],'updatedAt':_0x1585bd['updated_at'],'generation':_0x1585bd['generation']};}function v(_0x589dd8,_0x52360d){let _0x498be1=_0x589dd8['threadID']['localeCompare'](_0x52360d['threadID']);return _0x498be1===0x0?_0x589dd8['replyID']===_0x589dd8['threadID']?-0x1:_0x52360d['replyID']===_0x52360d['threadID']?0x1:_0x589dd8['createdAt']-_0x52360d['createdAt']||_0x589dd8['replyID']['localeCompare'](_0x52360d['replyID']):_0x498be1;}function y(_0x281863,_0x275a10){return _0x281863['length']===_0x275a10['length']&&_0x281863['every']((_0x2b0b14,_0x2d4dbc)=>_0x2b0b14===_0x275a10[_0x2d4dbc]);}function b(_0x5042bd){if(!_0x5042bd?.['filename'])throw TypeError('SQLiteCommentDatabaseAdapter\x20requires\x20a\x20filename');if(_0x5042bd['busyTimeoutMs']!==void 0x0&&(!Number['isSafeInteger'](_0x5042bd['busyTimeoutMs'])||_0x5042bd['busyTimeoutMs']<0x0))throw TypeError('busyTimeoutMs\x20must\x20be\x20a\x20non-negative\x20safe\x20integer');}function x(_0x827089){return Error(_0x827089);}exports['SQLiteCommentDatabaseAdapter']=h;
1
+ Object['defineProperty'](exports,Symbol['toStringTag'],{'value':'Module'});var e=Object['create'],t=Object['defineProperty'],n=Object['getOwnPropertyDescriptor'],r=Object['getOwnPropertyNames'],i=Object['getPrototypeOf'],a=Object['prototype']['hasOwnProperty'],o=(_0x1e0f31,_0x17bbb6,_0x651c50,_0xb22ca8)=>{if(_0x17bbb6&&typeof _0x17bbb6=='object'||typeof _0x17bbb6=='function'){for(var _0x4f0880=r(_0x17bbb6),_0x3f3778=0x0,_0x50d9a8=_0x4f0880['length'],_0x5c1570;_0x3f3778<_0x50d9a8;_0x3f3778++)_0x5c1570=_0x4f0880[_0x3f3778],!a['call'](_0x1e0f31,_0x5c1570)&&_0x5c1570!==_0x651c50&&t(_0x1e0f31,_0x5c1570,{'get':(_0x13350e=>_0x17bbb6[_0x13350e])['bind'](null,_0x5c1570),'enumerable':!(_0xb22ca8=n(_0x17bbb6,_0x5c1570))||_0xb22ca8['enumerable']});}return _0x1e0f31;},s=(_0x17dbd5,_0x16e695,_0x63991a)=>(_0x63991a=_0x17dbd5==null?{}:e(i(_0x17dbd5)),o(_0x16e695||!_0x17dbd5||!_0x17dbd5['__esModule']?t(_0x63991a,'default',{'value':_0x17dbd5,'enumerable':!0x0}):_0x63991a,_0x17dbd5));let c=require('node:crypto'),l=require('libsql');l=s(l,0x1);let u=require('@univerjs/protocol');var d=0x1388,f='comment',p=0x1,m=['collaboration_comments'],h=class{['_database'];['_disposed']=!0x1;constructor(_0x13b0ee){b(_0x13b0ee),this['_database']=new l['default'](_0x13b0ee['filename'],{'timeout':_0x13b0ee['busyTimeoutMs']??d});try{this['_database']['exec']('PRAGMA\x20busy_timeout\x20=\x20'+(_0x13b0ee['busyTimeoutMs']??d)+';'),this['_initializeSchema']();}catch(_0x359989){throw this['_database']['close'](),_0x359989;}}async['createRoot'](_0x55b752,_0x428a7f){return this['_assertOpen'](),this['_transaction'](()=>{if(this['_getByReply'](_0x55b752['unitID'],_0x55b752['threadID']))return{'status':'duplicate'};let _0x3c5597=Date['now']();return this['_insert']({..._0x55b752,'replyID':_0x55b752['threadID'],'solved':u['CommentSolvedStatus']['OpenOrReOpen'],'createdAt':_0x3c5597,'updatedAt':_0x3c5597,'generation':(0x0,c['randomUUID'])()}),{'status':'created','record':this['_require'](_0x55b752['unitID'],_0x55b752['threadID'])};});}async['createReply'](_0x464303,_0x345716){return this['_assertOpen'](),this['_transaction'](()=>{if(this['_getByReply'](_0x464303['unitID'],_0x464303['replyID']))return{'status':'duplicate'};let _0x246435=this['_getByReply'](_0x464303['unitID'],_0x464303['threadID']);if(!_0x246435||_0x246435['threadID']!==_0x246435['replyID'])return{'status':'not-found'};if(_0x246435['solved']!==u['CommentSolvedStatus']['OpenOrReOpen'])return{'status':'closed'};let _0x202da3=Date['now']();return this['_insert']({..._0x464303,'solved':_0x246435['solved'],'createdAt':_0x202da3,'updatedAt':_0x202da3,'generation':(0x0,c['randomUUID'])()}),{'status':'created','record':this['_require'](_0x464303['unitID'],_0x464303['replyID'])};});}async['getComment'](_0x4a676a,_0x4344cb){this['_assertOpen']();let _0x31dbf0=this['_getByReply'](_0x4a676a['unitID'],_0x4a676a['replyID']);return _0x31dbf0?.['threadID']===_0x4a676a['threadID']?_0x31dbf0:null;}async['listThreads'](_0x33f1d0,_0x2edb97){this['_assertOpen']();let _0x13a822=[...new Set(_0x33f1d0['threadIDs'])];return(_0x13a822['length']===0x0?this['_database']['prepare'](g+'\x20WHERE\x20unit_id\x20=\x20?')['all'](_0x33f1d0['unitID']):this['_database']['prepare'](g+'\x20WHERE\x20unit_id\x20=\x20?\x20AND\x20thread_id\x20IN\x20('+_0x13a822['map'](()=>'?')['join'](',')+')')['all'](_0x33f1d0['unitID'],..._0x13a822))['map'](_)['sort'](v);}async['editComment'](_0x8c7abc,_0x1a983e){return this['_assertOpen'](),this['_transaction'](()=>{let _0x17620a=this['_getByReply'](_0x8c7abc['unitID'],_0x8c7abc['replyID']),_0x321c3c=this['_getByReply'](_0x8c7abc['unitID'],_0x8c7abc['threadID']);return!_0x17620a||_0x17620a['threadID']!==_0x8c7abc['threadID']||!_0x321c3c?{'status':'not-found'}:_0x321c3c['solved']===u['CommentSolvedStatus']['OpenOrReOpen']?_0x17620a['authorUserID']===_0x8c7abc['expectedAuthorUserID']?_0x17620a['content']===_0x8c7abc['content']&&y(_0x17620a['mentions'],_0x8c7abc['mentions'])?{'status':'unchanged','record':_0x17620a}:(this['_database']['prepare']('UPDATE\x20collaboration_comments\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20SET\x20content\x20=\x20?,\x20mentions_json\x20=\x20?,\x20updated_at\x20=\x20?\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20unit_id\x20=\x20?\x20AND\x20thread_id\x20=\x20?\x20AND\x20reply_id\x20=\x20?')['run'](_0x8c7abc['content'],JSON['stringify'](_0x8c7abc['mentions']),Math['max'](Date['now'](),_0x17620a['updatedAt']+0x1),_0x8c7abc['unitID'],_0x8c7abc['threadID'],_0x8c7abc['replyID']),{'status':'edited','record':this['_require'](_0x8c7abc['unitID'],_0x8c7abc['replyID'])}):{'status':'author-mismatch'}:{'status':'closed'};});}async['setThreadSolved'](_0xd2bf38,_0x1a2dd4){return this['_assertOpen'](),this['_transaction'](()=>{let _0x1f14e5=this['_getByReply'](_0xd2bf38['unitID'],_0xd2bf38['threadID']);return!_0x1f14e5||_0x1f14e5['threadID']!==_0x1f14e5['replyID']?{'status':'not-found'}:_0x1f14e5['solved']===_0xd2bf38['solved']?{'status':'unchanged'}:(this['_database']['prepare']('UPDATE\x20collaboration_comments\x20SET\x20solved\x20=\x20?,\x20updated_at\x20=\x20?\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20unit_id\x20=\x20?\x20AND\x20reply_id\x20=\x20?')['run'](_0xd2bf38['solved'],Math['max'](Date['now'](),_0x1f14e5['updatedAt']+0x1),_0xd2bf38['unitID'],_0xd2bf38['threadID']),{'status':'updated'});});}async['deleteComment'](_0x59b2ff,_0x27a66c){return this['_assertOpen'](),this['_transaction'](()=>{let _0x42b397=_0x59b2ff['replyID']??_0x59b2ff['threadID'],_0x23681c=this['_getByReply'](_0x59b2ff['unitID'],_0x42b397);return!_0x23681c||_0x23681c['threadID']!==_0x59b2ff['threadID']?{'status':'not-found'}:_0x23681c['generation']===_0x59b2ff['expectedGeneration']?(_0x59b2ff['replyID']===void 0x0?this['_database']['prepare']('DELETE\x20FROM\x20collaboration_comments\x20WHERE\x20unit_id\x20=\x20?\x20AND\x20thread_id\x20=\x20?')['run'](_0x59b2ff['unitID'],_0x59b2ff['threadID']):this['_database']['prepare']('DELETE\x20FROM\x20collaboration_comments\x20WHERE\x20unit_id\x20=\x20?\x20AND\x20thread_id\x20=\x20?\x20AND\x20reply_id\x20=\x20?\x20AND\x20generation\x20=\x20?')['run'](_0x59b2ff['unitID'],_0x59b2ff['threadID'],_0x59b2ff['replyID'],_0x59b2ff['expectedGeneration']),{'status':'deleted'}):{'status':'generation-mismatch'};});}async['dispose'](){this['_disposed']||(this['_disposed']=!0x0,this['_database']['close']());}['_initializeSchema'](){this['_transaction'](()=>{if(!this['_hasTable']('collaboration_schema_versions')){if(this['_hasAnyOwnedTable']())throw x('SQLite\x20Comment\x20tables\x20exist\x20without\x20a\x20schema\x20version');this['_database']['exec']('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20CREATE\x20TABLE\x20collaboration_schema_versions\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20component\x20TEXT\x20PRIMARY\x20KEY,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20version\x20INTEGER\x20NOT\x20NULL\x20CHECK\x20(version\x20>=\x201)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20);\x0a\x20\x20\x20\x20\x20\x20\x20\x20');}let _0x30e05b=this['_database']['prepare']('SELECT\x20version\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20collaboration_schema_versions\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20component\x20=\x20?')['get'](f);if(_0x30e05b){if(_0x30e05b['version']!==p)throw x('SQLite\x20Comment\x20schema\x20version\x20'+_0x30e05b['version']+'\x20is\x20not\x20supported');let _0x122844=m['filter'](_0x37f75b=>!this['_hasTable'](_0x37f75b));if(_0x122844['length']>0x0)throw x('SQLite\x20Comment\x20schema\x20v1\x20is\x20incomplete:\x20missing\x20'+_0x122844['join'](',\x20'));return;}if(this['_hasAnyOwnedTable']())throw x('SQLite\x20Comment\x20tables\x20exist\x20without\x20a\x20schema\x20version');this['_database']['exec']('\x0a\x20\x20\x20\x20\x20\x20\x20\x20CREATE\x20TABLE\x20collaboration_comments\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20unit_id\x20TEXT\x20NOT\x20NULL,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20thread_id\x20TEXT\x20NOT\x20NULL,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20reply_id\x20TEXT\x20NOT\x20NULL,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20author_user_id\x20TEXT\x20NOT\x20NULL,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20content\x20TEXT\x20NOT\x20NULL,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20mentions_json\x20TEXT\x20NOT\x20NULL,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20solved\x20INTEGER\x20NOT\x20NULL,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20created_at\x20INTEGER\x20NOT\x20NULL,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20updated_at\x20INTEGER\x20NOT\x20NULL,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20generation\x20TEXT\x20NOT\x20NULL,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20PRIMARY\x20KEY\x20(unit_id,\x20reply_id)\x0a\x20\x20\x20\x20\x20\x20\x20\x20);\x0a\x0a\x20\x20\x20\x20\x20\x20\x20\x20CREATE\x20INDEX\x20collaboration_comments_thread_lookup\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ON\x20collaboration_comments(unit_id,\x20thread_id,\x20created_at,\x20reply_id);\x0a\x0a\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20collaboration_schema_versions\x20(component,\x20version)\x0a\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20(\x27comment\x27,\x201);\x0a\x20\x20\x20\x20\x20\x20');});}['_hasTable'](_0x54070d){return!!this['_database']['prepare']('SELECT\x201\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20sqlite_schema\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20type\x20=\x20\x27table\x27\x20AND\x20name\x20=\x20?')['get'](_0x54070d);}['_hasAnyOwnedTable'](){return m['some'](_0x5e4884=>this['_hasTable'](_0x5e4884));}['_insert'](_0x4393f3){this['_database']['prepare']('INSERT\x20INTO\x20collaboration_comments\x0a\x20\x20\x20\x20\x20\x20\x20(unit_id,\x20thread_id,\x20reply_id,\x20author_user_id,\x20content,\x20mentions_json,\x0a\x20\x20\x20\x20\x20\x20\x20\x20solved,\x20created_at,\x20updated_at,\x20generation)\x0a\x20\x20\x20\x20\x20\x20\x20VALUES\x20(?,\x20?,\x20?,\x20?,\x20?,\x20?,\x20?,\x20?,\x20?,\x20?)')['run'](_0x4393f3['unitID'],_0x4393f3['threadID'],_0x4393f3['replyID'],_0x4393f3['authorUserID'],_0x4393f3['content'],JSON['stringify'](_0x4393f3['mentions']),_0x4393f3['solved'],_0x4393f3['createdAt'],_0x4393f3['updatedAt'],_0x4393f3['generation']);}['_getByReply'](_0x1415e1,_0x5f650d){let _0x500d98=this['_database']['prepare'](g+'\x20WHERE\x20unit_id\x20=\x20?\x20AND\x20reply_id\x20=\x20?')['get'](_0x1415e1,_0x5f650d);return _0x500d98?_(_0x500d98):null;}['_require'](_0x57d632,_0x4940c6){let _0x18094d=this['_getByReply'](_0x57d632,_0x4940c6);if(!_0x18094d)throw Error('SQLite\x20Comment\x20write\x20did\x20not\x20persist\x20its\x20record');return _0x18094d;}['_transaction'](_0x29810d){this['_database']['exec']('BEGIN\x20IMMEDIATE;');try{let _0x43ebdc=_0x29810d();return this['_database']['exec']('COMMIT;'),_0x43ebdc;}catch(_0x43145e){try{this['_database']['exec']('ROLLBACK;');}catch{}throw _0x43145e;}}['_assertOpen'](){if(this['_disposed'])throw Error('SQLite\x20Comment\x20Database\x20Adapter\x20is\x20disposed');}},g='SELECT\x20unit_id,\x20thread_id,\x20reply_id,\x20author_user_id,\x0a\x20\x20content,\x20mentions_json,\x20solved,\x20created_at,\x20updated_at,\x20generation\x0a\x20\x20FROM\x20collaboration_comments';function _(_0x10517c){let _0x13a8b8=JSON['parse'](_0x10517c['mentions_json']);if(!Array['isArray'](_0x13a8b8)||_0x13a8b8['some'](_0x498204=>typeof _0x498204!='string'))throw Error('SQLite\x20Comment\x20contains\x20invalid\x20mentions');if(_0x10517c['solved']!==u['CommentSolvedStatus']['OpenOrReOpen']&&_0x10517c['solved']!==u['CommentSolvedStatus']['Solved'])throw Error('SQLite\x20Comment\x20contains\x20invalid\x20solved\x20status');return{'unitID':_0x10517c['unit_id'],'threadID':_0x10517c['thread_id'],'replyID':_0x10517c['reply_id'],'authorUserID':_0x10517c['author_user_id'],'content':_0x10517c['content'],'mentions':_0x13a8b8,'solved':_0x10517c['solved'],'createdAt':_0x10517c['created_at'],'updatedAt':_0x10517c['updated_at'],'generation':_0x10517c['generation']};}function v(_0x4b3b2e,_0x580193){let _0x42c558=_0x4b3b2e['threadID']['localeCompare'](_0x580193['threadID']);return _0x42c558===0x0?_0x4b3b2e['replyID']===_0x4b3b2e['threadID']?-0x1:_0x580193['replyID']===_0x580193['threadID']?0x1:_0x4b3b2e['createdAt']-_0x580193['createdAt']||_0x4b3b2e['replyID']['localeCompare'](_0x580193['replyID']):_0x42c558;}function y(_0x1044c3,_0x145de7){return _0x1044c3['length']===_0x145de7['length']&&_0x1044c3['every']((_0xb283d4,_0x22d419)=>_0xb283d4===_0x145de7[_0x22d419]);}function b(_0x173726){if(!_0x173726?.['filename'])throw TypeError('SQLiteCommentDatabaseAdapter\x20requires\x20a\x20filename');if(_0x173726['busyTimeoutMs']!==void 0x0&&(!Number['isSafeInteger'](_0x173726['busyTimeoutMs'])||_0x173726['busyTimeoutMs']<0x0))throw TypeError('busyTimeoutMs\x20must\x20be\x20a\x20non-negative\x20safe\x20integer');}function x(_0x1807d4){return Error(_0x1807d4);}exports['SQLiteCommentDatabaseAdapter']=h;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- function _0x5796(_0x39eef6,_0x2ec4ff){_0x39eef6=_0x39eef6-0x94;const _0x25fdfe=_0x25fd();let _0x57962a=_0x25fdfe[_0x39eef6];return _0x57962a;}const _0x4ace70=_0x5796;(function(_0x2b572f,_0x2f26a2){const _0x525795=_0x5796,_0x1ab4b7=_0x2b572f();while(!![]){try{const _0x403a57=parseInt(_0x525795(0x94))/0x1+parseInt(_0x525795(0x9d))/0x2*(-parseInt(_0x525795(0x96))/0x3)+parseInt(_0x525795(0x9b))/0x4*(-parseInt(_0x525795(0x98))/0x5)+-parseInt(_0x525795(0x9a))/0x6*(-parseInt(_0x525795(0x99))/0x7)+-parseInt(_0x525795(0x9e))/0x8+parseInt(_0x525795(0x97))/0x9+-parseInt(_0x525795(0x9c))/0xa*(-parseInt(_0x525795(0x95))/0xb);if(_0x403a57===_0x2f26a2)break;else _0x1ab4b7['push'](_0x1ab4b7['shift']());}catch(_0x64c740){_0x1ab4b7['push'](_0x1ab4b7['shift']());}}}(_0x25fd,0x817a0));import _0xb6eee5 from'./index.cjs';const facadeExport0=_0xb6eee5[_0x4ace70(0x9f)];export{facadeExport0 as SQLiteCommentDatabaseAdapter};function _0x25fd(){const _0x21eaf9=['2tUQZdG','2401392cPBvwD','SQLiteCommentDatabaseAdapter','1025149GkkoiQ','121Rplkkc','1388475bJVxmw','1067148waMTBf','205tSYLlF','3332CWzLjS','774tCCBQz','21356CVDtEh','279190bEppHd'];_0x25fd=function(){return _0x21eaf9;};return _0x25fd();}
1
+ function _0x5d6e(_0xd8899,_0x2de910){_0xd8899=_0xd8899-0xe1;const _0x2587fd=_0x2587();let _0x5d6ef5=_0x2587fd[_0xd8899];return _0x5d6ef5;}(function(_0x1a58bd,_0x56b060){const _0x2c0c34=_0x5d6e,_0x438447=_0x1a58bd();while(!![]){try{const _0x391e65=-parseInt(_0x2c0c34(0xe2))/0x1*(-parseInt(_0x2c0c34(0xe3))/0x2)+parseInt(_0x2c0c34(0xe7))/0x3+-parseInt(_0x2c0c34(0xec))/0x4*(-parseInt(_0x2c0c34(0xe8))/0x5)+-parseInt(_0x2c0c34(0xe4))/0x6*(parseInt(_0x2c0c34(0xeb))/0x7)+parseInt(_0x2c0c34(0xe9))/0x8+parseInt(_0x2c0c34(0xe6))/0x9*(-parseInt(_0x2c0c34(0xe5))/0xa)+-parseInt(_0x2c0c34(0xe1))/0xb*(parseInt(_0x2c0c34(0xea))/0xc);if(_0x391e65===_0x56b060)break;else _0x438447['push'](_0x438447['shift']());}catch(_0x5b5cac){_0x438447['push'](_0x438447['shift']());}}}(_0x2587,0xc64b1));import _0x157562 from'./index.cjs';const facadeExport0=_0x157562['SQLiteCommentDatabaseAdapter'];function _0x2587(){const _0x326a81=['145etwnWB','6113496plDVMk','239964ERqXcM','124082VcZPHA','111404scSGtw','121NohYXi','455YrQAdu','1398MMYcqr','318JDJOKF','1269640wqPMwt','45kLCYhG','2149689zFKSIa'];_0x2587=function(){return _0x326a81;};return _0x2587();}export{facadeExport0 as SQLiteCommentDatabaseAdapter};
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "engines": {
5
5
  "node": ">=22"
6
6
  },
7
- "version": "1.0.0-rc.0",
7
+ "version": "1.0.0",
8
8
  "main": "./dist/index.cjs",
9
9
  "module": "./dist/index.mjs",
10
10
  "types": "./dist/index.d.ts",
@@ -19,8 +19,8 @@
19
19
  "dist"
20
20
  ],
21
21
  "dependencies": {
22
- "@univerjs-pro/collaboration-comment-service": "1.0.0-rc.0",
23
- "@univerjs/protocol": "1.0.0-rc.0",
22
+ "@univerjs-pro/collaboration-comment-service": "1.0.0",
23
+ "@univerjs/protocol": "1.0.0",
24
24
  "libsql": "^0.5.29"
25
25
  }
26
26
  }