import { type Action } from 'redux'; import { custom, function_, is, literal, object, pipe, readonly, type InferOutput } from 'valibot'; const REGISTER_ACTION_SINK = 'WEB_CHAT_INTERNAL/REGISTER_ACTION_SINK' as const; const registerActionSinkActionSchema = pipe( object({ payload: pipe( object({ sink: custom<(action: Action) => void>(value => is(function_(), value)) }), readonly() ), type: literal(REGISTER_ACTION_SINK) }), readonly() ); type RegisterActionSinkAction = InferOutput; function registerActionSink(sink: (action: Action) => void): RegisterActionSinkAction { return { payload: { sink }, type: REGISTER_ACTION_SINK }; } export default registerActionSink; export { REGISTER_ACTION_SINK, registerActionSinkActionSchema, type RegisterActionSinkAction };