@just-in/core
Version:
A TypeScript-first framework for building adaptive digital health interventions.
50 lines • 1.91 kB
TypeScript
import { JustInWrapper } from './JustInWrapper';
/**
* JustinLite is a lightweight version of the core JustInWrapper singleton,
* designed specifically for stateless environments like Google Cloud Functions or Cloud Run.
*
* It extends the core functionality with lifecycle controls such as singleton reset
* and event engine queue waiting.
*/
declare class JustinLiteWrapper extends JustInWrapper {
protected static instance: JustinLiteWrapper | null;
private static EVENT_QUEUE_WAIT_TIME;
/**
* Private constructor ensures use through getInstance().
*/
protected constructor();
/**
* Retrieves the singleton instance of JustinLite.
* @returns {JustinLite} The singleton instance.
*/
static getInstance(): JustinLiteWrapper;
/**
* Resets all singleton instances used by the framework.
*
* This should be called at the start of a stateless execution context,
* such as in Google Cloud Functions or tests.
*/
static reset(): void;
/**
* Cleanses the database by clearing the EVENTS_QUEUE, EVENTS, and USERS collections.
* This is useful for ensuring a clean state before starting a new execution.
*
* @returns {Promise<void>} A promise that resolves when the database is cleansed.
*/
cleanseDB(): Promise<void>;
/**
* Waits until the event engine queue is empty before proceeding.
* Useful for ensuring all events are processed before shutdown in serverless environments.
*
* @param timeout - Maximum wait time in milliseconds (default: 10 seconds)
* @throws Error if the queue is not empty within the timeout period
*/
waitUntilQueueIsEmpty(timeout?: number): Promise<void>;
}
interface JustInLiteAPI {
(): JustinLiteWrapper;
reset(): void;
}
export declare const JustInLite: JustInLiteAPI;
export {};
//# sourceMappingURL=JustInLite.d.ts.map