import { createToken } from '@tinkoff/dippy' ; import type { Action } from '@tramvai/core' ; description export const ACTION_REGISTRY_TOKEN = createToken < ActionsRegistry > ( 'actionRegistry' ) ; description export const ACTION_EXECUTION_TOKEN = createToken < ActionExecution > ( 'actionExecution' ) ; description export const ACTION_PAGE_RUNNER_TOKEN = createToken < ActionPageRunner > ( 'actionPageRunner' ) ; description export const ACTION_CONDITIONALS = createToken < ActionCondition [ ] > ( 'actionConditionals' , { multi : true , } ) ; export interface ActionsRegistry { add ( type , actions ) : void ; get ( type , addingActions ? ) : Action [ ] ; getGlobal ( ) : Action [ ] ; remove ( type , actions ? ) : void ; } export interface ActionExecution { execution : Map < string , any [ ] > ; run ( action , payload ) : Promise < any > ; } export interface ActionPageRunner { runActions ( actions , stopRunAtError ? ) : Promise < any > ; } export interface ActionConditionChecker < State = any > { payload : any ; parameters : any ; conditions : Record < string , any > ; type : 'global' | 'local' ; allow ( ) : void ; setState ( value ) : void ; getState ( ) : State ; forbid ( ) : void ; } export type ActionCondition = { key : string ; fn : ( checker : ActionConditionChecker ) => void ; } ;