@daiso-tech/core
Version:
The library offers flexible, framework-agnostic solutions for modern web applications, built on adaptable components that integrate seamlessly with popular frameworks like Next Js.
70 lines (69 loc) • 2.85 kB
TypeScript
/**
* @module Semaphore
*/
import { type IKey } from "../../namespace/contracts/_module.js";
import { type InferInstance } from "../../utilities/_module.js";
/**
* The error is thrown when trying to acquire a semaphore slot, but all slots are already taken.
*
* IMPORT_PATH: `"@daiso-tech/core/semaphore/contracts"`
* @group Errors
*/
export declare class LimitReachedSemaphoreError extends Error {
static create(key: IKey, cause?: unknown): LimitReachedSemaphoreError;
/**
* Note: Do not instantiate `LimitReachedSemaphoreError` directly via the constructor. Use the static `create()` factory method instead.
* The constructor remains public only to maintain compatibility with errorPolicy types and prevent type errors.
* @internal
*/
constructor(message: string, cause?: unknown);
}
/**
* The error is thrown when trying to refresh a semaphore slot that is already expired.
*
* IMPORT_PATH: `"@daiso-tech/core/semaphore/contracts"`
* @group Errors
*/
export declare class FailedRefreshSemaphoreError extends Error {
static create(key: IKey, slotId: string, cause?: unknown): FailedRefreshSemaphoreError;
/**
* Note: Do not instantiate `FailedRefreshSemaphoreError` directly via the constructor. Use the static `create()` factory method instead.
* The constructor remains public only to maintain compatibility with errorPolicy types and prevent type errors.
* @internal
*/
constructor(message: string, cause?: unknown);
}
/**
* The error is thrown when trying to release a semaphore slot that is already expired.
*
* IMPORT_PATH: `"@daiso-tech/core/semaphore/contracts"`
* @group Errors
*/
export declare class FailedReleaseSemaphoreError extends Error {
static create(key: IKey, slotId: string, cause?: unknown): FailedReleaseSemaphoreError;
/**
* Note: Do not instantiate `FailedReleaseSemaphoreError` directly via the constructor. Use the static `create()` factory method instead.
* The constructor remains public only to maintain compatibility with errorPolicy types and prevent type errors.
* @internal
*/
constructor(message: string, cause?: unknown);
}
/**
* IMPORT_PATH: `"@daiso-tech/core/semaphore/contracts"`
* @group Errors
*/
export declare const SEMAPHORE_ERRORS: {
readonly ReachedLimit: typeof LimitReachedSemaphoreError;
readonly FailedRefresh: typeof FailedRefreshSemaphoreError;
readonly FailedRelease: typeof FailedReleaseSemaphoreError;
};
/**
* IMPORT_PATH: `"@daiso-tech/core/semaphore/contracts"`
* @group Errors
*/
export type AllSemaphoreErrors = InferInstance<(typeof SEMAPHORE_ERRORS)[keyof typeof SEMAPHORE_ERRORS]>;
/**
* IMPORT_PATH: `"@daiso-tech/core/semaphore/contracts"`
* @group Errors
*/
export declare function isSemaphoreError(value: unknown): value is AllSemaphoreErrors;