@openvcs/sdk 0.4.2 → 0.4.3-beta.145
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/lib/runtime/vcs-delegate-base.d.ts +4 -0
- package/lib/runtime/vcs-delegate-base.js +8 -0
- package/lib/runtime/vcs-delegate-metadata.d.ts +4 -0
- package/lib/runtime/vcs-delegate-metadata.js +2 -0
- package/lib/types/vcs.d.ts +21 -0
- package/package.json +1 -1
- package/src/lib/runtime/vcs-delegate-base.ts +16 -0
- package/src/lib/runtime/vcs-delegate-metadata.ts +4 -0
- package/src/lib/types/vcs.ts +24 -0
- package/test/vcs-delegate-base.test.js +27 -0
- package/test/vcs-delegate-base.types.ts +10 -1
|
@@ -125,5 +125,9 @@ export declare abstract class VcsDelegateBase<TDeps, TContext = PluginRuntimeCon
|
|
|
125
125
|
cherryPick(_params: VcsTypes.VcsCherryPickParams, _context: TContext): VcsHandlerResult<null>;
|
|
126
126
|
/** Handles `vcs.revert_commit`. */
|
|
127
127
|
revertCommit(_params: VcsTypes.VcsRevertCommitParams, _context: TContext): VcsHandlerResult<null>;
|
|
128
|
+
/** Handles `vcs.validate_url`. */
|
|
129
|
+
validateUrl(_params: VcsTypes.VcsValidateUrlParams, _context: TContext): VcsHandlerResult<VcsTypes.VcsValidationResult>;
|
|
130
|
+
/** Handles `vcs.validate_path`. */
|
|
131
|
+
validatePath(_params: VcsTypes.VcsValidatePathParams, _context: TContext): VcsHandlerResult<VcsTypes.VcsValidationResult>;
|
|
128
132
|
}
|
|
129
133
|
export {};
|
|
@@ -253,5 +253,13 @@ class VcsDelegateBase {
|
|
|
253
253
|
revertCommit(_params, _context) {
|
|
254
254
|
return this.unimplemented('revertCommit');
|
|
255
255
|
}
|
|
256
|
+
/** Handles `vcs.validate_url`. */
|
|
257
|
+
validateUrl(_params, _context) {
|
|
258
|
+
return this.unimplemented('validateUrl');
|
|
259
|
+
}
|
|
260
|
+
/** Handles `vcs.validate_path`. */
|
|
261
|
+
validatePath(_params, _context) {
|
|
262
|
+
return this.unimplemented('validatePath');
|
|
263
|
+
}
|
|
256
264
|
}
|
|
257
265
|
exports.VcsDelegateBase = VcsDelegateBase;
|
|
@@ -54,6 +54,8 @@ export type VcsDelegateBindings<TContext> = {
|
|
|
54
54
|
stashShow: NonNullable<VcsTypes.VcsDelegates<TContext>['vcs.stash_show']>;
|
|
55
55
|
cherryPick: NonNullable<VcsTypes.VcsDelegates<TContext>['vcs.cherry_pick']>;
|
|
56
56
|
revertCommit: NonNullable<VcsTypes.VcsDelegates<TContext>['vcs.revert_commit']>;
|
|
57
|
+
validateUrl: NonNullable<VcsTypes.VcsDelegates<TContext>['vcs.validate_url']>;
|
|
58
|
+
validatePath: NonNullable<VcsTypes.VcsDelegates<TContext>['vcs.validate_path']>;
|
|
57
59
|
};
|
|
58
60
|
/** Enumerates the class-friendly method names recognized by `VcsDelegateBase`. */
|
|
59
61
|
export type VcsDelegateMethodName = keyof VcsDelegateBindings<PluginRuntimeContext>;
|
|
@@ -111,6 +113,8 @@ export declare const VCS_DELEGATE_METHOD_MAPPINGS: {
|
|
|
111
113
|
readonly stashShow: "vcs.stash_show";
|
|
112
114
|
readonly cherryPick: "vcs.cherry_pick";
|
|
113
115
|
readonly revertCommit: "vcs.revert_commit";
|
|
116
|
+
readonly validateUrl: "vcs.validate_url";
|
|
117
|
+
readonly validatePath: "vcs.validate_path";
|
|
114
118
|
};
|
|
115
119
|
/** Resolves the RPC method implemented by one class-friendly delegate method. */
|
|
116
120
|
export type VcsDelegateRpcMethodName<TMethodName extends VcsDelegateMethodName> = (typeof VCS_DELEGATE_METHOD_MAPPINGS)[TMethodName];
|
package/lib/types/vcs.d.ts
CHANGED
|
@@ -395,6 +395,23 @@ export interface VcsRevertCommitParams extends VcsSessionParams {
|
|
|
395
395
|
/** Indicates whether the editor should be skipped. */
|
|
396
396
|
no_edit?: boolean;
|
|
397
397
|
}
|
|
398
|
+
/** Describes the result returned by URL or path validation. */
|
|
399
|
+
export interface VcsValidationResult {
|
|
400
|
+
/** Indicates whether the URL or path is valid for this backend. */
|
|
401
|
+
ok: boolean;
|
|
402
|
+
/** Stores an optional human-readable reason when validation fails. */
|
|
403
|
+
reason?: string;
|
|
404
|
+
}
|
|
405
|
+
/** Describes params for `vcs.validate_url`. */
|
|
406
|
+
export interface VcsValidateUrlParams extends RequestParams {
|
|
407
|
+
/** Stores the repository URL to validate. */
|
|
408
|
+
url: string;
|
|
409
|
+
}
|
|
410
|
+
/** Describes params for `vcs.validate_path`. */
|
|
411
|
+
export interface VcsValidatePathParams extends RequestParams {
|
|
412
|
+
/** Stores the local path to validate. */
|
|
413
|
+
path: string;
|
|
414
|
+
}
|
|
398
415
|
/** Describes the delegate map supported by the SDK runtime for `vcs.*`. */
|
|
399
416
|
export interface VcsDelegates<TContext = unknown> {
|
|
400
417
|
/** Handles `vcs.get_caps`. */
|
|
@@ -501,4 +518,8 @@ export interface VcsDelegates<TContext = unknown> {
|
|
|
501
518
|
'vcs.cherry_pick'?: RpcMethodHandler<VcsCherryPickParams, null, TContext>;
|
|
502
519
|
/** Handles `vcs.revert_commit`. */
|
|
503
520
|
'vcs.revert_commit'?: RpcMethodHandler<VcsRevertCommitParams, null, TContext>;
|
|
521
|
+
/** Handles `vcs.validate_url`. */
|
|
522
|
+
'vcs.validate_url'?: RpcMethodHandler<VcsValidateUrlParams, VcsValidationResult, TContext>;
|
|
523
|
+
/** Handles `vcs.validate_path`. */
|
|
524
|
+
'vcs.validate_path'?: RpcMethodHandler<VcsValidatePathParams, VcsValidationResult, TContext>;
|
|
504
525
|
}
|
package/package.json
CHANGED
|
@@ -494,4 +494,20 @@ export abstract class VcsDelegateBase<
|
|
|
494
494
|
): VcsHandlerResult<null> {
|
|
495
495
|
return this.unimplemented('revertCommit');
|
|
496
496
|
}
|
|
497
|
+
|
|
498
|
+
/** Handles `vcs.validate_url`. */
|
|
499
|
+
validateUrl(
|
|
500
|
+
_params: VcsTypes.VcsValidateUrlParams,
|
|
501
|
+
_context: TContext,
|
|
502
|
+
): VcsHandlerResult<VcsTypes.VcsValidationResult> {
|
|
503
|
+
return this.unimplemented('validateUrl');
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/** Handles `vcs.validate_path`. */
|
|
507
|
+
validatePath(
|
|
508
|
+
_params: VcsTypes.VcsValidatePathParams,
|
|
509
|
+
_context: TContext,
|
|
510
|
+
): VcsHandlerResult<VcsTypes.VcsValidationResult> {
|
|
511
|
+
return this.unimplemented('validatePath');
|
|
512
|
+
}
|
|
497
513
|
}
|
|
@@ -89,6 +89,8 @@ export type VcsDelegateBindings<TContext> = {
|
|
|
89
89
|
stashShow: NonNullable<VcsTypes.VcsDelegates<TContext>['vcs.stash_show']>;
|
|
90
90
|
cherryPick: NonNullable<VcsTypes.VcsDelegates<TContext>['vcs.cherry_pick']>;
|
|
91
91
|
revertCommit: NonNullable<VcsTypes.VcsDelegates<TContext>['vcs.revert_commit']>;
|
|
92
|
+
validateUrl: NonNullable<VcsTypes.VcsDelegates<TContext>['vcs.validate_url']>;
|
|
93
|
+
validatePath: NonNullable<VcsTypes.VcsDelegates<TContext>['vcs.validate_path']>;
|
|
92
94
|
};
|
|
93
95
|
|
|
94
96
|
/** Enumerates the class-friendly method names recognized by `VcsDelegateBase`. */
|
|
@@ -148,6 +150,8 @@ export const VCS_DELEGATE_METHOD_MAPPINGS = {
|
|
|
148
150
|
stashShow: 'vcs.stash_show',
|
|
149
151
|
cherryPick: 'vcs.cherry_pick',
|
|
150
152
|
revertCommit: 'vcs.revert_commit',
|
|
153
|
+
validateUrl: 'vcs.validate_url',
|
|
154
|
+
validatePath: 'vcs.validate_path',
|
|
151
155
|
} as const satisfies Record<
|
|
152
156
|
VcsDelegateMethodName,
|
|
153
157
|
keyof VcsTypes.VcsDelegates<PluginRuntimeContext>
|
package/src/lib/types/vcs.ts
CHANGED
|
@@ -455,6 +455,26 @@ export interface VcsRevertCommitParams extends VcsSessionParams {
|
|
|
455
455
|
no_edit?: boolean;
|
|
456
456
|
}
|
|
457
457
|
|
|
458
|
+
/** Describes the result returned by URL or path validation. */
|
|
459
|
+
export interface VcsValidationResult {
|
|
460
|
+
/** Indicates whether the URL or path is valid for this backend. */
|
|
461
|
+
ok: boolean;
|
|
462
|
+
/** Stores an optional human-readable reason when validation fails. */
|
|
463
|
+
reason?: string;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/** Describes params for `vcs.validate_url`. */
|
|
467
|
+
export interface VcsValidateUrlParams extends RequestParams {
|
|
468
|
+
/** Stores the repository URL to validate. */
|
|
469
|
+
url: string;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
/** Describes params for `vcs.validate_path`. */
|
|
473
|
+
export interface VcsValidatePathParams extends RequestParams {
|
|
474
|
+
/** Stores the local path to validate. */
|
|
475
|
+
path: string;
|
|
476
|
+
}
|
|
477
|
+
|
|
458
478
|
/** Describes the delegate map supported by the SDK runtime for `vcs.*`. */
|
|
459
479
|
export interface VcsDelegates<TContext = unknown> {
|
|
460
480
|
/** Handles `vcs.get_caps`. */
|
|
@@ -629,4 +649,8 @@ export interface VcsDelegates<TContext = unknown> {
|
|
|
629
649
|
'vcs.cherry_pick'?: RpcMethodHandler<VcsCherryPickParams, null, TContext>;
|
|
630
650
|
/** Handles `vcs.revert_commit`. */
|
|
631
651
|
'vcs.revert_commit'?: RpcMethodHandler<VcsRevertCommitParams, null, TContext>;
|
|
652
|
+
/** Handles `vcs.validate_url`. */
|
|
653
|
+
'vcs.validate_url'?: RpcMethodHandler<VcsValidateUrlParams, VcsValidationResult, TContext>;
|
|
654
|
+
/** Handles `vcs.validate_path`. */
|
|
655
|
+
'vcs.validate_path'?: RpcMethodHandler<VcsValidatePathParams, VcsValidationResult, TContext>;
|
|
632
656
|
}
|
|
@@ -254,3 +254,30 @@ test('all VcsDelegateBase stubs throw method-specific errors', () => {
|
|
|
254
254
|
);
|
|
255
255
|
}
|
|
256
256
|
});
|
|
257
|
+
|
|
258
|
+
test('VcsDelegateBase maps validateUrl and validatePath to rpc delegates', () => {
|
|
259
|
+
class ValidationDelegates extends VcsDelegateBase {
|
|
260
|
+
validateUrl(params) {
|
|
261
|
+
return { ok: params.url.includes('.git') };
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
validatePath(params) {
|
|
265
|
+
return { ok: params.path.endsWith('.git') };
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
const delegates = new ValidationDelegates({}).toDelegates();
|
|
270
|
+
assert.deepEqual(Object.keys(delegates).sort(), ['vcs.validate_path', 'vcs.validate_url']);
|
|
271
|
+
|
|
272
|
+
const urlResult = delegates['vcs.validate_url']({ url: 'https://example.com/repo.git' }, {});
|
|
273
|
+
assert.strictEqual(urlResult.ok, true);
|
|
274
|
+
|
|
275
|
+
const urlResultFail = delegates['vcs.validate_url']({ url: 'https://example.com/repo' }, {});
|
|
276
|
+
assert.strictEqual(urlResultFail.ok, false);
|
|
277
|
+
|
|
278
|
+
const pathResult = delegates['vcs.validate_path']({ path: '/repo/.git' }, {});
|
|
279
|
+
assert.strictEqual(pathResult.ok, true);
|
|
280
|
+
|
|
281
|
+
const pathResultFail = delegates['vcs.validate_path']({ path: '/repo' }, {});
|
|
282
|
+
assert.strictEqual(pathResultFail.ok, false);
|
|
283
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright © 2025-2026 OpenVCS Contributors
|
|
2
2
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
3
3
|
|
|
4
|
-
import type { RequestParams, VcsCapabilities } from '../src/lib/types';
|
|
4
|
+
import type { RequestParams, VcsCapabilities, VcsValidationResult } from '../src/lib/types';
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
7
|
VcsDelegateBase,
|
|
@@ -42,3 +42,12 @@ class InvalidVcsDelegates extends VcsDelegateBase<{}> {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
new InvalidVcsDelegates({});
|
|
45
|
+
|
|
46
|
+
class InvalidValidateOverride extends VcsDelegateBase<{}> {
|
|
47
|
+
// @ts-expect-error `validateUrl` must return `VcsValidationResult`.
|
|
48
|
+
override validateUrl(): string {
|
|
49
|
+
return 'invalid';
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
new InvalidValidateOverride({});
|