@feng0531/dsh-vcs 0.8.5 → 0.8.7

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/index.mjs CHANGED
@@ -3,7 +3,6 @@ import {readFileSync} from 'node:fs';
3
3
  import {registerFrontendAssets} from './frontend-assets.mjs';
4
4
  const runningFrontend=JSON.parse(readFileSync(new URL('./dist/frontend.json',import.meta.url),'utf8'));
5
5
  import * as adapter from './vcs.mjs';
6
- import * as branchAdapter from './branch-switch.mjs';
7
6
  import {createIndexUnstageCoordinator} from './index-change-host.mjs';
8
7
  import {createIndexStageCoordinator} from './index-stage-host.mjs';
9
8
  import {createCommitCoordinator} from './commit-host.mjs';
@@ -15,9 +14,8 @@ import {encodeGitTag} from './src/git-tag-object.mjs';
15
14
  import {createPartialStageCoordinator} from './partial-stage-host.mjs';
16
15
  import {createPartialUnstageCoordinator} from './partial-unstage-host.mjs';
17
16
  import {createLineStageCoordinator,createLineUnstageCoordinator} from './line-index-host.mjs';
18
- import {createBranchSwitchCoordinator,acquireRepositoryAccess} from './branch-switch-host.mjs';
17
+ import {acquireRepositoryAccess} from './confirmed-operation.mjs';
19
18
  import {withOperationBudget} from './src/operation-budget.mjs';
20
- import {runtimeInfo,checkUpdate} from './dist/updates.mjs';
21
19
  import {createSvnHttpsHost} from './dist/svn-host.mjs';
22
20
  import {historySearchArgs,validateDateBound,isObjectId,isChangeId} from './git-history.mjs';
23
21
 
@@ -452,10 +450,9 @@ async function readRepository(api, endpoint, repository, payload, {cwd, mode, si
452
450
  }
453
451
 
454
452
  /** Limit active adapter operations and retain only bounded, short-lived discovery grants. */
455
- export function createHandler(ctx, api = {...adapter,...branchAdapter}, maxActive = 4, { now = Date.now, ttlMs = 5 * 60_000, maxSessions = 32, maxRepositories = 512, operationTimeoutMs = 15000, bindSvnIdentityResolver } = {}) {
453
+ export function createHandler(ctx, api = adapter, maxActive = 4, { now = Date.now, ttlMs = 5 * 60_000, maxSessions = 32, maxRepositories = 512, operationTimeoutMs = 15000, bindSvnIdentityResolver } = {}) {
456
454
  let active = 0, activeImages = 0, activeSegments = 0;
457
455
  const sessions = new Map();
458
- const branchSwitch=createBranchSwitchCoordinator({api,now});
459
456
  const commit=createCommitCoordinator({api,now});
460
457
  const amend=createAmendCoordinator({api,now});
461
458
  const branchCreate=createBranchCreateCoordinator({api,now});
@@ -480,7 +477,6 @@ export function createHandler(ctx, api = {...adapter,...branchAdapter}, maxActiv
480
477
  const lineUnstage=createLineUnstageCoordinator({api,now});
481
478
 
482
479
  const clearGrantCache = entry => {
483
- branchSwitch.invalidate(entry);
484
480
  branchCreate.invalidate(entry);
485
481
  tagCreate.invalidate(entry);
486
482
  lightweightTag.invalidate(entry);
@@ -533,20 +529,6 @@ export function createHandler(ctx, api = {...adapter,...branchAdapter}, maxActiv
533
529
  });
534
530
  }
535
531
 
536
- /** Update queries accept no fields and are admitted separately from repository reads. */
537
- async function handleUpdateRequest(endpoint, payload, signal) {
538
- try {
539
- signal?.throwIfAborted();
540
- if (!payload || typeof payload !== 'object' || Array.isArray(payload) || Object.keys(payload).length) throw invalid('Update requests accept no fields.');
541
- if (endpoint === 'vcs/runtime-info') return {ok: true, value: runtimeInfo()};
542
- if (active >= maxActive) return failure('vcs/busy', 'Too many VCS requests. Please retry.');
543
- active++;
544
- try { return {ok: true, value: await checkUpdate({signal})}; } finally { active--; }
545
- } catch (error) {
546
- return failure(signal?.aborted ? 'vcs/cancelled' : 'vcs/update-failed', error.message);
547
- }
548
- }
549
-
550
532
  /** Discovery creates, replaces or merges grants; a stale scan can never resurrect one. */
551
533
  async function discoverRepositories(payload, cwd, entry, signal) {
552
534
  if (!entry) {
@@ -613,7 +595,7 @@ export function createHandler(ctx, api = {...adapter,...branchAdapter}, maxActiv
613
595
  }
614
596
 
615
597
  const execute = async (endpoint, payload, signal) => {
616
- if (UPDATE_ENDPOINTS.has(endpoint)) return handleUpdateRequest(endpoint, payload, signal);
598
+ if (UPDATE_ENDPOINTS.has(endpoint) || ['vcs/branches','vcs/branch-switch-prepare','vcs/branch-switch-confirm'].includes(endpoint)) return failure('vcs/not-found', 'This VCS feature has been removed.');
617
599
  if (!ACTION_ENDPOINTS.has(endpoint)) return failure('vcs/not-found', 'Unknown VCS endpoint.');
618
600
  if (active >= maxActive) return failure('vcs/busy', 'Too many VCS requests. Please retry.');
619
601
  active++;
@@ -655,10 +637,6 @@ export function createHandler(ctx, api = {...adapter,...branchAdapter}, maxActiv
655
637
  try{return {ok:true,value:await commit.confirm(payload,{entry,repository,cwd,signal,assertAuthorized:authorize})};}
656
638
  finally{api.clearHistoricalCache?.(repository.root);}
657
639
  }
658
- if(endpoint==='vcs/branch-switch-confirm'){
659
- try{return {ok:true,value:await branchSwitch.confirm(payload,{entry,repository,cwd,signal,assertAuthorized:authorize})};}
660
- finally{api.clearHistoricalCache?.(repository.root);}
661
- }
662
640
  if(endpoint==='vcs/index-unstage-confirm'){
663
641
  try{return {ok:true,value:await indexUnstage.confirm(payload,{entry,repository,cwd,signal,assertAuthorized:authorize})};}
664
642
  finally{api.clearHistoricalCache?.(repository.root);}
@@ -687,8 +665,6 @@ export function createHandler(ctx, api = {...adapter,...branchAdapter}, maxActiv
687
665
  if(endpoint==='vcs/branch-create-prepare')return {ok:true,value:await branchCreate.prepare(payload,{entry,repository,cwd,signal,assertAuthorized:authorize})};
688
666
  if(endpoint==='vcs/amend-prepare')return {ok:true,value:await amend.prepare(payload,{entry,repository,cwd,signal,assertAuthorized:authorize})};
689
667
  if(endpoint==='vcs/commit-prepare')return {ok:true,value:await commit.prepare(payload,{entry,repository,cwd,signal,assertAuthorized:authorize})};
690
- if(endpoint==='vcs/branches'){const value=await api.listLocalBranches({...repository},{signal});await authorize();return {ok:true,value};}
691
- if(endpoint==='vcs/branch-switch-prepare')return {ok:true,value:await branchSwitch.prepare(payload,{entry,repository,cwd,signal,assertAuthorized:authorize})};
692
668
  if(endpoint==='vcs/index-unstage-prepare')return {ok:true,value:await indexUnstage.prepare({...payload,path:payload.id},{entry,repository,cwd,signal,assertAuthorized:authorize})};
693
669
  if(endpoint==='vcs/index-stage-prepare')return {ok:true,value:await indexStage.prepare({...payload,path:payload.id},{entry,repository,cwd,signal,assertAuthorized:authorize})};
694
670
  if(endpoint==='vcs/partial-stage-plan')return {ok:true,value:await partialStage.plan(payload,{entry,repository,cwd,signal,assertAuthorized:authorize})};
@@ -746,7 +722,7 @@ export function createHandler(ctx, api = {...adapter,...branchAdapter}, maxActiv
746
722
  return failure(error?.code === 'TIMEOUT' ? 'vcs/timeout' : 'vcs/operation-failed', error.message);
747
723
  }
748
724
  };
749
- handle.dispose=()=>{lightweightTag.clear();tagCreate.clear();branchCreate.clear();amend.clear();commit.clear();branchSwitch.clear();indexUnstage.clear();indexStage.clear();partialStage.clear();partialUnstage.clear();lineStage.clear();lineUnstage.clear();for(const id of sessions.keys())revokeSession(id);};
725
+ handle.dispose=()=>{lightweightTag.clear();tagCreate.clear();branchCreate.clear();amend.clear();commit.clear();indexUnstage.clear();indexStage.clear();partialStage.clear();partialUnstage.clear();lineStage.clear();lineUnstage.clear();for(const id of sessions.keys())revokeSession(id);};
750
726
  return handle;
751
727
  }
752
728
 
@@ -797,7 +773,7 @@ export function registerDirectAssets(ctx, load = filename => readFile(new URL('.
797
773
  export function apply(ctx) {
798
774
  // Pass the plugin owner explicitly: the nested rpc getter can retain the
799
775
  // connection service context, which does not inject webServer.
800
- const host=createSvnHttpsHost(ctx,{...adapter,...branchAdapter});
776
+ const host=createSvnHttpsHost(ctx,adapter);
801
777
  ctx.effect(()=>()=>{ host.dispose(); adapter.clearHistoricalCache?.(); });
802
778
  ctx.connection.register(ctx, RPC_CHANNEL, host.handle);
803
779
  registerAssets(ctx);
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@feng0531/dsh-vcs",
3
- "version": "0.8.5",
3
+ "version": "0.8.7",
4
4
  "private": false,
5
5
  "publishConfig": { "access": "public", "registry": "https://registry.npmjs.org/" },
6
6
  "type": "module",
7
- "description": "Git and SVN change preview with confirmed safe local Git branch switching for DSH",
7
+ "description": "Git and SVN change preview and confirmed local Git index and commit operations for DSH",
8
8
  "exports": {
9
9
  ".": "./index.mjs",
10
10
  "./client": "./dist/client.js",