From 17811c11efd200cf6cabeaba7fcc071f8374ec2f Mon Sep 17 00:00:00 2001 From: geisterfurz007 Date: Sat, 29 Jun 2024 22:00:15 +0200 Subject: [PATCH] Does this build now? --- ...graphql-npm-3.0.0-beta.55-27e9ac4479.patch | 12 ++++++++++ package.json | 3 ++- packages/web/src/app/(app)/layout.tsx | 2 +- .../app/(payload)/access/require-one-of.ts | 2 +- .../app/(payload)/collections/groupchats.ts | 23 +++++++++++-------- .../src/app/(payload)/collections/users.ts | 4 ++-- .../components/after-login/after-login.tsx | 2 +- .../(payload)/graphql/queries/may-operate.ts | 8 ++++++- packages/web/src/payload-types.ts | 8 ++++++- packages/web/src/payload.config.ts | 8 +++++-- 10 files changed, 53 insertions(+), 19 deletions(-) create mode 100644 .yarn/patches/@payloadcms-graphql-npm-3.0.0-beta.55-27e9ac4479.patch diff --git a/.yarn/patches/@payloadcms-graphql-npm-3.0.0-beta.55-27e9ac4479.patch b/.yarn/patches/@payloadcms-graphql-npm-3.0.0-beta.55-27e9ac4479.patch new file mode 100644 index 00000000..5c9650f7 --- /dev/null +++ b/.yarn/patches/@payloadcms-graphql-npm-3.0.0-beta.55-27e9ac4479.patch @@ -0,0 +1,12 @@ +diff --git a/dist/exports/types.js b/dist/exports/types.js +index 2fe1b45aff53a41694b647c8cb1212e0edd6b014..1a82b4dd74a6dd5524f6c2ef856a5d68829005df 100644 +--- a/dist/exports/types.js ++++ b/dist/exports/types.js +@@ -1,5 +1,5 @@ + export { GraphQLJSON, GraphQLJSONObject } from '../packages/graphql-type-json/index.js'; + export { buildPaginatedListType } from '../schema/buildPaginatedListType.js'; +-export { default as GraphQL } from 'graphql'; ++export * as GraphQL from 'graphql'; + + //# sourceMappingURL=types.js.map +\ No newline at end of file diff --git a/package.json b/package.json index 44856dbd..5a63cd86 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,8 @@ ], "resolutions": { "react-test-renderer": "18.2.0", - "ts-node": "10.9.1" + "ts-node": "10.9.1", + "@payloadcms/graphql@npm:3.0.0-beta.55": "patch:@payloadcms/graphql@npm%3A3.0.0-beta.55#~/.yarn/patches/@payloadcms-graphql-npm-3.0.0-beta.55-27e9ac4479.patch" }, "packageManager": "yarn@4.0.2" } diff --git a/packages/web/src/app/(app)/layout.tsx b/packages/web/src/app/(app)/layout.tsx index 3192c7d1..f100e12c 100644 --- a/packages/web/src/app/(app)/layout.tsx +++ b/packages/web/src/app/(app)/layout.tsx @@ -49,7 +49,7 @@ export const metadata: Metadata = { const RootLayout = async ({children}: PropsWithChildren) => { const user = await getCurrentUser(); // TODO figure out why I am not allowed to check with payload here... - const routes: NavLinkDefinition[] = [] /*await getNavRoutes()*/; + const routes: NavLinkDefinition[] = await getNavRoutes(); return ( diff --git a/packages/web/src/app/(payload)/access/require-one-of.ts b/packages/web/src/app/(payload)/access/require-one-of.ts index 98540948..22018e8b 100644 --- a/packages/web/src/app/(payload)/access/require-one-of.ts +++ b/packages/web/src/app/(payload)/access/require-one-of.ts @@ -1,4 +1,4 @@ -import {type GeneratedTypes,type FieldAccess, type TypeWithID} from 'payload'; +import {type GeneratedTypes, type FieldAccess, type TypeWithID} from 'payload'; import {type SessionUser} from '../collections/users'; type Role = GeneratedTypes['collections']['users']['roles'][number]; diff --git a/packages/web/src/app/(payload)/collections/groupchats.ts b/packages/web/src/app/(payload)/collections/groupchats.ts index b694d639..9fa8cb67 100644 --- a/packages/web/src/app/(payload)/collections/groupchats.ts +++ b/packages/web/src/app/(payload)/collections/groupchats.ts @@ -1,4 +1,9 @@ -import {type GeneratedTypes, type Payload, type CollectionConfig, type ValidateOptions} from 'payload'; +import { + type GeneratedTypes, + type Payload, + type CollectionConfig, + type ValidateOptions, +} from 'payload'; import {type Groupchat, type GroupchatKeyword} from '../../../payload-types'; import {allowUpdateDeleteOwner} from '../access/allow-update-delete-owner'; import {requireOneOf} from '../access/require-one-of'; @@ -210,15 +215,15 @@ export const Groupchats: CollectionConfig = { const keywords = doc.keywords.length > 0 ? await req.payload.find({ - collection: 'groupchat-keywords', - where: { - id: { - in: doc.keywords.map((k: number | GroupchatKeyword) => - typeof k === 'number' ? k : k.id, - ), + collection: 'groupchat-keywords', + where: { + id: { + in: doc.keywords.map((k: number | GroupchatKeyword) => + typeof k === 'number' ? k : k.id, + ), + }, }, - }, - }) + }) : {docs: []}; const {owners, ...sanitized} = doc; diff --git a/packages/web/src/app/(payload)/collections/users.ts b/packages/web/src/app/(payload)/collections/users.ts index 896f4ca1..1b1ca1ae 100644 --- a/packages/web/src/app/(payload)/collections/users.ts +++ b/packages/web/src/app/(payload)/collections/users.ts @@ -1,9 +1,9 @@ -import {type GeneratedTypes,type CollectionConfig} from 'payload'; +import {type GeneratedTypes, type CollectionConfig} from 'payload'; import {hiddenUnlessOwner} from '../access/hidden-unless-owner'; import {requireOneOf} from '../access/require-one-of'; +import {AuthState} from '../lib/auth-state'; import {ytfAuthStrategy} from '../lib/auth-strategy'; import {getAuthStateFromHeaders} from '../lib/get-auth-state-from-headers'; -import { AuthState } from '../lib/auth-state'; export type PayloadUser = GeneratedTypes['collections']['users']; diff --git a/packages/web/src/app/(payload)/components/after-login/after-login.tsx b/packages/web/src/app/(payload)/components/after-login/after-login.tsx index 3e956bc0..e590bcfe 100644 --- a/packages/web/src/app/(payload)/components/after-login/after-login.tsx +++ b/packages/web/src/app/(payload)/components/after-login/after-login.tsx @@ -1,7 +1,7 @@ 'use client'; import React, {type FC, useEffect, useState} from 'react'; -import {AuthState} from "../../lib/auth-state"; +import {AuthState} from '../../lib/auth-state'; import {AuthenticatedMishap} from './components/authenticated-mishap'; import {MissingAccess} from './components/missing-access'; import {MissingCookie} from './components/missing-cookie'; diff --git a/packages/web/src/app/(payload)/graphql/queries/may-operate.ts b/packages/web/src/app/(payload)/graphql/queries/may-operate.ts index 6969e79e..b70ec8f1 100644 --- a/packages/web/src/app/(payload)/graphql/queries/may-operate.ts +++ b/packages/web/src/app/(payload)/graphql/queries/may-operate.ts @@ -1,4 +1,10 @@ -import {type GeneratedTypes,type Access, NotFound, type CollectionConfig, type PayloadRequest } from 'payload'; +import { + type GeneratedTypes, + type Access, + NotFound, + type CollectionConfig, + type PayloadRequest, +} from 'payload'; import {type PayloadUser, toRequestUser} from '../../collections/users'; import {type QueryFactory} from '../../utils/merge-queries'; diff --git a/packages/web/src/payload-types.ts b/packages/web/src/payload-types.ts index 1ce6234b..9856261c 100644 --- a/packages/web/src/payload-types.ts +++ b/packages/web/src/payload-types.ts @@ -58,7 +58,13 @@ export interface Media { export interface Groupchat { id: number; name: string; - platform: 'discord' | 'facebook' | 'instagram' | 'signal' | 'telegram' | 'whatsapp'; + platform: + | 'discord' + | 'facebook' + | 'instagram' + | 'signal' + | 'telegram' + | 'whatsapp'; showUnauthenticated?: boolean | null; description?: string | null; url: string; diff --git a/packages/web/src/payload.config.ts b/packages/web/src/payload.config.ts index 632c9e46..cc8096d5 100644 --- a/packages/web/src/payload.config.ts +++ b/packages/web/src/payload.config.ts @@ -2,6 +2,7 @@ import path from 'path'; import {fileURLToPath} from 'url'; import {postgresAdapter} from '@payloadcms/db-postgres'; import {slateEditor} from '@payloadcms/richtext-slate'; +import {PHASE_PRODUCTION_BUILD} from 'next/constants'; import {buildConfig, type Config} from 'payload'; import sharp from 'sharp'; import {Features} from './app/(payload)/collections/features'; @@ -14,13 +15,15 @@ import {setupCronJobs} from './app/(payload)/cron-jobs'; import {mimicUserOperationMutation} from './app/(payload)/graphql/mutations/mimic-user-operation'; import {groupchatSearchTokenQuery} from './app/(payload)/graphql/queries/groupchat-search-token'; import {mayOperateQuery} from './app/(payload)/graphql/queries/may-operate'; -// import {ensureDbExists} from './app/(payload)/utils/ensure-db-exists'; +import {ensureDbExists} from './app/(payload)/utils/ensure-db-exists'; import {mergeQueries} from './app/(payload)/utils/merge-queries'; const filename = fileURLToPath(import.meta.url); const dirname = path.dirname(filename); -// await ensureDbExists(); +if (process.env.NEXT_PHASE !== PHASE_PRODUCTION_BUILD) { + await ensureDbExists(); +} const config: Config = { admin: { @@ -30,6 +33,7 @@ const config: Config = { }, }, onInit: async (payload) => { + if (process.env.NEXT_PHASE === PHASE_PRODUCTION_BUILD) return; // TODO wait for drizzle to resolve this and run migrations prior to JS container // https://github.com/drizzle-team/drizzle-orm/issues/819 // await payload.db.migrate();