Compare commits

..

86 Commits

Author SHA1 Message Date
Elliot DeNolf
5bba969f0d chore(release): v3.0.0-beta.19 [skip ci] 2024-04-26 17:08:50 -04:00
Jarrod Flesch
3a43fd34c0 chore: fixes bad auto import (#6070) 2024-04-26 16:45:24 -04:00
Jarrod Flesch
d9005b3f53 chore: file uploads, broken import path (#6069) 2024-04-26 16:26:11 -04:00
Jarrod Flesch
fab9e32175 fix: correct createPayloadRequest routeParams (#6059) 2024-04-26 16:13:21 -04:00
Jarrod Flesch
e71c1c2ec4 fix: formData handling on Vercel (#6067) 2024-04-26 16:10:14 -04:00
Dan Ribbens
81fb0515fb fix: bulk publish from collection list (#6065) 2024-04-26 15:46:02 -04:00
Elliot DeNolf
739dfc1434 chore: convert all errors to named exports (#6061) 2024-04-26 13:24:18 -04:00
Jacob Fletcher
a4e8795666 fix(deps): dedupes react (#6064) 2024-04-26 13:22:12 -04:00
Elliot DeNolf
14134d637d fix: properly handle external file url (#6060) 2024-04-26 12:02:07 -04:00
Elliot DeNolf
2b698a9018 chore: add more valid pr scopes [skip ci] 2024-04-26 11:55:01 -04:00
Elliot DeNolf
91684c8a7d ci: app build with packed (#6051) 2024-04-26 00:19:44 -04:00
Elliot DeNolf
fbdfe1d9dd chore: set -ex on pack and build step 2024-04-25 23:56:16 -04:00
Elliot DeNolf
7221725121 chore: start mongo for build 2024-04-25 23:46:48 -04:00
Elliot DeNolf
640348df3a chore: use --ignore-workspace in template install 2024-04-25 23:37:05 -04:00
Elliot DeNolf
4ed99e017a ci: add app-build-with-packed job 2024-04-25 23:28:28 -04:00
Elliot DeNolf
df6b9dd30b ci(scripts): update pack-all-to-dest 2024-04-25 23:25:31 -04:00
Elliot DeNolf
faf142baff chore: sort package.json files (#6050) 2024-04-25 22:41:55 -04:00
Elliot DeNolf
f80cb9f553 chore: clean up package.json descriptions and keywords 2024-04-25 22:39:03 -04:00
Elliot DeNolf
d3eaa1fceb chore: add sort-package-json to lint-staged 2024-04-25 22:23:58 -04:00
Elliot DeNolf
df77152851 chore: add sort-package-json, sort all package.json files 2024-04-25 22:19:37 -04:00
Elliot DeNolf
937202b27c fix(deps): remove monorepo deps 2024-04-25 22:12:44 -04:00
Paul
3581f39c31 chore: update whitelabel example (#6049) 2024-04-25 17:24:42 -03:00
Paul
c1d9c81b68 chore: update virtual fields example (#6043) 2024-04-25 16:13:10 -03:00
Jarrod Flesch
20355a4dd4 fix: version restoration (#6040) 2024-04-25 14:15:12 -04:00
Elliot DeNolf
cf66d7f09b docs: new packages (#6041) 2024-04-25 13:14:52 -04:00
Elliot DeNolf
30afe81462 docs: add docs for all new storage packages 2024-04-25 13:08:32 -04:00
Elliot DeNolf
18ee6e8867 docs: add docs for email-nodemailer 2024-04-25 13:08:18 -04:00
Paul
9f78a93403 chore: update hierarchy example (#6036) 2024-04-25 12:54:17 -03:00
Dan Ribbens
bd046e2437 fix(db-postgres): use locales suffix (#6032) 2024-04-25 11:07:52 -04:00
Elliot DeNolf
e9004a93a4 ci(scripts): safer package details retrieval 2024-04-25 10:50:41 -04:00
Elliot DeNolf
4816a1638a chore(release): v3.0.0-beta.18 [skip ci] 2024-04-25 10:31:56 -04:00
Jarrod Flesch
22c53392a3 chore: improves types for payloadRequest (#6012) 2024-04-25 10:23:03 -04:00
Paul
bdaa9e831d chore: add e2e tests for creating first user (#6027) 2024-04-25 10:57:50 -03:00
James Mikrut
036bcd6b8f chore: adds uuid to test (#6030) 2024-04-25 09:51:49 -04:00
Dan Ribbens
4d2bc861cf fix: disable api key beta (#6021) 2024-04-25 09:39:30 -04:00
James Mikrut
98722dc0fd fix(db-postgres): postgres version id bug (#6026) 2024-04-25 09:23:13 -04:00
James Mikrut
629d7c3263 fix(db-postgres): fully functional dbNames (#6023) 2024-04-24 22:42:24 -04:00
James Mikrut
5f7af5317a fix(next): ensures create-first user works (#6020) 2024-04-24 22:23:14 -04:00
James
8bb1b60964 chore: removes unused line 2024-04-24 22:22:40 -04:00
Elliot DeNolf
7ef5493414 ci(scripts): misc improvements 2024-04-24 21:04:12 -04:00
James
a3ac838221 chore: cleanup 2024-04-24 19:52:58 -04:00
James
14400d1cb9 chore: functional create-first-user 2024-04-24 19:48:58 -04:00
James
7d531646fd Merge branch 'fix/create-first-user-pt2' of github.com:payloadcms/payload into fix/create-first-user-pt2 2024-04-24 18:05:02 -04:00
Jacob Fletcher
6f6c1435c7 fix(ui): renders stay logged in modal (#6009) 2024-04-24 16:19:11 -04:00
Elliot DeNolf
332b8b6f34 ci(scripts): true publish with pLimit 2024-04-24 15:26:24 -04:00
Elliot DeNolf
d40a734080 wip: create first user fix 2024-04-24 15:17:13 -04:00
Dan Ribbens
94f1dfef52 fix: bulk publish (#6007) 2024-04-24 15:05:02 -04:00
Elliot DeNolf
0857dbe465 Revert "fix: issues creating the first user (#5986)"
This reverts commit 0ede95f375.
2024-04-24 14:36:08 -04:00
Elliot DeNolf
71f19fba58 chore(release): v3.0.0-beta.15 [skip ci] 2024-04-24 13:41:28 -04:00
Paul
24b18fb0fd feat!: removed getDataAndFile and getLocales from createPayloadRequest in favour of new utilities addDataAndFileToRequest and addLocalesToRequest (#5999) 2024-04-24 13:31:54 -03:00
Elliot DeNolf
5731241a5c fix(db-postgres): postgres uuid (#6003)
Co-authored-by: James <james@trbl.design>
2024-04-24 11:59:39 -04:00
Dan Ribbens
47e70abb4e fix: type collection config missing dbName (#5983) 2024-04-24 11:32:59 -04:00
Paul
0ede95f375 fix: issues creating the first user (#5986)
Co-authored-by: Jarrod Flesch <jarrodmflesch@gmail.com>
2024-04-24 11:30:52 -04:00
Jarrod Flesch
b723efdd3b chore: fixing flakey tests (#5984) 2024-04-24 00:44:43 -04:00
Elliot DeNolf
14c513690d ci: lint pr titles (#5988) 2024-04-23 23:40:55 -04:00
Alessio Gravili
88f239e784 feat(richtext-lexical)!: rework population behavior and allow richText adapter field hooks (#5893)
BREAKING:

- Unpopulated lexical relationship, link and upload nodes now save the relationTo document ID under value instead of value.id. This matches the behavior of core relationship fields. This changes the shape of the saved JSON data
- Any custom features which add their own population promises need to be reworked. populationPromises no longer accepts the promises as a return value. Instead, it expects you to mutate the promises array which is passed through, which mimics the way it works in core
2024-04-23 20:43:07 -04:00
Alessio Gravili
a1f6bf8a67 fix(richtext-lexical): Heading feature: enabledHeadingSizes not being applied 2024-04-23 20:37:11 -04:00
Alessio Gravili
912dcd38df fix(richtext-lexical): add missing HorizontalRuleFeature export 2024-04-23 20:25:12 -04:00
Alessio Gravili
da5028cdee feat(richtext-lexical): show loading indicator while block nodes are loading 2024-04-23 20:22:18 -04:00
Elliot DeNolf
899faa62f1 chore: update pnpm-lock 2024-04-23 17:01:57 -04:00
Alessio Gravili
9df6a644c9 chore: update lockfile 2024-04-23 16:37:02 -04:00
Alessio Gravili
1a6d9eaa11 Merge remote-tracking branch 'origin/beta' into fix/lexical-localization 2024-04-23 16:33:54 -04:00
Alessio Gravili
7d447af277 chore: add remaining missing preferences prop to validations 2024-04-23 15:46:01 -04:00
Elliot DeNolf
d8baaab849 chore(release): v3.0.0-beta.14 [skip ci] 2024-04-23 15:29:35 -04:00
Jarrod Flesch
3e1523f007 fix: move graphql-http from devDep to dep in next package (#5982)
Co-authored-by: Elliot DeNolf <denolfe@gmail.com>
2024-04-23 15:27:43 -04:00
Alessio Gravili
fa38af025f Merge branch 'beta' into fix/lexical-localization 2024-04-23 15:20:56 -04:00
Elliot DeNolf
6ca9ff847f chore(release): v3.0.0-beta.13 [skip ci] 2024-04-23 15:15:21 -04:00
Alessio Gravili
a8824b2b51 fix: incorrect value for empty preferences passed into buildStateFromSchema 2024-04-23 15:12:55 -04:00
Alessio Gravili
6aa3752b16 feat(richtext-lexical): allow richtext adapters to hook into field hooks 2024-04-23 15:10:35 -04:00
Elliot DeNolf
c483a439bf build: adjust pnpm engines version 2024-04-23 15:01:00 -04:00
Jarrod Flesch
74bdf1c681 chore: reduces graphql dependencies (#5979)
Co-authored-by: Elliot DeNolf <denolfe@gmail.com>
2024-04-23 15:00:09 -04:00
James Mikrut
7437d9fe58 Fix/postgres relation names (#5976) 2024-04-23 14:56:43 -04:00
Elliot DeNolf
51f7351962 fix(cpa): install db adapter in package.json (#5921) 2024-04-23 14:03:01 -04:00
Elliot DeNolf
d01fcb921b chore: tsconfig.json back to default 2024-04-23 13:18:45 -04:00
Elliot DeNolf
6179c938bf ci: remove email e2e tests, ethereal calls failing 2024-04-23 13:18:10 -04:00
Elliot DeNolf
dbbcb658a9 fix(deps): proper deps for storage-s3 and storage-vercel-blob (#5975) 2024-04-23 13:17:00 -04:00
James
16f97ad7c3 chore: disables forced pg for tests 2024-04-23 13:13:59 -04:00
James
bc7445ed99 Merge branch 'beta' of github.com:payloadcms/payload into fix/postgres-relation-names 2024-04-23 12:43:32 -04:00
James
e4d024cd0d chore: properly destroys db in postgres 2024-04-23 12:43:25 -04:00
James
1005de8295 fix(db-postgres): shortens relation names 2024-04-23 12:14:01 -04:00
Elliot DeNolf
c79289cedf chore(release): v3.0.0-beta.12 [skip ci] (#5972) 2024-04-23 11:02:08 -04:00
Jarrod Flesch
6a745be036 chore: pass mock req through with validate function to slate richText validation function (#5971) 2024-04-23 10:57:36 -04:00
Alessio Gravili
999059bc61 fix(richtext-lexical): properly validate block node nested fields, fixes one failing e2e test suite we previously skipped 2024-04-17 11:47:24 -04:00
Alessio Gravili
39ba39c237 feat(richtext-lexical)!: rework how population works and saves data, improve node typing 2024-04-17 11:46:47 -04:00
Alessio Gravili
58ea94f6ac feat: pass through doc preferences to field validate function and improve types 2024-04-17 09:27:04 -04:00
Alessio Gravili
a2afc38894 fix(richtext-lexical): do not allow empty url field in link drawer 2024-04-16 11:03:12 -04:00
504 changed files with 22531 additions and 18675 deletions

View File

@@ -138,9 +138,9 @@ jobs:
database:
- mongodb
- postgres
# - postgres-custom-schema
# - postgres-uuid
# - supabase
- postgres-custom-schema
- postgres-uuid
- supabase
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
@@ -237,7 +237,6 @@ jobs:
- access-control
- admin
- auth
- email
- field-error-states
- fields-relationship
- fields
@@ -295,6 +294,50 @@ jobs:
if-no-files-found: ignore
retention-days: 1
app-build-with-packed:
runs-on: ubuntu-latest
needs: build
steps:
# https://github.com/actions/virtual-environments/issues/1187
- name: tune linux network
run: sudo ethtool -K eth0 tx off rx off
- name: Setup Node@${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install pnpm
uses: pnpm/action-setup@v3
with:
version: ${{ env.PNPM_VERSION }}
run_install: false
- name: Restore build
uses: actions/cache@v4
timeout-minutes: 10
with:
path: ./*
key: ${{ github.sha }}-${{ github.run_number }}
- name: Start MongoDB
uses: supercharge/mongodb-github-action@1.10.0
with:
mongodb-version: 6.0
- name: Pack and build app
run: |
set -ex
pnpm run script:pack --dest templates/blank-3.0
cd templates/blank-3.0
cp .env.example .env
ls -la
pnpm add ./*.tgz
pnpm install --ignore-workspace
cat package.json
pnpm run build
tests-type-generation:
if: false # This should be replaced with gen on a real Payload project
runs-on: ubuntu-latest

99
.github/workflows/pr-title.yml vendored Normal file
View File

@@ -0,0 +1,99 @@
name: pr-title
on:
pull_request:
types:
- opened
- edited
- synchronize
permissions:
pull-requests: write
jobs:
main:
name: lint-pr-title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
id: lint_pr_title
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
types: |
build
chore
ci
docs
feat
fix
perf
refactor
revert
style
test
types
scopes: |
cpa
db-\*
db-mongodb
db-postgres
email-nodemailer
eslint
graphql
live-preview
live-preview-react
next
payload
plugin-cloud
plugin-cloud-storage
plugin-form-builder
plugin-nested-docs
plugin-redirects
plugin-relationship-object-ids
plugin-search
plugin-sentry
plugin-seo
plugin-stripe
richtext-\*
richtext-lexical
richtext-slate
storage-\*
storage-azure
storage-gcs
storage-vercel-blob
storage-s3
translations
ui
templates
examples
deps
# Disallow uppercase letters at the beginning of the subject
subjectPattern: ^(?![A-Z]).+$
- uses: marocchino/sticky-pull-request-comment@v2
# When the previous steps fails, the workflow would stop. By adding this
# condition you can continue the execution with the populated error message.
if: always() && (steps.lint_pr_title.outputs.error_message != null)
with:
header: pr-title-lint-error
message: |
Pull Request titles must follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/) and have valid scopes.
${{ steps.lint_pr_title.outputs.error_message }}
```
feat(ui): add Button component
^ ^ ^
| | |__ Subject
| |_______ Scope
|____________ Type
```
# Delete a previous comment when the issue has been resolved
- if: ${{ steps.lint_pr_title.outputs.error_message == null }}
uses: marocchino/sticky-pull-request-comment@v2
with:
header: pr-title-lint-error
delete: true

View File

@@ -1,2 +1,2 @@
DATABASE_URI=mongodb://127.0.0.1/payload-template-blank
DATABASE_URI=mongodb://127.0.0.1/payload-template-blank-3-0
PAYLOAD_SECRET=YOUR_SECRET_HERE

View File

@@ -0,0 +1,7 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
parserOptions: {
project: ['./tsconfig.json'],
tsconfigRootDir: __dirname,
},
}

View File

@@ -1,6 +1,43 @@
build
dist
/media
node_modules
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz
/.idea/*
!/.idea/runConfigurations
# testing
/coverage
# next.js
/.next/
/out/
# production
/build
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# local env files
.env*.local
# vercel
.vercel
# typescript
*.tsbuildinfo
next-env.d.ts
.env
/media

View File

@@ -1,8 +0,0 @@
module.exports = {
printWidth: 100,
parser: 'typescript',
semi: false,
singleQuote: true,
trailingComma: 'all',
arrowParens: 'avoid',
}

View File

@@ -0,0 +1,6 @@
{
"singleQuote": true,
"trailingComma": "all",
"printWidth": 100,
"semi": false
}

View File

@@ -1,8 +1,10 @@
# Payload Hierarchy Example
# Payload Blank Template
This example demonstrates how to achieve a virtual hierarchy between documents in your [Payload](https://github.com/payloadcms/payload) application.
A blank template for [Payload](https://github.com/payloadcms/payload) to help you get up and running quickly. This repo may have been created by running `npx create-payload-app@latest` and selecting the "blank" template or by cloning this template on [Payload Cloud](https://payloadcms.com/new/clone/blank).
## Quick Start
See the official [Examples Directory](https://github.com/payloadcms/payload/tree/main/examples) for details on how to use Payload in a variety of different ways.
## Development
To spin up the project locally, follow these steps:
@@ -14,33 +16,15 @@ To spin up the project locally, follow these steps:
That's it! Changes made in `./src` will be reflected in your app.
## How it works
### Docker
This example achieves parent/child relationships between your documents through the use of virtual fields. When you query a document with the `?children=true` query param, an afterRead hook is used to populate the documents within its own tree.
Alternatively, you can use [Docker](https://www.docker.com) to spin up this project locally. To do so, follow these steps:
For more information on how virtual fields, see the [Official Virtual Fields Example](https://github.com/payloadcms/payload/tree/main/examples/virtual-fields).
1. Follow [steps 1 and 2 from above](#development), the docker-compose file will automatically use the `.env` file in your project root
1. Next run `docker-compose up`
1. Follow [steps 4 and 5 from above](#development) to login and create your first admin user
### Collections
See the [Collections](https://payloadcms.com/docs/configuration/collections) docs for details on how to extend any of this functionality.
- #### Users
The `users` collection is a default payload users collection.
- #### Entities
The `entities` collection can define a parent as any other entity. It has a virtual field that will also populate children when it is called via the API using a query `children=true`. See [Virtual Fields](https://github.com/payloadcms/payload/tree/main/examples/virtual-fields) for more details on how virtual fields work.
The virtual field retrieves __all__ children which includes other entities and people.
- #### People
The `people` collection is a collection that can define an array of parent entities. It also has an allocation field. This is for demonstrating attaching data to a parent-child relationship.
## Development
To spin up this example locally, follow the [Quick Start](#quick-start).
That's it! The Docker instance will help you get up and running quickly while also standardizing the development environment across your teams.
## Production

View File

@@ -0,0 +1,8 @@
import { withPayload } from '@payloadcms/next/withPayload'
/** @type {import('next').NextConfig} */
const nextConfig = {
// Your Next.js config here
}
export default withPayload(nextConfig)

View File

@@ -2,34 +2,38 @@
"name": "hierarchy",
"description": "A hierarchy example with Payload",
"version": "1.0.0",
"main": "dist/server.js",
"license": "MIT",
"type": "module",
"scripts": {
"dev": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts nodemon",
"build:payload": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload build",
"build:server": "tsc",
"build": "yarn copyfiles && yarn build:payload && yarn build:server",
"serve": "cross-env PAYLOAD_CONFIG_PATH=dist/payload.config.js NODE_ENV=production node dist/server.js",
"copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png}\" dist/",
"generate:types": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload generate:types",
"generate:graphQLSchema": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload generate:graphQLSchema",
"payload": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload"
"dev": "cross-env NODE_OPTIONS=--no-deprecation next dev",
"devsafe": "rm -rf .next && cross-env NODE_OPTIONS=--no-deprecation next dev",
"build": "cross-env NODE_OPTIONS=--no-deprecation next build",
"payload": "cross-env NODE_OPTIONS=--no-deprecation payload",
"start": "cross-env NODE_OPTIONS=--no-deprecation next start",
"lint": "cross-env NODE_OPTIONS=--no-deprecation next lint",
"generate:types": "payload generate:types"
},
"engines": {
"node": ">=18.19.0"
},
"dependencies": {
"@payloadcms/bundler-webpack": "^1.0.0",
"@payloadcms/db-mongodb": "^1.0.0",
"@payloadcms/plugin-cloud": "^3.0.0",
"@payloadcms/richtext-slate": "^1.0.0",
"@payloadcms/db-mongodb": "beta",
"@payloadcms/next": "beta",
"@payloadcms/plugin-cloud": "beta",
"@payloadcms/richtext-lexical": "beta",
"cross-env": "^7.0.3",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"payload": "^2.0.0"
"next": "14.3.0-canary.7",
"payload": "beta",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"sharp": "0.32.6"
},
"devDependencies": {
"@types/express": "^4.17.9",
"copyfiles": "^2.4.1",
"nodemon": "^2.0.6",
"ts-node": "^9.1.1",
"typescript": "^4.8.4"
"@types/node": "^20.11.25",
"@types/react": "^18.2.64",
"@types/react-dom": "^18.2.21",
"dotenv": "^16.4.5",
"tsx": "^4.7.1",
"typescript": "^5.4.2"
}
}

5880
examples/hierarchy/pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,17 @@
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
import config from '@payload-config'
/* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
import { RootPage } from '@payloadcms/next/views'
type Args = {
params: {
segments: string[]
}
searchParams: {
[key: string]: string | string[]
}
}
const Page = ({ params, searchParams }: Args) => RootPage({ config, params, searchParams })
export default Page

View 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'
export const GET = REST_GET(config)
export const POST = REST_POST(config)
export const DELETE = REST_DELETE(config)
export const PATCH = REST_PATCH(config)

View 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_PLAYGROUND_GET } from '@payloadcms/next/routes'
export const GET = GRAPHQL_PLAYGROUND_GET(config)

View 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'
export const POST = GRAPHQL_POST(config)

View File

@@ -0,0 +1,16 @@
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
import configPromise from '@payload-config'
import '@payloadcms/next/css'
import { RootLayout } from '@payloadcms/next/layouts'
/* 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

View File

@@ -1,4 +1,4 @@
import { CollectionConfig } from 'payload/types'
import type { CollectionConfig } from 'payload/types'
export const Entities: CollectionConfig = {
slug: 'entities',
@@ -18,7 +18,6 @@ export const Entities: CollectionConfig = {
{
name: 'children',
type: 'relationship',
relationTo: ['entities', 'people'],
access: {
create: () => false,
update: () => false,
@@ -26,40 +25,40 @@ export const Entities: CollectionConfig = {
hooks: {
afterRead: [
async ({ data, req }) => {
if (!req.query.children || !data) return
const { id } = data
if (!req.query.children) return
const people = await req.payload.find({
req,
collection: 'people',
depth: 0,
limit: 0,
pagination: false,
req,
where: {
'parents.parent': { equals: id },
},
limit: 0,
depth: 0,
pagination: false,
})
const entities = await req.payload.find({
req,
collection: 'entities',
depth: 0,
limit: 0,
pagination: false,
req,
where: {
parent: { equals: id },
},
limit: 0,
depth: 0,
pagination: false,
})
return [
...entities.docs.map(entity => {
...entities.docs.map((entity) => {
return {
relationTo: 'entity',
value: entity,
}
}),
...people.docs.map(person => {
...people.docs.map((person) => {
return {
relationTo: 'people',
value: person,
@@ -69,6 +68,7 @@ export const Entities: CollectionConfig = {
},
],
},
relationTo: ['entities', 'people'],
},
{
name: 'parent',

View File

@@ -1,4 +1,4 @@
import { CollectionConfig } from 'payload/types'
import type { CollectionConfig } from 'payload/types'
export const People: CollectionConfig = {
slug: 'people',
@@ -23,8 +23,8 @@ export const People: CollectionConfig = {
{
name: 'allocation',
type: 'number',
min: 0,
max: 100,
min: 0,
},
],
},

View File

@@ -1,15 +1,13 @@
import { CollectionConfig } from 'payload/types'
import type { CollectionConfig } from 'payload/types'
const Users: CollectionConfig = {
export const Users: CollectionConfig = {
slug: 'users',
auth: true,
admin: {
useAsTitle: 'email',
},
auth: true,
fields: [
// Email added by default
// Add more fields as needed
],
}
export default Users

View File

@@ -1,30 +1,39 @@
import path from 'path'
import { payloadCloud } from '@payloadcms/plugin-cloud'
import { mongooseAdapter } from '@payloadcms/db-mongodb'
import { webpackBundler } from '@payloadcms/bundler-webpack'
import { slateEditor } from '@payloadcms/richtext-slate'
// import { payloadCloud } from '@payloadcms/plugin-cloud'
import { lexicalEditor } from '@payloadcms/richtext-lexical'
import path from 'path'
import { buildConfig } from 'payload/config'
// import sharp from 'sharp'
import { fileURLToPath } from 'url'
import Users from './collections/Users'
import { Entities } from './collections/Entities'
import { People } from './collections/People'
import { Users } from './collections/Users'
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
export default buildConfig({
admin: {
user: Users.slug,
bundler: webpackBundler(),
},
editor: slateEditor({}),
collections: [Users, Entities, People],
typescript: {
outputFile: path.resolve(__dirname, 'payload-types.ts'),
},
graphQL: {
schemaOutputFile: path.resolve(__dirname, 'generated-schema.graphql'),
},
plugins: [payloadCloud()],
collections: [Entities, People, Users],
editor: lexicalEditor({}),
// plugins: [payloadCloud()], // TODO: Re-enable when cloud supports 3.0
db: mongooseAdapter({
url: process.env.DATABASE_URI,
url: process.env.DATABASE_URI || '',
}),
secret: process.env.PAYLOAD_SECRET || '',
typescript: {
outputFile: path.resolve(dirname, 'payload-types.ts'),
},
// Sharp is now an optional dependency -
// if you want to resize images, crop, set focal point, etc.
// make sure to install it and pass it to the config.
// This is temporary - we may make an adapter pattern
// for this before reaching 3.0 stable
// sharp,
})

View File

@@ -1,27 +0,0 @@
import express from 'express'
import payload from 'payload'
require('dotenv').config()
const app = express()
// Redirect root to Admin panel
app.get('/', (_, res) => {
res.redirect('/admin')
})
const start = async () => {
// Initialize Payload
await payload.init({
secret: process.env.PAYLOAD_SECRET,
express: app,
onInit: async () => {
payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`)
},
})
// Add your own express routes here
app.listen(3000)
}
start()

View File

@@ -1,22 +1,28 @@
{
"compilerOptions": {
"target": "es5",
"baseUrl": ".",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"strict": false,
"esModuleInterop": true,
"skipLibCheck": true,
"outDir": "./dist",
"rootDir": "./src",
"jsx": "react",
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"paths": {
"payload/generated-types": ["./src/payload-types.ts"]
"@/*": ["./src/*"],
"@payload-config": ["./src/payload.config.ts"]
}
},
"include": ["src"],
"exclude": ["node_modules", "dist", "build"],
"ts-node": {
"transpileOnly": true,
"swc": true
}
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,3 +1,3 @@
MONGODB_URI=mongodb://127.0.0.1/payload-example-vitual-fields
PAYLOAD_SECRET=ENTER-STRING-HERE
PAYLOAD_PUBLIC_SERVER_URL=http://localhost:8000
DATABASE_URI=mongodb://127.0.0.1/payload-template-blank-3-0
PAYLOAD_SECRET=YOUR_SECRET_HERE
PAYLOAD_PUBLIC_SEED=true

View File

@@ -0,0 +1,7 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
parserOptions: {
project: ['./tsconfig.json'],
tsconfigRootDir: __dirname,
},
}

View File

@@ -1,5 +1,43 @@
build
dist
node_modules
package-lock.json
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz
/.idea/*
!/.idea/runConfigurations
# testing
/coverage
# next.js
/.next/
/out/
# production
/build
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# local env files
.env*.local
# vercel
.vercel
# typescript
*.tsbuildinfo
next-env.d.ts
.env
/media

View File

@@ -4,26 +4,31 @@
"main": "dist/server.js",
"license": "MIT",
"scripts": {
"dev": "cross-env PAYLOAD_PUBLIC_SEED=true PAYLOAD_DROP_DATABASE=true PAYLOAD_CONFIG_PATH=src/payload.config.ts nodemon",
"build:payload": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload build",
"build:server": "tsc",
"build": "yarn copyfiles && yarn build:payload && yarn build:server",
"serve": "cross-env PAYLOAD_CONFIG_PATH=dist/payload.config.js NODE_ENV=production node dist/server.js",
"copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png}\" dist/",
"generate:types": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload generate:types",
"generate:graphQLSchema": "PAYLOAD_CONFIG_PATH=src/payload.config.ts payload generate:graphQLSchema"
"dev": "cross-env NODE_OPTIONS=--no-deprecation next dev",
"devsafe": "rm -rf .next && cross-env NODE_OPTIONS=--no-deprecation next dev",
"build": "cross-env NODE_OPTIONS=--no-deprecation next build",
"payload": "cross-env NODE_OPTIONS=--no-deprecation payload",
"start": "cross-env NODE_OPTIONS=--no-deprecation next start",
"lint": "cross-env NODE_OPTIONS=--no-deprecation next lint",
"generate:types": "payload generate:types"
},
"dependencies": {
"dotenv": "^8.2.0",
"express": "^4.17.1",
"payload": "latest"
"@payloadcms/db-mongodb": "beta",
"@payloadcms/next": "beta",
"@payloadcms/richtext-lexical": "beta",
"cross-env": "^7.0.3",
"next": "^14.3.0-canary.7",
"payload": "beta",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"sharp": "0.32.6"
},
"devDependencies": {
"@types/express": "^4.17.9",
"copyfiles": "^2.4.1",
"cross-env": "^7.0.3",
"nodemon": "^2.0.6",
"ts-node": "^9.1.1",
"typescript": "^4.8.4"
"@types/node": "^20.11.25",
"@types/react": "^18.2.64",
"@types/react-dom": "^18.2.21",
"dotenv": "^16.4.5",
"tsx": "^4.7.1",
"typescript": "^5.4.2"
}
}

5184
examples/virtual-fields/pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,17 @@
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
import config from '@payload-config'
/* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
import { RootPage } from '@payloadcms/next/views'
type Args = {
params: {
segments: string[]
}
searchParams: {
[key: string]: string | string[]
}
}
const Page = ({ params, searchParams }: Args) => RootPage({ config, params, searchParams })
export default Page

View 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'
export const GET = REST_GET(config)
export const POST = REST_POST(config)
export const DELETE = REST_DELETE(config)
export const PATCH = REST_PATCH(config)

View 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_PLAYGROUND_GET } from '@payloadcms/next/routes'
export const GET = GRAPHQL_PLAYGROUND_GET(config)

View 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'
export const POST = GRAPHQL_POST(config)

View File

@@ -0,0 +1,16 @@
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
import configPromise from '@payload-config'
import '@payloadcms/next/css'
import { RootLayout } from '@payloadcms/next/layouts'
/* 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

View File

@@ -1,14 +1,15 @@
import payload from 'payload';
import { CollectionConfig, FieldHook } from 'payload/types';
import type { CollectionConfig, FieldHook } from 'payload/types'
const getTotalPrice: FieldHook = async ({ data }) => {
const { price, salesTaxPercentage, fees } = data.tickets;
const totalPrice = Math.round(price * (1 + (salesTaxPercentage / 100))) + fees;
const getTotalPrice: FieldHook = ({ data }) => {
if (!data) return 0
return totalPrice;
};
const { fees, price, salesTaxPercentage } = data.tickets
const totalPrice = Math.round(price * (1 + salesTaxPercentage / 100)) + fees
const Events: CollectionConfig = {
return totalPrice
}
export const Events: CollectionConfig = {
slug: 'events',
admin: {
defaultColumns: ['title', 'date', 'location'],
@@ -31,9 +32,9 @@ const Events: CollectionConfig = {
{
name: 'location',
type: 'relationship',
relationTo: 'locations',
maxDepth: 0,
hasMany: false,
maxDepth: 0,
relationTo: 'locations',
},
],
},
@@ -82,12 +83,14 @@ const Events: CollectionConfig = {
readOnly: true,
},
hooks: {
beforeChange: [({ siblingData }) => {
// Mutate the sibling data to prevent DB storage
// eslint-disable-next-line no-param-reassign
siblingData.totalPrice = undefined;
}],
afterRead: [getTotalPrice],
beforeChange: [
({ siblingData }) => {
// Mutate the sibling data to prevent DB storage
// eslint-disable-next-line no-param-reassign
siblingData.totalPrice = undefined
},
],
},
},
],
@@ -95,6 +98,4 @@ const Events: CollectionConfig = {
],
},
],
};
export default Events;
}

View File

@@ -1,30 +1,33 @@
/* eslint-disable import/no-extraneous-dependencies */
import payload from 'payload';
import { CollectionConfig, FieldHook } from 'payload/types';
import type { CollectionConfig, FieldHook } from 'payload/types'
const formatLocation: FieldHook = async ({ data }) => {
return `${data.city}${data.state ? `, ${data.state},` : ','} ${data.country}`;
};
const formatLocation: FieldHook = ({ data }) => {
if (!data) return ''
return `${data.city}${data.state ? `, ${data.state},` : ','} ${data.country}`
}
const getLocationStaff: FieldHook = async ({ data }) => {
const staff = await payload.find({
const getLocationStaff: FieldHook = async ({ data, req }) => {
if (!data) return null
const staff = await req.payload.find({
collection: 'staff',
where: {
location: {
equals: data.id,
},
},
});
})
if (staff.docs) {
return staff.docs.map((doc) => doc.id);
return staff.docs.map((doc) => doc.id)
}
return null;
};
return null
}
const getNextEvent: FieldHook = async ({ data }) => {
const eventsByDate = await payload.find({
const getNextEvent: FieldHook = async ({ data, req }) => {
if (!data) return null
const eventsByDate = await req.payload.find({
collection: 'events',
sort: 'date',
where: {
@@ -32,30 +35,32 @@ const getNextEvent: FieldHook = async ({ data }) => {
equals: data.id,
},
},
});
})
if (eventsByDate?.docs) {
return eventsByDate.docs[0]?.id;
return eventsByDate.docs[0]?.id
}
return null;
};
return null
}
const getAllEvents: FieldHook = async ({ data }) => {
const allEvents = await payload.find({
const getAllEvents: FieldHook = async ({ data, req }) => {
if (!data) return null
const allEvents = await req.payload.find({
collection: 'events',
where: {
location: {
equals: data.id,
},
},
});
if (allEvents.docs) return allEvents.docs.map((doc) => doc.id);
})
if (allEvents.docs) return allEvents.docs.map((doc) => doc.id)
return null;
};
return null
}
const Locations: CollectionConfig = {
export const Locations: CollectionConfig = {
slug: 'locations',
admin: {
defaultColumns: ['location', 'nextEvent'],
@@ -64,18 +69,7 @@ const Locations: CollectionConfig = {
fields: [
{
name: 'location',
label: false,
type: 'text',
hooks: {
beforeChange: [({ siblingData }) => {
// Mutate the sibling data to prevent DB storage
// eslint-disable-next-line no-param-reassign
siblingData.location = undefined;
}],
afterRead: [
formatLocation,
],
},
access: {
create: () => false,
update: () => false,
@@ -83,6 +77,17 @@ const Locations: CollectionConfig = {
admin: {
hidden: true,
},
hooks: {
afterRead: [formatLocation],
beforeChange: [
({ siblingData }) => {
// Mutate the sibling data to prevent DB storage
// eslint-disable-next-line no-param-reassign
siblingData.location = undefined
},
],
},
label: false,
},
{
type: 'row',
@@ -105,10 +110,7 @@ const Locations: CollectionConfig = {
},
{
name: 'events',
maxDepth: 0,
type: 'relationship',
relationTo: 'events',
hasMany: true,
access: {
create: () => false,
update: () => false,
@@ -116,21 +118,23 @@ const Locations: CollectionConfig = {
admin: {
readOnly: true,
},
hasMany: true,
hooks: {
beforeChange: [({ siblingData }) => {
// Mutate the sibling data to prevent DB storage
// eslint-disable-next-line no-param-reassign
siblingData.events = undefined;
}],
afterRead: [getAllEvents],
beforeChange: [
({ siblingData }) => {
// Mutate the sibling data to prevent DB storage
// eslint-disable-next-line no-param-reassign
siblingData.events = undefined
},
],
},
maxDepth: 0,
relationTo: 'events',
},
{
name: 'staff',
type: 'relationship',
relationTo: 'staff',
hasMany: true,
maxDepth: 0,
access: {
create: () => false,
update: () => false,
@@ -138,37 +142,42 @@ const Locations: CollectionConfig = {
admin: {
readOnly: true,
},
hasMany: true,
hooks: {
beforeChange: [({ siblingData }) => {
// Mutate the sibling data to prevent DB storage
// eslint-disable-next-line no-param-reassign
siblingData.staff = undefined;
}],
afterRead: [getLocationStaff],
beforeChange: [
({ siblingData }) => {
// Mutate the sibling data to prevent DB storage
// eslint-disable-next-line no-param-reassign
siblingData.staff = undefined
},
],
},
maxDepth: 0,
relationTo: 'staff',
},
{
name: 'nextEvent',
type: 'relationship',
relationTo: 'events',
admin: {
position: 'sidebar',
readOnly: true,
},
access: {
create: () => false,
update: () => false,
},
hooks: {
beforeChange: [({ siblingData }) => {
// Mutate the sibling data to prevent DB storage
// eslint-disable-next-line no-param-reassign
siblingData.nextEvent = undefined;
}],
afterRead: [getNextEvent],
admin: {
position: 'sidebar',
readOnly: true,
},
hooks: {
afterRead: [getNextEvent],
beforeChange: [
({ siblingData }) => {
// Mutate the sibling data to prevent DB storage
// eslint-disable-next-line no-param-reassign
siblingData.nextEvent = undefined
},
],
},
relationTo: 'events',
},
],
};
export default Locations;
}

View File

@@ -1,10 +1,11 @@
import { CollectionConfig, FieldHook } from 'payload/types';
import type { CollectionConfig, FieldHook } from 'payload/types'
const populateFullTitle: FieldHook = async ({ data }) => (
`${data.title} ${data.firstName} ${data.lastName}`
);
const populateFullTitle: FieldHook = ({ data }) => {
if (!data) return ''
return `${data.title} ${data.firstName} ${data.lastName}`
}
const Staff: CollectionConfig = {
export const Staff: CollectionConfig = {
slug: 'staff',
admin: {
defaultColumns: ['fullTitle', 'location'],
@@ -18,19 +19,19 @@ const Staff: CollectionConfig = {
create: () => false,
update: () => false,
},
hooks: {
beforeChange: [({ siblingData }) => {
// Mutate the sibling data to prevent DB storage
// eslint-disable-next-line no-param-reassign
siblingData.fullTitle = undefined;
}],
afterRead: [
populateFullTitle,
],
},
admin: {
hidden: true,
},
hooks: {
afterRead: [populateFullTitle],
beforeChange: [
({ siblingData }) => {
// Mutate the sibling data to prevent DB storage
// eslint-disable-next-line no-param-reassign
siblingData.fullTitle = undefined
},
],
},
},
{
name: 'title',
@@ -50,12 +51,10 @@ const Staff: CollectionConfig = {
{
name: 'location',
type: 'relationship',
relationTo: 'locations',
maxDepth: 0,
hasMany: true,
maxDepth: 0,
relationTo: 'locations',
required: true,
},
],
};
export default Staff;
}

View File

@@ -1,18 +1,16 @@
import { CollectionConfig } from 'payload/types';
import type { CollectionConfig } from 'payload/types'
const Users: CollectionConfig = {
export const Users: CollectionConfig = {
slug: 'users',
auth: true,
admin: {
useAsTitle: 'email',
},
access: {
read: () => true,
},
admin: {
useAsTitle: 'email',
},
auth: true,
fields: [
// Email added by default
// Add more fields as needed
],
};
export default Users;
}

View File

@@ -1,24 +1,16 @@
import React from 'react';
import React from 'react'
const BeforeLogin: React.FC = () => {
export const BeforeLogin: React.FC = () => {
if (process.env.PAYLOAD_PUBLIC_SEED === 'true') {
return (
<div>
<h3>Virtual Fields Demo</h3>
<p>
Log in with the email
{' '}
<strong>dev@payloadcms.com</strong>
{' '}
and the password
{' '}
<strong>test</strong>
.
Log in with the email <strong>dev@payloadcms.com</strong> and the password{' '}
<strong>test</strong>.
</p>
</div>
);
)
}
return null;
};
export default BeforeLogin;
return null
}

View File

@@ -1,29 +1,38 @@
import { buildConfig } from 'payload/config';
import path from 'path';
import Events from './collections/Events';
import Locations from './collections/Location';
import Staff from './collections/Staff';
import Users from './collections/Users';
import BeforeLogin from './components/BeforeLogin';
import { mongooseAdapter } from '@payloadcms/db-mongodb'
import { lexicalEditor } from '@payloadcms/richtext-lexical'
import path from 'path'
import { buildConfig } from 'payload/config'
import { fileURLToPath } from 'url'
import { Events } from './collections/Events'
import { Locations } from './collections/Location'
import { Staff } from './collections/Staff'
import { Users } from './collections/Users'
import { BeforeLogin } from './components/BeforeLogin'
import { seedData } from './seed'
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
export default buildConfig({
serverURL: 'http://localhost:3000',
admin: {
user: Users.slug,
components: {
beforeLogin: [BeforeLogin],
},
user: Users.slug,
},
collections: [
Events,
Locations,
Staff,
Users,
],
collections: [Events, Locations, Staff, Users],
editor: lexicalEditor({}),
serverURL: 'http://localhost:3000',
// plugins: [payloadCloud()], // TODO: Re-enable when cloud supports 3.0
db: mongooseAdapter({
url: process.env.DATABASE_URI || '',
}),
onInit: async (payload) => {
await seedData(payload)
},
secret: process.env.PAYLOAD_SECRET || '',
typescript: {
outputFile: path.resolve(__dirname, 'payload-types.ts'),
outputFile: path.resolve(dirname, 'payload-types.ts'),
},
graphQL: {
schemaOutputFile: path.resolve(__dirname, 'generated-schema.graphql'),
},
});
})

View File

@@ -1,45 +1,45 @@
export const eventsOne = [
{
title: 'Event 1',
date: '2023-02-01T00:00:00.000Z',
pricing: {
price: 10,
fees: 5,
price: 10,
},
tickets: {
fees: 3.5,
price: 100,
salesTaxPercentage: 10,
fees: 3.50,
},
title: 'Event 1',
},
{
title: 'Event 2',
date: '2023-03-01T00:00:00.000Z',
tickets: {
fees: 5,
price: 20,
salesTaxPercentage: 20,
fees: 5,
},
title: 'Event 2',
},
];
]
export const eventsTwo = [
{
title: 'Event 3',
date: '2023-03-31T23:00:00.000Z',
tickets: {
fees: 2,
price: 10,
salesTaxPercentage: 10,
fees: 2,
},
title: 'Event 3',
},
{
title: 'Event 4',
date: '2023-04-30T23:00:00.000Z',
tickets: {
fees: 5,
price: 50,
salesTaxPercentage: 10,
fees: 5,
},
title: 'Event 4',
},
];
]

View File

@@ -1,28 +1,27 @@
import payload from 'payload';
import { MongoClient } from 'mongodb';
import { eventsOne, eventsTwo } from './events';
import { locationOne, locationTwo } from './locations';
import { staffOne, staffTwo } from './staff';
import type { Payload } from 'payload'
export async function seedData() {
import { eventsOne, eventsTwo } from './events'
import { locationOne, locationTwo } from './locations'
import { staffOne, staffTwo } from './staff'
export async function seedData(payload: Payload) {
await payload.create({
collection: 'users',
data: {
email: 'dev@payloadcms.com',
password: 'test',
},
});
})
const { id: locationOneID } = await payload.create({
collection: 'locations',
data: locationOne,
});
})
const { id: locationTwoID } = await payload.create({
collection: 'locations',
data: locationTwo,
});
})
await payload.create({
collection: 'staff',
@@ -30,8 +29,7 @@ export async function seedData() {
...staffOne,
location: [locationOneID],
},
});
})
await payload.create({
collection: 'staff',
@@ -39,30 +37,31 @@ export async function seedData() {
...staffTwo,
location: [locationTwoID],
},
});
})
eventsOne.map((event) => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
payload.create({
collection: 'events',
data: {
...event,
location: locationOneID,
},
});
return null;
});
})
return null
})
eventsTwo.map((event) => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
payload.create({
collection: 'events',
data: {
...event,
location: locationTwoID,
},
});
})
return null;
});
return null
})
}

View File

@@ -1,12 +1,12 @@
export const locationOne = {
city: 'Grand Rapids',
country: 'USA',
state: 'MI',
events: [],
};
state: 'MI',
}
export const locationTwo = {
city: 'London',
country: 'UK',
events: [],
};
}

View File

@@ -1,11 +1,11 @@
export const staffOne = {
title: 'Mr',
firstName: 'John',
lastName: 'Doe',
};
title: 'Mr',
}
export const staffTwo = {
title: 'Miss',
firstName: 'Jane',
lastName: 'Doe',
};
title: 'Miss',
}

View File

@@ -1,37 +0,0 @@
import express from 'express';
import payload from 'payload';
import path from 'path';
import { seedData } from './seed';
require('dotenv').config({
path: path.resolve(__dirname, '../.env'),
});
const app = express();
// Redirect all traffic at root to admin UI
app.get('/', (_, res) => {
res.redirect('/admin');
});
const start = async () => {
// Initialize Payload
await payload.init({
secret: process.env.PAYLOAD_SECRET,
mongoURL: process.env.MONGODB_URI,
express: app,
onInit: async () => {
payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`);
},
});
if (process.env.PAYLOAD_PUBLIC_SEED === 'true') {
payload.logger.info('---- SEEDING DATABASE ----');
await seedData();
payload.logger.info('---- SEED COMPLETE ----');
}
app.listen(3000);
};
start();

View File

@@ -1,18 +1,44 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"baseUrl": ".",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"strict": false,
"esModuleInterop": true,
"skipLibCheck": true,
"outDir": "./dist",
"rootDir": "./src",
"jsx": "react"
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": [
"./src/*"
],
"@payload-config": [
"./src/payload.config.ts"
]
},
"target": "ES2017"
},
"include": ["src"],
"exclude": ["node_modules", "dist", "build"],
"ts-node": {
"transpileOnly": true
}
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts"
],
"exclude": [
"node_modules"
]
}

View File

@@ -1,3 +1,3 @@
MONGODB_URI=mongodb://127.0.0.1/payload-example-whitelabel
DATABASE_URI=mongodb://127.0.0.1/payload-example-whitelabel
PAYLOAD_SECRET=ENTER-STRING-HERE
PAYLOAD_PUBLIC_SERVER_URL=http://localhost:8000

View File

@@ -0,0 +1,7 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
parserOptions: {
project: ['./tsconfig.json'],
tsconfigRootDir: __dirname,
},
}

View File

@@ -0,0 +1,43 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz
/.idea/*
!/.idea/runConfigurations
# testing
/coverage
# next.js
/.next/
/out/
# production
/build
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# local env files
.env*.local
# vercel
.vercel
# typescript
*.tsbuildinfo
next-env.d.ts
.env
/media

View File

@@ -0,0 +1 @@
legacy-peer-deps=true

5
examples/whitelabel/next-env.d.ts vendored Normal file
View File

@@ -0,0 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.

View File

@@ -1,5 +1,4 @@
{
"$schema": "https://json.schemastore.org/nodemon.json",
"ext": "ts",
"exec": "ts-node src/server.ts -- -I",
"stdin": false

View File

@@ -4,26 +4,31 @@
"main": "dist/server.js",
"license": "MIT",
"scripts": {
"dev": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts nodemon",
"build:payload": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload build",
"build:server": "tsc",
"build": "yarn copyfiles && yarn build:payload && yarn build:server",
"serve": "cross-env PAYLOAD_CONFIG_PATH=dist/payload.config.js NODE_ENV=production node dist/server.js",
"copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png}\" dist/",
"generate:types": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload generate:types",
"generate:graphQLSchema": "PAYLOAD_CONFIG_PATH=src/payload.config.ts payload generate:graphQLSchema"
"dev": "cross-env NODE_OPTIONS=--no-deprecation next dev",
"devsafe": "rm -rf .next && cross-env NODE_OPTIONS=--no-deprecation next dev",
"build": "cross-env NODE_OPTIONS=--no-deprecation next build",
"payload": "cross-env NODE_OPTIONS=--no-deprecation payload",
"start": "cross-env NODE_OPTIONS=--no-deprecation next start",
"lint": "cross-env NODE_OPTIONS=--no-deprecation next lint",
"generate:types": "payload generate:types"
},
"dependencies": {
"dotenv": "^8.2.0",
"express": "^4.17.1",
"payload": "latest"
"@payloadcms/db-mongodb": "beta",
"@payloadcms/next": "beta",
"@payloadcms/richtext-lexical": "beta",
"cross-env": "^7.0.3",
"next": "^14.3.0-canary.7",
"payload": "beta",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"sharp": "0.32.6"
},
"devDependencies": {
"@types/express": "^4.17.9",
"copyfiles": "^2.4.1",
"cross-env": "^7.0.3",
"nodemon": "^2.0.6",
"ts-node": "^9.1.1",
"typescript": "^4.8.4"
"@types/node": "^20.11.25",
"@types/react": "^18.2.64",
"@types/react-dom": "^18.2.21",
"dotenv": "^16.4.5",
"tsx": "^4.7.1",
"typescript": "^5.4.2"
}
}

5184
examples/whitelabel/pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

View File

Before

Width:  |  Height:  |  Size: 842 B

After

Width:  |  Height:  |  Size: 842 B

View File

Before

Width:  |  Height:  |  Size: 346 KiB

After

Width:  |  Height:  |  Size: 346 KiB

View File

@@ -0,0 +1,17 @@
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
import config from '@payload-config'
/* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
import { RootPage } from '@payloadcms/next/views'
type Args = {
params: {
segments: string[]
}
searchParams: {
[key: string]: string | string[]
}
}
const Page = ({ params, searchParams }: Args) => RootPage({ config, params, searchParams })
export default Page

View 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'
export const GET = REST_GET(config)
export const POST = REST_POST(config)
export const DELETE = REST_DELETE(config)
export const PATCH = REST_PATCH(config)

View 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_PLAYGROUND_GET } from '@payloadcms/next/routes'
export const GET = GRAPHQL_PLAYGROUND_GET(config)

View 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'
export const POST = GRAPHQL_POST(config)

View File

@@ -0,0 +1,16 @@
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
import configPromise from '@payload-config'
import '@payloadcms/next/css'
import { RootLayout } from '@payloadcms/next/layouts'
/* 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

View File

@@ -1,4 +1,4 @@
import React from 'react';
import React from 'react'
const css = `
html[data-theme="dark"] .text {
@@ -13,27 +13,25 @@ const css = `
width: 50px;
height: 50px;
}
`;
`
export const Icon = () => {
return (
<svg
className="graphic-icon"
width="430"
fill="none"
height="435"
viewBox="0 0 430 435"
fill="none"
width="430"
xmlns="http://www.w3.org/2000/svg"
>
<style>
{css}
</style>
<style>{css}</style>
<rect
className="bg"
width="430"
fill="#0C0C0C"
height="434"
transform="translate(0 0.154785)"
fill="#0C0C0C"
width="430"
/>
<path
className="text"
@@ -41,5 +39,5 @@ export const Icon = () => {
fill="white"
/>
</svg>
);
};
)
}

View File

@@ -1,4 +1,4 @@
import React from 'react';
import React from 'react'
const css = `
html[data-theme="dark"] path {
@@ -8,25 +8,20 @@ const css = `
.graphic-logo {
width: 150px;
height: auto;
}`;
}`
export const Logo = () => {
return (
<svg
className="graphic-logo"
xmlns="http://www.w3.org/2000/svg"
fill="#0F0F0F"
viewBox="0 0 518 563"
xmlns="http://www.w3.org/2000/svg"
>
<style type="text/css">
{css}
</style>
<g
transform="translate(0,563) scale(0.1,-0.1)"
fill="#000000"
stroke="none"
>
<path d="M440 3060 l0 -2170 2150 0 2150 0 0 2170 0 2170 -2150 0 -2150 0 0
<style type="text/css">{css}</style>
<g fill="#000000" stroke="none" transform="translate(0,563) scale(0.1,-0.1)">
<path
d="M440 3060 l0 -2170 2150 0 2150 0 0 2170 0 2170 -2150 0 -2150 0 0
-2170z m1855 301 c52 -24 88 -63 117 -126 19 -42 23 -71 26 -182 4 -151 -8
-213 -58 -281 -55 -77 -140 -107 -230 -83 -66 18 -105 53 -141 128 -31 61 -33
74 -37 189 -5 145 16 233 69 298 60 72 169 97 254 57z m766 8 c74 -25 126 -85
@@ -39,15 +34,17 @@ export const Logo = () => {
264 -19 144 13 296 79 366 60 63 167 84 247 47z m-2505 -296 l0 -305 165 0
165 0 0 -35 0 -35 -210 0 -210 0 0 340 0 340 45 0 45 0 0 -305z"
/>
<path d="M2140 3286 c-80 -44 -114 -265 -64 -418 44 -135 193 -147 254 -22 22
<path
d="M2140 3286 c-80 -44 -114 -265 -64 -418 44 -135 193 -147 254 -22 22
44 24 63 24 184 1 122 -2 140 -23 183 -13 26 -36 56 -51 67 -33 23 -102 26
-140 6z"
/>
<path d="M3667 3280 c-14 -11 -36 -41 -49 -68 -20 -42 -23 -61 -23 -177 0
<path
d="M3667 3280 c-14 -11 -36 -41 -49 -68 -20 -42 -23 -61 -23 -177 0
-120 2 -134 27 -187 30 -65 64 -88 129 -88 35 0 48 6 79 38 52 52 63 98 58
257 -3 117 -6 134 -28 173 -14 24 -37 50 -52 58 -40 21 -110 18 -141 -6z"
/>
</g>
</svg>
);
};
)
}

View File

@@ -1,12 +1,16 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { buildConfig } from 'payload/config';
import path from 'path';
import { mongooseAdapter } from '@payloadcms/db-mongodb'
import { lexicalEditor } from '@payloadcms/richtext-lexical'
import path from 'path'
import { buildConfig } from 'payload/config'
import { fileURLToPath } from 'url'
import { Icon } from './graphics/Icon';
import { Logo } from './graphics/Logo';
import { Icon } from './graphics/Icon'
import { Logo } from './graphics/Logo'
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
export default buildConfig({
serverURL: 'http://localhost:3000',
admin: {
// Add your own logo and icon here
components: {
@@ -22,10 +26,13 @@ export default buildConfig({
titleSuffix: '- Your App Name',
},
},
db: mongooseAdapter({
url: process.env.DATABASE_URI || '',
}),
editor: lexicalEditor({}),
secret: process.env.PAYLOAD_SECRET || '',
serverURL: 'http://localhost:3000',
typescript: {
outputFile: path.resolve(__dirname, 'payload-types.ts'),
outputFile: path.resolve(dirname, 'payload-types.ts'),
},
graphQL: {
schemaOutputFile: path.resolve(__dirname, 'generated-schema.graphql'),
},
});
})

View File

@@ -1,30 +0,0 @@
/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable @typescript-eslint/no-var-requires */
import express from 'express';
import payload from 'payload';
import path from 'path';
require('dotenv').config();
const app = express();
// Redirect root to Admin panel
app.get('/', (_, res) => {
res.redirect('/admin');
});
app.use('/assets', express.static(path.resolve(__dirname, '../assets')));
// Initialize Payload
payload.init({
secret: process.env.PAYLOAD_SECRET,
mongoURL: process.env.MONGODB_URI,
express: app,
onInit: () => {
payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`);
},
});
// Add your own express routes here
app.listen(3000);

View File

@@ -1,18 +1,44 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"baseUrl": ".",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"strict": false,
"esModuleInterop": true,
"skipLibCheck": true,
"outDir": "./dist",
"rootDir": "./src",
"jsx": "react"
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": [
"./src/*"
],
"@payload-config": [
"./src/payload.config.ts"
]
},
"target": "ES2017"
},
"include": ["src"],
"exclude": ["node_modules", "dist", "build"],
"ts-node": {
"transpileOnly": true
}
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts"
],
"exclude": [
"node_modules"
]
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,20 +1,14 @@
{
"name": "payload-monorepo",
"version": "3.0.0-beta.12",
"version": "3.0.0-beta.19",
"private": true,
"type": "module",
"workspaces:": [
"packages/*",
"test/*"
],
"scripts": {
"build": "pnpm run build:core",
"obliterate-playwright-cache": "rm -rf ~/Library/Caches/ms-playwright && find /System/Volumes/Data/private/var/folders -type d -name 'playwright*' -exec rm -rf {} +",
"build:all": "turbo build",
"build:core": "turbo build --filter \"!@payloadcms/plugin-*\"",
"build:plugins": "turbo build --filter \"@payloadcms/plugin-*\"",
"build:app": "next build",
"build:app:analyze": "cross-env ANALYZE=true next build",
"build:core": "turbo build --filter \"!@payloadcms/plugin-*\"",
"build:create-payload-app": "turbo build --filter create-payload-app",
"build:db-mongodb": "turbo build --filter db-mongodb",
"build:db-postgres": "turbo build --filter db-postgres",
@@ -34,20 +28,21 @@
"build:plugin-sentry": "turbo build --filter plugin-sentry",
"build:plugin-seo": "turbo build --filter plugin-seo",
"build:plugin-stripe": "turbo build --filter plugin-stripe",
"build:plugins": "turbo build --filter \"@payloadcms/plugin-*\"",
"build:richtext-lexical": "turbo build --filter richtext-lexical",
"build:richtext-slate": "turbo build --filter richtext-slate",
"build:tests": "pnpm --filter payload-test-suite run typecheck",
"build:translations": "turbo build --filter translations",
"build:ui": "turbo build --filter ui",
"clean": "turbo clean",
"clean:cache": "rimraf node_modules/.cache && rimraf packages/payload/node_modules/.cache && rimraf .next",
"clean:build": "find . \\( -type d \\( -name dist -o -name .cache -o -name .next -o -name .turbo \\) -o -type f -name tsconfig.tsbuildinfo \\) -not -path '*/node_modules/*' -exec rm -rf {} +",
"clean:all": "find . \\( -type d \\( -name node_modules -o -name dist -o -name .cache -o -name .next -o -name .turbo \\) -o -type f -name tsconfig.tsbuildinfo \\) -exec rm -rf {} +",
"clean:build": "find . \\( -type d \\( -name dist -o -name .cache -o -name .next -o -name .turbo \\) -o -type f -name tsconfig.tsbuildinfo \\) -not -path '*/node_modules/*' -exec rm -rf {} +",
"clean:cache": "rimraf node_modules/.cache && rimraf packages/payload/node_modules/.cache && rimraf .next",
"dev": "cross-env NODE_OPTIONS=--no-deprecation node ./test/dev.js",
"devsafe": "rimraf .next && pnpm dev",
"dev:generate-graphql-schema": "cross-env NODE_OPTIONS=--no-deprecation tsx ./test/generateGraphQLSchema.ts",
"dev:generate-types": "cross-env NODE_OPTIONS=--no-deprecation tsx ./test/generateTypes.ts",
"dev:postgres": "cross-env NODE_OPTIONS=--no-deprecation PAYLOAD_DATABASE=postgres node ./test/dev.js",
"devsafe": "rimraf .next && pnpm dev",
"docker:restart": "pnpm docker:stop --remove-orphans && pnpm docker:start",
"docker:start": "docker compose -f packages/plugin-cloud-storage/docker-compose.yml up -d",
"docker:stop": "docker compose -f packages/plugin-cloud-storage/docker-compose.yml down",
@@ -55,22 +50,31 @@
"generate:types": "PAYLOAD_CONFIG_PATH=./test/_community/config.ts node --no-deprecation ./packages/payload/bin.js generate:types",
"lint": "eslint \"packages/**/*.ts\"",
"lint-staged": "lint-staged",
"obliterate-playwright-cache": "rm -rf ~/Library/Caches/ms-playwright && find /System/Volumes/Data/private/var/folders -type d -name 'playwright*' -exec rm -rf {} +",
"prepare": "husky install",
"pretest": "pnpm build",
"reinstall": "pnpm clean:all && pnpm install",
"script:pack": "tsx scripts/pack-all-to-dest.ts",
"release:alpha": "tsx ./scripts/release.ts --bump prerelease --tag alpha",
"release:beta": "tsx ./scripts/release.ts --bump prerelease --tag beta",
"script:pack": "tsx scripts/pack-all-to-dest.ts",
"pretest": "pnpm build",
"test": "pnpm test:int && pnpm test:components && pnpm test:e2e",
"test:components": "cross-env NODE_OPTIONS=--no-deprecation jest --config=jest.components.config.js",
"test:e2e": "cross-env NODE_OPTIONS=--no-deprecation NODE_NO_WARNINGS=1 tsx ./test/runE2E.ts",
"test:e2e:debug": "cross-env NODE_OPTIONS=--no-deprecation NODE_NO_WARNINGS=1 PWDEBUG=1 DISABLE_LOGGING=true playwright test",
"test:e2e:headed": "cross-env NODE_OPTIONS=--no-deprecation NODE_NO_WARNINGS=1 DISABLE_LOGGING=true playwright test --headed",
"test:int:postgres": "cross-env NODE_OPTIONS=--no-deprecation NODE_NO_WARNINGS=1 PAYLOAD_DATABASE=postgres DISABLE_LOGGING=true jest --forceExit --detectOpenHandles --config=test/jest.config.js --runInBand",
"test:int": "cross-env NODE_OPTIONS=--no-deprecation NODE_NO_WARNINGS=1 DISABLE_LOGGING=true jest --forceExit --detectOpenHandles --config=test/jest.config.js --runInBand",
"test:int:postgres": "cross-env NODE_OPTIONS=--no-deprecation NODE_NO_WARNINGS=1 PAYLOAD_DATABASE=postgres DISABLE_LOGGING=true jest --forceExit --detectOpenHandles --config=test/jest.config.js --runInBand",
"test:unit": "cross-env NODE_OPTIONS=--no-deprecation NODE_NO_WARNINGS=1 DISABLE_LOGGING=true jest --forceExit --detectOpenHandles --config=jest.config.js --runInBand",
"translateNewKeys": "pnpm --filter payload run translateNewKeys"
},
"lint-staged": {
"**/package.json": "sort-package-json",
"*.{md,mdx,yml,json}": "prettier --write",
"*.{js,jsx,ts,tsx}": [
"prettier --write",
"eslint --cache --fix"
]
},
"devDependencies": {
"@aws-sdk/client-s3": "^3.525.0",
"@next/bundle-analyzer": "^14.1.0",
@@ -78,6 +82,7 @@
"@payloadcms/eslint-config": "workspace:*",
"@payloadcms/live-preview-react": "workspace:*",
"@playwright/test": "1.43.0",
"@sentry/react": "^7.77.0",
"@swc/cli": "^0.1.62",
"@swc/jest": "0.2.36",
"@testing-library/jest-dom": "6.4.2",
@@ -140,8 +145,8 @@
"prettier": "^3.0.3",
"prompts": "2.4.2",
"qs": "6.11.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"read-stream": "^2.1.1",
"rimraf": "3.0.2",
"semver": "^7.5.4",
@@ -150,6 +155,7 @@
"simple-git": "^3.24.0",
"slash": "3.0.0",
"slate": "0.91.4",
"sort-package-json": "^2.10.0",
"swc-plugin-transform-remove-imports": "^1.12.1",
"tempfile": "^3.0.0",
"tempy": "^1.0.1",
@@ -165,21 +171,14 @@
},
"engines": {
"node": ">=18.20.2",
"pnpm": ">=8.15.7"
},
"lint-staged": {
"*.{md,mdx,yml,json}": "prettier --write",
"*.{js,jsx,ts,tsx}": [
"prettier --write",
"eslint --cache --fix"
]
},
"dependencies": {
"@sentry/react": "^7.77.0",
"ajv": "^8.12.0",
"passport-strategy": "1.0.0"
"pnpm": "^8.15.7"
},
"pnpm": {
"allowedDeprecatedVersions": {
"abab": "2",
"domexception": "4",
"uuid": "3.4.0"
},
"overrides": {
"copyfiles": "$copyfiles",
"cross-env": "$cross-env",
@@ -191,13 +190,12 @@
"react-dom": "$react-dom",
"typescript": "$typescript"
},
"allowedDeprecatedVersions": {
"uuid": "3.4.0",
"abab": "2",
"domexception": "4"
},
"patchedDependencies": {
"playwright@1.43.0": "patches/playwright@1.43.0.patch"
}
}
},
"workspaces:": [
"packages/*",
"test/*"
]
}

View File

@@ -1,31 +1,38 @@
{
"name": "create-payload-app",
"version": "3.0.0-beta.12",
"license": "MIT",
"type": "module",
"version": "3.0.0-beta.19",
"homepage": "https://payloadcms.com",
"bin": {
"create-payload-app": "bin/cli.js"
},
"repository": {
"type": "git",
"url": "https://github.com/payloadcms/payload.git",
"directory": "packages/create-payload-app"
},
"scripts": {
"build": "pnpm pack-template-files && pnpm typecheck && pnpm build:swc",
"typecheck": "tsc",
"pack-template-files": "tsx src/scripts/pack-template-files.ts",
"build:swc": "swc ./src -d ./dist --config-file .swcrc",
"clean": "rimraf {dist,*.tsbuildinfo}",
"test": "jest",
"prepublishOnly": "pnpm clean && pnpm build"
"license": "MIT",
"type": "module",
"exports": {
"./commands": {
"import": "./src/lib/init-next.ts",
"require": "./src/lib/init-next.ts",
"types": "./src/lib/init-next.ts"
}
},
"bin": {
"create-payload-app": "bin/cli.js"
},
"files": [
"package.json",
"dist",
"bin"
],
"scripts": {
"build": "pnpm pack-template-files && pnpm typecheck && pnpm build:swc",
"build:swc": "swc ./src -d ./dist --config-file .swcrc",
"clean": "rimraf {dist,*.tsbuildinfo}",
"pack-template-files": "tsx src/scripts/pack-template-files.ts",
"prepublishOnly": "pnpm clean && pnpm build",
"test": "jest",
"typecheck": "tsc"
},
"dependencies": {
"@clack/prompts": "^0.7.0",
"@sindresorhus/slugify": "^1.1.0",
@@ -49,12 +56,5 @@
"@types/fs-extra": "^9.0.12",
"@types/jest": "^27.0.3",
"@types/node": "20.12.5"
},
"exports": {
"./commands": {
"import": "./src/lib/init-next.ts",
"require": "./src/lib/init-next.ts",
"types": "./src/lib/init-next.ts"
}
}
}

View File

@@ -1,5 +1,9 @@
import fse from 'fs-extra'
import globby from 'globby'
import { fileURLToPath } from 'node:url'
import path from 'path'
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
import type { DbDetails } from '../types.js'
@@ -15,6 +19,34 @@ export async function configurePayloadConfig(args: {
return
}
// Update package.json
const packageJsonPath =
'projectDir' in args.projectDirOrConfigPath &&
path.resolve(args.projectDirOrConfigPath.projectDir, 'package.json')
if (packageJsonPath && fse.existsSync(packageJsonPath)) {
try {
const packageObj = await fse.readJson(packageJsonPath)
const dbPackage = dbReplacements[args.dbDetails.type]
// Delete all other db adapters
Object.values(dbReplacements).forEach((p) => {
if (p.packageName !== dbPackage.packageName) {
delete packageObj.dependencies[p.packageName]
}
})
// Set version of db adapter to match payload version
packageObj.dependencies[dbPackage.packageName] = packageObj.dependencies['payload']
await fse.writeJson(packageJsonPath, packageObj, { spaces: 2 })
} catch (err: unknown) {
warning(`Unable to configure Payload in package.json`)
warning(err instanceof Error ? err.message : '')
}
}
try {
let payloadConfigPath: string | undefined
if (!('payloadConfigPath' in args.projectDirOrConfigPath)) {

View File

@@ -1,22 +1,34 @@
{
"name": "@payloadcms/db-mongodb",
"version": "3.0.0-beta.12",
"version": "3.0.0-beta.19",
"description": "The officially supported MongoDB database adapter for Payload",
"homepage": "https://payloadcms.com",
"repository": {
"type": "git",
"url": "https://github.com/payloadcms/payload.git",
"directory": "packages/db-mongodb"
},
"license": "MIT",
"homepage": "https://payloadcms.com",
"type": "module",
"author": {
"email": "info@payloadcms.com",
"name": "Payload",
"email": "info@payloadcms.com",
"url": "https://payloadcms.com"
},
"type": "module",
"exports": {
".": {
"import": "./src/index.ts",
"require": "./src/index.ts",
"types": "./src/index.ts"
}
},
"main": "./src/index.ts",
"types": "./src/types.ts",
"files": [
"dist",
"mock.js",
"predefinedMigrations"
],
"scripts": {
"build": "pnpm build:swc && pnpm build:types",
"build:swc": "swc ./src -d ./dist --config-file .swcrc-build",
@@ -44,27 +56,15 @@
"peerDependencies": {
"payload": "workspace:*"
},
"exports": {
".": {
"import": "./src/index.ts",
"require": "./src/index.ts",
"types": "./src/index.ts"
}
},
"publishConfig": {
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.js",
"types": "./dist/index.d.ts"
}
}
},
"files": [
"dist",
"mock.js",
"predefinedMigrations"
]
},
"main": "./dist/index.js",
"types": "./dist/index.d.ts"
}
}

View File

@@ -1,6 +1,6 @@
import type { QueryOptions } from 'mongoose'
import type { Count } from 'payload/database'
import type { PayloadRequest } from 'payload/types'
import type { PayloadRequestWithData } from 'payload/types'
import { flattenWhereToOperators } from 'payload/database'
@@ -10,7 +10,7 @@ import { withSession } from './withSession.js'
export const count: Count = async function count(
this: MongooseAdapter,
{ collection, locale, req = {} as PayloadRequest, where },
{ collection, locale, req = {} as PayloadRequestWithData, where },
) {
const Model = this.collections[collection]
const options: QueryOptions = withSession(this, req.transactionID)

View File

@@ -1,5 +1,5 @@
import type { Create } from 'payload/database'
import type { Document, PayloadRequest } from 'payload/types'
import type { Document, PayloadRequestWithData } from 'payload/types'
import type { MongooseAdapter } from './index.js'
@@ -8,7 +8,7 @@ import { withSession } from './withSession.js'
export const create: Create = async function create(
this: MongooseAdapter,
{ collection, data, req = {} as PayloadRequest },
{ collection, data, req = {} as PayloadRequestWithData },
) {
const Model = this.collections[collection]
const options = withSession(this, req.transactionID)

View File

@@ -1,5 +1,5 @@
import type { CreateGlobal } from 'payload/database'
import type { PayloadRequest } from 'payload/types'
import type { PayloadRequestWithData } from 'payload/types'
import type { MongooseAdapter } from './index.js'
@@ -8,7 +8,7 @@ import { withSession } from './withSession.js'
export const createGlobal: CreateGlobal = async function createGlobal(
this: MongooseAdapter,
{ slug, data, req = {} as PayloadRequest },
{ slug, data, req = {} as PayloadRequestWithData },
) {
const Model = this.globals
const global = {

View File

@@ -1,5 +1,5 @@
import type { CreateGlobalVersion } from 'payload/database'
import type { PayloadRequest } from 'payload/types'
import type { PayloadRequestWithData } from 'payload/types'
import type { Document } from 'payload/types'
import type { MongooseAdapter } from './index.js'
@@ -8,7 +8,15 @@ import { withSession } from './withSession.js'
export const createGlobalVersion: CreateGlobalVersion = async function createGlobalVersion(
this: MongooseAdapter,
{ autosave, createdAt, globalSlug, parent, req = {} as PayloadRequest, updatedAt, versionData },
{
autosave,
createdAt,
globalSlug,
parent,
req = {} as PayloadRequestWithData,
updatedAt,
versionData,
},
) {
const VersionModel = this.versions[globalSlug]
const options = withSession(this, req.transactionID)

View File

@@ -1,5 +1,5 @@
import type { CreateVersion } from 'payload/database'
import type { PayloadRequest } from 'payload/types'
import type { PayloadRequestWithData } from 'payload/types'
import type { Document } from 'payload/types'
import type { MongooseAdapter } from './index.js'
@@ -13,7 +13,7 @@ export const createVersion: CreateVersion = async function createVersion(
collectionSlug,
createdAt,
parent,
req = {} as PayloadRequest,
req = {} as PayloadRequestWithData,
updatedAt,
versionData,
},

View File

@@ -1,5 +1,5 @@
import type { DeleteMany } from 'payload/database'
import type { PayloadRequest } from 'payload/types'
import type { PayloadRequestWithData } from 'payload/types'
import type { MongooseAdapter } from './index.js'
@@ -7,7 +7,7 @@ import { withSession } from './withSession.js'
export const deleteMany: DeleteMany = async function deleteMany(
this: MongooseAdapter,
{ collection, req = {} as PayloadRequest, where },
{ collection, req = {} as PayloadRequestWithData, where },
) {
const Model = this.collections[collection]
const options = {

View File

@@ -1,5 +1,5 @@
import type { DeleteOne } from 'payload/database'
import type { PayloadRequest } from 'payload/types'
import type { PayloadRequestWithData } from 'payload/types'
import type { Document } from 'payload/types'
import type { MongooseAdapter } from './index.js'
@@ -9,7 +9,7 @@ import { withSession } from './withSession.js'
export const deleteOne: DeleteOne = async function deleteOne(
this: MongooseAdapter,
{ collection, req = {} as PayloadRequest, where },
{ collection, req = {} as PayloadRequestWithData, where },
) {
const Model = this.collections[collection]
const options = withSession(this, req.transactionID)

View File

@@ -1,5 +1,5 @@
import type { DeleteVersions } from 'payload/database'
import type { PayloadRequest } from 'payload/types'
import type { PayloadRequestWithData } from 'payload/types'
import type { MongooseAdapter } from './index.js'
@@ -7,7 +7,7 @@ import { withSession } from './withSession.js'
export const deleteVersions: DeleteVersions = async function deleteVersions(
this: MongooseAdapter,
{ collection, locale, req = {} as PayloadRequest, where },
{ collection, locale, req = {} as PayloadRequestWithData, where },
) {
const VersionsModel = this.versions[collection]
const options = {

View File

@@ -1,6 +1,6 @@
import type { PaginateOptions } from 'mongoose'
import type { Find } from 'payload/database'
import type { PayloadRequest } from 'payload/types'
import type { PayloadRequestWithData } from 'payload/types'
import { flattenWhereToOperators } from 'payload/database'
@@ -12,7 +12,16 @@ import { withSession } from './withSession.js'
export const find: Find = async function find(
this: MongooseAdapter,
{ collection, limit, locale, page, pagination, req = {} as PayloadRequest, sort: sortArg, where },
{
collection,
limit,
locale,
page,
pagination,
req = {} as PayloadRequestWithData,
sort: sortArg,
where,
},
) {
const Model = this.collections[collection]
const collectionConfig = this.payload.collections[collection].config

View File

@@ -1,5 +1,5 @@
import type { FindGlobal } from 'payload/database'
import type { PayloadRequest } from 'payload/types'
import type { PayloadRequestWithData } from 'payload/types'
import { combineQueries } from 'payload/database'
@@ -10,7 +10,7 @@ import { withSession } from './withSession.js'
export const findGlobal: FindGlobal = async function findGlobal(
this: MongooseAdapter,
{ slug, locale, req = {} as PayloadRequest, where },
{ slug, locale, req = {} as PayloadRequestWithData, where },
) {
const Model = this.globals
const options = {

View File

@@ -1,6 +1,6 @@
import type { PaginateOptions } from 'mongoose'
import type { FindGlobalVersions } from 'payload/database'
import type { PayloadRequest } from 'payload/types'
import type { PayloadRequestWithData } from 'payload/types'
import { flattenWhereToOperators } from 'payload/database'
import { buildVersionGlobalFields } from 'payload/versions'
@@ -19,7 +19,7 @@ export const findGlobalVersions: FindGlobalVersions = async function findGlobalV
locale,
page,
pagination,
req = {} as PayloadRequest,
req = {} as PayloadRequestWithData,
skip,
sort: sortArg,
where,

View File

@@ -1,6 +1,6 @@
import type { MongooseQueryOptions } from 'mongoose'
import type { FindOne } from 'payload/database'
import type { PayloadRequest } from 'payload/types'
import type { PayloadRequestWithData } from 'payload/types'
import type { Document } from 'payload/types'
import type { MongooseAdapter } from './index.js'
@@ -10,7 +10,7 @@ import { withSession } from './withSession.js'
export const findOne: FindOne = async function findOne(
this: MongooseAdapter,
{ collection, locale, req = {} as PayloadRequest, where },
{ collection, locale, req = {} as PayloadRequestWithData, where },
) {
const Model = this.collections[collection]
const options: MongooseQueryOptions = {

View File

@@ -1,6 +1,6 @@
import type { PaginateOptions } from 'mongoose'
import type { FindVersions } from 'payload/database'
import type { PayloadRequest } from 'payload/types'
import type { PayloadRequestWithData } from 'payload/types'
import { flattenWhereToOperators } from 'payload/database'
@@ -18,7 +18,7 @@ export const findVersions: FindVersions = async function findVersions(
locale,
page,
pagination,
req = {} as PayloadRequest,
req = {} as PayloadRequestWithData,
skip,
sort: sortArg,
where,

View File

@@ -1,4 +1,4 @@
import type { PayloadRequest } from 'payload/types'
import type { PayloadRequestWithData } from 'payload/types'
import {
commitTransaction,
@@ -50,7 +50,7 @@ export async function migrateFresh(
msg: `Found ${migrationFiles.length} migration files.`,
})
const req = { payload } as PayloadRequest
const req = { payload } as PayloadRequestWithData
// Run all migrate up
for (const migration of migrationFiles) {

View File

@@ -1,6 +1,6 @@
import type { PaginateOptions } from 'mongoose'
import type { QueryDrafts } from 'payload/database'
import type { PayloadRequest } from 'payload/types'
import type { PayloadRequestWithData } from 'payload/types'
import { combineQueries, flattenWhereToOperators } from 'payload/database'
@@ -12,7 +12,16 @@ import { withSession } from './withSession.js'
export const queryDrafts: QueryDrafts = async function queryDrafts(
this: MongooseAdapter,
{ collection, limit, locale, page, pagination, req = {} as PayloadRequest, sort: sortArg, where },
{
collection,
limit,
locale,
page,
pagination,
req = {} as PayloadRequestWithData,
sort: sortArg,
where,
},
) {
const VersionModel = this.versions[collection]
const collectionConfig = this.payload.collections[collection].config

View File

@@ -1,5 +1,5 @@
import type { UpdateGlobal } from 'payload/database'
import type { PayloadRequest } from 'payload/types'
import type { PayloadRequestWithData } from 'payload/types'
import type { MongooseAdapter } from './index.js'
@@ -8,7 +8,7 @@ import { withSession } from './withSession.js'
export const updateGlobal: UpdateGlobal = async function updateGlobal(
this: MongooseAdapter,
{ slug, data, req = {} as PayloadRequest },
{ slug, data, req = {} as PayloadRequestWithData },
) {
const Model = this.globals
const options = {

View File

@@ -1,5 +1,5 @@
import type { UpdateGlobalVersionArgs } from 'payload/database'
import type { PayloadRequest, TypeWithID } from 'payload/types'
import type { PayloadRequestWithData, TypeWithID } from 'payload/types'
import type { MongooseAdapter } from './index.js'
@@ -11,7 +11,7 @@ export async function updateGlobalVersion<T extends TypeWithID>(
id,
global,
locale,
req = {} as PayloadRequest,
req = {} as PayloadRequestWithData,
versionData,
where,
}: UpdateGlobalVersionArgs<T>,

View File

@@ -1,5 +1,5 @@
import type { UpdateOne } from 'payload/database'
import type { PayloadRequest } from 'payload/types'
import type { PayloadRequestWithData } from 'payload/types'
import type { MongooseAdapter } from './index.js'
@@ -9,7 +9,7 @@ import { withSession } from './withSession.js'
export const updateOne: UpdateOne = async function updateOne(
this: MongooseAdapter,
{ id, collection, data, locale, req = {} as PayloadRequest, where: whereArg },
{ id, collection, data, locale, req = {} as PayloadRequestWithData, where: whereArg },
) {
const where = id ? { id: { equals: id } } : whereArg
const Model = this.collections[collection]

View File

@@ -1,5 +1,5 @@
import type { UpdateVersion } from 'payload/database'
import type { PayloadRequest } from 'payload/types'
import type { PayloadRequestWithData } from 'payload/types'
import type { MongooseAdapter } from './index.js'
@@ -7,7 +7,7 @@ import { withSession } from './withSession.js'
export const updateVersion: UpdateVersion = async function updateVersion(
this: MongooseAdapter,
{ id, collection, locale, req = {} as PayloadRequest, versionData, where },
{ id, collection, locale, req = {} as PayloadRequestWithData, versionData, where },
) {
const VersionModel = this.versions[collection]
const whereToUse = where || { id: { equals: id } }

View File

@@ -1,22 +1,38 @@
{
"name": "@payloadcms/db-postgres",
"version": "3.0.0-beta.12",
"version": "3.0.0-beta.19",
"description": "The officially supported Postgres database adapter for Payload",
"homepage": "https://payloadcms.com",
"repository": {
"type": "git",
"url": "https://github.com/payloadcms/payload.git",
"directory": "packages/db-postgres"
},
"license": "MIT",
"homepage": "https://payloadcms.com",
"type": "module",
"author": {
"email": "info@payloadcms.com",
"name": "Payload",
"email": "info@payloadcms.com",
"url": "https://payloadcms.com"
},
"type": "module",
"exports": {
".": {
"import": "./src/index.ts",
"require": "./src/index.ts",
"types": "./src/index.ts"
},
"./types": {
"import": "./src/types.ts",
"require": "./src/types.ts",
"types": "./src/types.ts"
}
},
"main": "./src/index.ts",
"types": "./src/types.ts",
"files": [
"dist",
"mock.js"
],
"scripts": {
"build": "pnpm build:swc && pnpm build:types",
"build:swc": "swc ./src -d ./dist --config-file .swcrc",
@@ -43,21 +59,7 @@
"peerDependencies": {
"payload": "workspace:*"
},
"exports": {
".": {
"import": "./src/index.ts",
"require": "./src/index.ts",
"types": "./src/index.ts"
},
"./types": {
"import": "./src/types.ts",
"require": "./src/types.ts",
"types": "./src/types.ts"
}
},
"publishConfig": {
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"import": "./dist/index.js",
@@ -69,10 +71,8 @@
"require": "./dist/types.js",
"types": "./dist/types.d.ts"
}
}
},
"files": [
"dist",
"mock.js"
]
},
"main": "./dist/index.js",
"types": "./dist/index.d.ts"
}
}

View File

@@ -2,13 +2,13 @@ import type { Count } from 'payload/database'
import type { SanitizedCollectionConfig } from 'payload/types'
import { sql } from 'drizzle-orm'
import toSnakeCase from 'to-snake-case'
import type { ChainedMethods } from './find/chainMethods.js'
import type { PostgresAdapter } from './types.js'
import { chainMethods } from './find/chainMethods.js'
import buildQuery from './queries/buildQuery.js'
import { getTableName } from './schema/getTableName.js'
export const count: Count = async function count(
this: PostgresAdapter,
@@ -16,10 +16,7 @@ export const count: Count = async function count(
) {
const collectionConfig: SanitizedCollectionConfig = this.payload.collections[collection].config
const tableName = getTableName({
adapter: this,
config: collectionConfig,
})
const tableName = this.tableNameMap.get(toSnakeCase(collectionConfig.slug))
const db = this.sessions[req.transactionID]?.db || this.drizzle
const table = this.tables[tableName]

View File

@@ -1,8 +1,9 @@
import type { Create } from 'payload/database'
import toSnakeCase from 'to-snake-case'
import type { PostgresAdapter } from './types.js'
import { getTableName } from './schema/getTableName.js'
import { upsertRow } from './upsertRow/index.js'
export const create: Create = async function create(
@@ -12,6 +13,8 @@ export const create: Create = async function create(
const db = this.sessions[req.transactionID]?.db || this.drizzle
const collection = this.payload.collections[collectionSlug].config
const tableName = this.tableNameMap.get(toSnakeCase(collection.slug))
const result = await upsertRow({
adapter: this,
data,
@@ -19,10 +22,7 @@ export const create: Create = async function create(
fields: collection.fields,
operation: 'create',
req,
tableName: getTableName({
adapter: this,
config: collection,
}),
tableName,
})
return result

View File

@@ -1,18 +1,21 @@
import type { CreateGlobalArgs } from 'payload/database'
import type { PayloadRequest, TypeWithID } from 'payload/types'
import type { PayloadRequestWithData, TypeWithID } from 'payload/types'
import toSnakeCase from 'to-snake-case'
import type { PostgresAdapter } from './types.js'
import { getTableName } from './schema/getTableName.js'
import { upsertRow } from './upsertRow/index.js'
export async function createGlobal<T extends TypeWithID>(
this: PostgresAdapter,
{ slug, data, req = {} as PayloadRequest }: CreateGlobalArgs,
{ slug, data, req = {} as PayloadRequestWithData }: CreateGlobalArgs,
): Promise<T> {
const db = this.sessions[req.transactionID]?.db || this.drizzle
const globalConfig = this.payload.globals.config.find((config) => config.slug === slug)
const tableName = this.tableNameMap.get(toSnakeCase(globalConfig.slug))
const result = await upsertRow<T>({
adapter: this,
data,
@@ -20,10 +23,7 @@ export async function createGlobal<T extends TypeWithID>(
fields: globalConfig.fields,
operation: 'create',
req,
tableName: getTableName({
adapter: this,
config: globalConfig,
}),
tableName,
})
return result

View File

@@ -1,26 +1,28 @@
import type { TypeWithVersion } from 'payload/database'
import type { PayloadRequest, TypeWithID } from 'payload/types'
import type { PayloadRequestWithData, TypeWithID } from 'payload/types'
import { sql } from 'drizzle-orm'
import { type CreateGlobalVersionArgs } from 'payload/database'
import { buildVersionGlobalFields } from 'payload/versions'
import toSnakeCase from 'to-snake-case'
import type { PostgresAdapter } from './types.js'
import { getTableName } from './schema/getTableName.js'
import { upsertRow } from './upsertRow/index.js'
export async function createGlobalVersion<T extends TypeWithID>(
this: PostgresAdapter,
{ autosave, globalSlug, req = {} as PayloadRequest, versionData }: CreateGlobalVersionArgs,
{
autosave,
globalSlug,
req = {} as PayloadRequestWithData,
versionData,
}: CreateGlobalVersionArgs,
) {
const db = this.sessions[req.transactionID]?.db || this.drizzle
const global = this.payload.globals.config.find(({ slug }) => slug === globalSlug)
const tableName = getTableName({
adapter: this,
config: global,
versions: true,
})
const tableName = this.tableNameMap.get(`_${toSnakeCase(global.slug)}${this.versionsSuffix}`)
const result = await upsertRow<TypeWithVersion<T>>({
adapter: this,

View File

@@ -1,12 +1,12 @@
import type { CreateVersionArgs, TypeWithVersion } from 'payload/database'
import type { PayloadRequest, TypeWithID } from 'payload/types'
import type { PayloadRequestWithData, TypeWithID } from 'payload/types'
import { sql } from 'drizzle-orm'
import { buildVersionCollectionFields } from 'payload/versions'
import toSnakeCase from 'to-snake-case'
import type { PostgresAdapter } from './types.js'
import { getTableName } from './schema/getTableName.js'
import { upsertRow } from './upsertRow/index.js'
export async function createVersion<T extends TypeWithID>(
@@ -15,17 +15,18 @@ export async function createVersion<T extends TypeWithID>(
autosave,
collectionSlug,
parent,
req = {} as PayloadRequest,
req = {} as PayloadRequestWithData,
versionData,
}: CreateVersionArgs<T>,
) {
const db = this.sessions[req.transactionID]?.db || this.drizzle
const collection = this.payload.collections[collectionSlug].config
const tableName = getTableName({
adapter: this,
config: collection,
versions: true,
})
const defaultTableName = toSnakeCase(collection.slug)
const tableName = this.tableNameMap.get(`_${defaultTableName}${this.versionsSuffix}`)
const version = { ...versionData }
if (version.id) delete version.id
const result = await upsertRow<TypeWithVersion<T>>({
adapter: this,
@@ -33,7 +34,7 @@ export async function createVersion<T extends TypeWithID>(
autosave,
latest: true,
parent,
version: versionData,
version,
},
db,
fields: buildVersionCollectionFields(collection),
@@ -43,15 +44,9 @@ export async function createVersion<T extends TypeWithID>(
})
const table = this.tables[tableName]
const relationshipsTable =
this.tables[
getTableName({
adapter: this,
config: collection,
relationships: true,
versions: true,
})
]
this.tables[`_${defaultTableName}${this.versionsSuffix}${this.relationshipsSuffix}`]
if (collection.versions.drafts) {
await db.execute(sql`

View File

@@ -1,20 +1,21 @@
import type { DeleteMany } from 'payload/database'
import type { PayloadRequest } from 'payload/types'
import type { PayloadRequestWithData } from 'payload/types'
import { inArray } from 'drizzle-orm'
import toSnakeCase from 'to-snake-case'
import type { PostgresAdapter } from './types.js'
import { findMany } from './find/findMany.js'
import { getTableName } from './schema/getTableName.js'
export const deleteMany: DeleteMany = async function deleteMany(
this: PostgresAdapter,
{ collection, req = {} as PayloadRequest, where },
{ collection, req = {} as PayloadRequestWithData, where },
) {
const db = this.sessions[req.transactionID]?.db || this.drizzle
const collectionConfig = this.payload.collections[collection].config
const tableName = getTableName({ adapter: this, config: collectionConfig })
const tableName = this.tableNameMap.get(toSnakeCase(collectionConfig.slug))
const result = await findMany({
adapter: this,

View File

@@ -1,26 +1,25 @@
import type { DeleteOne } from 'payload/database'
import type { PayloadRequest } from 'payload/types'
import type { PayloadRequestWithData } from 'payload/types'
import { eq } from 'drizzle-orm'
import toSnakeCase from 'to-snake-case'
import type { PostgresAdapter } from './types.js'
import { buildFindManyArgs } from './find/buildFindManyArgs.js'
import buildQuery from './queries/buildQuery.js'
import { selectDistinct } from './queries/selectDistinct.js'
import { getTableName } from './schema/getTableName.js'
import { transform } from './transform/read/index.js'
export const deleteOne: DeleteOne = async function deleteOne(
this: PostgresAdapter,
{ collection: collectionSlug, req = {} as PayloadRequest, where: whereArg },
{ collection: collectionSlug, req = {} as PayloadRequestWithData, where: whereArg },
) {
const db = this.sessions[req.transactionID]?.db || this.drizzle
const collection = this.payload.collections[collectionSlug].config
const tableName = getTableName({
adapter: this,
config: collection,
})
const tableName = this.tableNameMap.get(toSnakeCase(collection.slug))
let docToDelete: Record<string, unknown>
const { joinAliases, joins, selectFields, where } = await buildQuery({

Some files were not shown because too many files have changed in this diff Show More