@@ -26,6 +26,9 @@ interface PapiBackendTestMock {
2626/**
2727 * Type guard for the mocked @papi/backend default export. Allows destructuring mocks without type
2828 * assertions.
29+ *
30+ * @param m - The value to test, typically the default export of the mocked module.
31+ * @returns `true` if `m` exposes all expected `__mock*` properties.
2932 */
3033function isPapiBackendTestMock ( m : unknown ) : m is PapiBackendTestMock {
3134 return (
@@ -74,6 +77,12 @@ type WebViewProvider = {
7477 ) : Promise < WebViewDefinition | undefined > ;
7578} ;
7679
80+ /**
81+ * Type guard that narrows an unknown value to a {@link WebViewProvider}.
82+ *
83+ * @param x - The value to test.
84+ * @returns `true` if `x` has a callable `getWebView` method.
85+ */
7786function isWebViewProvider ( x : unknown ) : x is WebViewProvider {
7887 return ! ! x && typeof x === 'object' && 'getWebView' in x && typeof x . getWebView === 'function' ;
7988}
@@ -85,12 +94,26 @@ function getRegisteredProvider(): WebViewProvider {
8594 return raw ;
8695}
8796
97+ /**
98+ * Finds the handler registered for `commandName` in the most recent `activate()` call.
99+ *
100+ * @param commandName - The fully-qualified command name to look up.
101+ * @returns The registered handler function, or `undefined` if none was registered for that name.
102+ */
88103function findRegisteredHandler ( commandName : string ) : ( ( ...args : unknown [ ] ) => unknown ) | undefined {
89104 const call = jest . mocked ( __mockRegisterCommand ) . mock . calls . find ( ( c ) => c [ 0 ] === commandName ) ;
90105 const rawHandler : unknown = call ?. [ 1 ] ;
91106 return isCallable ( rawHandler ) ? rawHandler : undefined ;
92107}
93108
109+ /**
110+ * Activates the extension and returns a typed wrapper around the `interlinearizer.openForWebView`
111+ * command handler.
112+ *
113+ * @returns A function that invokes the handler with an optional WebView ID and resolves to the
114+ * opened WebView ID string, or `undefined` if the handler returns a non-string.
115+ * @throws If the handler was not registered during `activate()`.
116+ */
94117async function getOpenForWebViewHandler ( ) : Promise <
95118 ( webViewId ?: string ) => Promise < string | undefined >
96119> {
@@ -128,6 +151,14 @@ function getCloseWebViewCallback(): (event: { webView: SavedWebViewDefinition })
128151 return ( event ) => cb ( event ) ;
129152}
130153
154+ /**
155+ * Activates the extension and returns a typed wrapper around the `interlinearizer.createProject`
156+ * command handler.
157+ *
158+ * @returns A function that invokes the handler with a source project ID and analysis languages,
159+ * resolving to the JSON-stringified project or `undefined` if the handler returns a non-string.
160+ * @throws If the handler was not registered during `activate()`.
161+ */
131162async function getCreateProjectHandler ( ) : Promise <
132163 ( sourceProjectId : string , analysisLanguages : string [ ] ) => Promise < string | undefined >
133164> {
@@ -144,6 +175,14 @@ async function getCreateProjectHandler(): Promise<
144175 } ;
145176}
146177
178+ /**
179+ * Activates the extension and returns a typed wrapper around the `interlinearizer.deleteProject`
180+ * command handler.
181+ *
182+ * @returns A function that invokes the handler with a project UUID and resolves when deletion
183+ * completes.
184+ * @throws If the handler was not registered during `activate()`.
185+ */
147186async function getDeleteProjectHandler ( ) : Promise < ( id : string ) => Promise < void > > {
148187 const context = createTestActivationContext ( ) ;
149188 await activate ( context ) ;
@@ -154,6 +193,14 @@ async function getDeleteProjectHandler(): Promise<(id: string) => Promise<void>>
154193 } ;
155194}
156195
196+ /**
197+ * Activates the extension and returns a typed wrapper around the
198+ * `interlinearizer.getProjectsForSource` command handler.
199+ *
200+ * @returns A function that invokes the handler with a source project ID and resolves to the
201+ * JSON-stringified project array (falls back to `'[]'` if the handler returns a non-string).
202+ * @throws If the handler was not registered during `activate()`.
203+ */
157204async function getProjectsForSourceHandler ( ) : Promise <
158205 ( sourceProjectId : string ) => Promise < string >
159206> {
@@ -167,6 +214,15 @@ async function getProjectsForSourceHandler(): Promise<
167214 } ;
168215}
169216
217+ /**
218+ * Activates the extension and returns a typed wrapper around the
219+ * `interlinearizer.updateProjectMetadata` command handler.
220+ *
221+ * @returns A function that invokes the handler with a project UUID and updated fields, resolving to
222+ * the JSON-stringified updated project or `undefined` if the project was not found or the handler
223+ * returns a non-string.
224+ * @throws If the handler was not registered during `activate()`.
225+ */
170226async function getUpdateProjectMetadataHandler ( ) : Promise <
171227 (
172228 id : string ,
0 commit comments