@univerjs-pro/collaboration-history-endpoint 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/README.md CHANGED
@@ -34,7 +34,7 @@ transport.register(historyEndpoint);
34
34
  transport.register(collabEndpoint);
35
35
  ```
36
36
 
37
- Register authentication first, followed by History Endpoint and the main Collaboration Endpoint. History Endpoint uses the application-provided Transport `userID` and calls History Service APIs for protocol requests. It does not own authentication, ACLs, History storage, or segmentation policy.
37
+ Register authentication first, followed by History Endpoint and the main Collaboration Endpoint. History Endpoint uses the `userID` provided by Transport authentication and maps protocol requests to History Service calls. Configure authorization in History Service middleware.
38
38
 
39
39
  ## HTTP routes
40
40
 
@@ -44,6 +44,6 @@ Register authentication first, followed by History Endpoint and the main Collabo
44
44
  | `GET` | `/universer-api/history/:unitID/creators` | `listHistoryCreators` | Read history creators |
45
45
  | `GET` | `/universer-api/history/:unitID/cs` | `getHistoryChangesets` | Read changesets for history revisions |
46
46
 
47
- All three routes call History Service with `ctx.userID/customData` set by Transport middleware for the current HTTP request and enter the corresponding History Service middleware. History Endpoint does not create or read a WebSocket Session.
47
+ All three routes call History Service with `ctx.userID/customData` set by Transport middleware for the current HTTP request and enter the corresponding History Service middleware.
48
48
 
49
- Install authorization middleware for every History Service action. Transport owns and disposes Endpoint; disposing Endpoint does not dispose History Service or its Database Adapter.
49
+ Transport disposes the Endpoint. The application manages History Service and its Database Adapter.
package/README.zh-CN.md CHANGED
@@ -35,9 +35,9 @@ transport.register(historyEndpoint);
35
35
  transport.register(collabEndpoint);
36
36
  ```
37
37
 
38
- 先注册认证,再注册 History Endpoint 和主协同 Endpoint。History Endpoint 使用应用通过
39
- Transport 提供的 `userID`,调用 History Service API 处理协议请求;它不负责认证、ACL、
40
- History 存储或分段策略。
38
+ 先注册认证,再注册 History Endpoint 和主协同 Endpoint。History Endpoint 使用 Transport
39
+ 认证提供的 `userID`,将协议请求映射为 History Service 调用。权限校验配置在 History
40
+ Service middleware 中。
41
41
 
42
42
  ## HTTP 路由
43
43
 
@@ -48,7 +48,6 @@ History 存储或分段策略。
48
48
  | `GET` | `/universer-api/history/:unitID/cs` | `getHistoryChangesets` | 读取历史 revision 对应的 changesets |
49
49
 
50
50
  三条路由都使用当前 HTTP 请求由 Transport middleware 设置的 `ctx.userID/customData`,并
51
- 进入对应 History Service middleware;History Endpoint 不创建或读取 WebSocket Session。
51
+ 进入对应 History Service middleware。
52
52
 
53
- 应用应在 History Service 的各 action 安装权限 middleware。Transport 拥有并释放
54
- Endpoint;释放 Endpoint 不会释放 History Service 或 Database Adapter。
53
+ Transport 负责释放 Endpoint,应用管理 History Service 和 Database Adapter。
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object['defineProperty'](exports,Symbol['toStringTag'],{'value':'Module'});let e=require('@univerjs-pro/collaboration-service'),t=require('@univerjs-pro/collaboration-transport-node'),n=require('@univerjs/protocol');var r={'code':n['ErrorCode']['OK'],'message':''},i=class{['_service'];['_disposed']=!0x1;constructor(_0x3eaac5){if(this['_service']=_0x3eaac5,!_0x3eaac5)throw TypeError('UniverHistoryEndpoint\x20requires\x20a\x20service');}['register'](_0x21b0a6){if(this['_disposed'])throw new e['CollabError']('INTERNAL_ERROR','History\x20Endpoint\x20is\x20disposed');for(let [_0x3ac24b,_0x220ce]of[['list','list'],['creators','creators'],['cs','changesets']])_0x21b0a6['get']('/universer-api/history/:unitID/'+_0x3ac24b,_0x101af6=>this['_handleHttp'](_0x101af6,{'name':_0x220ce,'unitID':_0x101af6['params']['unitID']}));}async['_handleHttp'](_0x449ce1,_0x2d118e){try{if(this['_disposed'])throw new e['CollabError']('INTERNAL_ERROR','History\x20Endpoint\x20is\x20disposed');let _0x45050b=new URL(_0x449ce1['incomingMessage']['url']??'/','http://localhost');if(!_0x449ce1['userID'])throw new e['CollabError']('UNAUTHENTICATED','HTTP\x20user\x20is\x20not\x20authenticated');let _0x1293d8={'userID':_0x449ce1['userID'],'customData':_0x449ce1['customData']};switch(_0x2d118e['name']){case'list':{let _0x15faec=await this['_service']['getHistoryList']({'unitID':_0x2d118e['unitID'],'length':o(_0x45050b['searchParams']['get']('length')),..._0x45050b['searchParams']['get']('lastLabel')?{'lastLabel':_0x45050b['searchParams']['get']('lastLabel')}:{},...c(_0x45050b['searchParams']['get']('origin')),'userIDs':_0x45050b['searchParams']['getAll']('userIds')['filter'](Boolean)},_0x1293d8);d(_0x449ce1['response'],0xc8,{'error':r,...a(_0x15faec)});return;}case'creators':{let _0x18b731=await this['_service']['listHistoryCreators']({'unitID':_0x2d118e['unitID']},_0x1293d8);d(_0x449ce1['response'],0xc8,{'error':r,'creators':_0x18b731['creators']['map'](({userID:_0x48b2f0,..._0x2a6ca0})=>({..._0x2a6ca0,'userId':_0x48b2f0}))});return;}case'changesets':{let _0x1da2e6=s(_0x45050b['searchParams']['get']('startRevision'),'startRevision'),_0x4233aa=s(_0x45050b['searchParams']['get']('endRevision'),'endRevision'),_0x308f2e=await this['_service']['getHistoryChangesets']({'unitID':_0x2d118e['unitID'],'startRevision':_0x1da2e6,'endRevision':_0x4233aa},_0x1293d8);d(_0x449ce1['response'],0xc8,{'error':r,..._0x308f2e});return;}}}catch(_0x4602f8){l(_0x449ce1['response'],_0x4602f8);}}['dispose'](){this['_disposed']=!0x0;}};function a(_0x49a50a){let _0xd7cec4=Object['fromEntries'](Object['entries'](_0x49a50a['entities']['datas'])['map'](([_0x21a134,{userID:_0x2e6e57,unitID:_0x3e9a42,userIDs:_0x1ef8ad,..._0x368b80}])=>[_0x21a134,{..._0x368b80,'userId':_0x2e6e57,'unitId':_0x3e9a42,'userIds':_0x1ef8ad}]));return{..._0x49a50a,'entities':{..._0x49a50a['entities'],'datas':_0xd7cec4}};}function o(_0x3b7c12){return _0x3b7c12===null||_0x3b7c12===''?0x14:s(_0x3b7c12,'length');}function s(_0x4e2630,_0x1ed71c){if(!_0x4e2630||!/^\d+$/['test'](_0x4e2630))throw new e['CollabError']('INVALID_REQUEST',_0x1ed71c+'\x20must\x20be\x20a\x20positive\x20integer');let _0x5bfa96=Number(_0x4e2630);if(!Number['isSafeInteger'](_0x5bfa96)||_0x5bfa96<0x1)throw new e['CollabError']('INVALID_REQUEST',_0x1ed71c+'\x20must\x20be\x20a\x20positive\x20integer');return _0x5bfa96;}function c(_0x964e6f){if(_0x964e6f===null||_0x964e6f===''||_0x964e6f==='0')return{};if(_0x964e6f==='1'||_0x964e6f==='2')return{'origin':Number(_0x964e6f)};throw new e['CollabError']('INVALID_REQUEST','origin\x20must\x20be\x200,\x201\x20or\x202');}function l(_0x55a4d6,_0x3ab948){let _0x35dc54=u(_0x3ab948);d(_0x55a4d6,_0x35dc54['status'],{'error':_0x35dc54['error']});}function u(_0x343c13){if(_0x343c13 instanceof t['NodeTransportError'])return{'status':_0x343c13['code']==='REQUEST_BODY_TOO_LARGE'?0x19d:_0x343c13['code']==='TRANSPORT_DISPOSED'?0x1f7:0x190,'error':{'code':_0x343c13['code']==='TRANSPORT_DISPOSED'?n['ErrorCode']['INTERNAL_ERROR']:n['ErrorCode']['INVALID_ARGUMENT'],'message':_0x343c13['message']}};if(!(_0x343c13 instanceof e['CollabError']))return{'status':0x1f4,'error':{'code':n['ErrorCode']['INTERNAL_ERROR'],'message':'Internal\x20server\x20error'}};let _0x2015b1={'UNAUTHENTICATED':{'status':0x191,'code':n['ErrorCode']['UNAUTHENTICATED']},'INVALID_REQUEST':{'status':0x190,'code':n['ErrorCode']['INVALID_ARGUMENT']},'UNIT_NOT_FOUND':{'status':0x194,'code':n['ErrorCode']['NOT_FOUND']},'PERMISSION_DENIED':{'status':0x193,'code':n['ErrorCode']['PERMISSION_DENIED']},'OT_CONFLICT':{'status':0x199,'code':n['ErrorCode']['APPLY_REJECT']},'REVISION_MISMATCH':{'status':0x199,'code':n['ErrorCode']['CHANGESET_REVISION_CONFILICT']},'ADAPTER_FAILURE':{'status':0x1f7,'code':n['ErrorCode']['INTERNAL_ERROR']},'INTERNAL_ERROR':{'status':0x1f4,'code':n['ErrorCode']['INTERNAL_ERROR']}}[_0x343c13['code']];return{'status':_0x2015b1['status'],'error':{'code':_0x2015b1['code'],'message':_0x343c13['message']}};}function d(_0x5e8a30,_0x570199,_0x4a4690){_0x5e8a30['writableEnded']||_0x5e8a30['destroyed']||(_0x5e8a30['statusCode']=_0x570199,_0x5e8a30['setHeader']('content-type','application/json;\x20charset=utf-8'),_0x5e8a30['end'](JSON['stringify'](_0x4a4690)));}exports['UniverHistoryEndpoint']=i;
1
+ Object['defineProperty'](exports,Symbol['toStringTag'],{'value':'Module'});let e=require('@univerjs-pro/collaboration-service'),t=require('@univerjs-pro/collaboration-transport-node'),n=require('@univerjs/protocol');var r={'code':n['ErrorCode']['OK'],'message':''},i=class{['_service'];['_disposed']=!0x1;constructor(_0x221e7e){if(this['_service']=_0x221e7e,!_0x221e7e)throw TypeError('UniverHistoryEndpoint\x20requires\x20a\x20service');}['register'](_0x1aaca1){if(this['_disposed'])throw new e['CollabError']('INTERNAL_ERROR','History\x20Endpoint\x20is\x20disposed');for(let [_0x79f0c5,_0x3bf562]of[['list','list'],['creators','creators'],['cs','changesets']])_0x1aaca1['get']('/universer-api/history/:unitID/'+_0x79f0c5,_0x2cf606=>this['_handleHttp'](_0x2cf606,{'name':_0x3bf562,'unitID':_0x2cf606['params']['unitID']}));}async['_handleHttp'](_0x58c1fc,_0x54cb11){try{if(this['_disposed'])throw new e['CollabError']('INTERNAL_ERROR','History\x20Endpoint\x20is\x20disposed');let _0x9c326=new URL(_0x58c1fc['incomingMessage']['url']??'/','http://localhost');if(!_0x58c1fc['userID'])throw new e['CollabError']('UNAUTHENTICATED','HTTP\x20user\x20is\x20not\x20authenticated');let _0x30fdc3={'userID':_0x58c1fc['userID'],'customData':_0x58c1fc['customData']};switch(_0x54cb11['name']){case'list':{let _0x4377a8=await this['_service']['getHistoryList']({'unitID':_0x54cb11['unitID'],'length':o(_0x9c326['searchParams']['get']('length')),..._0x9c326['searchParams']['get']('lastLabel')?{'lastLabel':_0x9c326['searchParams']['get']('lastLabel')}:{},...c(_0x9c326['searchParams']['get']('origin')),'userIDs':_0x9c326['searchParams']['getAll']('userIds')['filter'](Boolean)},_0x30fdc3);d(_0x58c1fc['response'],0xc8,{'error':r,...a(_0x4377a8)});return;}case'creators':{let _0x5f5cbe=await this['_service']['listHistoryCreators']({'unitID':_0x54cb11['unitID']},_0x30fdc3);d(_0x58c1fc['response'],0xc8,{'error':r,'creators':_0x5f5cbe['creators']['map'](({userID:_0x5aef46,..._0x45ed74})=>({..._0x45ed74,'userId':_0x5aef46}))});return;}case'changesets':{let _0x2b8858=s(_0x9c326['searchParams']['get']('startRevision'),'startRevision'),_0x13ff3e=s(_0x9c326['searchParams']['get']('endRevision'),'endRevision'),_0x17bc69=await this['_service']['getHistoryChangesets']({'unitID':_0x54cb11['unitID'],'startRevision':_0x2b8858,'endRevision':_0x13ff3e},_0x30fdc3);d(_0x58c1fc['response'],0xc8,{'error':r,..._0x17bc69});return;}}}catch(_0x1f1f61){l(_0x58c1fc['response'],_0x1f1f61);}}['dispose'](){this['_disposed']=!0x0;}};function a(_0x20b9d2){let _0x3f9879=Object['fromEntries'](Object['entries'](_0x20b9d2['entities']['datas'])['map'](([_0x1075be,{userID:_0x47f4b2,unitID:_0x2e3574,userIDs:_0x145961,..._0xf94ec1}])=>[_0x1075be,{..._0xf94ec1,'userId':_0x47f4b2,'unitId':_0x2e3574,'userIds':_0x145961}]));return{..._0x20b9d2,'entities':{..._0x20b9d2['entities'],'datas':_0x3f9879}};}function o(_0x5df715){return _0x5df715===null||_0x5df715===''?0x14:s(_0x5df715,'length');}function s(_0x339ff7,_0x3f9a4b){if(!_0x339ff7||!/^\d+$/['test'](_0x339ff7))throw new e['CollabError']('INVALID_REQUEST',_0x3f9a4b+'\x20must\x20be\x20a\x20positive\x20integer');let _0x243066=Number(_0x339ff7);if(!Number['isSafeInteger'](_0x243066)||_0x243066<0x1)throw new e['CollabError']('INVALID_REQUEST',_0x3f9a4b+'\x20must\x20be\x20a\x20positive\x20integer');return _0x243066;}function c(_0x5ce324){if(_0x5ce324===null||_0x5ce324===''||_0x5ce324==='0')return{};if(_0x5ce324==='1'||_0x5ce324==='2')return{'origin':Number(_0x5ce324)};throw new e['CollabError']('INVALID_REQUEST','origin\x20must\x20be\x200,\x201\x20or\x202');}function l(_0x36e98b,_0x434eb7){let _0x56d9cc=u(_0x434eb7);d(_0x36e98b,_0x56d9cc['status'],{'error':_0x56d9cc['error']});}function u(_0x231901){if(_0x231901 instanceof t['NodeTransportError'])return{'status':_0x231901['code']==='REQUEST_BODY_TOO_LARGE'?0x19d:_0x231901['code']==='TRANSPORT_DISPOSED'?0x1f7:0x190,'error':{'code':_0x231901['code']==='TRANSPORT_DISPOSED'?n['ErrorCode']['INTERNAL_ERROR']:n['ErrorCode']['INVALID_ARGUMENT'],'message':_0x231901['message']}};if(!(_0x231901 instanceof e['CollabError']))return{'status':0x1f4,'error':{'code':n['ErrorCode']['INTERNAL_ERROR'],'message':'Internal\x20server\x20error'}};let _0x4b3781={'UNAUTHENTICATED':{'status':0x191,'code':n['ErrorCode']['UNAUTHENTICATED']},'INVALID_REQUEST':{'status':0x190,'code':n['ErrorCode']['INVALID_ARGUMENT']},'UNIT_NOT_FOUND':{'status':0x194,'code':n['ErrorCode']['NOT_FOUND']},'PERMISSION_DENIED':{'status':0x193,'code':n['ErrorCode']['PERMISSION_DENIED']},'OT_CONFLICT':{'status':0x199,'code':n['ErrorCode']['APPLY_REJECT']},'REVISION_MISMATCH':{'status':0x199,'code':n['ErrorCode']['CHANGESET_REVISION_CONFILICT']},'ADAPTER_FAILURE':{'status':0x1f7,'code':n['ErrorCode']['INTERNAL_ERROR']},'INTERNAL_ERROR':{'status':0x1f4,'code':n['ErrorCode']['INTERNAL_ERROR']}}[_0x231901['code']];return{'status':_0x4b3781['status'],'error':{'code':_0x4b3781['code'],'message':_0x231901['message']}};}function d(_0x2c1b87,_0x35877e,_0xba0566){_0x2c1b87['writableEnded']||_0x2c1b87['destroyed']||(_0x2c1b87['statusCode']=_0x35877e,_0x2c1b87['setHeader']('content-type','application/json;\x20charset=utf-8'),_0x2c1b87['end'](JSON['stringify'](_0xba0566)));}exports['UniverHistoryEndpoint']=i;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- function _0x386e(){const _0x18e98c=['1726390VnFhbT','94ZyQHga','13044APHMsV','486896TMqaxX','2003348fMvlFZ','3GKNoBG','1085IeueVq','3596770eJqmEG','3634884dhyXQS','17466WIWViQ'];_0x386e=function(){return _0x18e98c;};return _0x386e();}(function(_0x2109e1,_0x44fccd){const _0x585cb9=_0x1e2e,_0x4a4d30=_0x2109e1();while(!![]){try{const _0x30a448=parseInt(_0x585cb9(0x1a7))/0x1*(parseInt(_0x585cb9(0x19e))/0x2)+parseInt(_0x585cb9(0x1a1))/0x3*(-parseInt(_0x585cb9(0x1a0))/0x4)+-parseInt(_0x585cb9(0x1a6))/0x5+-parseInt(_0x585cb9(0x1a5))/0x6*(-parseInt(_0x585cb9(0x1a2))/0x7)+parseInt(_0x585cb9(0x19f))/0x8+parseInt(_0x585cb9(0x1a4))/0x9+-parseInt(_0x585cb9(0x1a3))/0xa;if(_0x30a448===_0x44fccd)break;else _0x4a4d30['push'](_0x4a4d30['shift']());}catch(_0x1fb4a7){_0x4a4d30['push'](_0x4a4d30['shift']());}}}(_0x386e,0x4ee93));function _0x1e2e(_0x1ff1fd,_0x4ae511){_0x1ff1fd=_0x1ff1fd-0x19e;const _0x386e08=_0x386e();let _0x1e2e33=_0x386e08[_0x1ff1fd];return _0x1e2e33;}import _0x22bb4a from'./index.cjs';const facadeExport0=_0x22bb4a['UniverHistoryEndpoint'];export{facadeExport0 as UniverHistoryEndpoint};
1
+ function _0xf4fc(_0x4c601b,_0x49b55d){_0x4c601b=_0x4c601b-0xde;const _0x4ed845=_0x4ed8();let _0xf4fc78=_0x4ed845[_0x4c601b];return _0xf4fc78;}const _0x389652=_0xf4fc;(function(_0x43c03a,_0xbbfa80){const _0x234bb6=_0xf4fc,_0x59d82f=_0x43c03a();while(!![]){try{const _0x260eaa=-parseInt(_0x234bb6(0xdf))/0x1+-parseInt(_0x234bb6(0xe5))/0x2*(-parseInt(_0x234bb6(0xe6))/0x3)+-parseInt(_0x234bb6(0xe7))/0x4+parseInt(_0x234bb6(0xe2))/0x5+parseInt(_0x234bb6(0xe4))/0x6*(-parseInt(_0x234bb6(0xde))/0x7)+parseInt(_0x234bb6(0xe0))/0x8+parseInt(_0x234bb6(0xe1))/0x9;if(_0x260eaa===_0xbbfa80)break;else _0x59d82f['push'](_0x59d82f['shift']());}catch(_0x51629f){_0x59d82f['push'](_0x59d82f['shift']());}}}(_0x4ed8,0x91a9f));function _0x4ed8(){const _0x3987c0=['9583vhFFDE','386966oYVCCp','1273352Isxlbu','13736214yxwNkx','521300luaiiv','UniverHistoryEndpoint','3144lMTqIZ','63128wgwLGr','78AfkeoB','3637512edBvFc'];_0x4ed8=function(){return _0x3987c0;};return _0x4ed8();}import _0x2d7763 from'./index.cjs';const facadeExport0=_0x2d7763[_0x389652(0xe3)];export{facadeExport0 as UniverHistoryEndpoint};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@univerjs-pro/collaboration-history-endpoint",
3
3
  "type": "module",
4
- "version": "1.0.0-rc.0",
4
+ "version": "1.0.0",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
7
7
  "types": "./dist/index.d.ts",
@@ -16,9 +16,9 @@
16
16
  "dist"
17
17
  ],
18
18
  "dependencies": {
19
- "@univerjs-pro/collaboration-history-service": "1.0.0-rc.0",
20
- "@univerjs-pro/collaboration-service": "1.0.0-rc.0",
21
- "@univerjs-pro/collaboration-transport-node": "1.0.0-rc.0",
22
- "@univerjs/protocol": "1.0.0-rc.0"
19
+ "@univerjs-pro/collaboration-history-service": "1.0.0",
20
+ "@univerjs-pro/collaboration-service": "1.0.0",
21
+ "@univerjs-pro/collaboration-transport-node": "1.0.0",
22
+ "@univerjs/protocol": "1.0.0"
23
23
  }
24
24
  }