@datalayer/core
Version:
[](https://datalayer.io)
79 lines (78 loc) • 2.85 kB
TypeScript
import { EnvironmentDTO } from '../models/EnvironmentDTO';
import { AuthenticationManager } from './auth';
/** Handlers for SDK method lifecycle events. */
export interface SDKHandlers {
/** Called before any SDK method execution */
beforeCall?: (methodName: string, args: any[]) => void | Promise<void>;
/** Called after successful SDK method execution */
afterCall?: (methodName: string, result: any) => void | Promise<void>;
/** Called when an SDK method throws an error */
onError?: (methodName: string, error: any) => void | Promise<void>;
}
/** Configuration options for the Datalayer Client. */
export interface DatalayerClientConfig {
/** Authentication token for API requests */
token?: string;
/** URL for the IAM service */
iamRunUrl?: string;
/** URL for the Runtimes service */
runtimesRunUrl?: string;
/** URL for the Spacer service */
spacerRunUrl?: string;
/** Handlers for intercepting SDK method calls */
handlers?: SDKHandlers;
}
/** Base Client class providing core configuration and token management. */
export declare class DatalayerClientBase {
/** URL for IAM service */
readonly iamRunUrl: string;
/** URL for Runtimes service */
readonly runtimesRunUrl: string;
/** URL for Spacer service */
readonly spacerRunUrl: string;
/** Authentication token */
token?: string;
/** Environments */
readonly environments: EnvironmentDTO[];
/** Method lifecycle handlers */
readonly handlers?: SDKHandlers;
/** Authentication manager */
readonly auth: AuthenticationManager;
/**
* Create a DatalayerClient base instance.
* @param config - Client configuration options
*/
constructor(config: DatalayerClientConfig);
/**
* Get the current configuration including service URLs and token.
* @returns Current configuration
*/
getConfig(): DatalayerClientConfig;
/** Get the IAM service URL. */
getIamRunUrl(): string;
/** Get the Runtimes service URL. */
getRuntimesRunUrl(): string;
/** Get the Spacer service URL. */
getSpacerRunUrl(): string;
/** Get the current authentication token. */
getToken(): string | undefined;
/**
* set the authentication token for all API requests.
* @param token - New authentication token
*/
setToken(token: string): Promise<void>;
/**
* Wrap all SDK methods with handlers for cross-cutting concerns.
* Called automatically by the DatalayerClient constructor.
*
* @internal
*/
protected wrapAllMethods(): void;
/**
* Get all method names from mixins only.
* @returns Array of mixin method names to wrap
* @internal
*/
private getAllMethodNames;
calculateCreditsFromMinutes(minutes: number, burningRate: number): number;
}