@cpanel/api
Version:
cPanel API JavaScript and TypeScript interface libraries. This library provides a set of classes for calling cPanel WHM API 1 and UAPI calls. The classes hide much of the complexity of these APIs behind classes the abstract the underlying variances betwee
135 lines (134 loc) • 3.97 kB
TypeScript
import { LocationService } from "./location-service";
/**
* Check if the protocol is https.
* @param protocol Protocol to test
* @return true if its https: in any case, false otherwise.
*/
export declare function isHttps(protocol: string): boolean;
/**
* Check if the protocol is http.
* @param protocol Protocol to test
* @return true if its http: in any case, false otherwise.
*/
export declare function isHttp(protocol: string): boolean;
/**
* Strip any trailing slashes from a string.
*
* @method stripTrailingSlash
* @param path The path string to process.
* @return The path string without a trailing slash.
*/
export declare function stripTrailingSlash(path: string): string;
/**
* Add a trailing slash to a string if it doesn't have one.
*
* @method ensureTrailingSlash
* @param path The path string to process.
* @return The path string with a guaranteed trailing slash.
*/
export declare function ensureTrailingSlash(path: string): string;
/**
* Helper class used to calculate paths within cPanel applications.
*/
export declare class ApplicationPath {
private unprotectedPaths;
/**
* Name of the application
*/
applicationName: string;
/**
* Protocol used to access the page.
*/
protocol: string;
/**
* Port used to access the product.
*/
port: number;
/**
* Path part of the URL.
*/
path: string;
/**
* Domain used to access the page.
*/
domain: string;
/**
*Session token.
*/
securityToken: string;
/**
* The path to the application.
*/
applicationPath: string;
/**
* The name of the theme in the path.
*/
theme: string;
/**
* The theme path.
*/
themePath: string;
/**
* Just the protocol, domain, and port.
*/
rootUrl: string;
/**
* Create the PathHelper. This class is used to help generate paths
* within an application. It has special knowledge about how paths are
* constructed in the cPanel family of applications.
*
* @param location Abstraction for the window.location object to aid in unit testing this module.
*/
constructor(location: LocationService);
/**
* Return whether we are running inside some other framework or application
*
* @return true if this is an unrecognized application or framework; false otherwise
*/
get isOther(): boolean;
/**
* Return whether we are running inside an unprotected path
*
* @return true if this is unprotected; false otherwise
*/
get isUnprotected(): boolean;
/**
* Return whether we are running inside cPanel or something else (e.g., WHM)
*
* @return true if this is cPanel; false otherwise
*/
get isCpanel(): boolean;
/**
* Return whether we are running inside WHM or something else (e.g., WHM)
*
* @return true if this is WHM; false otherwise
*/
get isWhm(): boolean;
/**
* Return whether we are running inside WHM or something else (e.g., WHM)
*
* @return true if this is Webmail; false otherwise
*/
get isWebmail(): boolean;
/**
* Get the domain relative path for the relative URL path.
*
* @param relative Relative path to the resource.
* @return Domain relative URL path including theme, if applicable, for the application to the file.
*/
buildPath(relative: string): string;
/**
* Get the full url path for the relative URL path.
*
* @param relative Relative path to the resource.
* @return Full URL path including theme, if applicable, for the application to the file.
*/
buildFullPath(relative: string): string;
/**
* Build a path relative to the security token
*
* @param relative Relative path to the resource.
* @return Full path to the token relative resource.
*/
buildTokenPath(relative: string): string;
}