@univerjs-pro/collaboration-comment-database-memory 1.0.0-beta.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/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # @univerjs-pro/collaboration-comment-database-memory
2
+
3
+ English | [简体中文](./README.zh-CN.md)
4
+
5
+ An in-process `ICommentDatabaseAdapter` for tests, local development, and temporary Thread Comment Services.
6
+
7
+ ```bash
8
+ pnpm add \
9
+ @univerjs-pro/collaboration-comment-service \
10
+ @univerjs-pro/collaboration-comment-database-memory
11
+ ```
12
+
13
+ ```ts
14
+ const database = new MemoryCommentDatabaseAdapter();
15
+ const commentService = new UniverCommentService({ database });
16
+
17
+ await commentService.dispose();
18
+ await database.dispose();
19
+ ```
20
+
21
+ The Adapter serializes operations per Unit and implements the same concurrency-version checks as the SQLite Adapter.
22
+
23
+ All comments are lost when the process exits, and state is not shared between Node.js processes. Use SQLite or another persistent Adapter for persistent production data.
@@ -0,0 +1,24 @@
1
+ # @univerjs-pro/collaboration-comment-database-memory
2
+
3
+ [English](./README.md) | [简体中文](./README.zh-CN.md)
4
+
5
+ 进程内 `ICommentDatabaseAdapter`,适合测试、本地开发和临时 Thread Comment Service。
6
+
7
+ ```bash
8
+ pnpm add \
9
+ @univerjs-pro/collaboration-comment-service \
10
+ @univerjs-pro/collaboration-comment-database-memory
11
+ ```
12
+
13
+ ```ts
14
+ const database = new MemoryCommentDatabaseAdapter();
15
+ const commentService = new UniverCommentService({ database });
16
+
17
+ await commentService.dispose();
18
+ await database.dispose();
19
+ ```
20
+
21
+ Adapter 按 Unit 串行操作,并实现与 SQLite Adapter 相同的并发版本检查。
22
+
23
+ 进程退出后所有评论丢失,多个 Node.js 进程也不共享状态。持久化生产数据应使用 SQLite
24
+ 或其他持久化 Adapter。
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ Object['defineProperty'](exports,Symbol['toStringTag'],{'value':'Module'});let e=require('node:crypto'),t=require('@univerjs/protocol');var n=class{['_units']=new Map();['_queues']=new Map();['_calls']=new Set();['_state']='running';['_disposePromise'];['createRoot'](_0x3faade,_0x4344cf){return this['_call'](()=>this['_enqueue'](_0x3faade['unitID'],()=>{let _0xa43a2e=this['_unit'](_0x3faade['unitID']);if(_0xa43a2e['has'](_0x3faade['threadID']))return{'status':'duplicate'};let _0x2ce616=Date['now'](),_0x2eb5b7={..._0x3faade,'replyID':_0x3faade['threadID'],'mentions':[..._0x3faade['mentions']],'solved':t['CommentSolvedStatus']['OpenOrReOpen'],'createdAt':_0x2ce616,'updatedAt':_0x2ce616,'generation':(0x0,e['randomUUID'])()};return _0xa43a2e['set'](_0x2eb5b7['replyID'],_0x2eb5b7),{'status':'created','record':r(_0x2eb5b7)};}));}['createReply'](_0x1e03d4,_0x206125){return this['_call'](()=>this['_enqueue'](_0x1e03d4['unitID'],()=>{let _0x534a02=this['_unit'](_0x1e03d4['unitID']);if(_0x534a02['has'](_0x1e03d4['replyID']))return{'status':'duplicate'};let _0xdb1c7a=_0x534a02['get'](_0x1e03d4['threadID']);if(!_0xdb1c7a||_0xdb1c7a['replyID']!==_0xdb1c7a['threadID'])return{'status':'not-found'};if(_0xdb1c7a['solved']!==t['CommentSolvedStatus']['OpenOrReOpen'])return{'status':'closed'};let _0x34a072=Date['now'](),_0x8ec4b={..._0x1e03d4,'mentions':[..._0x1e03d4['mentions']],'solved':_0xdb1c7a['solved'],'createdAt':_0x34a072,'updatedAt':_0x34a072,'generation':(0x0,e['randomUUID'])()};return _0x534a02['set'](_0x8ec4b['replyID'],_0x8ec4b),{'status':'created','record':r(_0x8ec4b)};}));}['getComment'](_0x4c497b,_0x2b9b05){return this['_call'](()=>this['_enqueue'](_0x4c497b['unitID'],()=>{let _0x4ccf4a=this['_units']['get'](_0x4c497b['unitID'])?.['get'](_0x4c497b['replyID']);return _0x4ccf4a?.['threadID']===_0x4c497b['threadID']?r(_0x4ccf4a):null;}));}['listThreads'](_0x457f82,_0x3911b8){return this['_call'](()=>this['_enqueue'](_0x457f82['unitID'],()=>{let _0xa9b5bc=new Set(_0x457f82['threadIDs']);return[...this['_units']['get'](_0x457f82['unitID'])?.['values']()??[]]['filter'](_0x4644dd=>_0xa9b5bc['size']===0x0||_0xa9b5bc['has'](_0x4644dd['threadID']))['sort'](i)['map'](r);}));}['editComment'](_0x417052,_0x50b335){return this['_call'](()=>this['_enqueue'](_0x417052['unitID'],()=>{let _0x10fb39=this['_units']['get'](_0x417052['unitID']),_0x59e850=_0x10fb39?.['get'](_0x417052['replyID']),_0x25da9f=_0x10fb39?.['get'](_0x417052['threadID']);if(!_0x59e850||_0x59e850['threadID']!==_0x417052['threadID']||!_0x25da9f)return{'status':'not-found'};if(_0x25da9f['solved']!==t['CommentSolvedStatus']['OpenOrReOpen'])return{'status':'closed'};if(_0x59e850['authorUserID']!==_0x417052['expectedAuthorUserID'])return{'status':'author-mismatch'};if(_0x59e850['content']===_0x417052['content']&&a(_0x59e850['mentions'],_0x417052['mentions']))return{'status':'unchanged','record':r(_0x59e850)};let _0x120e37={..._0x59e850,'content':_0x417052['content'],'mentions':[..._0x417052['mentions']],'updatedAt':Math['max'](Date['now'](),_0x59e850['updatedAt']+0x1)};return _0x10fb39['set'](_0x417052['replyID'],_0x120e37),{'status':'edited','record':r(_0x120e37)};}));}['setThreadSolved'](_0x24d513,_0x4fdc6b){return this['_call'](()=>this['_enqueue'](_0x24d513['unitID'],()=>{let _0x2f21df=this['_units']['get'](_0x24d513['unitID']),_0x32a5d1=_0x2f21df?.['get'](_0x24d513['threadID']);return!_0x32a5d1||_0x32a5d1['replyID']!==_0x32a5d1['threadID']?{'status':'not-found'}:_0x32a5d1['solved']===_0x24d513['solved']?{'status':'unchanged'}:(_0x2f21df['set'](_0x24d513['threadID'],{..._0x32a5d1,'solved':_0x24d513['solved'],'updatedAt':Math['max'](Date['now'](),_0x32a5d1['updatedAt']+0x1)}),{'status':'updated'});}));}['deleteComment'](_0x19e95e,_0x416ca7){return this['_call'](()=>this['_enqueue'](_0x19e95e['unitID'],()=>{let _0xedad5e=this['_units']['get'](_0x19e95e['unitID']),_0x1f3aae=_0x19e95e['replyID']??_0x19e95e['threadID'],_0x56a61b=_0xedad5e?.['get'](_0x1f3aae);if(!_0x56a61b||_0x56a61b['threadID']!==_0x19e95e['threadID'])return{'status':'not-found'};if(_0x56a61b['generation']!==_0x19e95e['expectedGeneration'])return{'status':'generation-mismatch'};if(_0x19e95e['replyID']===void 0x0){for(let [_0x46203d,_0x313d44]of _0xedad5e)_0x313d44['threadID']===_0x19e95e['threadID']&&_0xedad5e['delete'](_0x46203d);}else _0xedad5e['delete'](_0x19e95e['replyID']);return _0xedad5e['size']===0x0&&this['_units']['delete'](_0x19e95e['unitID']),{'status':'deleted'};}));}['dispose'](){return this['_disposePromise']?this['_disposePromise']:(this['_state']='disposing',this['_disposePromise']=((async()=>{await Promise['allSettled']([...this['_calls']]),this['_queues']['clear'](),this['_state']='disposed';})()),this['_disposePromise']);}['_unit'](_0x18efdd){let _0x5b2d3d=this['_units']['get'](_0x18efdd);if(_0x5b2d3d)return _0x5b2d3d;let _0x437304=new Map();return this['_units']['set'](_0x18efdd,_0x437304),_0x437304;}['_enqueue'](_0x5bfc2c,_0x5028f1){let _0x782fd8=(this['_queues']['get'](_0x5bfc2c)??Promise['resolve']())['catch'](()=>void 0x0)['then'](_0x5028f1),_0x392ea5=_0x782fd8['then'](()=>void 0x0,()=>void 0x0);return this['_queues']['set'](_0x5bfc2c,_0x392ea5),_0x392ea5['finally'](()=>{this['_queues']['get'](_0x5bfc2c)===_0x392ea5&&this['_queues']['delete'](_0x5bfc2c);}),_0x782fd8;}['_call'](_0x4b73e2){if(this['_state']!=='running')return Promise['reject'](Error('Memory\x20Comment\x20Database\x20Adapter\x20is\x20'+this['_state']));let _0x663494=_0x4b73e2();return this['_calls']['add'](_0x663494),_0x663494['finally'](()=>this['_calls']['delete'](_0x663494))['catch'](()=>void 0x0),_0x663494;}};function r(_0x374c14){return{..._0x374c14,'mentions':[..._0x374c14['mentions']]};}function i(_0x1ace91,_0x4afe9e){let _0x1b33bf=_0x1ace91['threadID']['localeCompare'](_0x4afe9e['threadID']);return _0x1b33bf===0x0?_0x1ace91['replyID']===_0x1ace91['threadID']?-0x1:_0x4afe9e['replyID']===_0x4afe9e['threadID']?0x1:_0x1ace91['createdAt']-_0x4afe9e['createdAt']||_0x1ace91['replyID']['localeCompare'](_0x4afe9e['replyID']):_0x1b33bf;}function a(_0x4b3dd7,_0x4b4d8f){return _0x4b3dd7['length']===_0x4b4d8f['length']&&_0x4b3dd7['every']((_0x3968fb,_0x1fe1cc)=>_0x3968fb===_0x4b4d8f[_0x1fe1cc]);}exports['MemoryCommentDatabaseAdapter']=n;
@@ -0,0 +1,23 @@
1
+ import { CommentDatabaseContext, CommentRecord, CreateCommentDatabaseResult, CreateReplyDatabaseInput, CreateReplyDatabaseResult, CreateRootDatabaseInput, DeleteCommentDatabaseInput, DeleteCommentDatabaseResult, EditCommentDatabaseInput, EditCommentDatabaseResult, GetCommentDatabaseInput, ICommentDatabaseAdapter, ListThreadsDatabaseInput, SetThreadSolvedDatabaseInput, SetThreadSolvedDatabaseResult } from "@univerjs-pro/collaboration-comment-service";
2
+
3
+ //#region src/memory-comment-database-adapter.d.ts
4
+ declare class MemoryCommentDatabaseAdapter implements ICommentDatabaseAdapter {
5
+ private readonly _units;
6
+ private readonly _queues;
7
+ private readonly _calls;
8
+ private _state;
9
+ private _disposePromise;
10
+ createRoot(input: CreateRootDatabaseInput, _context: CommentDatabaseContext): Promise<CreateCommentDatabaseResult>;
11
+ createReply(input: CreateReplyDatabaseInput, _context: CommentDatabaseContext): Promise<CreateReplyDatabaseResult>;
12
+ getComment(input: GetCommentDatabaseInput, _context: CommentDatabaseContext): Promise<CommentRecord | null>;
13
+ listThreads(input: ListThreadsDatabaseInput, _context: CommentDatabaseContext): Promise<readonly CommentRecord[]>;
14
+ editComment(input: EditCommentDatabaseInput, _context: CommentDatabaseContext): Promise<EditCommentDatabaseResult>;
15
+ setThreadSolved(input: SetThreadSolvedDatabaseInput, _context: CommentDatabaseContext): Promise<SetThreadSolvedDatabaseResult>;
16
+ deleteComment(input: DeleteCommentDatabaseInput, _context: CommentDatabaseContext): Promise<DeleteCommentDatabaseResult>;
17
+ dispose(): Promise<void>;
18
+ private _unit;
19
+ private _enqueue;
20
+ private _call;
21
+ }
22
+ //#endregion
23
+ export { MemoryCommentDatabaseAdapter };
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ function _0x39ea(){const _0x1c0816=['5031765aBvyQS','975334eztonN','429216TSzcNL','1367864HZfKMz','MemoryCommentDatabaseAdapter','390246cdPXYJ','30zDmywL','1fRZBrt','5367229BZvfGB','1805548DGeibs'];_0x39ea=function(){return _0x1c0816;};return _0x39ea();}const _0x779a7f=_0x23c2;(function(_0x563b9b,_0x5d41f2){const _0x4a3bc0=_0x23c2,_0x146b4c=_0x563b9b();while(!![]){try{const _0x51cd8f=parseInt(_0x4a3bc0(0x191))/0x1*(-parseInt(_0x4a3bc0(0x195))/0x2)+parseInt(_0x4a3bc0(0x196))/0x3+parseInt(_0x4a3bc0(0x193))/0x4+parseInt(_0x4a3bc0(0x190))/0x5*(parseInt(_0x4a3bc0(0x18f))/0x6)+-parseInt(_0x4a3bc0(0x192))/0x7+parseInt(_0x4a3bc0(0x197))/0x8+parseInt(_0x4a3bc0(0x194))/0x9;if(_0x51cd8f===_0x5d41f2)break;else _0x146b4c['push'](_0x146b4c['shift']());}catch(_0x1b2c9c){_0x146b4c['push'](_0x146b4c['shift']());}}}(_0x39ea,0x70647));import _0x2b5cee from'./index.cjs';function _0x23c2(_0x282875,_0x30771d){_0x282875=_0x282875-0x18f;const _0x39ea8b=_0x39ea();let _0x23c26a=_0x39ea8b[_0x282875];return _0x23c26a;}const facadeExport0=_0x2b5cee[_0x779a7f(0x198)];export{facadeExport0 as MemoryCommentDatabaseAdapter};
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "@univerjs-pro/collaboration-comment-database-memory",
3
+ "type": "module",
4
+ "version": "1.0.0-beta.2",
5
+ "main": "./dist/index.cjs",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.cjs"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "dependencies": {
19
+ "@univerjs-pro/collaboration-comment-service": "1.0.0-beta.2",
20
+ "@univerjs/protocol": "1.0.0-beta.2"
21
+ }
22
+ }