import { z } from 'zod'
import { pikkuFunc } from '#pikku/pikku-types.gen.js'

export const GetMeOutput = z.object({
  userId: z.string(),
  email: z.string(),
  displayName: z.string(),
})

export const getMe = pikkuFunc({
  expose: true,
  description: 'Return the current authenticated user session.',
  output: GetMeOutput,
  func: async (_services, _data, { session }) => ({
    userId: session!.userId,
    email: session!.email,
    displayName: session!.displayName,
  }),
})
