1- import axios from "axios" ;
2- import * as https from "https" ;
31import * as path from "path" ;
42import * as vscode from "vscode" ;
53
6- import { AtelierAPI } from "../api" ;
7- import { handleError } from "../utils" ;
4+ import { AtelierAPI } from "../../api" ;
5+ import { SourceControlApi } from "../../api/ccs/sourceControl" ;
6+ import { handleError } from "../../utils" ;
87
98interface ResolveContextExpressionResponse {
109 status ?: string ;
@@ -30,43 +29,20 @@ export async function resolveContextExpression(): Promise<void> {
3029
3130 const routine = path . basename ( document . fileName ) ;
3231 const api = new AtelierAPI ( document . uri ) ;
33- const { host, port, username, password, https : useHttps , pathPrefix } = api . config ;
3432
35- if ( ! host || ! port ) {
36- void vscode . window . showErrorMessage ( "No active InterSystems server connection for this file." ) ;
33+ let sourceControlApi : SourceControlApi ;
34+ try {
35+ sourceControlApi = SourceControlApi . fromAtelierApi ( api ) ;
36+ } catch ( error ) {
37+ void vscode . window . showErrorMessage ( error instanceof Error ? error . message : String ( error ) ) ;
3738 return ;
3839 }
3940
40- const normalizedPrefix = pathPrefix ? ( pathPrefix . startsWith ( "/" ) ? pathPrefix : `/${ pathPrefix } ` ) : "" ;
41-
42- const baseUrl = `${ useHttps ? "https" : "http" } ://${ host } :${ port } ${ encodeURI ( normalizedPrefix ) } ` ;
43- const url = `${ baseUrl } /api/sourcecontrol/vscode/resolveContextExpression` ;
44-
45- const httpsAgent = new https . Agent ( {
46- rejectUnauthorized : vscode . workspace . getConfiguration ( "http" ) . get ( "proxyStrictSSL" ) ,
47- } ) ;
48-
4941 try {
50- const response = await axios . post < ResolveContextExpressionResponse > (
51- url ,
52- {
53- routine,
54- contextExpression,
55- } ,
56- {
57- headers : {
58- "Content-Type" : "application/json" ,
59- } ,
60- auth :
61- typeof username === "string" && typeof password === "string"
62- ? {
63- username,
64- password,
65- }
66- : undefined ,
67- httpsAgent,
68- }
69- ) ;
42+ const response = await sourceControlApi . post < ResolveContextExpressionResponse > ( "/resolveContextExpression" , {
43+ routine,
44+ contextExpression,
45+ } ) ;
7046
7147 const data = response . data ?? { } ;
7248 if ( typeof data . status === "string" && data . status . toLowerCase ( ) === "success" && data . textExpression ) {
0 commit comments