import {type BackendEndpoint, type Variant} from '@myparcel-pdk/common';
import {type OneOrMore, type PromiseOr} from '@myparcel/ts-utils';
import {
type ActionParameters,
type ActionResponse,
type AdminInstance,
type AnyActionDefinition,
type BackendEndpointResponse,
type EndpointAdminActionMap,
type MaybeAdminAction,
type PdkNotification,
} from '../../types';
import {type AdminAction} from '../../data';
export type ResolvedAdminAction = A extends MaybeAdminAction
? A
: A extends keyof EndpointAdminActionMap
? EndpointAdminActionMap[A]
: never;
export interface ActionContext<
A extends MaybeAdminAction | BackendEndpoint = undefined,
R extends ResolvedAdminAction = ResolvedAdminAction,
> {
action: AnyActionDefinition;
instance: AdminInstance;
notifications: Record;
parameters: ActionParameters;
}
export interface ActionContextWithResponse extends ActionContext {
response: ActionResponse;
}
export type PlainModifier = string | number | undefined;
type ModifierCallback = (context: ActionContext) => PlainModifier;
export type QueryModifier =
| PlainModifier
| (A extends BackendEndpoint ? ModifierCallback : never);
export type QueryHandler = (
context: ActionContext,
) => PromiseOr> | void>;