Skip to content

Commit

Permalink
refactor: move paging from services to lib
Browse files Browse the repository at this point in the history
  • Loading branch information
Paulijuz committed Nov 7, 2024
1 parent 696d119 commit 685626a
Show file tree
Hide file tree
Showing 32 changed files with 41 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/actions/education/schools/read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createActionError } from '@/actions/error'
import { safeServerCall } from '@/actions/safeServerCall'
import { readSchool, readSchools, readSchoolsPage, readStandardSchools } from '@/services/education/schools/read'
import { getUser } from '@/auth/getUser'
import type { ReadPageInput } from '@/services/paging/Types'
import type { ReadPageInput } from '@/lib/paging/Types'
import type { ActionReturn } from '@/actions/Types'
import type { ExpandedSchool, SchoolCursor, SchoolFiltered } from '@/education/schools/Types'

Expand Down
2 changes: 1 addition & 1 deletion src/actions/images/collections/read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { includeVisibility } from '@/services/visibility/read'
import { checkVisibility } from '@/auth/checkVisibility'
import { SpecialCollection } from '@prisma/client'
import type { VisibilityCollapsed } from '@/services/visibility/Types'
import type { ReadPageInput } from '@/services/paging/Types'
import type { ReadPageInput } from '@/lib/paging/Types'
import type { ImageCollection } from '@prisma/client'
import type {
ExpandedImageCollection,
Expand Down
2 changes: 1 addition & 1 deletion src/actions/images/read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { readImage, readImagesPage, readSpecialImage } from '@/services/images/r
import { createBadImage } from '@/services/images/create'
import { SpecialImage } from '@prisma/client'
import type { Image } from '@prisma/client'
import type { ReadPageInput } from '@/services/paging/Types'
import type { ReadPageInput } from '@/lib/paging/Types'
import type { ActionReturn } from '@/actions/Types'
import type { ImageDetails, ImageCursor } from '@/services/images/Types'

Expand Down
2 changes: 1 addition & 1 deletion src/actions/lockers/read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createActionError } from '@/actions/error'
import { readLocker, readLockerPage, updateLockerReservationIfExpired } from '@/services/lockers/read'
import { getUser } from '@/auth/getUser'
import type { ActionReturn } from '@/actions/Types'
import type { ReadPageInput } from '@/services/paging/Types'
import type { ReadPageInput } from '@/lib/paging/Types'
import type { LockerWithReservation, LockerCursor } from '@/services/lockers/Types'

/**
Expand Down
2 changes: 1 addition & 1 deletion src/actions/news/read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { safeServerCall } from '@/actions/safeServerCall'
import { readNews, readNewsCurrent, readOldNewsPage } from '@/services/news/read'
import type { ExpandedNewsArticle, NewsCursor, SimpleNewsArticle } from '@/services/news/Types'
import type { ActionReturn } from '@/actions/Types'
import type { ReadPageInput } from '@/services/paging/Types'
import type { ReadPageInput } from '@/lib/paging/Types'

export async function readOldNewsPageAction<const PageSize extends number>(
readPageImput: ReadPageInput<PageSize, NewsCursor>
Expand Down
2 changes: 1 addition & 1 deletion src/actions/omegaquotes/read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createActionError } from '@/actions/error'
import { getUser } from '@/auth/getUser'
import { readQuotesPage } from '@/services/omegaquotes/read'
import type { ActionReturn } from '@/actions/Types'
import type { ReadPageInput } from '@/services/paging/Types'
import type { ReadPageInput } from '@/lib/paging/Types'
import type { OmegaquoteCursor, OmegaquoteFiltered } from '@/services/omegaquotes/Types'

export async function readQuotesPageAction<const PageSize extends number>(
Expand Down
2 changes: 1 addition & 1 deletion src/actions/users/read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { User } from '@/services/users'
import type { ExpandedGroup } from '@/services/groups/Types'
import type { UserDetails, UserCursor, UserPagingReturn, Profile } from '@/services/users/Types'
import type { ActionReturn } from '@/actions/Types'
import type { ReadPageInput } from '@/services/paging/Types'
import type { ReadPageInput } from '@/lib/paging/Types'
import type { Permission } from '@prisma/client'

/**
Expand Down
2 changes: 1 addition & 1 deletion src/contexts/paging/CompanyPaging.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import generatePagingProvider, { generatePagingContext } from './PagingGenerator'
import { readCompanyPageAction } from '@/actions/career/companies/read'
import type { CompanyCursor, CompanyDetails, CompanyExpanded } from '@/services/career/companies/Types'
import type { ReadPageInput } from '@/services/paging/Types'
import type { ReadPageInput } from '@/lib/paging/Types'

export type PageSizeCompany = 10
const fetcher = async (x: ReadPageInput<PageSizeCompany, CompanyCursor, CompanyDetails>) => {
Expand Down
2 changes: 1 addition & 1 deletion src/contexts/paging/DotPaging.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client'
import generatePagingProvider, { generatePagingContext } from './PagingGenerator'
import { readDotPage } from '@/actions/dots/read'
import type { ReadPageInput } from '@/services/paging/Types'
import type { ReadPageInput } from '@/lib/paging/Types'
import type { DotDetails, DotCursor, DotWrapperWithDots } from '@/services/dots/Types'

export type PageSizeDots = 30
Expand Down
2 changes: 1 addition & 1 deletion src/contexts/paging/EventArchivePaging.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import generatePagingProvider, { generatePagingContext } from './PagingGenerator'
import { readArchivedEventsPage } from '@/actions/events/read'
import type { EventArchiveCursor, EventArchiveDetails, EventExpanded } from '@/services/events/Types'
import type { ReadPageInput } from '@/services/paging/Types'
import type { ReadPageInput } from '@/lib/paging/Types'

export type PageSizeEventArchive = 12
const fetcher = async (x: ReadPageInput<PageSizeEventArchive, EventArchiveCursor, EventArchiveDetails>) => {
Expand Down
2 changes: 1 addition & 1 deletion src/contexts/paging/ImageCollectionPaging.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client'
import generatePagingProvider, { generatePagingContext } from './PagingGenerator'
import { readImageCollectionsPageAction } from '@/actions/images/collections/read'
import type { ReadPageInput } from '@/services/paging/Types'
import type { ReadPageInput } from '@/lib/paging/Types'
import type { ImageCollectionCursor, ImageCollectionPageReturn } from '@/services/images/collections/Types'

export type PageSizeImageCollection = 12
Expand Down
2 changes: 1 addition & 1 deletion src/contexts/paging/ImagePaging.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client'
import generatePagingProvider, { generatePagingContext } from './PagingGenerator'
import { readImagesPageAction } from '@/actions/images/read'
import type { ReadPageInput } from '@/services/paging/Types'
import type { ReadPageInput } from '@/lib/paging/Types'
import type { Image } from '@prisma/client'
import type { ImageCursor, ImageDetails } from '@/services/images/Types'

Expand Down
2 changes: 1 addition & 1 deletion src/contexts/paging/JobAdInactivePaging.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client'
import generatePagingProvider, { generatePagingContext } from './PagingGenerator'
import { readInactiveJobAdsPageAction } from '@/actions/career/jobAds/read'
import type { ReadPageInput } from '@/services/paging/Types'
import type { ReadPageInput } from '@/lib/paging/Types'
import type { JobAdInactiveCursor, JobAdInactiveDetails, SimpleJobAd } from '@/services/career/jobAds/Types'

export type PageSizeJobAdInactive = 12
Expand Down
2 changes: 1 addition & 1 deletion src/contexts/paging/LockerPaging.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client'
import generatePagingProvider, { generatePagingContext } from '@/contexts/paging/PagingGenerator'
import { readLockerPageAction } from '@/actions/lockers/read'
import type { ReadPageInput } from '@/services/paging/Types'
import type { ReadPageInput } from '@/lib/paging/Types'
import type { LockerCursor, LockerWithReservation } from '@/services/lockers/Types'

export type PageSizeLocker = 20
Expand Down
2 changes: 1 addition & 1 deletion src/contexts/paging/OldNewsPaging.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client'
import generatePagingProvider, { generatePagingContext } from './PagingGenerator'
import { readOldNewsPageAction } from '@/actions/news/read'
import type { ReadPageInput } from '@/services/paging/Types'
import type { ReadPageInput } from '@/lib/paging/Types'
import type { NewsCursor, SimpleNewsArticle } from '@/services/news/Types'

export type PageSizeOldNews = 20
Expand Down
2 changes: 1 addition & 1 deletion src/contexts/paging/OmegaquotesPaging.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client'
import generatePagingProvider, { generatePagingContext } from '@/contexts/paging/PagingGenerator'
import { readQuotesPageAction } from '@/actions/omegaquotes/read'
import type { ReadPageInput } from '@/services/paging/Types'
import type { ReadPageInput } from '@/lib/paging/Types'
import type { OmegaquoteCursor, OmegaquoteFiltered } from '@/services/omegaquotes/Types'

export type PageSizeOmegaquote = 20;
Expand Down
2 changes: 1 addition & 1 deletion src/contexts/paging/PagingGenerator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import React, { createContext, useState, useRef, useEffect } from 'react'
import type { ActionReturn } from '@/actions/Types'
import type { ReadPageInput, Page } from '@/services/paging/Types'
import type { ReadPageInput, Page } from '@/lib/paging/Types'
import type { Context as ReactContextType } from 'react'

export type StateTypes<Data, Cursor, PageSize extends number> = {
Expand Down
2 changes: 1 addition & 1 deletion src/contexts/paging/SchoolPaging.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client'
import generatePagingProvider, { generatePagingContext } from './PagingGenerator'
import { readSchoolsPageAction } from '@/education/schools/read'
import type { ReadPageInput } from '@/services/paging/Types'
import type { ReadPageInput } from '@/lib/paging/Types'
import type { ExpandedSchool, SchoolCursor } from '@/education/schools/Types'

export type PageSizeSchool = 8
Expand Down
2 changes: 1 addition & 1 deletion src/contexts/paging/UserPaging.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client'
import generatePagingProvider, { generatePagingContext } from './PagingGenerator'
import { readUserPageAction } from '@/actions/users/read'
import type { ReadPageInput } from '@/services/paging/Types'
import type { ReadPageInput } from '@/lib/paging/Types'
import type { UserDetails, UserPagingReturn, UserCursor } from '@/services/users/Types'

export type PageSizeUsers = 50;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'server-only'
import type { Page } from '@/services/paging/Types'
import type { Page } from '@/lib/paging/Types'

/**
* A function to generate the cursor-paging selection for a given page
Expand Down
4 changes: 2 additions & 2 deletions src/services/career/companies/read.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'server-only'
import { CompanyRelationIncluder } from './ConfigVars'
import { ServiceMethodHandler } from '@/services/ServiceMethodHandler'
import { cursorPageingSelection } from '@/services/paging/cursorPageingSelection'
import type { ReadPageInput } from '@/services/paging/Types'
import { cursorPageingSelection } from '@/lib/paging/cursorPageingSelection'
import type { ReadPageInput } from '@/lib/paging/Types'
import type { CompanyCursor, CompanyDetails, CompanyExpanded } from './Types'

export const readPage = ServiceMethodHandler({
Expand Down
4 changes: 2 additions & 2 deletions src/services/career/jobAds/read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { jobAdArticleRealtionsIncluder, simpleJobAdArticleRealtionsIncluder } fr
import { CompanyRelationIncluder } from '@/career/companies/ConfigVars'
import { ServerError } from '@/services/error'
import { ServiceMethodHandler } from '@/services/ServiceMethodHandler'
import { cursorPageingSelection } from '@/services/paging/cursorPageingSelection'
import { cursorPageingSelection } from '@/lib/paging/cursorPageingSelection'
import type { ExpandedJobAd, JobAdInactiveCursor, JobAdInactiveDetails, SimpleJobAd } from './Types'
import type { ReadPageInput } from '@/services/paging/Types'
import type { ReadPageInput } from '@/lib/paging/Types'

/**
* This handler reads a jobAd by id or articleName and order
Expand Down
4 changes: 2 additions & 2 deletions src/services/dots/read.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'server-only'
import { DotWrapperWithDotsIncluder } from './ConfigVars'
import { ServiceMethodHandler } from '@/services/ServiceMethodHandler'
import { cursorPageingSelection } from '@/services/paging/cursorPageingSelection'
import type { ReadPageInput } from '@/services/paging/Types'
import { cursorPageingSelection } from '@/lib/paging/cursorPageingSelection'
import type { ReadPageInput } from '@/lib/paging/Types'
import type { DotCursor, DotDetails } from './Types'

/**
Expand Down
4 changes: 2 additions & 2 deletions src/services/education/schools/read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { SchoolFilteredSelection, SchoolRelationIncluder } from './ConfigVars'
import { prismaCall } from '@/services/prismaCall'
import logger from '@/lib/logger'
import prisma from '@/prisma'
import { cursorPageingSelection } from '@/services/paging/cursorPageingSelection'
import { cursorPageingSelection } from '@/lib/paging/cursorPageingSelection'
import { StandardSchool } from '@prisma/client'
import type { ExpandedSchool, SchoolCursor, SchoolFiltered } from './Types'
import type { ReadPageInput } from '@/services/paging/Types'
import type { ReadPageInput } from '@/lib/paging/Types'

export async function readSchoolsPage<const PageSize extends number>({
page,
Expand Down
4 changes: 2 additions & 2 deletions src/services/events/read.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import 'server-only'
import { eventFilterSeletion } from './ConfigVars'
import { ServiceMethodHandler } from '@/services/ServiceMethodHandler'
import { cursorPageingSelection } from '@/services/paging/cursorPageingSelection'
import { cursorPageingSelection } from '@/lib/paging/cursorPageingSelection'
import { getOsloTime } from '@/lib/dates/getOsloTime'
import type { ReadPageInput } from '@/services/paging/Types'
import type { ReadPageInput } from '@/lib/paging/Types'
import type { EventArchiveCursor, EventArchiveDetails } from './Types'

export const read = ServiceMethodHandler({
Expand Down
4 changes: 2 additions & 2 deletions src/services/images/collections/read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import logger from '@/lib/logger'
import { prismaCall } from '@/services/prismaCall'
import { ServerError } from '@/services/error'
import { readSpecialVisibility } from '@/services/visibility/read'
import { cursorPageingSelection } from '@/services/paging/cursorPageingSelection'
import { cursorPageingSelection } from '@/lib/paging/cursorPageingSelection'
import type { SpecialCollection, ImageCollection, Image } from '@prisma/client'
import type {
ExpandedImageCollection,
ImageCollectionCursor,
ImageCollectionPageReturn
} from '@/services/images/collections/Types'
import type { VisibilityFilter } from '@/auth/getVisibilityFilter'
import type { ReadPageInput } from '@/services/paging/Types'
import type { ReadPageInput } from '@/lib/paging/Types'


/**
Expand Down
4 changes: 2 additions & 2 deletions src/services/images/read.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import 'server-only'
import { cursorPageingSelection } from '@/services/paging/cursorPageingSelection'
import { cursorPageingSelection } from '@/lib/paging/cursorPageingSelection'
import { prismaCall } from '@/services/prismaCall'
import { ServerError } from '@/services/error'
import prisma from '@/prisma'
import type { ReadPageInput } from '@/services/paging/Types'
import type { ReadPageInput } from '@/lib/paging/Types'
import type { ImageDetails, ImageCursor } from '@/services/images/Types'
import type { Image, SpecialImage } from '@prisma/client'

Expand Down
2 changes: 1 addition & 1 deletion src/services/lockers/read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { lockerReservationIncluder } from './reservations/ConfigVars'
import prisma from '@/prisma'
import { ServerError } from '@/services/error'
import { prismaCall } from '@/services/prismaCall'
import type { ReadPageInput } from '@/services/paging/Types'
import type { ReadPageInput } from '@/lib/paging/Types'
import type { LockerWithReservation, LockerCursor } from '@/services/lockers/Types'

export async function readLocker(id: number) {
Expand Down
4 changes: 2 additions & 2 deletions src/services/news/read.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import 'server-only'
import { cursorPageingSelection } from '@/services/paging/cursorPageingSelection'
import { cursorPageingSelection } from '@/lib/paging/cursorPageingSelection'
import { prismaCall } from '@/services/prismaCall'
import { ServerError } from '@/services/error'
import { newsArticleRealtionsIncluder, simpleNewsArticleRealtionsIncluder } from '@/services/news/ConfigVars'
import prisma from '@/prisma'
import type { ExpandedNewsArticle, NewsCursor, SimpleNewsArticle } from '@/services/news/Types'
import type { ReadPageInput } from '@/services/paging/Types'
import type { ReadPageInput } from '@/lib/paging/Types'

export async function readOldNewsPage<const PageSize extends number>(
{ page }: ReadPageInput<PageSize, NewsCursor>
Expand Down
4 changes: 2 additions & 2 deletions src/services/omegaquotes/read.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import 'server-only'
import { omegaQuoteFilterSelection } from './CofigVars'
import { cursorPageingSelection } from '@/services/paging/cursorPageingSelection'
import { cursorPageingSelection } from '@/lib/paging/cursorPageingSelection'
import { prismaCall } from '@/services/prismaCall'
import prisma from '@/prisma'
import type { ReadPageInput } from '@/services/paging/Types'
import type { ReadPageInput } from '@/lib/paging/Types'
import type { OmegaquoteCursor, OmegaquoteFiltered } from '@/services/omegaquotes/Types'

export async function readQuotesPage<const PageSize extends number>(
Expand Down
4 changes: 2 additions & 2 deletions src/services/users/read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { ServerError } from '@/services/error'
import { prismaCall } from '@/services/prismaCall'
import { getMembershipFilter } from '@/auth/getMembershipFilter'
import { readMembershipsOfUser } from '@/services/groups/memberships/read'
import { cursorPageingSelection } from '@/services/paging/cursorPageingSelection'
import { cursorPageingSelection } from '@/lib/paging/cursorPageingSelection'
import prisma from '@/prisma'
import { readPermissionsOfUser } from '@/services/permissionRoles/read'
import type { UserDetails, UserCursor, Profile, UserPagingReturn } from './Types'
import type { ReadPageInput } from '@/services/paging/Types'
import type { ReadPageInput } from '@/lib/paging/Types'
import type { User } from '@prisma/client'

/**
Expand Down

0 comments on commit 685626a

Please sign in to comment.