UNPKG

@debut/plugin-session

Version:

Trade session time, plugin debut

40 lines (39 loc) 1.46 kB
import { PluginInterface, TimeFrame } from '@debut/types'; export declare const enum TimeMode { 'Summer' = "Summer", 'Winter' = "Winter" } export interface SessionPluginOptions { interval: TimeFrame; timezone?: string; from?: string; to?: string; } export interface SessionPluginExtends { onDayEnded(): void; } interface Methods { createSessionValidator: typeof createSessionValidator; } export interface SessionAPI { session: Methods; } export interface SessionInterface extends PluginInterface { name: 'stats'; api: Methods; } export declare function sessionPlugin(options: SessionPluginOptions, onDayEnd?: (...args: unknown[]) => void): PluginInterface; export type SessionValidator = ReturnType<typeof createSessionFilter>; export type SessionValidatorResult = { inSession: boolean; dayChanged: boolean; }; /** * Метод создания валидатора из человеко читаемых дат */ export declare function createSessionValidator(interval: TimeFrame, timezone: string, from?: string, to?: string): (stamp: number) => SessionValidatorResult; /** * Метод создания валидатора сессионного окна по дате, с переходом на зимнее и летнее время */ declare function createSessionFilter(intervalMs: number, timezone: string, start: number, end: number): (stamp: number) => SessionValidatorResult; export {};