import type { Container } from "@webiny/di"; import type { PluginsContainer } from "@webiny/plugins"; export type GenericRecord = Record; export type NonEmptyArray = [T, ...T[]]; export type PossiblyUndefinedProperties = { [K in keyof T]: T[K] extends undefined ? T[K] : T[K] | undefined; }; export type BenchmarkRuns = GenericRecord; export interface BenchmarkMeasurement { name: string; category: string; start: Date; end: Date; elapsed: number; memory: number; } export interface BenchmarkEnableOnCallable { (): Promise; } export interface BenchmarkOutputCallableParams { benchmark: Benchmark; stop: () => "stop"; } export interface BenchmarkOutputCallable { (params: BenchmarkOutputCallableParams): Promise<"stop" | undefined | null | void>; } export interface BenchmarkMeasureOptions { name: string; category: string; } export interface Benchmark { elapsed: number; runs: BenchmarkRuns; measurements: BenchmarkMeasurement[]; output: () => Promise; onOutput: (cb: BenchmarkOutputCallable) => void; enableOn: (cb: BenchmarkEnableOnCallable) => void; measure: (options: BenchmarkMeasureOptions | string, cb: () => Promise) => Promise; enable: () => void; disable: () => void; } /** * The main context which is constructed on every request. * All other contexts should extend or augment this one. */ export interface Context { plugins: PluginsContainer; /** * @internal */ container: Container; readonly WEBINY_VERSION: string; /** * Not to be used outside of Webiny internal code. * @internal */ hasResult: () => boolean; /** * Not to be used outside of Webiny internal code. * @internal * * @private */ _result?: unknown; /** * Not to be used outside of Webiny internal code. * @internal */ setResult: (value: unknown) => void; /** * Not to be used outside of Webiny internal code. * @internal */ getResult: () => void; /** * Benchmark instance to help determine possible bugs and slow code. */ benchmark: Benchmark; }