import { createParamDecorator, ExecutionContext } from '@nestjs/common';
import type { ActorContext } from '../common/actor-context.js';

/**
 * 参数装饰器：从 request 上提取由 AccessTokenGuard 注入的 actor。
 */
export const CurrentActor = createParamDecorator(
  (_data: unknown, context: ExecutionContext): ActorContext => {
    const request = context
      .switchToHttp()
      .getRequest<{ actor: ActorContext }>();
    return request.actor;
  },
);
