import { constructMetadata } from '../shared';

import { ArgsWithMetadata } from './types';

export const withMetadata = <TArgs extends unknown[]>(
  args: TArgs,
  accessId?: string | null
): ArgsWithMetadata<TArgs> => {
  if (accessId) {
    args.push(constructMetadata({ accessId }));
  }

  return args as unknown as ArgsWithMetadata<TArgs>;
};
