@univerjs-pro/collaboration-comment-database-sqlite 1.0.0 → 1.0.1
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'});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=(_0xc31cd1,_0x54261d,_0x27dd1a,_0x469c1b)=>{if(_0x54261d&&typeof _0x54261d=='object'||typeof _0x54261d=='function'){for(var _0x52753e=r(_0x54261d),_0x2f874e=0x0,_0x573628=_0x52753e['length'],_0x12d6e1;_0x2f874e<_0x573628;_0x2f874e++)_0x12d6e1=_0x52753e[_0x2f874e],!a['call'](_0xc31cd1,_0x12d6e1)&&_0x12d6e1!==_0x27dd1a&&t(_0xc31cd1,_0x12d6e1,{'get':(_0x32c57c=>_0x54261d[_0x32c57c])['bind'](null,_0x12d6e1),'enumerable':!(_0x469c1b=n(_0x54261d,_0x12d6e1))||_0x469c1b['enumerable']});}return _0xc31cd1;},s=(_0x2c1eba,_0x19cb24,_0x393406)=>(_0x393406=_0x2c1eba==null?{}:e(i(_0x2c1eba)),o(_0x19cb24||!_0x2c1eba||!_0x2c1eba['__esModule']?t(_0x393406,'default',{'value':_0x2c1eba,'enumerable':!0x0}):_0x393406,_0x2c1eba));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(_0x3f8588){b(_0x3f8588),this['_database']=new l['default'](_0x3f8588['filename'],{'timeout':_0x3f8588['busyTimeoutMs']??d});try{this['_database']['exec']('PRAGMA\x20busy_timeout\x20=\x20'+(_0x3f8588['busyTimeoutMs']??d)+';'),this['_initializeSchema']();}catch(_0x119d92){throw this['_database']['close'](),_0x119d92;}}async['createRoot'](_0x3f306f,_0x3c1094){return this['_assertOpen'](),this['_transaction'](()=>{if(this['_getByReply'](_0x3f306f['unitID'],_0x3f306f['threadID']))return{'status':'duplicate'};let _0x54f52a=Date['now']();return this['_insert']({..._0x3f306f,'replyID':_0x3f306f['threadID'],'solved':u['CommentSolvedStatus']['OpenOrReOpen'],'createdAt':_0x54f52a,'updatedAt':_0x54f52a,'generation':(0x0,c['randomUUID'])()}),{'status':'created','record':this['_require'](_0x3f306f['unitID'],_0x3f306f['threadID'])};});}async['createReply'](_0x3a8275,_0x5d592a){return this['_assertOpen'](),this['_transaction'](()=>{if(this['_getByReply'](_0x3a8275['unitID'],_0x3a8275['replyID']))return{'status':'duplicate'};let _0x5b8471=this['_getByReply'](_0x3a8275['unitID'],_0x3a8275['threadID']);if(!_0x5b8471||_0x5b8471['threadID']!==_0x5b8471['replyID'])return{'status':'not-found'};if(_0x5b8471['solved']!==u['CommentSolvedStatus']['OpenOrReOpen'])return{'status':'closed'};let _0x46e2b7=Date['now']();return this['_insert']({..._0x3a8275,'solved':_0x5b8471['solved'],'createdAt':_0x46e2b7,'updatedAt':_0x46e2b7,'generation':(0x0,c['randomUUID'])()}),{'status':'created','record':this['_require'](_0x3a8275['unitID'],_0x3a8275['replyID'])};});}async['getComment'](_0x331280,_0x2bf595){this['_assertOpen']();let _0x47bfeb=this['_getByReply'](_0x331280['unitID'],_0x331280['replyID']);return _0x47bfeb?.['threadID']===_0x331280['threadID']?_0x47bfeb:null;}async['listThreads'](_0x283784,_0x3bf41d){this['_assertOpen']();let _0x6be53c=[...new Set(_0x283784['threadIDs'])];return(_0x6be53c['length']===0x0?this['_database']['prepare'](g+'\x20WHERE\x20unit_id\x20=\x20?')['all'](_0x283784['unitID']):this['_database']['prepare'](g+'\x20WHERE\x20unit_id\x20=\x20?\x20AND\x20thread_id\x20IN\x20('+_0x6be53c['map'](()=>'?')['join'](',')+')')['all'](_0x283784['unitID'],..._0x6be53c))['map'](_)['sort'](v);}async['editComment'](_0x3ec5dc,_0x142f1c){return this['_assertOpen'](),this['_transaction'](()=>{let _0x30130c=this['_getByReply'](_0x3ec5dc['unitID'],_0x3ec5dc['replyID']),_0x189183=this['_getByReply'](_0x3ec5dc['unitID'],_0x3ec5dc['threadID']);return!_0x30130c||_0x30130c['threadID']!==_0x3ec5dc['threadID']||!_0x189183?{'status':'not-found'}:_0x189183['solved']===u['CommentSolvedStatus']['OpenOrReOpen']?_0x30130c['authorUserID']===_0x3ec5dc['expectedAuthorUserID']?_0x30130c['content']===_0x3ec5dc['content']&&y(_0x30130c['mentions'],_0x3ec5dc['mentions'])?{'status':'unchanged','record':_0x30130c}:(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'](_0x3ec5dc['content'],JSON['stringify'](_0x3ec5dc['mentions']),Math['max'](Date['now'](),_0x30130c['updatedAt']+0x1),_0x3ec5dc['unitID'],_0x3ec5dc['threadID'],_0x3ec5dc['replyID']),{'status':'edited','record':this['_require'](_0x3ec5dc['unitID'],_0x3ec5dc['replyID'])}):{'status':'author-mismatch'}:{'status':'closed'};});}async['setThreadSolved'](_0x2e6aba,_0x3e3406){return this['_assertOpen'](),this['_transaction'](()=>{let _0x3fc648=this['_getByReply'](_0x2e6aba['unitID'],_0x2e6aba['threadID']);return!_0x3fc648||_0x3fc648['threadID']!==_0x3fc648['replyID']?{'status':'not-found'}:_0x3fc648['solved']===_0x2e6aba['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'](_0x2e6aba['solved'],Math['max'](Date['now'](),_0x3fc648['updatedAt']+0x1),_0x2e6aba['unitID'],_0x2e6aba['threadID']),{'status':'updated'});});}async['deleteComment'](_0x37fc59,_0x40aa5a){return this['_assertOpen'](),this['_transaction'](()=>{let _0x3491f5=_0x37fc59['replyID']??_0x37fc59['threadID'],_0x687633=this['_getByReply'](_0x37fc59['unitID'],_0x3491f5);return!_0x687633||_0x687633['threadID']!==_0x37fc59['threadID']?{'status':'not-found'}:_0x687633['generation']===_0x37fc59['expectedGeneration']?(_0x37fc59['replyID']===void 0x0?this['_database']['prepare']('DELETE\x20FROM\x20collaboration_comments\x20WHERE\x20unit_id\x20=\x20?\x20AND\x20thread_id\x20=\x20?')['run'](_0x37fc59['unitID'],_0x37fc59['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'](_0x37fc59['unitID'],_0x37fc59['threadID'],_0x37fc59['replyID'],_0x37fc59['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 _0x44402e=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(_0x44402e){if(_0x44402e['version']!==p)throw x('SQLite\x20Comment\x20schema\x20version\x20'+_0x44402e['version']+'\x20is\x20not\x20supported');let _0x65a013=m['filter'](_0x498677=>!this['_hasTable'](_0x498677));if(_0x65a013['length']>0x0)throw x('SQLite\x20Comment\x20schema\x20v1\x20is\x20incomplete:\x20missing\x20'+_0x65a013['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'](_0xb1a039){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'](_0xb1a039);}['_hasAnyOwnedTable'](){return m['some'](_0x3cd1b6=>this['_hasTable'](_0x3cd1b6));}['_insert'](_0x28b280){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'](_0x28b280['unitID'],_0x28b280['threadID'],_0x28b280['replyID'],_0x28b280['authorUserID'],_0x28b280['content'],JSON['stringify'](_0x28b280['mentions']),_0x28b280['solved'],_0x28b280['createdAt'],_0x28b280['updatedAt'],_0x28b280['generation']);}['_getByReply'](_0x3b32b2,_0x122fa0){let _0x681b62=this['_database']['prepare'](g+'\x20WHERE\x20unit_id\x20=\x20?\x20AND\x20reply_id\x20=\x20?')['get'](_0x3b32b2,_0x122fa0);return _0x681b62?_(_0x681b62):null;}['_require'](_0x279a5c,_0xf5f9f2){let _0x2f4a4d=this['_getByReply'](_0x279a5c,_0xf5f9f2);if(!_0x2f4a4d)throw Error('SQLite\x20Comment\x20write\x20did\x20not\x20persist\x20its\x20record');return _0x2f4a4d;}['_transaction'](_0x5de81e){this['_database']['exec']('BEGIN\x20IMMEDIATE;');try{let _0x270110=_0x5de81e();return this['_database']['exec']('COMMIT;'),_0x270110;}catch(_0x5e1447){try{this['_database']['exec']('ROLLBACK;');}catch{}throw _0x5e1447;}}['_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 _(_0x16ff73){let _0x41f221=JSON['parse'](_0x16ff73['mentions_json']);if(!Array['isArray'](_0x41f221)||_0x41f221['some'](_0x3069c6=>typeof _0x3069c6!='string'))throw Error('SQLite\x20Comment\x20contains\x20invalid\x20mentions');if(_0x16ff73['solved']!==u['CommentSolvedStatus']['OpenOrReOpen']&&_0x16ff73['solved']!==u['CommentSolvedStatus']['Solved'])throw Error('SQLite\x20Comment\x20contains\x20invalid\x20solved\x20status');return{'unitID':_0x16ff73['unit_id'],'threadID':_0x16ff73['thread_id'],'replyID':_0x16ff73['reply_id'],'authorUserID':_0x16ff73['author_user_id'],'content':_0x16ff73['content'],'mentions':_0x41f221,'solved':_0x16ff73['solved'],'createdAt':_0x16ff73['created_at'],'updatedAt':_0x16ff73['updated_at'],'generation':_0x16ff73['generation']};}function v(_0x1b546d,_0x399e93){let _0x15ff19=_0x1b546d['threadID']['localeCompare'](_0x399e93['threadID']);return _0x15ff19===0x0?_0x1b546d['replyID']===_0x1b546d['threadID']?-0x1:_0x399e93['replyID']===_0x399e93['threadID']?0x1:_0x1b546d['createdAt']-_0x399e93['createdAt']||_0x1b546d['replyID']['localeCompare'](_0x399e93['replyID']):_0x15ff19;}function y(_0x195784,_0x3d9704){return _0x195784['length']===_0x3d9704['length']&&_0x195784['every']((_0x207f35,_0x58ea81)=>_0x207f35===_0x3d9704[_0x58ea81]);}function b(_0x67556a){if(!_0x67556a?.['filename'])throw TypeError('SQLiteCommentDatabaseAdapter\x20requires\x20a\x20filename');if(_0x67556a['busyTimeoutMs']!==void 0x0&&(!Number['isSafeInteger'](_0x67556a['busyTimeoutMs'])||_0x67556a['busyTimeoutMs']<0x0))throw TypeError('busyTimeoutMs\x20must\x20be\x20a\x20non-negative\x20safe\x20integer');}function x(_0x63d44c){return Error(_0x63d44c);}exports['SQLiteCommentDatabaseAdapter']=h;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
(function(_0x16ea13,_0x2d6f69){const _0x2f095f=_0x2f21,_0x135c2b=_0x16ea13();while(!![]){try{const _0x53b223=parseInt(_0x2f095f(0x1a7))/0x1*(parseInt(_0x2f095f(0x1a4))/0x2)+-parseInt(_0x2f095f(0x1a1))/0x3*(parseInt(_0x2f095f(0x1a0))/0x4)+-parseInt(_0x2f095f(0x1a5))/0x5*(parseInt(_0x2f095f(0x1ab))/0x6)+parseInt(_0x2f095f(0x19f))/0x7+-parseInt(_0x2f095f(0x1a8))/0x8*(-parseInt(_0x2f095f(0x1aa))/0x9)+parseInt(_0x2f095f(0x1a3))/0xa*(parseInt(_0x2f095f(0x1a6))/0xb)+-parseInt(_0x2f095f(0x1a9))/0xc*(parseInt(_0x2f095f(0x1a2))/0xd);if(_0x53b223===_0x2d6f69)break;else _0x135c2b['push'](_0x135c2b['shift']());}catch(_0x25080f){_0x135c2b['push'](_0x135c2b['shift']());}}}(_0x36a3,0x50336));import _0x3d9d7d from'./index.cjs';const facadeExport0=_0x3d9d7d['SQLiteCommentDatabaseAdapter'];function _0x2f21(_0x4c4d4e,_0x5e90d8){_0x4c4d4e=_0x4c4d4e-0x19f;const _0x36a36d=_0x36a3();let _0x2f2176=_0x36a36d[_0x4c4d4e];return _0x2f2176;}function _0x36a3(){const _0x54d532=['179420CjlfUh','7686NLAxqN','664030zoWzMN','77YunzXw','18RcfUYI','3484984pCWwRS','84BndEtE','9ndTeIG','6qnNurt','3870272LINyRt','12rZovSQ','311352GAJhMl','762593tAdUUH'];_0x36a3=function(){return _0x54d532;};return _0x36a3();}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.
|
|
7
|
+
"version": "1.0.1",
|
|
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.
|
|
23
|
-
"@univerjs/protocol": "1.0.
|
|
22
|
+
"@univerjs-pro/collaboration-comment-service": "1.0.1",
|
|
23
|
+
"@univerjs/protocol": "1.0.1",
|
|
24
24
|
"libsql": "^0.5.29"
|
|
25
25
|
}
|
|
26
26
|
}
|