UNPKG

@datalayer/core

Version:

[![Datalayer](https://assets.datalayer.tech/datalayer-25.svg)](https://datalayer.io)

55 lines (54 loc) 2.38 kB
import type { Constructor } from '../utils/mixins'; import { UserDTO } from '../../models/UserDTO'; import { CreditsDTO } from '../../models/CreditsDTO'; import { HealthCheck } from '../../models/HealthCheck'; /** IAM mixin providing authentication and user management. */ export declare function IAMMixin<TBase extends Constructor>(Base: TBase): { new (...args: any[]): { currentUserCache?: UserDTO; /** * Get the current user's profile information. * @returns User model instance */ whoami(): Promise<UserDTO>; /** * Authenticate the user with a token. * @param token - Authentication token * @returns User object on successful login * @throws Error if token is invalid */ login(token: string): Promise<UserDTO>; /** Log out the current user. */ logout(): Promise<void>; /** * Get the current user's available credits and usage information. * @returns Credits model instance */ getCredits(): Promise<CreditsDTO>; /** * Calculate the maximum runtime duration in minutes based on available credits and burning rate. * @param availableCredits - The amount of credits available * @param burningRate - The burning rate per second for the environment * @returns Maximum runtime duration in minutes */ calculateMaxRuntimeMinutes(availableCredits: number, burningRate: number): number; /** * Calculate the credits required for a given runtime duration. * @param minutes - Runtime duration in minutes * @param burningRate - The burning rate per second for the environment * @returns Credits required (rounded up to nearest integer) */ calculateCreditsRequired(minutes: number, burningRate: number): number; /** * Calculate the burning rate per minute from the per-second rate. * @param burningRatePerSecond - The burning rate per second * @returns Burning rate per minute */ calculateBurningRatePerMinute(burningRatePerSecond: number): number; /** * Check the health status of the IAM service. * @returns Health check model instance */ checkIAMHealth(): Promise<HealthCheck>; }; } & TBase;