@univerjs-pro/collaboration-comment-database-sqlite 1.0.0 → 1.0.2

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=(_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;
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=(_0x48fc09,_0x39707a,_0x3d8e9f,_0x2041d3)=>{if(_0x39707a&&typeof _0x39707a=='object'||typeof _0x39707a=='function'){for(var _0x3b9c88=r(_0x39707a),_0x3be338=0x0,_0x6566c1=_0x3b9c88['length'],_0x1e8545;_0x3be338<_0x6566c1;_0x3be338++)_0x1e8545=_0x3b9c88[_0x3be338],!a['call'](_0x48fc09,_0x1e8545)&&_0x1e8545!==_0x3d8e9f&&t(_0x48fc09,_0x1e8545,{'get':(_0x74dadc=>_0x39707a[_0x74dadc])['bind'](null,_0x1e8545),'enumerable':!(_0x2041d3=n(_0x39707a,_0x1e8545))||_0x2041d3['enumerable']});}return _0x48fc09;},s=(_0x55f44d,_0xd25f03,_0x8ca1fe)=>(_0x8ca1fe=_0x55f44d==null?{}:e(i(_0x55f44d)),o(_0xd25f03||!_0x55f44d||!_0x55f44d['__esModule']?t(_0x8ca1fe,'default',{'value':_0x55f44d,'enumerable':!0x0}):_0x8ca1fe,_0x55f44d));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(_0x1076dd){b(_0x1076dd),this['_database']=new l['default'](_0x1076dd['filename'],{'timeout':_0x1076dd['busyTimeoutMs']??d});try{this['_database']['exec']('PRAGMA\x20busy_timeout\x20=\x20'+(_0x1076dd['busyTimeoutMs']??d)+';'),this['_initializeSchema']();}catch(_0x5f0cd2){throw this['_database']['close'](),_0x5f0cd2;}}async['createRoot'](_0x44577c,_0x56af57){return this['_assertOpen'](),this['_transaction'](()=>{if(this['_getByReply'](_0x44577c['unitID'],_0x44577c['threadID']))return{'status':'duplicate'};let _0x14ac2e=Date['now']();return this['_insert']({..._0x44577c,'replyID':_0x44577c['threadID'],'solved':u['CommentSolvedStatus']['OpenOrReOpen'],'createdAt':_0x14ac2e,'updatedAt':_0x14ac2e,'generation':(0x0,c['randomUUID'])()}),{'status':'created','record':this['_require'](_0x44577c['unitID'],_0x44577c['threadID'])};});}async['createReply'](_0x5b09d6,_0x3efb9e){return this['_assertOpen'](),this['_transaction'](()=>{if(this['_getByReply'](_0x5b09d6['unitID'],_0x5b09d6['replyID']))return{'status':'duplicate'};let _0x52f220=this['_getByReply'](_0x5b09d6['unitID'],_0x5b09d6['threadID']);if(!_0x52f220||_0x52f220['threadID']!==_0x52f220['replyID'])return{'status':'not-found'};if(_0x52f220['solved']!==u['CommentSolvedStatus']['OpenOrReOpen'])return{'status':'closed'};let _0x58463f=Date['now']();return this['_insert']({..._0x5b09d6,'solved':_0x52f220['solved'],'createdAt':_0x58463f,'updatedAt':_0x58463f,'generation':(0x0,c['randomUUID'])()}),{'status':'created','record':this['_require'](_0x5b09d6['unitID'],_0x5b09d6['replyID'])};});}async['getComment'](_0x36bf10,_0x11052f){this['_assertOpen']();let _0x2914c9=this['_getByReply'](_0x36bf10['unitID'],_0x36bf10['replyID']);return _0x2914c9?.['threadID']===_0x36bf10['threadID']?_0x2914c9:null;}async['listThreads'](_0x5ce5ad,_0x578981){this['_assertOpen']();let _0x465daf=[...new Set(_0x5ce5ad['threadIDs'])];return(_0x465daf['length']===0x0?this['_database']['prepare'](g+'\x20WHERE\x20unit_id\x20=\x20?')['all'](_0x5ce5ad['unitID']):this['_database']['prepare'](g+'\x20WHERE\x20unit_id\x20=\x20?\x20AND\x20thread_id\x20IN\x20('+_0x465daf['map'](()=>'?')['join'](',')+')')['all'](_0x5ce5ad['unitID'],..._0x465daf))['map'](_)['sort'](v);}async['editComment'](_0x1dfc44,_0x10e28c){return this['_assertOpen'](),this['_transaction'](()=>{let _0x35f9f5=this['_getByReply'](_0x1dfc44['unitID'],_0x1dfc44['replyID']),_0x6620f=this['_getByReply'](_0x1dfc44['unitID'],_0x1dfc44['threadID']);return!_0x35f9f5||_0x35f9f5['threadID']!==_0x1dfc44['threadID']||!_0x6620f?{'status':'not-found'}:_0x6620f['solved']===u['CommentSolvedStatus']['OpenOrReOpen']?_0x35f9f5['authorUserID']===_0x1dfc44['expectedAuthorUserID']?_0x35f9f5['content']===_0x1dfc44['content']&&y(_0x35f9f5['mentions'],_0x1dfc44['mentions'])?{'status':'unchanged','record':_0x35f9f5}:(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'](_0x1dfc44['content'],JSON['stringify'](_0x1dfc44['mentions']),Math['max'](Date['now'](),_0x35f9f5['updatedAt']+0x1),_0x1dfc44['unitID'],_0x1dfc44['threadID'],_0x1dfc44['replyID']),{'status':'edited','record':this['_require'](_0x1dfc44['unitID'],_0x1dfc44['replyID'])}):{'status':'author-mismatch'}:{'status':'closed'};});}async['setThreadSolved'](_0x474c3d,_0x12cb0a){return this['_assertOpen'](),this['_transaction'](()=>{let _0xbad25c=this['_getByReply'](_0x474c3d['unitID'],_0x474c3d['threadID']);return!_0xbad25c||_0xbad25c['threadID']!==_0xbad25c['replyID']?{'status':'not-found'}:_0xbad25c['solved']===_0x474c3d['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'](_0x474c3d['solved'],Math['max'](Date['now'](),_0xbad25c['updatedAt']+0x1),_0x474c3d['unitID'],_0x474c3d['threadID']),{'status':'updated'});});}async['deleteComment'](_0x2c22e6,_0x2867bb){return this['_assertOpen'](),this['_transaction'](()=>{let _0x5763c4=_0x2c22e6['replyID']??_0x2c22e6['threadID'],_0x14c20b=this['_getByReply'](_0x2c22e6['unitID'],_0x5763c4);return!_0x14c20b||_0x14c20b['threadID']!==_0x2c22e6['threadID']?{'status':'not-found'}:_0x14c20b['generation']===_0x2c22e6['expectedGeneration']?(_0x2c22e6['replyID']===void 0x0?this['_database']['prepare']('DELETE\x20FROM\x20collaboration_comments\x20WHERE\x20unit_id\x20=\x20?\x20AND\x20thread_id\x20=\x20?')['run'](_0x2c22e6['unitID'],_0x2c22e6['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'](_0x2c22e6['unitID'],_0x2c22e6['threadID'],_0x2c22e6['replyID'],_0x2c22e6['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 _0x1c64ef=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(_0x1c64ef){if(_0x1c64ef['version']!==p)throw x('SQLite\x20Comment\x20schema\x20version\x20'+_0x1c64ef['version']+'\x20is\x20not\x20supported');let _0x36f6fa=m['filter'](_0x42f5ba=>!this['_hasTable'](_0x42f5ba));if(_0x36f6fa['length']>0x0)throw x('SQLite\x20Comment\x20schema\x20v1\x20is\x20incomplete:\x20missing\x20'+_0x36f6fa['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'](_0x2e331c){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'](_0x2e331c);}['_hasAnyOwnedTable'](){return m['some'](_0x5ba84b=>this['_hasTable'](_0x5ba84b));}['_insert'](_0x166aca){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'](_0x166aca['unitID'],_0x166aca['threadID'],_0x166aca['replyID'],_0x166aca['authorUserID'],_0x166aca['content'],JSON['stringify'](_0x166aca['mentions']),_0x166aca['solved'],_0x166aca['createdAt'],_0x166aca['updatedAt'],_0x166aca['generation']);}['_getByReply'](_0x27fbdc,_0x125022){let _0x4b9ad2=this['_database']['prepare'](g+'\x20WHERE\x20unit_id\x20=\x20?\x20AND\x20reply_id\x20=\x20?')['get'](_0x27fbdc,_0x125022);return _0x4b9ad2?_(_0x4b9ad2):null;}['_require'](_0x2d97e7,_0x1ecf77){let _0x1733a2=this['_getByReply'](_0x2d97e7,_0x1ecf77);if(!_0x1733a2)throw Error('SQLite\x20Comment\x20write\x20did\x20not\x20persist\x20its\x20record');return _0x1733a2;}['_transaction'](_0x1ebebc){this['_database']['exec']('BEGIN\x20IMMEDIATE;');try{let _0x50929e=_0x1ebebc();return this['_database']['exec']('COMMIT;'),_0x50929e;}catch(_0x449986){try{this['_database']['exec']('ROLLBACK;');}catch{}throw _0x449986;}}['_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 _(_0x509dd8){let _0x500417=JSON['parse'](_0x509dd8['mentions_json']);if(!Array['isArray'](_0x500417)||_0x500417['some'](_0x56e6da=>typeof _0x56e6da!='string'))throw Error('SQLite\x20Comment\x20contains\x20invalid\x20mentions');if(_0x509dd8['solved']!==u['CommentSolvedStatus']['OpenOrReOpen']&&_0x509dd8['solved']!==u['CommentSolvedStatus']['Solved'])throw Error('SQLite\x20Comment\x20contains\x20invalid\x20solved\x20status');return{'unitID':_0x509dd8['unit_id'],'threadID':_0x509dd8['thread_id'],'replyID':_0x509dd8['reply_id'],'authorUserID':_0x509dd8['author_user_id'],'content':_0x509dd8['content'],'mentions':_0x500417,'solved':_0x509dd8['solved'],'createdAt':_0x509dd8['created_at'],'updatedAt':_0x509dd8['updated_at'],'generation':_0x509dd8['generation']};}function v(_0x4ccaf5,_0x33e078){let _0x119c74=_0x4ccaf5['threadID']['localeCompare'](_0x33e078['threadID']);return _0x119c74===0x0?_0x4ccaf5['replyID']===_0x4ccaf5['threadID']?-0x1:_0x33e078['replyID']===_0x33e078['threadID']?0x1:_0x4ccaf5['createdAt']-_0x33e078['createdAt']||_0x4ccaf5['replyID']['localeCompare'](_0x33e078['replyID']):_0x119c74;}function y(_0x520fb3,_0x436697){return _0x520fb3['length']===_0x436697['length']&&_0x520fb3['every']((_0x4131a9,_0x462938)=>_0x4131a9===_0x436697[_0x462938]);}function b(_0x1f7dc6){if(!_0x1f7dc6?.['filename'])throw TypeError('SQLiteCommentDatabaseAdapter\x20requires\x20a\x20filename');if(_0x1f7dc6['busyTimeoutMs']!==void 0x0&&(!Number['isSafeInteger'](_0x1f7dc6['busyTimeoutMs'])||_0x1f7dc6['busyTimeoutMs']<0x0))throw TypeError('busyTimeoutMs\x20must\x20be\x20a\x20non-negative\x20safe\x20integer');}function x(_0x546516){return Error(_0x546516);}exports['SQLiteCommentDatabaseAdapter']=h;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
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};
1
+ const _0x464f61=_0x2d1e;function _0x3b95(){const _0x2b0a04=['171331PlTQhJ','4812nGiLjW','8710610roKgCp','23844634QDDcMD','3015VMxZCf','8DknUyV','32McDGaG','593004KydpJz','12zcHtBm','9oknLHY','1448363SzpSKo','471885ENQdUS','SQLiteCommentDatabaseAdapter'];_0x3b95=function(){return _0x2b0a04;};return _0x3b95();}(function(_0x1478e7,_0x22dcc9){const _0x5f1447=_0x2d1e,_0x44f033=_0x1478e7();while(!![]){try{const _0x39ef4d=-parseInt(_0x5f1447(0x161))/0x1*(-parseInt(_0x5f1447(0x159))/0x2)+-parseInt(_0x5f1447(0x15f))/0x3+-parseInt(_0x5f1447(0x162))/0x4*(-parseInt(_0x5f1447(0x158))/0x5)+-parseInt(_0x5f1447(0x15b))/0x6+-parseInt(_0x5f1447(0x15e))/0x7*(-parseInt(_0x5f1447(0x15a))/0x8)+parseInt(_0x5f1447(0x15d))/0x9*(parseInt(_0x5f1447(0x156))/0xa)+-parseInt(_0x5f1447(0x157))/0xb*(parseInt(_0x5f1447(0x15c))/0xc);if(_0x39ef4d===_0x22dcc9)break;else _0x44f033['push'](_0x44f033['shift']());}catch(_0x321a18){_0x44f033['push'](_0x44f033['shift']());}}}(_0x3b95,0xa7627));import _0x3457ab from'./index.cjs';function _0x2d1e(_0xba6ba4,_0x5dae86){_0xba6ba4=_0xba6ba4-0x156;const _0x3b9534=_0x3b95();let _0x2d1e86=_0x3b9534[_0xba6ba4];return _0x2d1e86;}const facadeExport0=_0x3457ab[_0x464f61(0x160)];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",
7
+ "version": "1.0.2",
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",
23
- "@univerjs/protocol": "1.0.0",
22
+ "@univerjs-pro/collaboration-comment-service": "1.0.2",
23
+ "@univerjs/protocol": "1.0.2",
24
24
  "libsql": "^0.5.29"
25
25
  }
26
26
  }