import { controllerProcedure, protectedProcedure } from "../trpc.js";
import {
  TimelineDetailFiltersSchema,
  TimelineWindowFiltersSchema,
} from "./timeline-read-schema-support.js";
import {
  readMyTimelineEntriesView,
  readTimelineEntries,
  readTimelineEntriesDetail,
  readTimelineEntriesView,
} from "./timeline-entry-procedure-support.js";

export const timelineEntryReadProcedures = {
  getEntries: controllerProcedure
    .input(TimelineWindowFiltersSchema)
    .query(({ ctx, input }) => readTimelineEntries(ctx.db, input)),

  getEntriesView: controllerProcedure
    .input(TimelineWindowFiltersSchema)
    .query(({ ctx, input }) => readTimelineEntriesView(ctx.db, input)),

  getMyEntriesView: protectedProcedure
    .input(TimelineWindowFiltersSchema)
    .query(({ ctx, input }) => readMyTimelineEntriesView(ctx, input)),

  getEntriesDetail: controllerProcedure
    .input(TimelineDetailFiltersSchema)
    .query(({ ctx, input }) => readTimelineEntriesDetail(ctx.db, input)),
};
