buildx-connect
Version:
Official JavaScript/TypeScript SDK for Buildx low-code platform
85 lines (84 loc) • 2.33 kB
TypeScript
import { AxiosInstance, AxiosRequestConfig } from "axios";
import { BuildxConfig, ApiHeaders, ErrorResponse } from "../types";
/**
* Base service class that provides common functionality for all Buildx services
*/
export declare class BaseService {
config: BuildxConfig;
axiosInstance: AxiosInstance;
private _accessToken;
private _refreshToken;
constructor(config: BuildxConfig);
/**
* Update the service configuration
*/
updateConfig(config: BuildxConfig): void;
/**
* Set the access token
*/
setAccessToken(token: string | null): void;
/**
* Get the access token
*/
getAccessToken(): string | null;
/**
* Set the refresh token
*/
setRefreshToken(token: string | null): void;
/**
* Get the refresh token
*/
getRefreshToken(): string | null;
/**
* Clear all stored tokens
*/
clearTokens(): void;
/**
* Check if user is authenticated (has access token)
*/
isAuthenticated(): boolean;
/**
* Get default headers with authentication
*/
getHeaders(useRefreshToken?: boolean): Promise<ApiHeaders>;
/**
* Get headers without authentication (for public endpoints)
*/
getPublicHeaders(): ApiHeaders;
/**
* Make a GET request
*/
get<T = any>(url: string, config?: AxiosRequestConfig): Promise<T>;
/**
* Make a POST request
*/
post<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T>;
/**
* Make a PUT request
*/
put<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T>;
/**
* Make a PATCH request
*/
patch<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T>;
/**
* Make a DELETE request
*/
delete<T = any>(url: string, config?: AxiosRequestConfig): Promise<T>;
/**
* Handle API errors
*/
handleError(error: any): ErrorResponse;
/**
* Build URL with project ID
*/
buildProjectUrl(projectId?: string, path?: string): string;
/**
* Build URL with organization ID
*/
buildOrgUrl(organizationId?: string, path?: string): string;
/**
* Build query string from options
*/
buildQueryString(options: Record<string, any>): string;
}