@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.
162 lines (161 loc) • 6.41 kB
TypeScript
/**
* @module SharedLock
*/
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/shared-lock/contracts"`
* @group Errors
*/
export declare class LimitReachedReaderSemaphoreError extends Error {
static create(key: Key, cause?: unknown): LimitReachedReaderSemaphoreError;
/**
* Note: Do not instantiate `LimitReachedReaderSemaphoreError` 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/shared-lock/contracts"`
* @group Errors
*/
export declare class FailedRefreshReaderSemaphoreError extends Error {
static create(key: Key, slotId: string, cause?: unknown): FailedRefreshReaderSemaphoreError;
/**
* Note: Do not instantiate `FailedRefreshReaderSemaphoreError` 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/shared-lock/contracts"`
* @group Errors
*/
export declare class FailedReleaseReaderSemaphoreError extends Error {
static create(key: Key, slotId: string, cause?: unknown): FailedReleaseReaderSemaphoreError;
/**
* Note: Do not instantiate `FailedReleaseReaderSemaphoreError` 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/shared-lock/contracts"`
* @group Errors
*/
export declare const READER_SEMAPHORE_ERRORS: {
readonly ReachedLimit: typeof LimitReachedReaderSemaphoreError;
readonly FailedRefresh: typeof FailedRefreshReaderSemaphoreError;
readonly FailedRelease: typeof FailedReleaseReaderSemaphoreError;
};
/**
*
* IMPORT_PATH: `"@daiso-tech/core/shared-lock/contracts"`
* @group Errors
*/
export type AllReaderSemaphoreErrors = LimitReachedReaderSemaphoreError | FailedRefreshReaderSemaphoreError | FailedReleaseReaderSemaphoreError;
/**
*
* IMPORT_PATH: `"@daiso-tech/core/shared-lock/contracts"`
* @group Errors
*/
export declare function isReaderSemaphoreError(value: unknown): value is AllReaderSemaphoreErrors;
/**
* The error is thrown when trying to acquire a lock that is owned by a different owner.
*
* IMPORT_PATH: `"@daiso-tech/core/shared-lock/contracts"`
* @group Errors
*/
export declare class FailedAcquireWriterLockError extends Error {
static create(key: Key, cause?: unknown): FailedAcquireWriterLockError;
/**
* Note: Do not instantiate `FailedAcquireWriterLockError` 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 lock that is owned by a different owner.
*
* IMPORT_PATH: `"@daiso-tech/core/shared-lock/contracts"`
* @group Errors
*/
export declare class FailedReleaseWriterLockError extends Error {
static create(key: Key, lockId: string, cause?: unknown): FailedReleaseWriterLockError;
/**
* Note: Do not instantiate `FailedReleaseWriterLockError` 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 lock that is owned by a different owner.
*
* IMPORT_PATH: `"@daiso-tech/core/shared-lock/contracts"`
* @group Errors
*/
export declare class FailedRefreshWriterLockError extends Error {
static create(_key: Key, lockId: string, cause?: unknown): FailedRefreshWriterLockError;
/**
* Note: Do not instantiate `FailedRefreshWriterLockError` 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/shared-lock/contracts"`
* @group Errors
*/
export declare const WRITER_LOCK_ERRORS: {
readonly FailedAcquire: typeof FailedAcquireWriterLockError;
readonly FailedRelease: typeof FailedReleaseWriterLockError;
readonly FailedRefresh: typeof FailedRefreshWriterLockError;
};
/**
*
* IMPORT_PATH: `"@daiso-tech/core/shared-lock/contracts"`
* @group Errors
*/
export type AllWriterLockErrors = FailedAcquireWriterLockError | FailedReleaseWriterLockError | FailedRefreshWriterLockError;
/**
*
* IMPORT_PATH: `"@daiso-tech/core/shared-lock/contracts"`
* @group Errors
*/
export declare function isWriterLockError(value: unknown): value is AllWriterLockErrors;
/**
*
* IMPORT_PATH: `"@daiso-tech/core/shared-lock/contracts"`
* @group Errors
*/
export declare const SHARED_LOCK_ERRORS: {
readonly FailedAcquire: typeof FailedAcquireWriterLockError;
readonly FailedRelease: typeof FailedReleaseWriterLockError;
readonly FailedRefresh: typeof FailedRefreshWriterLockError;
readonly ReachedLimit: typeof LimitReachedReaderSemaphoreError;
};
/**
*
* IMPORT_PATH: `"@daiso-tech/core/shared-lock/contracts"`
* @group Errors
*/
export type AllSharedLockErrors = AllWriterLockErrors | AllReaderSemaphoreErrors;
/**
*
* IMPORT_PATH: `"@daiso-tech/core/shared-lock/contracts"`
* @group Errors
*/
export declare function isSharedLockError(value: unknown): value is AllSharedLockErrors;