@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.
156 lines (155 loc) • 6.69 kB
TypeScript
/**
* @module SharedLock
*/
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/shared-lock/contracts"`
* @group Errors
*/
export declare class LimitReachedReaderSemaphoreError extends Error {
static create(key: IKey, 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 refresh 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: IKey, 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: IKey, 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 ReachedLimitReader: typeof LimitReachedReaderSemaphoreError;
readonly FailedRefreshReader: typeof FailedRefreshReaderSemaphoreError;
readonly FailedReleaseReader: typeof FailedReleaseReaderSemaphoreError;
};
/**
* IMPORT_PATH: `"@daiso-tech/core/shared-lock/contracts"`
* @group Errors
*/
export type AllReaderSemaphoreErrors = InferInstance<(typeof READER_SEMAPHORE_ERRORS)[keyof typeof READER_SEMAPHORE_ERRORS]>;
/**
* 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 shared-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: IKey, 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 shared-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: IKey, 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 refresh a shared-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: IKey, 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 FailedAcquireWriter: typeof FailedAcquireWriterLockError;
readonly FailedReleaseWriter: typeof FailedReleaseWriterLockError;
readonly FailedRefreshWriter: typeof FailedRefreshWriterLockError;
};
/**
* IMPORT_PATH: `"@daiso-tech/core/shared-lock/contracts"`
* @group Errors
*/
export type AllWriterLockErrors = InferInstance<(typeof WRITER_LOCK_ERRORS)[keyof typeof WRITER_LOCK_ERRORS]>;
/**
* 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 FailedAcquireWriter: typeof FailedAcquireWriterLockError;
readonly FailedReleaseWriter: typeof FailedReleaseWriterLockError;
readonly FailedRefreshWriter: typeof FailedRefreshWriterLockError;
readonly ReachedLimitReader: typeof LimitReachedReaderSemaphoreError;
readonly FailedRefreshReader: typeof FailedRefreshReaderSemaphoreError;
readonly FailedReleaseReader: typeof FailedReleaseReaderSemaphoreError;
};
/**
* IMPORT_PATH: `"@daiso-tech/core/shared-lock/contracts"`
* @group Errors
*/
export type AllSharedLockErrors = InferInstance<(typeof SHARED_LOCK_ERRORS)[keyof typeof SHARED_LOCK_ERRORS]>;
/**
* IMPORT_PATH: `"@daiso-tech/core/shared-lock/contracts"`
* @group Errors
*/
export declare function isSharedLockError(value: unknown): value is AllSharedLockErrors;