UNPKG

@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.

72 lines (71 loc) 2.79 kB
/** * @module Semaphore */ import { type Key } from "../../namespace/_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: Key, 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 referesh 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: Key, 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: Key, 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 = LimitReachedSemaphoreError | FailedRefreshSemaphoreError | FailedReleaseSemaphoreError; /** * * IMPORT_PATH: `"@daiso-tech/core/semaphore/contracts"` * @group Errors */ export declare function isSemaphoreError(value: unknown): value is AllSemaphoreErrors;