Compare commits
41 Commits
v3.0.0-alp
...
v3.0.0-alp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4962f6c926 | ||
|
|
50f0e9298c | ||
|
|
89efcc5db1 | ||
|
|
c3119a5632 | ||
|
|
069bbd92b0 | ||
|
|
c4422a2593 | ||
|
|
3aab9d368e | ||
|
|
b6afab63b2 | ||
|
|
b93f5e9c44 | ||
|
|
630082035f | ||
|
|
c74e41fc76 | ||
|
|
08ce7c58b5 | ||
|
|
1853fde379 | ||
|
|
f29d22ca95 | ||
|
|
5ea5f928ab | ||
|
|
efd6d35eb3 | ||
|
|
2b2538f13a | ||
|
|
9375dae179 | ||
|
|
674bb3758d | ||
|
|
cedf9a2eb8 | ||
|
|
7d2dc5b6c6 | ||
|
|
9d2aad7bf9 | ||
|
|
f085d7609b | ||
|
|
a49243a42a | ||
|
|
e79f431f14 | ||
|
|
38e5b6e8e3 | ||
|
|
35bdb785c4 | ||
|
|
25cb146fde | ||
|
|
c10f0f4a9e | ||
|
|
3a3a7f6e16 | ||
|
|
684c4d2113 | ||
|
|
31502d2da3 | ||
|
|
3ee39ecca3 | ||
|
|
60dd71c59e | ||
|
|
0936f77930 | ||
|
|
3c09b95a8c | ||
|
|
9147d30152 | ||
|
|
6217c70fb5 | ||
|
|
3bd455ced2 | ||
|
|
0c45d5773a | ||
|
|
f48335444b |
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@@ -250,7 +250,7 @@ jobs:
|
||||
suite:
|
||||
- _community
|
||||
- access-control
|
||||
# - admin
|
||||
- admin
|
||||
- auth
|
||||
- email
|
||||
- field-error-states
|
||||
|
||||
11
.vscode/launch.json
vendored
11
.vscode/launch.json
vendored
@@ -23,6 +23,17 @@
|
||||
"request": "launch",
|
||||
"type": "node-terminal"
|
||||
},
|
||||
{
|
||||
"command": "node --no-deprecation test/loader/init.js",
|
||||
"cwd": "${workspaceFolder}",
|
||||
"name": "Run Loader",
|
||||
"request": "launch",
|
||||
"type": "node-terminal",
|
||||
"env": {
|
||||
"LOADER_TEST_FILE_PATH": "./dependency-test.js"
|
||||
// "LOADER_TEST_FILE_PATH": "../fields/config.ts"
|
||||
}
|
||||
},
|
||||
{
|
||||
"command": "node --no-deprecation test/dev.js admin",
|
||||
"cwd": "${workspaceFolder}",
|
||||
|
||||
@@ -14,8 +14,8 @@ type Args = {
|
||||
}
|
||||
}
|
||||
|
||||
export const generateMetadata = ({ params, searchParams }: Args): Promise<Metadata> =>
|
||||
generatePageMetadata({ config, params, searchParams })
|
||||
export const generateMetadata = ({ params }: Args): Promise<Metadata> =>
|
||||
generatePageMetadata({ config, params })
|
||||
|
||||
const NotFound = ({ params, searchParams }: Args) => NotFoundPage({ config, params, searchParams })
|
||||
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
import QueryString from 'qs'
|
||||
|
||||
import { PAYLOAD_SERVER_URL } from './serverURL.js'
|
||||
|
||||
export const fetchDoc = async <T>(args: {
|
||||
collection: string
|
||||
depth?: number
|
||||
id?: string
|
||||
slug?: string
|
||||
}): Promise<T> => {
|
||||
const { id, slug, collection, depth = 2 } = args || {}
|
||||
|
||||
const queryString = QueryString.stringify(
|
||||
{
|
||||
...(slug ? { 'where[slug][equals]': slug } : {}),
|
||||
...(depth ? { depth } : {}),
|
||||
},
|
||||
{ addQueryPrefix: true },
|
||||
)
|
||||
|
||||
const doc: T = await fetch(`${PAYLOAD_SERVER_URL}/api/${collection}${queryString}`, {
|
||||
cache: 'no-store',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
method: 'GET',
|
||||
})
|
||||
?.then((res) => res.json())
|
||||
?.then((res) => {
|
||||
if (res.errors) throw new Error(res?.errors?.[0]?.message ?? 'Error fetching doc')
|
||||
return res?.docs?.[0]
|
||||
})
|
||||
|
||||
return doc
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
import { PAYLOAD_SERVER_URL } from './serverURL.js'
|
||||
|
||||
export const fetchDocs = async <T>(collection: string): Promise<T[]> => {
|
||||
const docs: T[] = await fetch(`${PAYLOAD_SERVER_URL}/api/${collection}?depth=0&limit=100`, {
|
||||
cache: 'no-store',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
method: 'GET',
|
||||
})
|
||||
?.then((res) => res.json())
|
||||
?.then((res) => {
|
||||
if (res.errors) throw new Error(res?.errors?.[0]?.message ?? 'Error fetching docs')
|
||||
|
||||
return res?.docs
|
||||
})
|
||||
|
||||
return docs
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
import type { Footer } from '../../../test/live-preview/payload-types.js'
|
||||
|
||||
import { PAYLOAD_SERVER_URL } from './serverURL.js'
|
||||
|
||||
export async function fetchFooter(): Promise<Footer> {
|
||||
if (!PAYLOAD_SERVER_URL) throw new Error('PAYLOAD_SERVER_URL not found')
|
||||
|
||||
const footer = await fetch(`${PAYLOAD_SERVER_URL}/api/globals/footer`, {
|
||||
cache: 'no-store',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
method: 'GET',
|
||||
})
|
||||
.then((res) => {
|
||||
if (!res.ok) throw new Error('Error fetching doc')
|
||||
return res.json()
|
||||
})
|
||||
?.then((res) => {
|
||||
if (res?.errors) throw new Error(res?.errors[0]?.message || 'Error fetching footer')
|
||||
return res
|
||||
})
|
||||
|
||||
return footer
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
import type { Header } from '../../../test/live-preview/payload-types.js'
|
||||
|
||||
import { PAYLOAD_SERVER_URL } from './serverURL.js'
|
||||
|
||||
export async function fetchHeader(): Promise<Header> {
|
||||
if (!PAYLOAD_SERVER_URL) throw new Error('PAYLOAD_SERVER_URL not found')
|
||||
|
||||
const header = await fetch(`${PAYLOAD_SERVER_URL}/api/globals/header`, {
|
||||
cache: 'no-store',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
method: 'GET',
|
||||
})
|
||||
?.then((res) => {
|
||||
if (!res.ok) throw new Error('Error fetching doc')
|
||||
return res.json()
|
||||
})
|
||||
?.then((res) => {
|
||||
if (res?.errors) throw new Error(res?.errors[0]?.message || 'Error fetching header')
|
||||
return res
|
||||
})
|
||||
|
||||
return header
|
||||
}
|
||||
@@ -10,6 +10,12 @@ const withBundleAnalyzer = bundleAnalyzer({
|
||||
export default withBundleAnalyzer(
|
||||
withPayload({
|
||||
reactStrictMode: false,
|
||||
eslint: {
|
||||
ignoreDuringBuilds: true,
|
||||
},
|
||||
typescript: {
|
||||
ignoreBuildErrors: true,
|
||||
},
|
||||
async redirects() {
|
||||
return [
|
||||
{
|
||||
|
||||
26
package.json
26
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "payload-monorepo",
|
||||
"version": "3.0.0-alpha.55",
|
||||
"version": "3.0.0-alpha.58",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"workspaces:": [
|
||||
@@ -76,7 +76,7 @@
|
||||
"@octokit/core": "^5.1.0",
|
||||
"@payloadcms/eslint-config": "workspace:*",
|
||||
"@payloadcms/live-preview-react": "workspace:*",
|
||||
"@playwright/test": "^1.42.1",
|
||||
"@playwright/test": "1.43.0",
|
||||
"@swc/cli": "^0.1.62",
|
||||
"@swc/jest": "0.2.36",
|
||||
"@testing-library/jest-dom": "6.4.2",
|
||||
@@ -88,13 +88,13 @@
|
||||
"@types/conventional-changelog-writer": "^4.0.10",
|
||||
"@types/fs-extra": "^11.0.2",
|
||||
"@types/jest": "29.5.12",
|
||||
"@types/minimist": "1.2.2",
|
||||
"@types/node": "20.11.28",
|
||||
"@types/minimist": "1.2.5",
|
||||
"@types/node": "20.12.5",
|
||||
"@types/prompts": "^2.4.5",
|
||||
"@types/qs": "6.9.7",
|
||||
"@types/react": "18.2.15",
|
||||
"@types/qs": "6.9.14",
|
||||
"@types/react": "18.2.74",
|
||||
"@types/semver": "^7.5.3",
|
||||
"@types/shelljs": "0.8.12",
|
||||
"@types/shelljs": "0.8.15",
|
||||
"add-stream": "^1.0.0",
|
||||
"chalk": "^4.1.2",
|
||||
"comment-json": "^4.2.3",
|
||||
@@ -131,10 +131,11 @@
|
||||
"node-mocks-http": "^1.14.1",
|
||||
"nodemon": "3.0.3",
|
||||
"open": "^10.1.0",
|
||||
"p-limit": "^5.0.0",
|
||||
"pino": "8.15.0",
|
||||
"pino-pretty": "10.2.0",
|
||||
"playwright": "^1.42.1",
|
||||
"playwright-core": "^1.42.1",
|
||||
"playwright": "1.43.0",
|
||||
"playwright-core": "1.43.0",
|
||||
"prettier": "^3.0.3",
|
||||
"prompts": "2.4.2",
|
||||
"qs": "6.11.2",
|
||||
@@ -154,7 +155,7 @@
|
||||
"ts-node": "10.9.1",
|
||||
"tsx": "^4.7.1",
|
||||
"turbo": "^1.13.2",
|
||||
"typescript": "5.4.2",
|
||||
"typescript": "5.4.4",
|
||||
"uuid": "^9.0.1",
|
||||
"yocto-queue": "^1.0.0"
|
||||
},
|
||||
@@ -194,8 +195,7 @@
|
||||
"domexception": "4"
|
||||
},
|
||||
"patchedDependencies": {
|
||||
"playwright@1.42.1": "patches/playwright@1.42.1.patch"
|
||||
"playwright@1.43.0": "patches/playwright@1.43.0.patch"
|
||||
}
|
||||
},
|
||||
"packageManager": "pnpm@8.15.4+sha256.cea6d0bdf2de3a0549582da3983c70c92ffc577ff4410cbf190817ddc35137c2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
"build:swc": "swc ./src -d ./dist --config-file .swcrc",
|
||||
"clean": "rimraf {dist,*.tsbuildinfo}",
|
||||
"test": "jest",
|
||||
"prepublishOnly": "pnpm test && pnpm clean && pnpm build"
|
||||
"prepublishOnly": "pnpm clean && pnpm build"
|
||||
},
|
||||
"files": [
|
||||
"package.json",
|
||||
@@ -48,7 +48,7 @@
|
||||
"@types/esprima": "^4.0.6",
|
||||
"@types/fs-extra": "^9.0.12",
|
||||
"@types/jest": "^27.0.3",
|
||||
"@types/node": "^16.6.2"
|
||||
"@types/node": "20.12.5"
|
||||
},
|
||||
"exports": {
|
||||
"./commands": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/db-mongodb",
|
||||
"version": "3.0.0-alpha.55",
|
||||
"version": "3.0.0-alpha.58",
|
||||
"description": "The officially supported MongoDB database adapter for Payload",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/db-postgres",
|
||||
"version": "3.0.0-alpha.55",
|
||||
"version": "3.0.0-alpha.58",
|
||||
"description": "The officially supported Postgres database adapter for Payload",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/graphql",
|
||||
"version": "3.0.0-alpha.55",
|
||||
"version": "3.0.0-alpha.58",
|
||||
"main": "./src/index.ts",
|
||||
"types": "./src/index.d.ts",
|
||||
"type": "module",
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@payloadcms/eslint-config": "workspace:*",
|
||||
"@types/react": "^18.2.0",
|
||||
"@types/react": "18.2.74",
|
||||
"payload": "workspace:*"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
import path from 'path'
|
||||
import fs from 'fs'
|
||||
import { copyRecursiveSync } from './utilities/copyRecursiveSync'
|
||||
import { copyFile } from './utilities/copyFile'
|
||||
|
||||
const install = () => {
|
||||
const useSrc = fs.existsSync(path.resolve(process.cwd(), './src'))
|
||||
const hasAppFolder = fs.existsSync(path.resolve(process.cwd(), `./${useSrc ? 'src/' : 'app'}`))
|
||||
|
||||
if (!hasAppFolder) {
|
||||
console.error(
|
||||
`You need to have a ${
|
||||
useSrc ? 'src/' : 'app/'
|
||||
} folder in your project before running this command.`,
|
||||
)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const basePath = useSrc ? './src' : '.'
|
||||
|
||||
// Copy handlers into /api
|
||||
copyRecursiveSync(
|
||||
path.resolve(__dirname, './templates/pages/api'),
|
||||
path.resolve(process.cwd(), `${basePath}/pages/api`),
|
||||
)
|
||||
|
||||
// Copy admin into /app
|
||||
copyRecursiveSync(
|
||||
path.resolve(__dirname, './templates/app'),
|
||||
path.resolve(process.cwd(), `${basePath}/app`),
|
||||
)
|
||||
|
||||
const payloadConfigPath = path.resolve(process.cwd(), `${basePath}/payload`)
|
||||
|
||||
if (!fs.existsSync(payloadConfigPath)) {
|
||||
fs.mkdirSync(payloadConfigPath)
|
||||
}
|
||||
|
||||
// Copy payload initialization
|
||||
copyFile(
|
||||
path.resolve(__dirname, './templates/payloadClient.ts'),
|
||||
path.resolve(process.cwd(), `${basePath}/payload/payloadClient.ts`),
|
||||
)
|
||||
|
||||
// Copy base payload config
|
||||
copyFile(
|
||||
path.resolve(__dirname, './templates/payload.config.ts'),
|
||||
path.resolve(process.cwd(), `${basePath}/payload/payload.config.ts`),
|
||||
)
|
||||
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
export default install()
|
||||
@@ -1,7 +0,0 @@
|
||||
import fs from 'fs'
|
||||
|
||||
export const copyFile = (source, target) => {
|
||||
if (!fs.existsSync(target)) {
|
||||
fs.writeFileSync(target, fs.readFileSync(source))
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
|
||||
export function copyRecursiveSync(src, dest) {
|
||||
var exists = fs.existsSync(src)
|
||||
var stats = exists && fs.statSync(src)
|
||||
var isDirectory = exists && stats && stats.isDirectory()
|
||||
if (isDirectory) {
|
||||
fs.mkdirSync(dest, { recursive: true })
|
||||
fs.readdirSync(src).forEach(function (childItemName) {
|
||||
copyRecursiveSync(path.join(src, childItemName), path.join(dest, childItemName))
|
||||
})
|
||||
} else {
|
||||
fs.copyFileSync(src, dest)
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/next",
|
||||
"version": "3.0.0-alpha.55",
|
||||
"version": "3.0.0-alpha.58",
|
||||
"main": "./src/index.js",
|
||||
"types": "./src/index.js",
|
||||
"type": "module",
|
||||
@@ -10,9 +10,6 @@
|
||||
"url": "https://github.com/payloadcms/payload.git",
|
||||
"directory": "packages/next"
|
||||
},
|
||||
"bin": {
|
||||
"@payloadcms/next": "./dist/bin/index.js"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "pnpm copyfiles && pnpm build:swc && pnpm build:types && pnpm build:webpack && rm dist/prod/index.js",
|
||||
"build:swc": "swc ./src -d ./dist --config-file .swcrc",
|
||||
@@ -39,8 +36,8 @@
|
||||
"devDependencies": {
|
||||
"@next/eslint-plugin-next": "^14.1.0",
|
||||
"@payloadcms/eslint-config": "workspace:*",
|
||||
"@types/react": "18.2.15",
|
||||
"@types/react-dom": "18.2.7",
|
||||
"@types/react": "18.2.74",
|
||||
"@types/react-dom": "18.2.24",
|
||||
"@types/ws": "^8.5.10",
|
||||
"css-loader": "^6.10.0",
|
||||
"css-minimizer-webpack-plugin": "^6.0.0",
|
||||
|
||||
@@ -46,7 +46,7 @@ export const buildFormState = async ({ req }: { req: PayloadRequest }) => {
|
||||
|
||||
// Run the admin access function from the config if it exists
|
||||
if (adminAccessFunction) {
|
||||
const canAccessAdmin = await adminAccessFunction(req)
|
||||
const canAccessAdmin = await adminAccessFunction({ req })
|
||||
|
||||
if (!canAccessAdmin) {
|
||||
return Response.json(null, {
|
||||
|
||||
@@ -6,11 +6,12 @@ import './index.scss'
|
||||
|
||||
const baseClass = 'live-preview-iframe'
|
||||
|
||||
export const IFrame: React.FC<{
|
||||
ref: React.Ref<HTMLIFrameElement>
|
||||
type Props = {
|
||||
setIframeHasLoaded: (value: boolean) => void
|
||||
url: string
|
||||
}> = forwardRef((props, ref) => {
|
||||
}
|
||||
|
||||
export const IFrame = forwardRef<HTMLIFrameElement, Props>((props, ref) => {
|
||||
const { setIframeHasLoaded, url } = props
|
||||
|
||||
const { zoom } = useLivePreviewContext()
|
||||
|
||||
@@ -2,6 +2,7 @@ import type { I18n } from '@payloadcms/translations'
|
||||
import type { Metadata } from 'next'
|
||||
import type { SanitizedConfig } from 'payload/types'
|
||||
|
||||
import { getNextI18n } from '@payloadcms/next/utilities/getNextI18n.js'
|
||||
import { HydrateClientUser } from '@payloadcms/ui/elements/HydrateClientUser'
|
||||
import { DefaultTemplate } from '@payloadcms/ui/templates/Default'
|
||||
import React, { Fragment } from 'react'
|
||||
@@ -10,13 +11,18 @@ import { initPage } from '../../utilities/initPage.js'
|
||||
import { NotFoundClient } from './index.client.js'
|
||||
|
||||
export const generatePageMetadata = async ({
|
||||
i18n,
|
||||
config: configPromise,
|
||||
}: {
|
||||
config: SanitizedConfig
|
||||
i18n: I18n
|
||||
config: Promise<SanitizedConfig> | SanitizedConfig
|
||||
params?: { [key: string]: string | string[] }
|
||||
//eslint-disable-next-line @typescript-eslint/require-await
|
||||
}): Promise<Metadata> => {
|
||||
const config = await configPromise
|
||||
|
||||
const i18n = getNextI18n({
|
||||
config,
|
||||
})
|
||||
|
||||
return {
|
||||
title: i18n.t('general:notFound'),
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ export const generatePageMetadata = async ({ config: configPromise, params }: Ar
|
||||
const isGlobal = segmentOne === 'globals'
|
||||
const isCollection = segmentOne === 'collections'
|
||||
|
||||
const i18n = await getNextI18n({
|
||||
const i18n = getNextI18n({
|
||||
config,
|
||||
})
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ if (process.env.DISABLE_SWC !== 'true') {
|
||||
const dirname = path.dirname(filename)
|
||||
const url = pathToFileURL(dirname).toString() + '/'
|
||||
|
||||
register('./dist/bin/register/index.js', url)
|
||||
register('./dist/bin/loader/index.js', url)
|
||||
}
|
||||
|
||||
bin()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "payload",
|
||||
"version": "3.0.0-alpha.55",
|
||||
"version": "3.0.0-alpha.58",
|
||||
"description": "Node, React and MongoDB Headless CMS and Application Framework",
|
||||
"license": "MIT",
|
||||
"main": "./src/index.ts",
|
||||
@@ -61,7 +61,6 @@
|
||||
"nodemailer": "6.9.10",
|
||||
"pino": "8.15.0",
|
||||
"pino-pretty": "10.2.0",
|
||||
"pirates": "^4.0.6",
|
||||
"pluralize": "8.0.0",
|
||||
"probe-image-size": "^7.2.3",
|
||||
"sanitize-filename": "1.6.3",
|
||||
|
||||
@@ -19,10 +19,7 @@ export async function getAccessResults({ req }: GetAccessResultsArgs): Promise<P
|
||||
|
||||
if (userCollectionConfig) {
|
||||
results.canAccessAdmin = userCollectionConfig.access.admin
|
||||
? await userCollectionConfig.access.admin({
|
||||
payload,
|
||||
user,
|
||||
})
|
||||
? await userCollectionConfig.access.admin({ req })
|
||||
: isLoggedIn
|
||||
} else {
|
||||
results.canAccessAdmin = false
|
||||
|
||||
40
packages/payload/src/bin/loader/compile.ts
Normal file
40
packages/payload/src/bin/loader/compile.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import type * as ts from 'typescript'
|
||||
|
||||
import { transform } from '@swc-node/core'
|
||||
import { SourcemapMap } from '@swc-node/sourcemap-support'
|
||||
|
||||
import { tsCompilerOptionsToSwcConfig } from './read-default-tsconfig.js'
|
||||
|
||||
const injectInlineSourceMap = ({
|
||||
code,
|
||||
filename,
|
||||
map,
|
||||
}: {
|
||||
code: string
|
||||
filename: string
|
||||
map: string | undefined
|
||||
}): string => {
|
||||
if (map) {
|
||||
SourcemapMap.set(filename, map)
|
||||
const base64Map = Buffer.from(map, 'utf8').toString('base64')
|
||||
const sourceMapContent = `//# sourceMappingURL=data:application/json;charset=utf-8;base64,${base64Map}`
|
||||
return `${code}\n${sourceMapContent}`
|
||||
}
|
||||
return code
|
||||
}
|
||||
|
||||
export async function compile(
|
||||
sourcecode: string,
|
||||
filename: string,
|
||||
options: ts.CompilerOptions & { fallbackToTs?: (filename: string) => boolean },
|
||||
): Promise<string> {
|
||||
if (filename.endsWith('.d.ts')) {
|
||||
return ''
|
||||
}
|
||||
|
||||
const swcRegisterConfig = tsCompilerOptionsToSwcConfig(options, filename)
|
||||
|
||||
return transform(sourcecode, filename, swcRegisterConfig).then(({ code, map }) => {
|
||||
return injectInlineSourceMap({ code, filename, map })
|
||||
})
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import ts from 'typescript'
|
||||
import { fileURLToPath, pathToFileURL } from 'url'
|
||||
|
||||
import { CLIENT_EXTENSIONS } from './clientExtensions.js'
|
||||
import { compile } from './register.js'
|
||||
import { compile } from './compile.js'
|
||||
|
||||
interface ResolveContext {
|
||||
conditions: string[]
|
||||
@@ -26,6 +26,8 @@ type ResolveFn = (...args: Required<ResolveArgs>) => Promise<ResolveResult>
|
||||
const locatedConfig = getTsconfig()
|
||||
const tsconfig = locatedConfig.config.compilerOptions as unknown as ts.CompilerOptions
|
||||
|
||||
// Don't resolve d.ts files, because we aren't type-checking
|
||||
tsconfig.noDtsResolution = true
|
||||
tsconfig.module = ts.ModuleKind.ESNext
|
||||
tsconfig.moduleResolution = ts.ModuleResolutionKind.NodeNext
|
||||
|
||||
@@ -38,18 +40,25 @@ const host: ts.ModuleResolutionHost = {
|
||||
fileExists: ts.sys.fileExists,
|
||||
readFile: ts.sys.readFile,
|
||||
}
|
||||
const EXTENSIONS: string[] = [ts.Extension.Ts, ts.Extension.Tsx, ts.Extension.Dts, ts.Extension.Mts]
|
||||
const TS_EXTENSIONS: string[] = [
|
||||
ts.Extension.Ts,
|
||||
ts.Extension.Tsx,
|
||||
ts.Extension.Dts,
|
||||
ts.Extension.Mts,
|
||||
]
|
||||
|
||||
export const resolve: ResolveFn = async (specifier, context, nextResolve) => {
|
||||
const isTS = EXTENSIONS.some((ext) => specifier.endsWith(ext))
|
||||
const isTS = TS_EXTENSIONS.some((ext) => specifier.endsWith(ext))
|
||||
const isClient = CLIENT_EXTENSIONS.some((ext) => specifier.endsWith(ext))
|
||||
|
||||
// If a client file is resolved, we'll set `format: client`
|
||||
// and short circuit, so the load step
|
||||
// will return source code of empty object
|
||||
if (isClient) {
|
||||
const nextResult = await nextResolve(specifier, context, nextResolve)
|
||||
const specifierSegments = specifier.split('.')
|
||||
|
||||
return {
|
||||
format: '.' + specifierSegments[specifierSegments.length - 1],
|
||||
format: 'client',
|
||||
shortCircuit: true,
|
||||
url: nextResult.url,
|
||||
}
|
||||
@@ -64,9 +73,28 @@ export const resolve: ResolveFn = async (specifier, context, nextResolve) => {
|
||||
}
|
||||
}
|
||||
|
||||
// import/require from external library
|
||||
if (context.parentURL.includes('/node_modules/') && !isTS) {
|
||||
return nextResolve(specifier)
|
||||
// Try and resolve normally
|
||||
// This could fail, so we need to swallow that error
|
||||
// and keep going
|
||||
let nextResult: ResolveResult
|
||||
|
||||
// First, try to
|
||||
if (!isTS) {
|
||||
try {
|
||||
nextResult = await nextResolve(specifier, context, nextResolve)
|
||||
} catch (_) {
|
||||
// swallow error
|
||||
}
|
||||
}
|
||||
|
||||
if (nextResult) {
|
||||
const nextResultIsTS = TS_EXTENSIONS.some((ext) => nextResult.url.endsWith(ext))
|
||||
|
||||
return {
|
||||
...nextResult,
|
||||
format: nextResultIsTS ? 'ts' : nextResult.format,
|
||||
shortCircuit: true,
|
||||
}
|
||||
}
|
||||
|
||||
const { resolvedModule } = ts.resolveModuleName(
|
||||
@@ -77,14 +105,11 @@ export const resolve: ResolveFn = async (specifier, context, nextResolve) => {
|
||||
moduleResolutionCache,
|
||||
)
|
||||
|
||||
// import from local project to local project TS file
|
||||
if (
|
||||
resolvedModule &&
|
||||
!resolvedModule.resolvedFileName.includes('/node_modules/') &&
|
||||
EXTENSIONS.includes(resolvedModule.extension)
|
||||
) {
|
||||
if (resolvedModule) {
|
||||
const resolvedIsTS = TS_EXTENSIONS.includes(resolvedModule.extension)
|
||||
|
||||
return {
|
||||
format: 'ts',
|
||||
format: resolvedIsTS ? 'ts' : undefined,
|
||||
shortCircuit: true,
|
||||
url: pathToFileURL(resolvedModule.resolvedFileName).href,
|
||||
}
|
||||
@@ -92,9 +117,8 @@ export const resolve: ResolveFn = async (specifier, context, nextResolve) => {
|
||||
|
||||
// import from local project to either:
|
||||
// - something TS couldn't resolve
|
||||
// - external library
|
||||
// - local project non-TS file
|
||||
return nextResolve(specifier)
|
||||
return nextResolve(specifier, context, nextResolve)
|
||||
}
|
||||
|
||||
interface LoadContext {
|
||||
@@ -127,11 +151,11 @@ if (tsconfig.paths) {
|
||||
}
|
||||
|
||||
export const load: LoadFn = async (url, context, nextLoad) => {
|
||||
if (CLIENT_EXTENSIONS.some((e) => context.format === e)) {
|
||||
const rawSource = '{}'
|
||||
if (context.format === 'client') {
|
||||
const rawSource = 'export default {}'
|
||||
|
||||
return {
|
||||
format: 'json',
|
||||
format: 'module',
|
||||
shortCircuit: true,
|
||||
source: rawSource,
|
||||
}
|
||||
@@ -140,7 +164,7 @@ export const load: LoadFn = async (url, context, nextLoad) => {
|
||||
if (context.format === 'ts') {
|
||||
const { source } = await nextLoad(url, context)
|
||||
const code = typeof source === 'string' ? source : Buffer.from(source).toString()
|
||||
const compiled = await compile(code, fileURLToPath(url), swcOptions, true)
|
||||
const compiled = await compile(code, fileURLToPath(url), swcOptions)
|
||||
return {
|
||||
format: 'module',
|
||||
shortCircuit: true,
|
||||
@@ -1,125 +0,0 @@
|
||||
import type { Options } from '@swc-node/core'
|
||||
|
||||
import { transform, transformSync } from '@swc-node/core'
|
||||
import { SourcemapMap, installSourceMapSupport } from '@swc-node/sourcemap-support'
|
||||
import { getTsconfig } from 'get-tsconfig'
|
||||
import { platform } from 'os'
|
||||
import { resolve } from 'path'
|
||||
import { addHook } from 'pirates'
|
||||
import * as ts from 'typescript'
|
||||
|
||||
import { tsCompilerOptionsToSwcConfig } from './read-default-tsconfig.js'
|
||||
|
||||
const DEFAULT_EXTENSIONS = ['.js', '.jsx', '.es6', '.es', '.mjs', '.ts', '.tsx']
|
||||
const PLATFORM = platform()
|
||||
|
||||
const injectInlineSourceMap = ({
|
||||
code,
|
||||
filename,
|
||||
map,
|
||||
}: {
|
||||
code: string
|
||||
filename: string
|
||||
map: string | undefined
|
||||
}): string => {
|
||||
if (map) {
|
||||
SourcemapMap.set(filename, map)
|
||||
const base64Map = Buffer.from(map, 'utf8').toString('base64')
|
||||
const sourceMapContent = `//# sourceMappingURL=data:application/json;charset=utf-8;base64,${base64Map}`
|
||||
return `${code}\n${sourceMapContent}`
|
||||
}
|
||||
return code
|
||||
}
|
||||
|
||||
export function compile(
|
||||
sourcecode: string,
|
||||
filename: string,
|
||||
options: ts.CompilerOptions & { fallbackToTs?: (filename: string) => boolean },
|
||||
): string
|
||||
|
||||
export function compile(
|
||||
sourcecode: string,
|
||||
filename: string,
|
||||
options: ts.CompilerOptions & { fallbackToTs?: (filename: string) => boolean },
|
||||
async: false,
|
||||
): string
|
||||
|
||||
export function compile(
|
||||
sourcecode: string,
|
||||
filename: string,
|
||||
options: ts.CompilerOptions & { fallbackToTs?: (filename: string) => boolean },
|
||||
async: true,
|
||||
): Promise<string>
|
||||
|
||||
export function compile(
|
||||
sourcecode: string,
|
||||
filename: string,
|
||||
options: ts.CompilerOptions & { fallbackToTs?: (filename: string) => boolean },
|
||||
async: boolean,
|
||||
): Promise<string> | string
|
||||
|
||||
export function compile(
|
||||
sourcecode: string,
|
||||
filename: string,
|
||||
options: ts.CompilerOptions & { fallbackToTs?: (filename: string) => boolean },
|
||||
async = false,
|
||||
) {
|
||||
if (filename.endsWith('.d.ts')) {
|
||||
return ''
|
||||
}
|
||||
if (options.files && (options.files as string[]).length) {
|
||||
if (
|
||||
PLATFORM === 'win32' &&
|
||||
(options.files as string[]).every((file) => filename !== resolve(process.cwd(), file))
|
||||
) {
|
||||
return sourcecode
|
||||
}
|
||||
if (
|
||||
PLATFORM !== 'win32' &&
|
||||
(options.files as string[]).every((file) => !filename.endsWith(file))
|
||||
) {
|
||||
return sourcecode
|
||||
}
|
||||
}
|
||||
if (options && typeof options.fallbackToTs === 'function' && options.fallbackToTs(filename)) {
|
||||
delete options.fallbackToTs
|
||||
const { outputText, sourceMapText } = ts.transpileModule(sourcecode, {
|
||||
compilerOptions: options,
|
||||
fileName: filename,
|
||||
})
|
||||
return injectInlineSourceMap({ code: outputText, filename, map: sourceMapText })
|
||||
}
|
||||
|
||||
let swcRegisterConfig: Options
|
||||
if (process.env.SWCRC) {
|
||||
// when SWCRC environment variable is set to true it will use swcrc file
|
||||
swcRegisterConfig = {
|
||||
swc: {
|
||||
swcrc: true,
|
||||
},
|
||||
}
|
||||
} else {
|
||||
swcRegisterConfig = tsCompilerOptionsToSwcConfig(options, filename)
|
||||
}
|
||||
|
||||
if (async) {
|
||||
return transform(sourcecode, filename, swcRegisterConfig).then(({ code, map }) => {
|
||||
return injectInlineSourceMap({ code, filename, map })
|
||||
})
|
||||
} else {
|
||||
const { code, map } = transformSync(sourcecode, filename, swcRegisterConfig)
|
||||
return injectInlineSourceMap({ code, filename, map })
|
||||
}
|
||||
}
|
||||
|
||||
export function register(options: Partial<ts.CompilerOptions> = {}, hookOpts = {}) {
|
||||
const locatedConfig = getTsconfig()
|
||||
const tsconfig = locatedConfig.config.compilerOptions as unknown as ts.CompilerOptions
|
||||
options = tsconfig
|
||||
// options.module = ts.ModuleKind.CommonJS
|
||||
installSourceMapSupport()
|
||||
return addHook((code, filename) => compile(code, filename, options), {
|
||||
exts: DEFAULT_EXTENSIONS,
|
||||
...hookOpts,
|
||||
})
|
||||
}
|
||||
@@ -293,7 +293,7 @@ export type CollectionConfig = {
|
||||
* Access control
|
||||
*/
|
||||
access?: {
|
||||
admin?: (args?: any) => Promise<boolean> | boolean
|
||||
admin?: ({ req }: { req: PayloadRequest }) => Promise<boolean> | boolean
|
||||
create?: Access
|
||||
delete?: Access
|
||||
read?: Access
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
import type pino from 'pino'
|
||||
|
||||
import { createRequire } from 'module'
|
||||
import path from 'path'
|
||||
|
||||
import type { SanitizedConfig } from './types.js'
|
||||
|
||||
import { CLIENT_EXTENSIONS } from '../bin/register/clientExtensions.js'
|
||||
import Logger from '../utilities/logger.js'
|
||||
import { findConfig } from './find.js'
|
||||
import { validateSchema } from './validate.js'
|
||||
|
||||
const require = createRequire(import.meta.url)
|
||||
|
||||
const loadConfig = async (logger?: pino.Logger): Promise<SanitizedConfig> => {
|
||||
const localLogger = logger ?? Logger()
|
||||
|
||||
const configPath = findConfig()
|
||||
|
||||
CLIENT_EXTENSIONS.forEach((ext) => {
|
||||
require.extensions[ext] = () => null
|
||||
})
|
||||
|
||||
const configPromise = await import(configPath)
|
||||
|
||||
let config = await configPromise
|
||||
|
||||
if ('default' in config) config = await config.default
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
config = validateSchema(config, localLogger)
|
||||
}
|
||||
|
||||
return {
|
||||
...config,
|
||||
paths: {
|
||||
config: configPath,
|
||||
configDir: path.dirname(configPath),
|
||||
rawConfig: configPath,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export default loadConfig
|
||||
@@ -1,3 +1 @@
|
||||
export { getFileByPath } from '../uploads/getFileByPath.js'
|
||||
export { importConfig } from '../utilities/importConfig.js'
|
||||
export { importWithoutClientFiles } from '../utilities/importWithoutClientFiles.js'
|
||||
export { importConfig, importWithoutClientFiles } from '../utilities/importWithoutClientFiles.js'
|
||||
|
||||
1
packages/payload/src/exports/uploads.ts
Normal file
1
packages/payload/src/exports/uploads.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { getFileByPath } from '../uploads/getFileByPath.js'
|
||||
@@ -1,41 +0,0 @@
|
||||
import path from 'node:path'
|
||||
|
||||
import type { SanitizedConfig } from '../config/types.js'
|
||||
|
||||
import { importWithoutClientFiles } from './importWithoutClientFiles.js'
|
||||
|
||||
/**
|
||||
* Resolve and load Payload config from either a relative or absolute path
|
||||
*/
|
||||
export const importConfig = async (configPath: string) => {
|
||||
const isAbsolutePath = path.isAbsolute(configPath)
|
||||
if (isAbsolutePath) {
|
||||
const config = await importWithoutClientFiles<{ default: Promise<SanitizedConfig> }>(configPath)
|
||||
return await config.default
|
||||
}
|
||||
|
||||
const callerDir = path.dirname(getCallerInfo()[1].getFileName()).replace('file://', '')
|
||||
const fullConfigPath = path.resolve(callerDir, configPath)
|
||||
|
||||
const config = await importWithoutClientFiles<{ default: Promise<SanitizedConfig> }>(
|
||||
fullConfigPath,
|
||||
)
|
||||
return await config.default
|
||||
}
|
||||
|
||||
const getCallerInfo = () => {
|
||||
const _prepareStackTrace = Error.prepareStackTrace
|
||||
try {
|
||||
let result = []
|
||||
Error.prepareStackTrace = (_, callSites) => {
|
||||
const callSitesWithoutCurrent = callSites.slice(1)
|
||||
result = callSitesWithoutCurrent
|
||||
return callSitesWithoutCurrent
|
||||
}
|
||||
|
||||
new Error().stack
|
||||
return result
|
||||
} finally {
|
||||
Error.prepareStackTrace = _prepareStackTrace
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,51 @@ import { register } from 'node:module'
|
||||
import { fileURLToPath, pathToFileURL } from 'node:url'
|
||||
import path from 'path'
|
||||
|
||||
import type { SanitizedConfig } from '../config/types.js'
|
||||
|
||||
const filename = fileURLToPath(import.meta.url)
|
||||
const dirname = path.dirname(filename)
|
||||
|
||||
export const importWithoutClientFiles = async <T = unknown>(filePath: string) => {
|
||||
const url = pathToFileURL(filePath).toString()
|
||||
|
||||
register(path.resolve(dirname, '../../dist/bin/register/index.js'), url)
|
||||
register(path.resolve(dirname, '../../dist/bin/loader/index.js'), url)
|
||||
const result = await import(filePath)
|
||||
return result as T
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve and load Payload config from either a relative or absolute path
|
||||
*/
|
||||
export const importConfig = async (configPath: string) => {
|
||||
const isAbsolutePath = path.isAbsolute(configPath)
|
||||
if (isAbsolutePath) {
|
||||
const config = await importWithoutClientFiles<{ default: Promise<SanitizedConfig> }>(configPath)
|
||||
return await config.default
|
||||
}
|
||||
|
||||
const callerDir = path.dirname(getCallerInfo()[1].getFileName()).replace('file://', '')
|
||||
const fullConfigPath = path.resolve(callerDir, configPath)
|
||||
|
||||
const config = await importWithoutClientFiles<{ default: Promise<SanitizedConfig> }>(
|
||||
fullConfigPath,
|
||||
)
|
||||
return await config.default
|
||||
}
|
||||
|
||||
const getCallerInfo = () => {
|
||||
const _prepareStackTrace = Error.prepareStackTrace
|
||||
try {
|
||||
let result = []
|
||||
Error.prepareStackTrace = (_, callSites) => {
|
||||
const callSitesWithoutCurrent = callSites.slice(1)
|
||||
result = callSitesWithoutCurrent
|
||||
return callSitesWithoutCurrent
|
||||
}
|
||||
|
||||
new Error().stack
|
||||
return result
|
||||
} finally {
|
||||
Error.prepareStackTrace = _prepareStackTrace
|
||||
}
|
||||
}
|
||||
|
||||
2
packages/payload/uploads.d.ts
vendored
Normal file
2
packages/payload/uploads.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export { getFileByPath } from './dist/uploads/getFileByPath.js'
|
||||
//# sourceMappingURL=uploads.d.ts.map
|
||||
3
packages/payload/uploads.js
Normal file
3
packages/payload/uploads.js
Normal file
@@ -0,0 +1,3 @@
|
||||
export { getFileByPath } from './dist/uploads/getFileByPath.js'
|
||||
|
||||
//# sourceMappingURL=uploads.js.map
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@payloadcms/plugin-cloud-storage",
|
||||
"description": "The official cloud storage plugin for Payload CMS",
|
||||
"version": "3.0.0-alpha.55",
|
||||
"version": "3.0.0-alpha.58",
|
||||
"main": "./src/index.ts",
|
||||
"types": "./src/index.ts",
|
||||
"type": "module",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@payloadcms/plugin-cloud",
|
||||
"description": "The official Payload Cloud plugin",
|
||||
"version": "3.0.0-alpha.55",
|
||||
"version": "3.0.0-alpha.58",
|
||||
"main": "./src/index.ts",
|
||||
"types": "./src/index.ts",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@payloadcms/plugin-form-builder",
|
||||
"description": "Form builder plugin for Payload CMS",
|
||||
"version": "3.0.0-alpha.55",
|
||||
"version": "3.0.0-alpha.58",
|
||||
"homepage:": "https://payloadcms.com",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -34,7 +34,7 @@
|
||||
"@payloadcms/eslint-config": "workspace:*",
|
||||
"@types/escape-html": "^1.0.4",
|
||||
"@types/express": "^4.17.21",
|
||||
"@types/react": "18.2.15",
|
||||
"@types/react": "18.2.74",
|
||||
"copyfiles": "^2.4.1",
|
||||
"cross-env": "^7.0.3",
|
||||
"nodemon": "3.0.3",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/plugin-nested-docs",
|
||||
"version": "3.0.0-alpha.55",
|
||||
"version": "3.0.0-alpha.58",
|
||||
"description": "The official Nested Docs plugin for Payload",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/plugin-redirects",
|
||||
"version": "3.0.0-alpha.55",
|
||||
"version": "3.0.0-alpha.58",
|
||||
"homepage:": "https://payloadcms.com",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -36,7 +36,7 @@
|
||||
"devDependencies": {
|
||||
"@payloadcms/eslint-config": "workspace:*",
|
||||
"@types/express": "^4.17.9",
|
||||
"@types/react": "18.0.21",
|
||||
"@types/react": "18.2.74",
|
||||
"payload": "workspace:*",
|
||||
"react": "^18.0.0"
|
||||
},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/plugin-search",
|
||||
"version": "3.0.0-alpha.55",
|
||||
"version": "3.0.0-alpha.58",
|
||||
"homepage:": "https://payloadcms.com",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -41,7 +41,7 @@
|
||||
"devDependencies": {
|
||||
"@payloadcms/eslint-config": "workspace:*",
|
||||
"@types/express": "^4.17.9",
|
||||
"@types/react": "18.0.21",
|
||||
"@types/react": "18.2.74",
|
||||
"payload": "workspace:*",
|
||||
"react": "^18.0.0"
|
||||
},
|
||||
|
||||
@@ -44,8 +44,8 @@
|
||||
"@payloadcms/eslint-config": "workspace:*",
|
||||
"@types/express": "^4.17.9",
|
||||
"@types/jest": "^29.5.2",
|
||||
"@types/node": "18.11.3",
|
||||
"@types/react": "18.0.21",
|
||||
"@types/node": "20.12.5",
|
||||
"@types/react": "18.2.74",
|
||||
"copyfiles": "^2.4.1",
|
||||
"cross-env": "^7.0.3",
|
||||
"dotenv": "^8.2.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/plugin-seo",
|
||||
"version": "3.0.0-alpha.55",
|
||||
"version": "3.0.0-alpha.58",
|
||||
"homepage:": "https://payloadcms.com",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -40,7 +40,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@payloadcms/eslint-config": "workspace:*",
|
||||
"@types/react": "18.2.15",
|
||||
"@types/react": "18.2.74",
|
||||
"payload": "workspace:*",
|
||||
"@payloadcms/translations": "workspace:*",
|
||||
"@payloadcms/ui": "workspace:*",
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
"@payloadcms/eslint-config": "workspace:*",
|
||||
"@types/express": "^4.17.9",
|
||||
"@types/lodash.get": "^4.4.7",
|
||||
"@types/react": "18.0.21",
|
||||
"@types/react": "18.2.74",
|
||||
"@types/uuid": "^9.0.0",
|
||||
"payload": "workspace:*",
|
||||
"prettier": "^2.7.1",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/richtext-lexical",
|
||||
"version": "3.0.0-alpha.55",
|
||||
"version": "3.0.0-alpha.58",
|
||||
"description": "The officially supported Lexical richtext adapter for Payload",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -47,9 +47,9 @@
|
||||
"devDependencies": {
|
||||
"@payloadcms/eslint-config": "workspace:*",
|
||||
"@types/json-schema": "7.0.15",
|
||||
"@types/node": "20.6.2",
|
||||
"@types/react": "18.2.15",
|
||||
"@types/react-dom": "18.2.7",
|
||||
"@types/node": "20.12.5",
|
||||
"@types/react": "18.2.74",
|
||||
"@types/react-dom": "18.2.24",
|
||||
"payload": "workspace:*",
|
||||
"@payloadcms/translations": "workspace:*",
|
||||
"@payloadcms/ui": "workspace:*",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/richtext-slate",
|
||||
"version": "3.0.0-alpha.55",
|
||||
"version": "3.0.0-alpha.58",
|
||||
"description": "The officially supported Slate richtext adapter for Payload",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -33,8 +33,8 @@
|
||||
"devDependencies": {
|
||||
"@payloadcms/ui": "workspace:*",
|
||||
"@payloadcms/eslint-config": "workspace:*",
|
||||
"@types/node": "20.5.7",
|
||||
"@types/react": "18.2.15",
|
||||
"@types/node": "20.12.5",
|
||||
"@types/react": "18.2.74",
|
||||
"payload": "workspace:*"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/translations",
|
||||
"version": "3.0.0-alpha.54",
|
||||
"version": "3.0.0-alpha.58",
|
||||
"main": "./src/exports/index.ts",
|
||||
"types": "./src/types.ts",
|
||||
"type": "module",
|
||||
@@ -56,8 +56,8 @@
|
||||
"devDependencies": {
|
||||
"@payloadcms/eslint-config": "workspace:*",
|
||||
"@swc/core": "^1.3.102",
|
||||
"@types/react": "^18",
|
||||
"typescript": "5.4.2"
|
||||
"@types/react": "18.2.74",
|
||||
"typescript": "5.4.4"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/ui",
|
||||
"version": "3.0.0-alpha.55",
|
||||
"version": "3.0.0-alpha.58",
|
||||
"type": "module",
|
||||
"homepage": "https://payloadcms.com",
|
||||
"repository": {
|
||||
@@ -174,9 +174,9 @@
|
||||
"@payloadcms/eslint-config": "workspace:*",
|
||||
"@types/body-scroll-lock": "^3.1.0",
|
||||
"@types/qs": "6.9.7",
|
||||
"@types/react": "18.2.15",
|
||||
"@types/react": "18.2.74",
|
||||
"@types/react-datepicker": "4.11.2",
|
||||
"@types/react-dom": "18.2.7",
|
||||
"@types/react-dom": "18.2.24",
|
||||
"@types/uuid": "8.3.4",
|
||||
"postcss-loader": "^8.1.1",
|
||||
"postcss-preset-env": "^9.5.0",
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import type { Ref } from 'react'
|
||||
|
||||
import React, { forwardRef } from 'react'
|
||||
|
||||
import './index.scss'
|
||||
@@ -10,43 +8,40 @@ export type GutterProps = {
|
||||
left?: boolean
|
||||
negativeLeft?: boolean
|
||||
negativeRight?: boolean
|
||||
ref?: Ref<HTMLDivElement>
|
||||
right?: boolean
|
||||
}
|
||||
|
||||
const baseClass = 'gutter'
|
||||
|
||||
export const Gutter: React.FC<GutterProps> = forwardRef<HTMLDivElement, GutterProps>(
|
||||
(props, ref) => {
|
||||
const {
|
||||
children,
|
||||
className,
|
||||
left = true,
|
||||
negativeLeft = false,
|
||||
negativeRight = false,
|
||||
right = true,
|
||||
} = props
|
||||
export const Gutter = forwardRef<HTMLDivElement, GutterProps>((props, ref) => {
|
||||
const {
|
||||
children,
|
||||
className,
|
||||
left = true,
|
||||
negativeLeft = false,
|
||||
negativeRight = false,
|
||||
right = true,
|
||||
} = props
|
||||
|
||||
const shouldPadLeft = left && !negativeLeft
|
||||
const shouldPadRight = right && !negativeRight
|
||||
const shouldPadLeft = left && !negativeLeft
|
||||
const shouldPadRight = right && !negativeRight
|
||||
|
||||
return (
|
||||
<div
|
||||
className={[
|
||||
shouldPadLeft && `${baseClass}--left`,
|
||||
shouldPadRight && `${baseClass}--right`,
|
||||
negativeLeft && `${baseClass}--negative-left`,
|
||||
negativeRight && `${baseClass}--negative-right`,
|
||||
className,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' ')}
|
||||
ref={ref}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
},
|
||||
)
|
||||
return (
|
||||
<div
|
||||
className={[
|
||||
shouldPadLeft && `${baseClass}--left`,
|
||||
shouldPadRight && `${baseClass}--right`,
|
||||
negativeLeft && `${baseClass}--negative-left`,
|
||||
negativeRight && `${baseClass}--negative-right`,
|
||||
className,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' ')}
|
||||
ref={ref}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
})
|
||||
|
||||
Gutter.displayName = 'Gutter'
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
'use client'
|
||||
// TODO: abstract the `next/navigation` dependency out from this component
|
||||
import { usePathname, useRouter } from 'next/navigation.js'
|
||||
import queryString from 'qs'
|
||||
import { useRouter } from 'next/navigation.js'
|
||||
import React, { useCallback } from 'react'
|
||||
|
||||
export type SortColumnProps = {
|
||||
@@ -22,9 +21,8 @@ const baseClass = 'sort-column'
|
||||
|
||||
export const SortColumn: React.FC<SortColumnProps> = (props) => {
|
||||
const { name, Label, disable = false, label } = props
|
||||
const { searchParams } = useSearchParams()
|
||||
const { searchParams, stringifyParams } = useSearchParams()
|
||||
const router = useRouter()
|
||||
const pathname = usePathname()
|
||||
const { t } = useTranslation()
|
||||
|
||||
const { sort } = searchParams
|
||||
@@ -40,17 +38,16 @@ export const SortColumn: React.FC<SortColumnProps> = (props) => {
|
||||
|
||||
const setSort = useCallback(
|
||||
(newSort) => {
|
||||
const search = queryString.stringify(
|
||||
{
|
||||
...searchParams,
|
||||
sort: newSort,
|
||||
},
|
||||
{ addQueryPrefix: true },
|
||||
router.replace(
|
||||
stringifyParams({
|
||||
params: {
|
||||
sort: newSort,
|
||||
},
|
||||
replace: true,
|
||||
}),
|
||||
)
|
||||
|
||||
router.replace(`${pathname}?${search}`)
|
||||
},
|
||||
[searchParams, pathname, router],
|
||||
[router, stringifyParams],
|
||||
)
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,42 +1,33 @@
|
||||
diff --git a/index.mjs b/index.mjs
|
||||
index c736e9d13ad09e54ee6f1fe000a9c8d8aa853f40..92ca367464c3d582b7496fd57d59d2ff5849e398 100644
|
||||
index c736e9d13ad09e54ee6f1fe000a9c8d8aa853f40..54f9db62354009d5c34673876d73fbee1f648a19 100644
|
||||
--- a/index.mjs
|
||||
+++ b/index.mjs
|
||||
@@ -16,3 +16,6 @@
|
||||
@@ -16,3 +16,5 @@
|
||||
export * from 'playwright-core';
|
||||
import playwright from 'playwright-core';
|
||||
export default playwright;
|
||||
+
|
||||
+
|
||||
+export function createElement() {} // https://github.com/microsoft/playwright/issues/26824 TODO: Maybe create proxy which returns this from react instead? It should be React.createElement
|
||||
\ No newline at end of file
|
||||
diff --git a/lib/transform/esmLoader.js b/lib/transform/esmLoader.js
|
||||
index 80073de7dfc269c6f838e685850b9f32ea0c1f9a..be536bc0dd0969d692c58e4ca0b99f424bdc88a1 100644
|
||||
index 80073de7dfc269c6f838e685850b9f32ea0c1f9a..76e59df1c543fb47735ef68654bec5d3b24cc07c 100644
|
||||
--- a/lib/transform/esmLoader.js
|
||||
+++ b/lib/transform/esmLoader.js
|
||||
@@ -5,7 +5,17 @@ var _url = _interopRequireDefault(require("url"));
|
||||
@@ -5,6 +5,10 @@ var _url = _interopRequireDefault(require("url"));
|
||||
var _compilationCache = require("./compilationCache");
|
||||
var _transform = require("./transform");
|
||||
var _portTransport = require("./portTransport");
|
||||
+
|
||||
+
|
||||
+const fs2 = require('node:fs/promises')
|
||||
+const { fileURLToPath } = require('node:url')
|
||||
+
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
+
|
||||
+
|
||||
+const endsWith = ['scss', 'css', 'svg', 'png', 'jpg', 'eot', 'ttf', 'woff', 'woff2'];
|
||||
+
|
||||
+
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
/**
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
*
|
||||
@@ -25,6 +35,27 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
||||
@@ -25,6 +29,25 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
||||
// Node < 18.6: defaultResolve takes 3 arguments.
|
||||
// Node >= 18.6: nextResolve from the chain takes 2 arguments.
|
||||
async function resolve(specifier, context, defaultResolve) {
|
||||
+
|
||||
+ if(specifier?.endsWith('/node_modules/playwright')) {
|
||||
+ specifier = specifier.replace('/node_modules/playwright', '/node_modules/playwright/index.mjs')
|
||||
+ }
|
||||
@@ -55,12 +46,11 @@ index 80073de7dfc269c6f838e685850b9f32ea0c1f9a..be536bc0dd0969d692c58e4ca0b99f42
|
||||
+ url: nextResult.url,
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
var _currentFileDepsColle;
|
||||
if (context.parentURL && context.parentURL.startsWith('file://')) {
|
||||
const filename = _url.default.fileURLToPath(context.parentURL);
|
||||
@@ -41,6 +72,20 @@ async function resolve(specifier, context, defaultResolve) {
|
||||
@@ -41,6 +64,18 @@ async function resolve(specifier, context, defaultResolve) {
|
||||
// Node < 18.6: defaultLoad takes 3 arguments.
|
||||
// Node >= 18.6: nextLoad from the chain takes 2 arguments.
|
||||
async function load(moduleUrl, context, defaultLoad) {
|
||||
@@ -75,8 +65,6 @@ index 80073de7dfc269c6f838e685850b9f32ea0c1f9a..be536bc0dd0969d692c58e4ca0b99f42
|
||||
+ source: JSON.stringify(rawSource),
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+
|
||||
var _transport;
|
||||
// Bail out for wasm, json, etc.
|
||||
710
pnpm-lock.yaml
generated
710
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -18,7 +18,7 @@ import { updateChangelog } from './utils/updateChangelog.js'
|
||||
// Update this list with any packages to publish
|
||||
const packageWhitelist = [
|
||||
'payload',
|
||||
'translations',
|
||||
// 'translations',
|
||||
'ui',
|
||||
'next',
|
||||
'graphql',
|
||||
@@ -27,7 +27,7 @@ const packageWhitelist = [
|
||||
'richtext-slate',
|
||||
'richtext-lexical',
|
||||
|
||||
'create-payload-app',
|
||||
// 'create-payload-app',
|
||||
|
||||
// Plugins
|
||||
'plugin-cloud',
|
||||
@@ -210,9 +210,8 @@ async function main() {
|
||||
}
|
||||
|
||||
// Publish
|
||||
const results: { name: string; success: boolean; details?: string }[] = await pMap(
|
||||
packageDetails,
|
||||
async (pkg) => {
|
||||
const results: { name: string; success: boolean; details?: string }[] = await Promise.all(
|
||||
packageDetails.map(async (pkg) => {
|
||||
try {
|
||||
console.log(logPrefix, chalk.bold(`🚀 ${pkg.name} publishing...`))
|
||||
const cmdArgs = ['publish', '-C', pkg.packagePath, '--no-git-checks', '--tag', tag]
|
||||
@@ -238,8 +237,7 @@ async function main() {
|
||||
console.error(chalk.bold.red(`\n\n❌ ${pkg.name} ERROR: ${error.message}\n\n`))
|
||||
return { name: pkg.name, success: false }
|
||||
}
|
||||
},
|
||||
{ concurrency: 5 },
|
||||
}),
|
||||
)
|
||||
|
||||
console.log(chalk.bold.green(`\n\nResults:\n`))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import path from 'path'
|
||||
import { getFileByPath } from 'payload/node'
|
||||
import { getFileByPath } from 'payload/uploads'
|
||||
import { fileURLToPath } from 'url'
|
||||
|
||||
import { buildConfigWithDefaults } from '../buildConfigWithDefaults.js'
|
||||
|
||||
@@ -72,9 +72,16 @@ describe('admin', () => {
|
||||
let disableDuplicateURL: AdminUrlUtil
|
||||
let serverURL: string
|
||||
|
||||
beforeAll(async ({ browser }) => {
|
||||
beforeAll(async ({ browser }, testInfo) => {
|
||||
const prebuild = Boolean(process.env.CI)
|
||||
|
||||
if (prebuild) testInfo.setTimeout(testInfo.timeout * 2)
|
||||
|
||||
process.env.SEED_IN_CONFIG_ONINIT = 'false' // Makes it so the payload config onInit seed is not run. Otherwise, the seed would be run unnecessarily twice for the initial test run - once for beforeEach and once for onInit
|
||||
;({ payload, serverURL } = await initPayloadE2ENoConfig<Config>({ dirname }))
|
||||
;({ payload, serverURL } = await initPayloadE2ENoConfig<Config>({
|
||||
dirname,
|
||||
prebuild,
|
||||
}))
|
||||
geoUrl = new AdminUrlUtil(serverURL, geoCollectionSlug)
|
||||
postsUrl = new AdminUrlUtil(serverURL, postsCollectionSlug)
|
||||
customViewsURL = new AdminUrlUtil(serverURL, customViews2CollectionSlug)
|
||||
@@ -1271,10 +1278,14 @@ describe('admin', () => {
|
||||
const downChevron = page.locator('#heading-number .sort-column__desc')
|
||||
|
||||
await upChevron.click()
|
||||
await page.waitForURL(/sort=number/)
|
||||
|
||||
await expect(page.locator('.row-1 .cell-number')).toHaveText('1')
|
||||
await expect(page.locator('.row-2 .cell-number')).toHaveText('2')
|
||||
|
||||
await downChevron.click()
|
||||
await page.waitForURL(/sort=-number/)
|
||||
|
||||
await expect(page.locator('.row-1 .cell-number')).toHaveText('2')
|
||||
await expect(page.locator('.row-2 .cell-number')).toHaveText('1')
|
||||
})
|
||||
|
||||
10
test/dev.js
10
test/dev.js
@@ -1,15 +1,11 @@
|
||||
import minimist from 'minimist'
|
||||
import { MongoMemoryReplSet } from 'mongodb-memory-server'
|
||||
import { nextDev } from 'next/dist/cli/next-dev.js'
|
||||
import { dirname, resolve } from 'path'
|
||||
import { fileURLToPath } from 'url'
|
||||
import open, { openApp, apps } from 'open'
|
||||
import open from 'open'
|
||||
import { getNextJSRootDir } from './helpers/getNextJSRootDir.js'
|
||||
|
||||
import { createTestHooks } from './testHooks.js'
|
||||
|
||||
const _filename = fileURLToPath(import.meta.url)
|
||||
const _dirname = dirname(_filename)
|
||||
|
||||
process.env.PAYLOAD_DROP_DATABASE = 'true'
|
||||
|
||||
const {
|
||||
@@ -26,7 +22,7 @@ process.env.PAYLOAD_DROP_DATABASE = 'true'
|
||||
const { afterTest, beforeTest } = await createTestHooks(testSuiteArg)
|
||||
await beforeTest()
|
||||
|
||||
const rootDir = resolve(_dirname, '../')
|
||||
const rootDir = getNextJSRootDir(testSuiteArg)
|
||||
|
||||
// Open the admin if the -o flag is passed
|
||||
if (args.o) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import path from 'path'
|
||||
import { getFileByPath } from 'payload/node'
|
||||
import { getFileByPath } from 'payload/uploads'
|
||||
import { fileURLToPath } from 'url'
|
||||
|
||||
import { buildConfigWithDefaults } from '../buildConfigWithDefaults.js'
|
||||
|
||||
@@ -42,9 +42,16 @@ let serverURL: string
|
||||
// If we want to make this run in parallel: test.describe.configure({ mode: 'parallel' })
|
||||
|
||||
describe('fields', () => {
|
||||
beforeAll(async ({ browser }) => {
|
||||
beforeAll(async ({ browser }, testInfo) => {
|
||||
const prebuild = Boolean(process.env.CI)
|
||||
|
||||
if (prebuild) testInfo.setTimeout(testInfo.timeout * 3)
|
||||
|
||||
process.env.SEED_IN_CONFIG_ONINIT = 'false' // Makes it so the payload config onInit seed is not run. Otherwise, the seed would be run unnecessarily twice for the initial test run - once for beforeEach and once for onInit
|
||||
;({ payload, serverURL } = await initPayloadE2ENoConfig({ dirname }))
|
||||
;({ payload, serverURL } = await initPayloadE2ENoConfig({
|
||||
dirname,
|
||||
prebuild,
|
||||
}))
|
||||
|
||||
const context = await browser.newContext()
|
||||
page = await context.newPage()
|
||||
@@ -696,6 +703,8 @@ describe('fields', () => {
|
||||
'#field-customBlocks input[name="customBlocks.0.block1Title"]',
|
||||
)
|
||||
|
||||
await page.mouse.wheel(0, 1750)
|
||||
|
||||
await customBlocks.scrollIntoViewIfNeeded()
|
||||
|
||||
await expect(customBlocks).toHaveValue('Block 1: Prefilled Title')
|
||||
@@ -775,6 +784,7 @@ describe('fields', () => {
|
||||
const assertText3 = 'array row 3'
|
||||
const assertGroupText3 = 'text in group in row 3'
|
||||
await page.goto(url.create)
|
||||
await page.mouse.wheel(0, 1750)
|
||||
await page.locator('#field-potentiallyEmptyArray').scrollIntoViewIfNeeded()
|
||||
await wait(300)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { Payload } from 'payload'
|
||||
|
||||
import path from 'path'
|
||||
import { getFileByPath } from 'payload/node'
|
||||
import { getFileByPath } from 'payload/uploads'
|
||||
import { fileURLToPath } from 'url'
|
||||
|
||||
import { devUser } from '../credentials.js'
|
||||
|
||||
7
test/helpers/build.js
Normal file
7
test/helpers/build.js
Normal file
@@ -0,0 +1,7 @@
|
||||
import nextBuild from 'next/dist/build/index.js'
|
||||
|
||||
const build = async () => {
|
||||
await nextBuild.default(process.env.NEXTJS_DIR, false, false, false, true, true, false, 'default')
|
||||
}
|
||||
|
||||
build()
|
||||
25
test/helpers/getNextJSRootDir.js
Normal file
25
test/helpers/getNextJSRootDir.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import fs from 'fs'
|
||||
import { dirname, resolve } from 'path'
|
||||
import { fileURLToPath } from 'url'
|
||||
|
||||
const _filename = fileURLToPath(import.meta.url)
|
||||
const _dirname = dirname(_filename)
|
||||
|
||||
export const getNextJSRootDir = (testSuite) => {
|
||||
const testSuiteDir = resolve(_dirname, `../${testSuite}`)
|
||||
|
||||
let hasNextConfig = false
|
||||
|
||||
try {
|
||||
fs.accessSync(`${testSuiteDir}/next.config.mjs`, fs.constants.F_OK)
|
||||
hasNextConfig = true
|
||||
} catch (err) {
|
||||
// Swallow err - no config found
|
||||
}
|
||||
|
||||
if (hasNextConfig) return testSuiteDir
|
||||
|
||||
// If no next config found in test suite,
|
||||
// return monorepo root dir
|
||||
return resolve(_dirname, '../../')
|
||||
}
|
||||
@@ -1,17 +1,24 @@
|
||||
import { createServer } from 'http'
|
||||
import nextImport from 'next'
|
||||
import path from 'path'
|
||||
import { spawn } from 'node:child_process'
|
||||
import { dirname, resolve } from 'path'
|
||||
import { wait } from 'payload/utilities'
|
||||
import { parse } from 'url'
|
||||
import { fileURLToPath } from 'url'
|
||||
|
||||
import type { GeneratedTypes } from './sdk/types.js'
|
||||
|
||||
import { createTestHooks } from '../testHooks.js'
|
||||
import { getNextJSRootDir } from './getNextJSRootDir.js'
|
||||
import { PayloadTestSDK } from './sdk/index.js'
|
||||
import startMemoryDB from './startMemoryDB.js'
|
||||
|
||||
const _filename = fileURLToPath(import.meta.url)
|
||||
const _dirname = dirname(_filename)
|
||||
|
||||
type Args = {
|
||||
dirname: string
|
||||
prebuild?: boolean
|
||||
}
|
||||
|
||||
type Result<T extends GeneratedTypes<T>> = {
|
||||
@@ -21,6 +28,7 @@ type Result<T extends GeneratedTypes<T>> = {
|
||||
|
||||
export async function initPayloadE2ENoConfig<T extends GeneratedTypes<T>>({
|
||||
dirname,
|
||||
prebuild,
|
||||
}: Args): Promise<Result<T>> {
|
||||
const testSuiteName = dirname.split('/').pop()
|
||||
const { beforeTest } = await createTestHooks(testSuiteName)
|
||||
@@ -32,12 +40,36 @@ export async function initPayloadE2ENoConfig<T extends GeneratedTypes<T>>({
|
||||
|
||||
await startMemoryDB()
|
||||
|
||||
const dir = getNextJSRootDir(testSuiteName)
|
||||
|
||||
if (prebuild) {
|
||||
await new Promise<void>((res, rej) => {
|
||||
const buildArgs = ['--max-old-space-size=8192', resolve(_dirname, 'build.js')]
|
||||
|
||||
const childProcess = spawn('node', buildArgs, {
|
||||
stdio: 'inherit',
|
||||
env: {
|
||||
PATH: process.env.PATH,
|
||||
NODE_ENV: 'production',
|
||||
NEXTJS_DIR: dir,
|
||||
},
|
||||
})
|
||||
|
||||
childProcess.on('close', (code) => {
|
||||
if (code === 0) res()
|
||||
rej()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
process.env.NODE_OPTIONS = '--max-old-space-size=8192 --no-deprecation'
|
||||
|
||||
// @ts-expect-error
|
||||
const app = nextImport({
|
||||
dev: true,
|
||||
dev: !prebuild,
|
||||
hostname: 'localhost',
|
||||
port,
|
||||
dir: path.resolve(dirname, '../../'),
|
||||
dir,
|
||||
})
|
||||
|
||||
const handle = app.getRequestHandler()
|
||||
|
||||
@@ -22,7 +22,5 @@ export default async () => {
|
||||
global._mongoMemoryServer = db
|
||||
|
||||
process.env.MONGODB_MEMORY_SERVER_URI = `${global._mongoMemoryServer.getUri()}&retryWrites=true`
|
||||
|
||||
console.log(process.env.MONGODB_MEMORY_SERVER_URI)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
|
||||
import type { Metadata } from 'next'
|
||||
|
||||
import config from '@payload-config'
|
||||
/* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
|
||||
import { NotFoundPage, generatePageMetadata } from '@payloadcms/next/views/NotFound/index.js'
|
||||
|
||||
type Args = {
|
||||
params: {
|
||||
segments: string[]
|
||||
}
|
||||
searchParams: {
|
||||
[key: string]: string | string[]
|
||||
}
|
||||
}
|
||||
|
||||
export const generateMetadata = ({ params }: Args): Promise<Metadata> =>
|
||||
generatePageMetadata({ config, params })
|
||||
|
||||
const NotFound = ({ params, searchParams }: Args) => NotFoundPage({ config, params, searchParams })
|
||||
|
||||
export default NotFound
|
||||
@@ -0,0 +1,22 @@
|
||||
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
|
||||
import type { Metadata } from 'next'
|
||||
|
||||
import config from '@payload-config'
|
||||
/* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
|
||||
import { RootPage, generatePageMetadata } from '@payloadcms/next/views/Root/index.js'
|
||||
|
||||
type Args = {
|
||||
params: {
|
||||
segments: string[]
|
||||
}
|
||||
searchParams: {
|
||||
[key: string]: string | string[]
|
||||
}
|
||||
}
|
||||
|
||||
export const generateMetadata = ({ params, searchParams }: Args): Promise<Metadata> =>
|
||||
generatePageMetadata({ config, params, searchParams })
|
||||
|
||||
const Page = ({ params, searchParams }: Args) => RootPage({ config, params, searchParams })
|
||||
|
||||
export default Page
|
||||
9
test/live-preview/app/(payload)/api/[...slug]/route.ts
Normal file
9
test/live-preview/app/(payload)/api/[...slug]/route.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
|
||||
/* DO NOT MODIFY it because it could be re-written at any time. */
|
||||
import config from '@payload-config'
|
||||
import { REST_DELETE, REST_GET, REST_PATCH, REST_POST } from '@payloadcms/next/routes/index.js'
|
||||
|
||||
export const GET = REST_GET(config)
|
||||
export const POST = REST_POST(config)
|
||||
export const DELETE = REST_DELETE(config)
|
||||
export const PATCH = REST_PATCH(config)
|
||||
@@ -0,0 +1,6 @@
|
||||
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
|
||||
/* DO NOT MODIFY it because it could be re-written at any time. */
|
||||
import config from '@payload-config'
|
||||
import { GRAPHQL_PLAYGROUND_GET } from '@payloadcms/next/routes/index.js'
|
||||
|
||||
export const GET = GRAPHQL_PLAYGROUND_GET(config)
|
||||
6
test/live-preview/app/(payload)/api/graphql/route.ts
Normal file
6
test/live-preview/app/(payload)/api/graphql/route.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
|
||||
/* DO NOT MODIFY it because it could be re-written at any time. */
|
||||
import config from '@payload-config'
|
||||
import { GRAPHQL_POST } from '@payloadcms/next/routes/index.js'
|
||||
|
||||
export const POST = GRAPHQL_POST(config)
|
||||
8
test/live-preview/app/(payload)/custom.scss
Normal file
8
test/live-preview/app/(payload)/custom.scss
Normal file
@@ -0,0 +1,8 @@
|
||||
#custom-css {
|
||||
font-family: monospace;
|
||||
background-image: url('/placeholder.png');
|
||||
}
|
||||
|
||||
#custom-css::after {
|
||||
content: 'custom-css';
|
||||
}
|
||||
15
test/live-preview/app/(payload)/layout.tsx
Normal file
15
test/live-preview/app/(payload)/layout.tsx
Normal file
@@ -0,0 +1,15 @@
|
||||
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
|
||||
import configPromise from '@payload-config'
|
||||
import { RootLayout } from '@payloadcms/next/layouts/Root/index.js'
|
||||
/* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
|
||||
import React from 'react'
|
||||
|
||||
import './custom.scss'
|
||||
|
||||
type Args = {
|
||||
children: React.ReactNode
|
||||
}
|
||||
|
||||
const Layout = ({ children }: Args) => <RootLayout config={configPromise}>{children}</RootLayout>
|
||||
|
||||
export default Layout
|
||||
@@ -3,7 +3,7 @@
|
||||
import { useLivePreview } from '@payloadcms/live-preview-react'
|
||||
import React from 'react'
|
||||
|
||||
import type { Post as PostType } from '../../../../../test/live-preview/payload-types.js'
|
||||
import type { Post as PostType } from '../../../../../payload-types.js'
|
||||
|
||||
import { PAYLOAD_SERVER_URL } from '../../../_api/serverURL.js'
|
||||
import { Blocks } from '../../../_components/Blocks/index.js'
|
||||
@@ -1,7 +1,7 @@
|
||||
import { notFound } from 'next/navigation.js'
|
||||
import React from 'react'
|
||||
|
||||
import type { Post } from '../../../../../test/live-preview/payload-types.js'
|
||||
import type { Post } from '../../../../../payload-types.js'
|
||||
|
||||
import { fetchDoc } from '../../../_api/fetchDoc.js'
|
||||
import { fetchDocs } from '../../../_api/fetchDocs.js'
|
||||
35
test/live-preview/app/live-preview/_api/fetchDoc.ts
Normal file
35
test/live-preview/app/live-preview/_api/fetchDoc.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import type { Where } from 'payload/types'
|
||||
|
||||
import config from '@payload-config'
|
||||
import { getPayloadHMR } from '@payloadcms/next/utilities/getPayloadHMR.js'
|
||||
|
||||
export const fetchDoc = async <T>(args: {
|
||||
collection: string
|
||||
depth?: number
|
||||
slug?: string
|
||||
}): Promise<T> => {
|
||||
const payload = await getPayloadHMR({ config })
|
||||
const { slug, collection, depth = 2 } = args || {}
|
||||
|
||||
const where: Where = {}
|
||||
|
||||
if (slug) {
|
||||
where.slug = {
|
||||
equals: slug,
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const { docs } = await payload.find({
|
||||
collection,
|
||||
depth,
|
||||
where,
|
||||
})
|
||||
|
||||
if (docs[0]) return docs[0] as T
|
||||
} catch (err) {
|
||||
console.log('Error fetching doc', err)
|
||||
}
|
||||
|
||||
throw new Error('Error fetching doc')
|
||||
}
|
||||
20
test/live-preview/app/live-preview/_api/fetchDocs.ts
Normal file
20
test/live-preview/app/live-preview/_api/fetchDocs.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import config from '@payload-config'
|
||||
import { getPayloadHMR } from '@payloadcms/next/utilities/getPayloadHMR.js'
|
||||
|
||||
export const fetchDocs = async <T>(collection: string): Promise<T[]> => {
|
||||
const payload = await getPayloadHMR({ config })
|
||||
|
||||
try {
|
||||
const { docs } = await payload.find({
|
||||
collection,
|
||||
depth: 0,
|
||||
limit: 100,
|
||||
})
|
||||
|
||||
return docs as T[]
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
}
|
||||
|
||||
throw new Error('Error fetching docs')
|
||||
}
|
||||
20
test/live-preview/app/live-preview/_api/fetchFooter.ts
Normal file
20
test/live-preview/app/live-preview/_api/fetchFooter.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import config from '@payload-config'
|
||||
import { getPayloadHMR } from '@payloadcms/next/utilities/getPayloadHMR.js'
|
||||
|
||||
import type { Footer } from '../../../payload-types.js'
|
||||
|
||||
export async function fetchFooter(): Promise<Footer> {
|
||||
const payload = await getPayloadHMR({ config })
|
||||
|
||||
try {
|
||||
const footer = await payload.findGlobal({
|
||||
slug: 'footer',
|
||||
})
|
||||
|
||||
return footer as Footer
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
}
|
||||
|
||||
throw new Error('Error fetching footer.')
|
||||
}
|
||||
20
test/live-preview/app/live-preview/_api/fetchHeader.ts
Normal file
20
test/live-preview/app/live-preview/_api/fetchHeader.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import config from '@payload-config'
|
||||
import { getPayloadHMR } from '@payloadcms/next/utilities/getPayloadHMR.js'
|
||||
|
||||
import type { Header } from '../../../payload-types.js'
|
||||
|
||||
export async function fetchHeader(): Promise<Header> {
|
||||
const payload = await getPayloadHMR({ config })
|
||||
|
||||
try {
|
||||
const header = await payload.findGlobal({
|
||||
slug: 'header',
|
||||
})
|
||||
|
||||
return header as Header
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
}
|
||||
|
||||
throw new Error('Error fetching header.')
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { Page } from '../../../../test/live-preview/payload-types.js'
|
||||
import type { Page } from '../../../../payload-types.js'
|
||||
|
||||
export type ArchiveBlockProps = Extract<
|
||||
Exclude<Page['layout'], undefined>[0],
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react'
|
||||
|
||||
import type { Page } from '../../../../test/live-preview/payload-types.js'
|
||||
import type { Page } from '../../../../payload-types.js'
|
||||
|
||||
import { Gutter } from '../../_components/Gutter/index.js'
|
||||
import { CMSLink } from '../../_components/Link/index.js'
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { Fragment } from 'react'
|
||||
|
||||
import type { Page } from '../../../../test/live-preview/payload-types.js'
|
||||
import type { Page } from '../../../../payload-types.js'
|
||||
|
||||
import { Gutter } from '../../_components/Gutter/index.js'
|
||||
import { CMSLink } from '../../_components/Link/index.js'
|
||||
@@ -2,7 +2,7 @@ import type { StaticImageData } from 'next/image.js'
|
||||
|
||||
import React from 'react'
|
||||
|
||||
import type { Page } from '../../../../test/live-preview/payload-types.js'
|
||||
import type { Page } from '../../../../payload-types.js'
|
||||
|
||||
import { Gutter } from '../../_components/Gutter/index.js'
|
||||
import { Media } from '../../_components/Media/index.js'
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react'
|
||||
|
||||
import type { Post } from '../../../../test/live-preview/payload-types.js'
|
||||
import type { Post } from '../../../../payload-types.js'
|
||||
|
||||
import { Card } from '../../_components/Card/index.js'
|
||||
import { Gutter } from '../../_components/Gutter/index.js'
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { Fragment } from 'react'
|
||||
|
||||
import type { Page } from '../../../../test/live-preview/payload-types.js'
|
||||
import type { Page } from '../../../../payload-types.js'
|
||||
|
||||
import { Gutter } from '../../_components/Gutter/index.js'
|
||||
import RichText from '../../_components/RichText/index.js'
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { Fragment } from 'react'
|
||||
|
||||
import type { Page } from '../../../../test/live-preview/payload-types.js'
|
||||
import type { Page } from '../../../../payload-types.js'
|
||||
import type { RelationshipsBlockProps } from '../../_blocks/Relationships/index.js'
|
||||
import type { VerticalPaddingOptions } from '../VerticalPadding/index.js'
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user