import type { ActionConfig, FromActionConfig } from '../actions/index.js'; import type { NotUndefined, PrimitiveObject } from '../libs/bemedev/globals/types'; import type { GUARD_TYPE } from '../constants/index.js'; import type { EventObject } from '../events/index.js'; import type { EmptyObject, KeysMatching } from '@bemedev/decompose'; import type { FnMap, FnR } from '../types/index.js'; import type { RecordS, ReduceArray } from '../types/index.js'; type gType = typeof GUARD_TYPE; type and = gType['and']; type or = gType['or']; export type GuardUnion = ActionConfig | GuardAnd | GuardOr; export type GuardAnd = { [k in and]: GuardUnion[]; }; export type GuardOr = { [k in or]: GuardUnion[]; }; /** * JSON configuration for a guard. * * @see {@linkcode ActionConfig} for more details. * @see {@linkcode GuardAnd} for more details. * @see {@linkcode GuardOr} for more details. */ export type GuardConfig = GuardUnion; /** * Retrieves the name of the action if it is a describer, otherwise returns the action itself. * @template : type {@linkcode GuardConfig} [T], GuardConfig to reduce * @return The name of the action if it is a describer, otherwise the action itself. * * @see {@linkcode FromActionConfig} for more details. * @see {@linkcode ReduceArray} for more details. * @see {@linkcode GuardAnd} for more details. * @see {@linkcode GuardOr} for more details. */ export type FromGuard = T extends ActionConfig ? FromActionConfig : T extends GuardAnd ? FromGuard> : T extends GuardOr ? FromGuard> : never; export type PredicateS = boolean | FnMap; export type PredicateS2 = boolean | PredicateS3; export type PredicateS3 = FnR; export type PredicateUnion = PredicateS | PredicateAnd | PredicateOr; export type PredicateAnd = { and: PredicateUnion[]; }; export type PredicateOr = { or: PredicateUnion[]; }; /** * Union of all predicate functions. * @template : type {@linkcode EventObject} [E], the events map to use for resolving the predicate. * @template : [Pc], the type of the private context. * @template : type {@linkcode PrimitiveObject} [Tc], the type of the context. * * @returns A union type that can be a single predicate function, a combination of predicates with AND logic, or a combination of predicates with OR logic. * * @see {@linkcode PredicateS2} for single predicate function. * @see {@linkcode PredicateAnd} for combining multiple predicates with AND logic. * @see {@linkcode PredicateOr} for combining multiple predicates with OR logic. */ export type Predicate = PredicateS2 | PredicateAnd | PredicateOr; /** * Represents a map of predicates, where each key is a string and each value is a {@linkcode Predicate}. * * @template : type {@linkcode EventsMap} [E], the events map to use for resolving the predicate. * @template : type {@linkcode PromiseeMap} [P], the promisees map to use for resolving the predicate. * @template : [Pc], the type of the private context. * @template : type {@linkcode PrimitiveObject} [Tc], the type of the context. * * @returns A partial record where each key is a string and each value is a {@linkcode PredicateS}. * * @see {@linkcode RecordS} for single predicate function. */ export type PredicateMap = Partial>>; type _DefinedValue = KeysMatching<{ pContext: NotUndefined extends never ? EmptyObject : NotUndefined; context: NotUndefined extends never ? EmptyObject : NotUndefined; }>; /** * Represents a type that can be a defined value or a string representing an event or its type * * @template : [Pc] The type of the private context. * @template : type {@linkcode PrimitiveObject} [Tc] The type of the context. */ export type DefinedValue = _DefinedValue | 'events' | 'events.type' | 'events.payload'; export {}; //# sourceMappingURL=types.d.ts.map