@qbraid-core/ibm-cloud
Version:
Client for interacting with IBM's Qiskit Runtime Service via the IBM Cloud API.
99 lines (98 loc) • 3.67 kB
TypeScript
/**
* IBM Quantum Platform configuration data structure.
* Top-level keys are configuration "sections" (e.g., 'default-ibm-quantum-platform').
* Each section stores simple key/value pairs (string | boolean).
*/
export type IBMConfigData = Record<string, Record<string, string | boolean>>;
/**
* Default IBM Quantum Platform configuration.
* This can be used directly in frontend applications or as a base for filesystem config.
*/
export declare const DEFAULT_IBM_CONFIG: IBMConfigData;
export declare const IBM_DEFAULT_TOKEN_LIFETIME = 3600000;
/**
* Lightweight, browser-safe IBM Quantum Platform config wrapper.
* - In-memory only (no filesystem operations).
* - Provides helpers for API key (token) and service CRN (instance).
* - Maintains an in-memory bearer token with simple expiry logic.
*/
export declare class IBMConfig {
private config;
private bearerToken;
private tokenFetchTime;
/**
* Create a new IBMConfig.
* @param config Optional initial configuration. If omitted, a deep copy of DEFAULT_IBM_CONFIG is used.
*/
constructor(config?: IBMConfigData);
/**
* Get a shallow copy of the current configuration object.
* Note: nested section objects are not deeply cloned.
* @returns A shallow copy of the current configuration.
*/
getConfig(): IBMConfigData;
/**
* Shallow-merge top-level sections from the provided config into the current config.
*
* - Existing sections are preserved unless overwritten by the same section key in newConfig.
* - For a given section key, the entire section object is replaced (no deep merge of keys).
* Use setValue()/specific setters for per-key updates.
* @param newConfig The partial configuration to merge at the section level.
*/
updateConfig(newConfig: IBMConfigData): void;
/**
* Get the IBM API key (stored as 'token').
* @returns The API key string.
*/
getApiKey(): string;
/**
* Set the IBM API key (stored as 'token').
* @param apiKey The API key.
*/
setApiKey(apiKey: string): void;
/**
* Get the IBM Quantum service CRN (stored as 'instance').
* @returns The service CRN string.
*/
getServiceCRN(): string;
/**
* Set the IBM Quantum service CRN (stored as 'instance').
* @param crn The service CRN value.
*/
setServiceCRN(crn: string): void;
/**
* Get the in-memory bearer token (not persisted).
* @returns The bearer token string.
*/
getBearerToken(): string;
/**
* Set the in-memory bearer token (not persisted).
* @param token The bearer token value.
*/
setBearerToken(token: string): void;
/**
* Bearer token expiry check.
* Returns true if token was never set or lifetime exceeded.
*/
isBearerTokenExpired(): boolean;
/**
* Get a configuration section by name.
* @param section The section key.
* @returns The section object if present, otherwise undefined.
*/
getSection(section: string): Record<string, string | boolean> | undefined;
/**
* Get a value from a given section.
* @param section The section key.
* @param key The key within the section.
* @returns The value if present, otherwise undefined.
*/
getValue(section: string, key: string): string | boolean | undefined;
/**
* Set a value within a section, creating the section if needed.
* @param section The section key.
* @param key The key within the section.
* @param value The value to set.
*/
setValue(section: string, key: string, value: string | boolean): void;
}