Merge branch 'alpha' of https://github.com/payloadcms/payload into chore/alpha-remove-schemaOutputFile

This commit is contained in:
PatrikKozak
2024-03-11 15:10:32 -04:00
26 changed files with 87 additions and 58 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "payload-monorepo",
"version": "3.0.0-alpha.44",
"version": "3.0.0-alpha.45",
"private": true,
"type": "module",
"workspaces:": [

View File

@@ -1,6 +1,6 @@
{
"name": "@payloadcms/db-mongodb",
"version": "3.0.0-alpha.44",
"version": "3.0.0-alpha.45",
"description": "The officially supported MongoDB database adapter for Payload - Update 2",
"repository": "https://github.com/payloadcms/payload",
"license": "MIT",

View File

@@ -1,6 +1,6 @@
{
"name": "@payloadcms/db-postgres",
"version": "3.0.0-alpha.44",
"version": "3.0.0-alpha.45",
"description": "The officially supported Postgres database adapter for Payload",
"repository": "https://github.com/payloadcms/payload",
"license": "MIT",

View File

@@ -1,6 +1,6 @@
{
"name": "@payloadcms/graphql",
"version": "3.0.0-alpha.44",
"version": "3.0.0-alpha.45",
"main": "./src/index.ts",
"types": "./src/index.d.ts",
"type": "module",

View File

@@ -1,6 +1,6 @@
{
"name": "@payloadcms/next",
"version": "3.0.0-alpha.44",
"version": "3.0.0-alpha.45",
"main": "./src/index.ts",
"types": "./src/index.d.ts",
"type": "module",

View File

@@ -38,7 +38,7 @@ export const RootLayout = async ({
const payload = await getPayload({ config: configPromise })
const { cookies, permissions, user } = await auth({
const { cookies, permissions } = await auth({
headers,
payload,
})

View File

@@ -1,10 +1,13 @@
import type { Payload, PayloadRequest } from 'payload/types'
import { getAccessResults, getAuthenticatedUser, parseCookies } from 'payload/auth'
import { cache } from 'react'
export const auth = cache(
async ({ headers, payload }: { headers: Request['headers']; payload: Payload }) => {
type Args = {
headers: Request['headers']
payload: Payload
}
export const auth = async ({ headers, payload }: Args) => {
const cookies = parseCookies(headers)
const user = await getAuthenticatedUser({
@@ -30,5 +33,4 @@ export const auth = cache(
permissions,
user,
}
},
)
}

View File

@@ -8,7 +8,7 @@ let cached = global._payload
if (!cached) {
// eslint-disable-next-line no-multi-assign
cached = global._payload = { payload: null, promise: null }
cached = global._payload = { payload: null, promise: null, reload: false }
}
export const getPayload = async (options: InitOptions): Promise<Payload> => {
@@ -19,8 +19,11 @@ export const getPayload = async (options: InitOptions): Promise<Payload> => {
if (cached.payload) {
const config = await options.config
if (cached.reload) {
cached.reload = false
if (cached.reload === true) {
let resolve
cached.reload = new Promise((res) => (resolve = res))
if (typeof cached.payload.db.destroy === 'function') {
await cached.payload.db.destroy()
}
@@ -37,6 +40,11 @@ export const getPayload = async (options: InitOptions): Promise<Payload> => {
await cached.payload.db.init()
await cached.payload.db.connect({ hotReload: true })
resolve()
}
if (cached.reload instanceof Promise) {
await cached.reload
}
return cached.payload

View File

@@ -22,8 +22,8 @@ export { generateAccountMetadata } from './meta.js'
export const Account: React.FC<AdminViewProps> = async ({ initPageResult, searchParams }) => {
const {
permissions,
locale,
permissions,
req: {
i18n,
payload,
@@ -53,6 +53,7 @@ export const Account: React.FC<AdminViewProps> = async ({ initPageResult, search
id: user.id,
collection: userSlug,
depth: 0,
overrideAccess: false,
user,
})
} catch (error) {

View File

@@ -106,6 +106,7 @@ export const Document: React.FC<AdminViewProps> = async ({
collection: collectionSlug,
depth: 0,
locale: locale.code,
overrideAccess: false,
user,
})
} catch (error) {} // eslint-disable-line no-empty
@@ -148,6 +149,7 @@ export const Document: React.FC<AdminViewProps> = async ({
slug: globalSlug,
depth: 0,
locale: locale.code,
overrideAccess: false,
user,
})
} catch (error) {} // eslint-disable-line no-empty

View File

@@ -72,6 +72,7 @@ export const ListView: React.FC<AdminViewProps> = async ({ initPageResult, searc
collection: collectionSlug,
depth: 0,
limit,
overrideAccess: false,
user,
})

View File

@@ -15,7 +15,7 @@ export const VersionView: React.FC = async (props: ServerSideEditViewProps) => {
docID: id,
globalConfig,
permissions,
req: { payload, payload: { config } = {} } = {},
req: { payload, payload: { config } = {}, user } = {},
} = initPageResult
// /entityType/:entitySlug/:id/versions/:versionID
@@ -43,6 +43,8 @@ export const VersionView: React.FC = async (props: ServerSideEditViewProps) => {
collection: slug,
depth: 1,
locale: '*',
overrideAccess: false,
user,
})
publishedDoc = await payload.findByID({
@@ -51,6 +53,8 @@ export const VersionView: React.FC = async (props: ServerSideEditViewProps) => {
depth: 1,
draft: false,
locale: '*',
overrideAccess: false,
user,
})
mostRecentDoc = await payload.findByID({
@@ -59,6 +63,8 @@ export const VersionView: React.FC = async (props: ServerSideEditViewProps) => {
depth: 1,
draft: true,
locale: '*',
overrideAccess: false,
user,
})
} catch (error) {
return notFound()
@@ -75,6 +81,8 @@ export const VersionView: React.FC = async (props: ServerSideEditViewProps) => {
slug,
depth: 1,
locale: '*',
overrideAccess: false,
user,
})
publishedDoc = payload.findGlobal({
@@ -82,6 +90,8 @@ export const VersionView: React.FC = async (props: ServerSideEditViewProps) => {
depth: 1,
draft: false,
locale: '*',
overrideAccess: false,
user,
})
mostRecentDoc = payload.findGlobal({
@@ -89,6 +99,8 @@ export const VersionView: React.FC = async (props: ServerSideEditViewProps) => {
depth: 1,
draft: true,
locale: '*',
overrideAccess: false,
user,
})
} catch (error) {
return notFound()

View File

@@ -43,6 +43,7 @@ export const VersionsView: React.FC<ServerSideEditViewProps> = async (props) =>
collection: collectionSlug,
depth: 0,
limit: limit ? parseInt(limit?.toString(), 10) : undefined,
overrideAccess: false,
page: page ? parseInt(page.toString(), 10) : undefined,
sort: sort as string,
user,
@@ -62,6 +63,7 @@ export const VersionsView: React.FC<ServerSideEditViewProps> = async (props) =>
versionsData = await payload.findGlobalVersions({
slug: globalSlug,
depth: 0,
overrideAccess: false,
page: page ? parseInt(page as string, 10) : undefined,
sort: sort as string,
user,

View File

@@ -1,6 +1,6 @@
{
"name": "payload",
"version": "3.0.0-alpha.44",
"version": "3.0.0-alpha.45",
"description": "Node, React and MongoDB Headless CMS and Application Framework",
"license": "MIT",
"main": "./src/index.js",

View File

@@ -94,16 +94,10 @@ const collectionSchema = joi.object().keys({
maxLoginAttempts: joi.number(),
removeTokenFromResponses: joi.boolean().valid(true),
strategies: joi.array().items(
joi.alternatives().try(
strategyBaseSchema.keys({
joi.object().keys({
name: joi.string().required(),
strategy: joi.func().maxArity(1).required(),
authenticate: joi.func().required(),
}),
strategyBaseSchema.keys({
name: joi.string(),
strategy: joi.object().required(),
}),
),
),
tokenExpiration: joi.number(),
useAPIKey: joi.boolean(),

View File

@@ -85,6 +85,13 @@ const sanitizeCollections = (
delete sanitized.upload.handlers
}
if ('auth' in sanitized && typeof sanitized.auth === 'object') {
sanitized.auth = { ...sanitized.auth }
delete sanitized.auth.strategies
delete sanitized.auth.forgotPassword
delete sanitized.auth.verify
}
if ('admin' in sanitized) {
sanitized.admin = { ...sanitized.admin }

View File

@@ -1,7 +1,7 @@
{
"name": "@payloadcms/plugin-cloud-storage",
"description": "The official cloud storage plugin for Payload CMS",
"version": "3.0.0-alpha.44",
"version": "3.0.0-alpha.45",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"type": "module",

View File

@@ -1,7 +1,7 @@
{
"name": "@payloadcms/plugin-cloud",
"description": "The official Payload Cloud plugin",
"version": "3.0.0-alpha.44",
"version": "3.0.0-alpha.45",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"license": "MIT",

View File

@@ -1,6 +1,6 @@
{
"name": "@payloadcms/plugin-nested-docs",
"version": "3.0.0-alpha.44",
"version": "3.0.0-alpha.45",
"description": "The official Nested Docs plugin for Payload",
"repository": "https://github.com/payloadcms/payload",
"license": "MIT",

View File

@@ -1,6 +1,6 @@
{
"name": "@payloadcms/plugin-redirects",
"version": "3.0.0-alpha.44",
"version": "3.0.0-alpha.45",
"homepage:": "https://payloadcms.com",
"repository": "git@github.com:payloadcms/plugin-redirects.git",
"description": "Redirects plugin for Payload",

View File

@@ -1,6 +1,6 @@
{
"name": "@payloadcms/plugin-search",
"version": "3.0.0-alpha.44",
"version": "3.0.0-alpha.45",
"homepage:": "https://payloadcms.com",
"repository": "git@github.com:payloadcms/plugin-search.git",
"description": "Search plugin for Payload",

View File

@@ -1,6 +1,6 @@
{
"name": "@payloadcms/plugin-seo",
"version": "3.0.0-alpha.44",
"version": "3.0.0-alpha.45",
"homepage:": "https://payloadcms.com",
"repository": "git@github.com:payloadcms/plugin-seo.git",
"description": "SEO plugin for Payload",

View File

@@ -1,6 +1,6 @@
{
"name": "@payloadcms/richtext-lexical",
"version": "3.0.0-alpha.44",
"version": "3.0.0-alpha.45",
"description": "The officially supported Lexical richtext adapter for Payload",
"repository": "https://github.com/payloadcms/payload",
"license": "MIT",

View File

@@ -1,6 +1,6 @@
{
"name": "@payloadcms/richtext-slate",
"version": "3.0.0-alpha.44",
"version": "3.0.0-alpha.45",
"description": "The officially supported Slate richtext adapter for Payload",
"repository": "https://github.com/payloadcms/payload",
"license": "MIT",

View File

@@ -1,6 +1,6 @@
{
"name": "@payloadcms/translations",
"version": "3.0.0-alpha.44",
"version": "3.0.0-alpha.45",
"main": "./dist/exports/index.ts",
"types": "./dist/types.d.ts",
"type": "module",

View File

@@ -1,6 +1,6 @@
{
"name": "@payloadcms/ui",
"version": "3.0.0-alpha.44",
"version": "3.0.0-alpha.45",
"main": "./src/index.ts",
"types": "./dist/index.d.ts",
"type": "module",