import type { CommandContext } from "./types";

interface ResolverContext {
  user: {
    id: string;
    attributes: { permissions?: string[]; companyId?: string | null } | null;
  };
}

export function createContext(context: ResolverContext): CommandContext {
  return {
    actorId: context.user.id,
    permissions: [...new Set(context.user.attributes?.permissions ?? [])],
    companyId: context.user.attributes?.companyId,
  };
}
