UNPKG

@qbraid-core/base

Version:

Core functionality for interacting with qBraid Cloud Services.

31 lines (30 loc) 1.32 kB
/** * Interface for a disposable resource that can be cleaned up */ interface Disposable { dispose(): Promise<void>; } /** * Utility function to handle resource management similar to Python's context manager * @param resource A disposable resource with init and dispose methods * @param fn The function to execute with the managed resource */ export declare function using<T extends Disposable, R>(resource: T & { init(): Promise<void>; }, fn: (resource: T) => Promise<R>): Promise<R>; /** * Ensures a directory exists during the execution of a function and optionally cleans it up * @param dirPath Path to the directory * @param removeIfCreated Whether to remove the directory if it was created by this function * @param fn Function to execute while directory is guaranteed to exist */ export declare function ensureDirectory<R>(dirPath: string, removeIfCreated: boolean, fn: () => Promise<R>): Promise<R>; /** * Default URLs for qBraid services */ export declare const DEFAULT_API_URL = "https://api.qbraid.com"; export declare const DEFAULT_LAB_URL = "https://lab.qbraid.com"; export declare const DEFAULT_QBOOK_URL = "https://qbook.qbraid.com"; export declare const DEFAULT_ACCOUNT_URL = "https://account.qbraid.com/"; export declare const DEFAULT_HUB_URL = "https://lab.qbraid.com"; export {};