@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.
71 lines (70 loc) • 1.82 kB
TypeScript
/**
* @module Semaphore
*/
import { type TimeSpan } from "../../time-span/implementations/_module.js";
/**
*
* IMPORT_PATH: `"@daiso-tech/core/semaphore/contracts"`
* @group Contracts
*/
export declare const SEMAPHORE_STATE: {
readonly EXPIRED: "EXPIRED";
readonly LIMIT_REACHED: "LIMIT_REACHED";
readonly ACQUIRED: "ACQUIRED";
readonly UNACQUIRED: "UNACQUIRED";
};
/**
*
* IMPORT_PATH: `"@daiso-tech/core/semaphore/contracts"`
* @group Contracts
*/
export type SemaphoreStateLiterals = (typeof SEMAPHORE_STATE)[keyof typeof SEMAPHORE_STATE];
/**
*
* IMPORT_PATH: `"@daiso-tech/core/semaphore/contracts"`
* @group Contracts
*/
export type ISemaphoreExpiredState = {
type: (typeof SEMAPHORE_STATE)["EXPIRED"];
};
/**
*
* IMPORT_PATH: `"@daiso-tech/core/semaphore/contracts"`
* @group Contracts
*/
export type ISemaphoreUnacquiredState = {
type: (typeof SEMAPHORE_STATE)["UNACQUIRED"];
limit: number;
freeSlotsCount: number;
acquiredSlotsCount: number;
acquiredSlots: string[];
};
/**
*
* IMPORT_PATH: `"@daiso-tech/core/semaphore/contracts"`
* @group Contracts
*/
export type ISemaphoreAcquiredState = {
type: (typeof SEMAPHORE_STATE)["ACQUIRED"];
limit: number;
remainingTime: TimeSpan | null;
freeSlotsCount: number;
acquiredSlotsCount: number;
acquiredSlots: string[];
};
/**
*
* IMPORT_PATH: `"@daiso-tech/core/semaphore/contracts"`
* @group Contracts
*/
export type ISemaphoreLimitReachedState = {
type: (typeof SEMAPHORE_STATE)["LIMIT_REACHED"];
limit: number;
acquiredSlots: string[];
};
/**
*
* IMPORT_PATH: `"@daiso-tech/core/semaphore/contracts"`
* @group Contracts
*/
export type ISemaphoreState = ISemaphoreExpiredState | ISemaphoreAcquiredState | ISemaphoreUnacquiredState | ISemaphoreLimitReachedState;