export type PublicationQueryOptions = Readonly<{ draft: boolean overrideAccess: boolean }> const publicPublicationQuery = Object.freeze({ draft: false, overrideAccess: false, }) satisfies PublicationQueryOptions const previewPublicationQuery = Object.freeze({ draft: true, overrideAccess: true, }) satisfies PublicationQueryOptions /** * Keeps public Local API reads access-controlled while allowing the authenticated * Next.js draft-mode route to intentionally load the latest draft versions. */ export function getPublicationQueryOptions(isPreview: boolean): PublicationQueryOptions { return isPreview ? previewPublicationQuery : publicPublicationQuery } /** * Adds an explicit status predicate for public indexes such as sitemaps while * retaining the same anonymous access and draft behavior as public routes. */ export function getPublicPublishedQueryOptions() { return { ...getPublicationQueryOptions(false), where: { _status: { equals: 'published' as const, }, }, } }