Compare commits

..

303 Commits

Author SHA1 Message Date
Elliot DeNolf
a8c6827b68 fix(plugin-cloud): purge cache for all sizes 2024-03-11 22:12:10 -04:00
geisterfurz007
c038acb3a4 chore: fix typescript hallucinations (#4559)
* chore: fix typescript halluzinations

* chore: remove another unused ts-expect-error directive
2024-03-10 01:30:01 -05:00
Jarrod Flesch
f8c2ccf6b1 chore(examples/multi-tenant): updates readme, fixes payload.init 2024-03-10 00:38:51 -05:00
Akhil Naidu
e6092fd36c docs: improve naming for afterForgotPassword hook example code (#5062) 2024-03-10 00:22:58 -05:00
Max Morozov
e0eae77758 docs: fix typo (#5052) 2024-03-10 00:12:29 -05:00
mhjmaas
0780ff22bb chore(translations): NL mistranslation of crop from "gewas" to "bijsnijden" 2024-03-07 22:58:08 -05:00
Alessio Gravili
e7f6bfbe9d fix(richtext-lexical): Blocks: generated output schema is not fully correct (#5259) 2024-03-07 13:27:27 -05:00
Fabian Aggeler
23df60dba5 fix(richtext-lexical): Link: add open-in-new-tab to html converter 2024-03-07 13:22:02 -05:00
Dan Ribbens
8919b86571 chore(ecommerce-template): fix duplicate cart update calls (#5228) 2024-03-05 10:51:50 -05:00
dependabot[bot]
8104fac5ed chore(deps): bump ip from 2.0.0 to 2.0.1 in /examples/whitelabel (#5128)
Bumps [ip](https://github.com/indutny/node-ip) from 2.0.0 to 2.0.1.
- [Commits](https://github.com/indutny/node-ip/compare/v2.0.0...v2.0.1)

---
updated-dependencies:
- dependency-name: ip
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-26 11:25:00 -05:00
dependabot[bot]
59ef1263a5 chore(deps): bump ip from 2.0.0 to 2.0.1 in /examples/auth/payload (#5134)
Bumps [ip](https://github.com/indutny/node-ip) from 2.0.0 to 2.0.1.
- [Commits](https://github.com/indutny/node-ip/compare/v2.0.0...v2.0.1)

---
updated-dependencies:
- dependency-name: ip
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-26 11:24:53 -05:00
dependabot[bot]
813e3dbc98 chore(deps): bump ip from 2.0.0 to 2.0.1 in /examples/redirects/payload (#5138)
Bumps [ip](https://github.com/indutny/node-ip) from 2.0.0 to 2.0.1.
- [Commits](https://github.com/indutny/node-ip/compare/v2.0.0...v2.0.1)

---
updated-dependencies:
- dependency-name: ip
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-26 11:24:45 -05:00
dependabot[bot]
12a23092e1 chore(deps): bump ip from 1.1.8 to 1.1.9 in /examples/email (#5127)
Bumps [ip](https://github.com/indutny/node-ip) from 1.1.8 to 1.1.9.
- [Commits](https://github.com/indutny/node-ip/compare/v1.1.8...v1.1.9)

---
updated-dependencies:
- dependency-name: ip
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-26 11:24:23 -05:00
dependabot[bot]
4a49beb552 chore(deps): bump ip from 2.0.0 to 2.0.1 in /templates/blank (#5129)
Bumps [ip](https://github.com/indutny/node-ip) from 2.0.0 to 2.0.1.
- [Commits](https://github.com/indutny/node-ip/compare/v2.0.0...v2.0.1)

---
updated-dependencies:
- dependency-name: ip
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-26 11:24:14 -05:00
dependabot[bot]
80530c666e chore(deps): bump ip from 2.0.0 to 2.0.1 in /examples/multi-tenant (#5130)
Bumps [ip](https://github.com/indutny/node-ip) from 2.0.0 to 2.0.1.
- [Commits](https://github.com/indutny/node-ip/compare/v2.0.0...v2.0.1)

---
updated-dependencies:
- dependency-name: ip
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-26 11:24:09 -05:00
dependabot[bot]
f53e2df951 chore(deps): bump ip from 2.0.0 to 2.0.1 in /templates/website (#5131)
Bumps [ip](https://github.com/indutny/node-ip) from 2.0.0 to 2.0.1.
- [Commits](https://github.com/indutny/node-ip/compare/v2.0.0...v2.0.1)

---
updated-dependencies:
- dependency-name: ip
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-26 11:24:01 -05:00
dependabot[bot]
db58e2bab2 chore(deps): bump ip from 2.0.0 to 2.0.1 in /examples/custom-server (#5132)
Bumps [ip](https://github.com/indutny/node-ip) from 2.0.0 to 2.0.1.
- [Commits](https://github.com/indutny/node-ip/compare/v2.0.0...v2.0.1)

---
updated-dependencies:
- dependency-name: ip
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-26 11:23:56 -05:00
dependabot[bot]
d88e97e123 chore(deps): bump ip in /examples/draft-preview/payload (#5133)
Bumps [ip](https://github.com/indutny/node-ip) from 2.0.0 to 2.0.1.
- [Commits](https://github.com/indutny/node-ip/compare/v2.0.0...v2.0.1)

---
updated-dependencies:
- dependency-name: ip
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-26 11:23:48 -05:00
dependabot[bot]
bb72e506e6 chore(deps): bump ip from 2.0.0 to 2.0.1 in /examples/testing (#5135)
Bumps [ip](https://github.com/indutny/node-ip) from 2.0.0 to 2.0.1.
- [Commits](https://github.com/indutny/node-ip/compare/v2.0.0...v2.0.1)

---
updated-dependencies:
- dependency-name: ip
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-26 11:23:40 -05:00
dependabot[bot]
b1f727fd6a chore(deps): bump ip in /examples/live-preview/payload (#5136)
Bumps [ip](https://github.com/indutny/node-ip) from 2.0.0 to 2.0.1.
- [Commits](https://github.com/indutny/node-ip/compare/v2.0.0...v2.0.1)

---
updated-dependencies:
- dependency-name: ip
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-26 11:23:33 -05:00
dependabot[bot]
72af18229b chore(deps): bump ip in /examples/form-builder/payload (#5137)
Bumps [ip](https://github.com/indutny/node-ip) from 2.0.0 to 2.0.1.
- [Commits](https://github.com/indutny/node-ip/compare/v2.0.0...v2.0.1)

---
updated-dependencies:
- dependency-name: ip
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-26 11:23:27 -05:00
dependabot[bot]
af52b526c8 chore(deps): bump ip in /examples/nested-docs/payload (#5139)
Bumps [ip](https://github.com/indutny/node-ip) from 2.0.0 to 2.0.1.
- [Commits](https://github.com/indutny/node-ip/compare/v2.0.0...v2.0.1)

---
updated-dependencies:
- dependency-name: ip
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-26 11:23:17 -05:00
dependabot[bot]
60525623bf chore(deps): bump ip from 2.0.0 to 2.0.1 in /examples/hierarchy (#5140)
Bumps [ip](https://github.com/indutny/node-ip) from 2.0.0 to 2.0.1.
- [Commits](https://github.com/indutny/node-ip/compare/v2.0.0...v2.0.1)

---
updated-dependencies:
- dependency-name: ip
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-26 11:23:11 -05:00
dependabot[bot]
0fba582926 chore(deps): bump ip from 2.0.0 to 2.0.1 in /templates/ecommerce (#5126)
Bumps [ip](https://github.com/indutny/node-ip) from 2.0.0 to 2.0.1.
- [Commits](https://github.com/indutny/node-ip/compare/v2.0.0...v2.0.1)

---
updated-dependencies:
- dependency-name: ip
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-26 11:22:49 -05:00
Elliot DeNolf
5d1cad3adb chore(release): db-postgres/0.7.0 [skip ci] 2024-02-23 14:31:55 -05:00
Elliot DeNolf
e31f72da8e chore(release): plugin-nested-docs/1.0.12 [skip ci] 2024-02-23 14:31:26 -05:00
Elliot DeNolf
7aa058d604 chore(release): db-mongodb/1.4.3 [skip ci] 2024-02-23 14:31:11 -05:00
Elliot DeNolf
64e80d242e chore(release): payload/2.11.2 [skip ci] 2024-02-23 14:29:37 -05:00
Dan Ribbens
e8f2ca484e feat(db-postgres): configurable custom schema to use (#5047)
* feat(db-postgres): configurable custom schema to use

* test(db-postgres): use public schema

* chore(db-postgres): simplify drop schema

* chore: add postgres-custom-schema test to ci

* chore: add custom schema to postgres ci

* chore(db-postgres): custom schema in migrate

* chore: ci postgres wait condition
2024-02-23 12:48:06 -05:00
Dan Ribbens
ceca5c4e97 fix(db-postgres): set _parentID for array nested localized fields (#5117)
* fix(db-postgres): find missing path for nested arrays

* fix(db-postgres): set _parentID for array nested localized fields

* fix: afterRead fallbackLocale causing locale data loss

* chore(richtext-lexical): updated args to match payload type change

* test: simplify localization e2e duplicate
2024-02-23 12:44:30 -05:00
Dan Ribbens
ee13736288 chore(plugin-nested-docs): payload added to peerDependencies (#5143) 2024-02-23 12:37:42 -05:00
Dan Ribbens
815bdfac0b fix(db-mongodb): unique sparse for not required fields (#5114)
* fix(db-mongodb): unique sparse for not required fields

* chore(db-mongodb): cleanup sparse index condition

* test: indexed field fix
2024-02-23 12:36:34 -05:00
Dan Ribbens
7a7f0ed7e8 fix: disabling API Key does not remove the key (#5145)
* fix: disabling API Key does not remove the key

* chore: encryptKey hook return null

* chore: fix auth e2e test setup
2024-02-23 12:31:14 -05:00
Dan Ribbens
ad42d541b3 fix: transaction error from access endpoint (#5156)
* fix: transaction error from access endpoint

* chore: fix async race condition in getEntityPolicies
2024-02-23 12:28:43 -05:00
Elliot DeNolf
32ed95e1ee fix: handle thrown errors in config-level afterError hook (#5147) 2024-02-21 16:44:16 -05:00
Yunsup Sim
70e57fef18 fix: Add Context Provider in EditMany Component (#5005)
* fix: Add  Context Provider in EditMany Component

* test: Fix e2e test error
2024-02-21 16:39:34 -05:00
Jarrod Flesch
0a07f607b9 fix: only replace the drawer content with full edit component if it exists (#5144) 2024-02-21 15:44:09 -05:00
Piotr Rogowski
3918fc7c21 chore(plugin-seo): add pl translations (#5021) 2024-02-21 15:01:38 -05:00
Martin Chełminiak
13f71ac475 chore: console error for missing script when running npm run payload (#5078) 2024-02-19 10:13:50 -05:00
Ben Regenspan
07720e777a docs: Reword Hooks Overview re: server-only execution (#5070) 2024-02-19 09:56:55 -05:00
Sondre Ørland
efff47e400 chore: translation for image cropping in norwegian bokmål (#5113) 2024-02-19 09:47:32 -05:00
Elliot DeNolf
453ac218ea chore: reorder changelog 2024-02-17 01:38:13 -05:00
Elliot DeNolf
d4b09bd9cd chore(release): richtext-lexical/0.7.0 [skip ci] 2024-02-16 15:00:13 -05:00
Elliot DeNolf
dd67e03fc1 chore(release): plugin-search/1.1.0 [skip ci] 2024-02-16 15:00:03 -05:00
Elliot DeNolf
548de80bee chore(release): db-postgres/0.6.0 [skip ci] 2024-02-16 14:59:51 -05:00
Elliot DeNolf
2c05fbbb5e chore(release): plugin-form-builder/1.2.1 [skip ci] 2024-02-16 14:59:15 -05:00
Elliot DeNolf
9b54659818 chore(release): db-mongodb/1.4.2 [skip ci] 2024-02-16 14:58:57 -05:00
Elliot DeNolf
e9f550406e chore(release): payload/2.11.1 [skip ci] 2024-02-16 14:57:28 -05:00
Dan Ribbens
98b87e2278 feat(plugin-search): add req to beforeSync args for transactions (#5068)
* feat(plugin-search): pass `req` to beforeSync to support using transactions

* fix(plugin-search): hooks do not respect transactions

* chore(plugin-search): await hooks

* chore: remove eslint disable comments
2024-02-16 14:20:40 -05:00
Dan Ribbens
5f3d0169be fix: filterOptions errors cause transaction to abort (#5079)
* fix: filterOptions errors cause transaction to abort

* fix(db-mongodb): uncaught abortTransaction race condition

* chore: remove test that is not adding value

* chore: limit options on errors in filterOptions

* chore: limit options when an error occurs in filterOptions
2024-02-16 13:33:40 -05:00
Dan Ribbens
35c2a085ef fix(db-postgres): query using blockType (#5044)
* fix(db-postgres): query using blockType

* chore: cleanup commented lines
2024-02-16 13:30:26 -05:00
Dan Ribbens
1ac943ed5e fix: remove collection findByID caching (#5034) 2024-02-16 13:23:57 -05:00
Elliot DeNolf
25cee8bb10 fix(uploads): account for serverURL when retrieving external file (#5102) 2024-02-16 13:11:18 -05:00
Elliot DeNolf
419aef452d chore: add .localstack to gitignore 2024-02-16 12:53:28 -05:00
Elliot DeNolf
ea52489126 Merge pull request #4295 from payloadcms/test/plugin-cloud-storage-emulators
test(plugin-cloud-storage): use localstack for tests
2024-02-16 12:47:13 -05:00
Elliot DeNolf
e80c70acae test: cleanup 2024-02-16 12:33:07 -05:00
Elliot DeNolf
70b0064d0b test: adjust adapter log message 2024-02-16 11:32:00 -05:00
Elliot DeNolf
9636bf6efd test: rename .env -> .env.emulated, safely assert bucket contents 2024-02-16 11:31:14 -05:00
Elliot DeNolf
8f4d0da4e0 test: conditionally run plugin-cloud-storage 2024-02-16 11:31:14 -05:00
Elliot DeNolf
f0f1dbdcb0 ci: pnpm docker:start 2024-02-16 11:31:14 -05:00
Elliot DeNolf
a895aee8b1 ci: add localstack aws envs 2024-02-16 11:31:14 -05:00
Elliot DeNolf
aa1dac08c1 ci: add localstack setup 2024-02-16 11:31:14 -05:00
Elliot DeNolf
b8cd1c6ba4 test(plugin-cloud-storage): add test against localstack 2024-02-16 11:31:12 -05:00
Elliot DeNolf
6344464bc6 test(plugin-cloud-storage): add single docker compose for all emulators 2024-02-16 11:30:55 -05:00
Dan Ribbens
5d4022f144 fix(db-mongodb): find versions pagination (#5091) 2024-02-15 16:14:01 -05:00
Dan Ribbens
bf942fdfa6 feat(db-postgres): reconnect after disconnection from database (#5086) 2024-02-15 16:09:17 -05:00
Dan Ribbens
d6c25783cf feat(db-postgres): adds idType to use uuid or serial id columns (#3864)
* feat(db-postgres): WIP adds idType to use uuid or serial id columns

* chore: add postgres-uuid test ci

* chore: add postgres-uuid env vars

* chore: sanitizeQueryValue prevent invalid types

* fix(db-postgres): invalid parentID of nested arrays
2024-02-15 16:06:37 -05:00
Dan Ribbens
82e9d31127 fix(plugin-form-builder): hooks do not respect transactions (#5069)
* fix(plugin-form-builder): hooks do not respect transactions

* chore(plugin-form-builder): linting and cleanup
2024-02-15 15:55:42 -05:00
Elliot DeNolf
399e606b34 chore: use ref for pnpm overrides (#5081) 2024-02-13 12:37:43 -05:00
Alessio Gravili
0d18822062 feat(richtext-lexical)!: Update lexical from 0.12.6 to 0.13.1, port over all useful changes from playground (#5066)
* feat(richtext-lexical): Update lexical from 0.12.6 to 0.13.1, port over all useful changes from playground

* chore: upgrade lexical version used in monorepo
2024-02-12 17:54:50 +01:00
Alessio Gravili
00fc0343da feat(richtext-lexical): AddBlock handle for all nodes, even if they aren't empty paragraphs (#5063) 2024-02-12 16:11:41 +01:00
Alessio Gravili
6323965c65 fix(richtext-lexical): do not remove adjacent paragraph node when inserting certain nodes in empty editor (#5061) 2024-02-12 14:27:58 +01:00
Máté Tallósi
6d6823c3e5 feat(richtext-lexical): add justify aligment to AlignFeature (#4035) (#4868) 2024-02-12 14:27:12 +01:00
Alessio Gravili
ca70298436 chore: upgrade nodemon versions (#5059) 2024-02-12 14:11:57 +01:00
Elliot DeNolf
4f565759f6 chore(release): payload/2.11.0 [skip ci] 2024-02-09 16:12:03 -05:00
Jarrod Flesch
df39602758 feat: exposes collapsible provider with more functionality (#5043) 2024-02-09 10:38:30 -05:00
Elliot DeNolf
6ea6172afa chore(release): db-postgres/0.5.2 [skip ci] 2024-02-09 09:06:15 -05:00
Elliot DeNolf
486774796d chore(release): db-mongodb/1.4.1 [skip ci] 2024-02-09 09:06:06 -05:00
Elliot DeNolf
1cd1c38764 chore(release): payload/2.10.1 [skip ci] 2024-02-09 09:04:42 -05:00
Elliot DeNolf
f6d7da7510 fix: clearable cells handle null values (#5038) 2024-02-09 08:59:38 -05:00
Elliot DeNolf
cdc4cb971b fix(db-mongodb): handle null values with exists (#5037) 2024-02-09 08:58:10 -05:00
Elliot DeNolf
e0191b54e1 chore(release): richtext-lexical/0.6.1 [skip ci] 2024-02-08 11:49:02 -05:00
Alessio Gravili
2315781f18 fix(richtext-lexical): make editor reactive to initialValue changes (#5010) 2024-02-08 15:30:21 +01:00
Elliot DeNolf
a0a58e7fd2 fix: query relationships by explicit id field (#5022) 2024-02-07 14:18:13 -05:00
Jessica Chowdhury
e1813fb884 fix: ensures docs with the same id are shown in relationship field select (#4859) 2024-02-07 14:04:03 -05:00
Elliot DeNolf
da184d40ec fix(db-postgres): handle nested docs with drafts (#5012) 2024-02-06 21:27:33 -05:00
Elliot DeNolf
ca8675f89d chore(release): plugin-seo/2.2.1 [skip ci] 2024-02-06 15:41:58 -05:00
Elliot DeNolf
e8c6c9338d chore(release): db-postgres/0.5.1 [skip ci] 2024-02-06 15:41:35 -05:00
Elliot DeNolf
558534aff8 chore(release): richtext-lexical/0.6.0 [skip ci] 2024-02-06 15:41:04 -05:00
Elliot DeNolf
29c901ba9b chore(release): payload/2.10.0 [skip ci] 2024-02-06 15:38:33 -05:00
Elliot DeNolf
f3876c2a39 fix(db-postgres): localized field sort count (#4997)
* fix(db-postgres): localized field sort count

* test: localized sort doc count
2024-02-06 11:44:54 -05:00
Elliot DeNolf
c3a3942969 fix(db-postgres): filtering relationships with drafts enabled (#4998)
* fix(db-postgres): filtering relationships with drafts enabled

* test: draft relationship filtering
2024-02-06 11:16:27 -05:00
Paul
23b135b963 fix(templates): fix conflicting routes with Nextjs (#4725)
* Updated templates and readme to note conflicting routes

* Move information in readmes to blockquotes and move next-api to just next

* Remove unnecessary notes
2024-02-06 10:56:20 -05:00
Daniel Kirchhof
e3c8105cc2 feat: use deletion success message from server if provided (#4966) 2024-02-06 10:17:53 -05:00
Jarrod Flesch
2c71aaef75 chore: standardize req passed through the local API (#4994) 2024-02-05 15:43:59 -05:00
brachypelma
922fb9b7fa docs: added link to JSON field type (#4989) 2024-02-05 13:13:28 -05:00
Elliot DeNolf
0740d5095e fix(migrations): safely create migration file when no name passed (#4995) 2024-02-05 10:43:19 -05:00
Jacob Fletcher
b392d656fe chore(examples/multi-tentant): resets lastLoggedInTenant when none found (#4984) 2024-02-02 15:50:12 -05:00
Elliot DeNolf
c0eef90cdc ci: supabase (#4983)
* ci: supabase

* test: add supabase to adapter record

* test: adjust index tests conditional
2024-02-02 15:26:18 -05:00
Dan Ribbens
db22cbdf21 fix(plugin-seo): tabbedUI with email field causes duplicate field (#4944)
* fix(plugin-seo): tabbedUI with email field causes duplicate field

* chore(plugin-seo): code comment
2024-02-02 14:53:51 -05:00
Dan Ribbens
1e8a6b7899 feat: extend transactions to cover after and beforeOperation hooks (#4960)
* feat: extend transactions to cover after and beforeOperation hooks

* feat: use transactions in refresh operation

* docs: add req to beforeOperation and afterOperation args
2024-02-02 14:53:14 -05:00
Dan Ribbens
5d934ba02d feat: previousValue and previousSiblingDoc args added to beforeChange field hooks (#4958)
* feat: previousValue and previousSiblingDoc args added to beforeChange field hooks

* chore: fieldHook type docs
2024-02-02 13:59:11 -05:00
Elliot DeNolf
f651665f2f chore(deps): add pnpm overrides for common packages (#4980)
* chore(deps): add pnpm overrides for common packages

* chore(deps): bump @swc/core for compat w/ latest typescript
2024-02-02 13:21:57 -05:00
Elliot DeNolf
5d3659d48a fix(db-postgres): handle schema changes with supabase (#4968)
* fix(db-postgres): handle schema changes with supabase

* chore(deps): bump drizzle-orm for test suite
2024-02-02 11:29:32 -05:00
Dan Ribbens
47106d5a1a fix(db-postgres): indexes not creating for relationships, arrays, hasmany and blocks (#4976) 2024-02-02 11:16:21 -05:00
Jarrod Flesch
afa2b942e0 fix: ensures docPermissions fallback to collection permissions on create (#4969) 2024-02-01 16:54:52 -05:00
Dan Ribbens
20ddd0de5b chore: add indexes to preferences for performance (#4965) 2024-02-01 15:31:31 -05:00
Dan Ribbens
64f705c3c9 fix(db-postgres): indexes not created for non unique field names (#4967) 2024-02-01 15:21:15 -05:00
Daniel Shamburger
b30ea8aa6b docs: typo (#4948) 2024-01-31 15:40:55 -05:00
Mark Paolo Libunao
471d2113a7 feat: re-use existing logger instance passed to payload.init (#3124) 2024-01-31 15:40:14 -05:00
Alessio Gravili
8725d41164 feat: add more options to addFieldStatePromise so that it can be used for field flattening (#4799) 2024-01-30 23:02:58 +01:00
Dan Ribbens
0bd81aa25a fix(templates-ecommerce): hook errors for non-string ids (#4946) 2024-01-30 13:28:14 -05:00
Dan Ribbens
8c09ca9be5 examples: fix multi-tenant hooks to use transactions (#4955) 2024-01-30 13:26:13 -05:00
Alessio Gravili
90d7ee3e65 feat(richtext-lexical): Blocks: generate type definitions for blocks fields (#4529) 2024-01-30 16:51:18 +01:00
Kendell Joseph
58bbd8c00f chore(examples/hierarchy): adds hierarchy example (#4923) 2024-01-26 16:17:11 -05:00
Elliot DeNolf
003ad065c3 chore(release): plugin-cloud-storage/1.1.2 [skip ci] 2024-01-26 13:58:13 -05:00
Elliot DeNolf
70715926a8 chore(release): richtext-slate/1.4.0 [skip ci] 2024-01-26 13:57:45 -05:00
Elliot DeNolf
b3a6bfacf2 chore(release): db-postgres/0.5.0 [skip ci] 2024-01-26 13:57:34 -05:00
Elliot DeNolf
e1d9accb27 chore(release): db-mongodb/1.4.0 [skip ci] 2024-01-26 13:57:23 -05:00
Elliot DeNolf
f2f55a84cc chore(release): payload/2.9.0 [skip ci] 2024-01-26 13:55:20 -05:00
Dan Ribbens
eba53ba60a feat: forceAcceptWarning migration arg added to accept prompts (#4874)
* chore: gitignore test migrations

* feat: `forceAcceptWarning` migration args added to accept prompts

* chore: migrationDir env variable fallback

* chore: migrationDir testSuiteDir fallback

* chore: migrationDir testSuiteDir fallback fix

* chore: skip migrate down test
2024-01-26 13:48:53 -05:00
Dan Ribbens
f73d503fec fix(plugin-cloud-storage): slow get file performance large collections (#4927) 2024-01-26 13:43:55 -05:00
Dan Ribbens
6930c4e9f2 fix: upload input drawer does not show draft versions (#4903)
* chore: add field classname to upload field

* fix: upload input drawer does not show draft versions
2024-01-26 13:42:32 -05:00
Dan Ribbens
3eb681e847 fix: afterLogin hook write conflicts (#4904)
* fix: afterLogin hook conflict

* test: afterLogin hook returns for assertion

* chore: commit increment login attempt
2024-01-26 13:39:45 -05:00
Jarrod Flesch
cb4638cfa1 chore: make default views callable (#4928) 2024-01-26 13:38:36 -05:00
Dan Ribbens
b40e9f85a2 chore: use transactions in tests running mongoDB memory server (#4750)
* chore: use transactions in tests running mongoDB memory server

* chore: relationship test async setup changes

* chore: async test fix

* chore: flaky e2e localization test
2024-01-23 19:18:55 -05:00
Dan Ribbens
e5a7907a72 fix: remove No Options dropdown from hasMany fields (#4899) 2024-01-23 10:00:16 -05:00
Jarrod Flesch
3f25d1ca84 chore: re-orders request language detection (#4890) 2024-01-22 11:53:01 -05:00
Timothy Choi
d5720bea7b chore: add fieldIsGroupType type guard helper (#4872) 2024-01-19 14:19:35 -05:00
Jesse Sivonen
8ce15c8b07 fix(db-postgres): query unset relation (#4862) 2024-01-19 13:35:58 -05:00
Timothy Choi
9f5efef78f chore: lint #4766 (#4801)
* fix: import location for config test

* fix: linting fix
2024-01-18 09:25:52 -05:00
Dan Ribbens
dfba5222f3 fix(db-postgres): migrate down error (#4861) 2024-01-17 13:55:57 -05:00
Dan Ribbens
b99d24fcfa fix: migrate down missing filter for latest batch (#4860) 2024-01-17 13:54:30 -05:00
Elliot DeNolf
836ed77568 chore: update changelog [skip ci] 2024-01-16 16:39:42 -05:00
Elliot DeNolf
1c5d5b07c8 chore(release): plugin-seo/2.2.0 [skip ci] 2024-01-16 16:33:53 -05:00
Elliot DeNolf
da5f1f2240 chore(release): plugin-form-builder/1.2.0 [skip ci] 2024-01-16 16:33:44 -05:00
Elliot DeNolf
c84c58c7b4 chore(release): db-postgres/0.4.0 [skip ci] 2024-01-16 16:33:21 -05:00
Elliot DeNolf
1c1b8f3cec chore(release): db-mongodb/1.3.2 [skip ci] 2024-01-16 16:32:52 -05:00
Elliot DeNolf
3f69f83180 chore(release): payload/2.8.2 [skip ci] 2024-01-16 16:31:39 -05:00
beezee
371353f153 feat(db-postgres): support drizzle logging config (#4809) 2024-01-16 15:45:17 -05:00
Dan Ribbens
a92c6334b6 chore(db-postgres): update drizzle-kit to 0.20.5-608ae62 and drizzle-orm to latest (#4772) 2024-01-16 13:35:07 -05:00
Paul
eb9e771a9c fix(db-postgres): Remove duplicate keys from response (#4747)
* Remove duplicate keys from response

* Update to delete duplicates at a higher level and remove '_order' from array rows too
2024-01-16 13:22:08 -05:00
Patrik
ee5390aaca fix: removes max-width from field-types class & correctly sets it on uploads (#4829) 2024-01-16 13:12:58 -05:00
Paul
a861311c5a fix(db-mongodb): mongodb versions creating duplicates (#4825)
* Fixes the issue with mongodb versions

* Update other methods to use options too
2024-01-16 12:20:45 -05:00
James Mikrut
74c3fe1bb2 Merge pull request #4806 from payloadcms/fix/#4775-postgres-block-validation-arrays
fix(db-postgres): validateExistingBlockIsIdentical with arrays
2024-01-15 15:04:47 -05:00
James Mikrut
a2be50279e Merge pull request #4804 from payloadcms/fix/#4802-transaction-options-false
fix(db-mongodb): transactionOptions=false typeErrors
2024-01-15 15:04:01 -05:00
James Mikrut
403eb06acf Merge pull request #4723 from payloadcms/fix/4548-fix-missing-spread
fix(plugin-seo):Fix missing spread operator in URL generator function
2024-01-15 15:02:45 -05:00
James Mikrut
f5c2cd74cc Merge pull request #4695 from payloadcms/feat/4539-seo-plugin-allow-field-and-interface-overrides
feat(plugin-seo): Add support for interfaceName and fieldOverrides
2024-01-15 15:02:14 -05:00
Paul Popus
a6a1963ec6 Merge branch 'main' into feat/4539-seo-plugin-allow-field-and-interface-overrides 2024-01-15 16:29:49 -03:00
Dan Ribbens
0647c870f1 fix(db-postgres): validateExistingBlockIsIdentical with other tables 2024-01-13 22:46:05 -05:00
Dan Ribbens
3b88adc7d0 fix(db-postgres): validateExistingBlockIsIdentical with arrays 2024-01-13 22:40:30 -05:00
Dan Ribbens
82383a5b5f fix(db-mongodb): transactionOptions=false typeErrors 2024-01-13 14:59:16 -05:00
James Mikrut
f9dda628b2 Merge pull request #4730 from payloadcms/feat/4471-add-validation-for-form-submission
feat(plugin-form-builder):Add validation for form ID when creating a form submissions
2024-01-12 15:39:35 -05:00
Elliot DeNolf
93eb0e4a31 chore: update bug report template to renamed possible-bug label 2024-01-12 14:19:43 -05:00
Elliot DeNolf
2e362f44f4 chore(release): payload/2.8.1 [skip ci] 2024-01-12 12:44:15 -05:00
Jarrod Flesch
775502b161 fix: corrects config usage in build bin script (#4796) 2024-01-12 12:40:08 -05:00
Elliot DeNolf
84d75ce6ca chore(release): plugin-form-builder/1.1.2 [skip ci] 2024-01-12 10:47:08 -05:00
Elliot DeNolf
175cf229c0 chore(release): richtext-lexical/0.5.2 [skip ci] 2024-01-12 10:41:55 -05:00
Elliot DeNolf
bb40bd3efb chore(release): db-postgres/0.3.1 [skip ci] 2024-01-12 10:41:46 -05:00
Elliot DeNolf
3d74c133aa chore(release): db-mongodb/1.3.1 [skip ci] 2024-01-12 10:41:37 -05:00
Elliot DeNolf
0f6b6ca970 chore(release): bundler-webpack/1.0.6 [skip ci] 2024-01-12 10:41:29 -05:00
Elliot DeNolf
8e1692ef10 chore(release): bundler-vite/0.1.6 [skip ci] 2024-01-12 10:41:21 -05:00
Elliot DeNolf
1d1ee913fc chore(release): plugin-seo/2.1.0 [skip ci] 2024-01-12 10:40:45 -05:00
Elliot DeNolf
beca43341f chore(release): payload/2.8.0 [skip ci] 2024-01-12 10:39:41 -05:00
Patrik
84818469ea fix(plugin-form-builder): replaces curly brackets with lexical editor (#4753)
* chore: scaffolds fix for replacing curly brackets in email with lexical editor

* fix: submissionData not passed to nested fields

* chore: adds int test for lexical serializer

---------

Co-authored-by: Alessio Gravili <alessio@bonfireleads.com>
2024-01-12 10:37:01 -05:00
Patrik
0a259d27b5 fix: passes draft=true in fetch for relationships (#4784)
* fix: passes draft=true to fetch for relationships

* chore: removes unnecessary delay on field click in e2e test
2024-01-12 10:36:45 -05:00
Nico Bohne
e2e56a4d58 fix: text hasMany validation (#4789) 2024-01-11 23:16:52 -05:00
Patrik
d0f7677d5f fix: prioritizes value key when filtering / querying for relationships (#4727)
* fix: object equality query by prioritizing value key in relationship queries

* chore: adds e2e & int test

* chore: updates test for REST querying on poly relationships
2024-01-11 15:56:07 -05:00
Yuri Koshiishi
35956eb837 chore: use consistent param name in useField's setValue (#4710) 2024-01-11 14:25:48 -05:00
Timothy Choi
d92af295eb feat: allow custom config properties in blocks (#4766) 2024-01-11 13:57:32 -05:00
Marvin
493fde5ccc feat(logger): show local time (#4663) 2024-01-11 11:51:11 -05:00
David Oliver
c6bd20ef33 docs: improve email docs SMTP info (#4698) 2024-01-11 11:45:25 -05:00
Paul
6d5ac1de1e fix: allow a custom ID field to be nested inside unnamed tabs and rows (#4701)
* Adds a check for the first tab and e2e test for custom ID

* Add support for ids in any order inside an unnamed tab

* Update tests for rows

* Minor fixes and remove dead commented code
2024-01-11 10:17:24 -05:00
Dan Ribbens
fa3b3dd62d fix: migration regression (#4777) 2024-01-10 22:40:00 -05:00
Jarrod Flesch
1115387744 fix: build payload without initializing (#4028) 2024-01-10 20:40:46 -05:00
Elliot DeNolf
53e8690feb Merge pull request #4773 from payloadcms/fix/limit-zero
fix: limit=0 returns all docs
2024-01-10 17:00:07 -05:00
Maxime Marty-Dessus
4319fe1c6e feat(plugin-seo): add fr translations (#4774) 2024-01-10 16:48:07 -05:00
Elliot DeNolf
2fee0c0d44 docs: update pagination 2024-01-10 16:45:42 -05:00
Elliot DeNolf
7923edd7bc test: fix limit=0 test 2024-01-10 16:45:34 -05:00
Elliot DeNolf
5702b83e82 fix(db-postgres): totalPages value when limit=0 2024-01-10 16:45:07 -05:00
Elliot DeNolf
63e5c43fe6 fix(db-mongodb): limit=0 returns unpaginated 2024-01-10 16:44:57 -05:00
kiwagu
04f2888135 chore(examples/form-builder): removes legacyBehavior flags from next/link (#4764) 2024-01-10 16:26:50 -05:00
Elliot DeNolf
0f69b9c2f8 chore(templates): remove jackspeak resolutions 2024-01-10 13:06:50 -05:00
Elliot DeNolf
f1bb2f8151 feat(templates): bump plugin-cloud (#4770) 2024-01-10 13:03:50 -05:00
Elliot DeNolf
ea528b8c10 chore(release): eslint-config-payload/1.1.1 [skip ci] 2024-01-10 12:49:11 -05:00
Elliot DeNolf
0053e40404 chore(eslint): object-shorthand warn 2024-01-10 12:45:51 -05:00
Elliot DeNolf
605c0be43c chore(release): plugin-seo/2.0.0 [skip ci] 2024-01-10 12:41:02 -05:00
Elliot DeNolf
3152b4c4c5 chore: revert plugin-seo version bump 2024-01-10 12:40:37 -05:00
Elliot DeNolf
a64b80babc chore(release): plugin-cloud/3.0.0 [skip ci] 2024-01-10 12:34:02 -05:00
Elliot DeNolf
5cfde542b1 feat(plugin-cloud): use resend smtp instead of custom transport (#4746) 2024-01-10 12:22:02 -05:00
Patrik
772020963e fix(examples): bumps next to v13.5.1 (#4763) 2024-01-10 12:17:51 -05:00
Alessio Gravili
5e083689d0 feat(plugin-seo)!: remove support for payload <2.7.0 (#4765) 2024-01-10 17:29:29 +01:00
Taís Massaro
911764a490 chore: export useTheme and add documentation (#4718)
* chore(react-hooks): export useTheme hook

* docs(react-hooks): add useTheme documentation
2024-01-10 10:39:00 -05:00
Alessio Gravili
e3b81d913d chore(plugin-seo): remove test script from package.json (#4762) 2024-01-10 14:38:13 +01:00
Alessio Gravili
41b3b17911 chore(plugin-seo): add to CI, minor package.json improvements (#4761)
* chore: add plugin-seo to CI

* chore(plugin-seo): minor package.json improvements
2024-01-10 14:27:30 +01:00
Yunsup Sim
e9860b36f3 chore(plugin-seo): build command fix (#4756)
* chore(plugin-seo): build command fix

* chore: fix build script

---------

Co-authored-by: Alessio Gravili <alessio@bonfireleads.com>
2024-01-10 14:20:50 +01:00
Alessio Gravili
14b39fbc85 chore: eslint improvements (#4739)
* chore: add @typescript-eslint/prefer-ts-expect-error rule

* chore: fix @typescript-eslint/prefer-ts-expect-error rule

* chore: disable useless class-methods-use-this eslint rule

* chore: only warn for no-unused-vars rule

* remove unused ts-expect-error

* undo admin changes
2024-01-10 11:31:00 +01:00
Elliot DeNolf
d08e85d08c chore(release): plugin-nested-docs/1.0.11 [skip ci] 2024-01-09 16:32:02 -05:00
Elliot DeNolf
abcbf9974d chore(release): plugin-form-builder/1.1.1 [skip ci] 2024-01-09 16:31:52 -05:00
Elliot DeNolf
d01437d212 chore(release): plugin-seo/1.1.0 [skip ci] 2024-01-09 16:31:01 -05:00
Elliot DeNolf
06729a0a73 chore(release): db-postgres/0.3.0 [skip ci] 2024-01-09 16:30:49 -05:00
Elliot DeNolf
2bd7822a16 chore(release): db-mongodb/1.3.0 [skip ci] 2024-01-09 16:30:37 -05:00
Elliot DeNolf
bc7daf6b49 chore(release): payload/2.7.0 [skip ci] 2024-01-09 16:28:34 -05:00
James Mikrut
feab679ef7 Merge pull request #4615 from payloadcms/fix/relationship-field-number-ids-untitled
fix: relations with number based ids (postgres) show untitled ID: x
2024-01-09 15:30:41 -05:00
James Mikrut
be39ed4317 Merge pull request #4633 from payloadcms/fix/#3839-postgres-exist-json
fix(db-postgres): incorrect results querying json field using exists
2024-01-09 15:27:22 -05:00
James Mikrut
570e192eb4 Merge pull request #4741 from payloadcms/fix/#4591-migrate-down-batches
fix(db-postgres): migrate down not limited to latest batch
2024-01-09 13:50:45 -05:00
James Mikrut
22f4967dd4 Merge pull request #4726 from payloadcms/feat/migration-transactions
feat: improve transaction support by passing req to migrations
2024-01-09 13:50:00 -05:00
James Mikrut
4873c36129 Merge pull request #4722 from payloadcms/fix/#4719-migration-transaction-options
fix(db-mongodb): migration errors with transactionOptions false
2024-01-09 13:46:06 -05:00
James Mikrut
f0ec21cdda Merge pull request #4624 from payloadcms/fix/#3692-plugin-nested-docs-overrides
fix(plugin-nested-docs): custom overrides of breadcrumb and parent fields
2024-01-09 13:45:46 -05:00
dependabot[bot]
da737bdf8e chore(deps): bump follow-redirects in /examples/testing (#4735)
Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.15.2 to 1.15.4.
- [Release notes](https://github.com/follow-redirects/follow-redirects/releases)
- [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.15.2...v1.15.4)

---
updated-dependencies:
- dependency-name: follow-redirects
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-09 13:18:29 -05:00
dependabot[bot]
40508880c1 chore(deps): bump follow-redirects in /templates/blank (#4736)
Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.15.2 to 1.15.4.
- [Release notes](https://github.com/follow-redirects/follow-redirects/releases)
- [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.15.2...v1.15.4)

---
updated-dependencies:
- dependency-name: follow-redirects
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-09 13:18:18 -05:00
dependabot[bot]
8f420d841a chore(deps): bump follow-redirects in /templates/website (#4737)
Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.15.3 to 1.15.4.
- [Release notes](https://github.com/follow-redirects/follow-redirects/releases)
- [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.15.3...v1.15.4)

---
updated-dependencies:
- dependency-name: follow-redirects
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-09 13:18:08 -05:00
dependabot[bot]
9022e27308 chore(deps): bump follow-redirects in /templates/ecommerce (#4734)
Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.15.3 to 1.15.4.
- [Release notes](https://github.com/follow-redirects/follow-redirects/releases)
- [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.15.3...v1.15.4)

---
updated-dependencies:
- dependency-name: follow-redirects
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-09 13:17:59 -05:00
Patrik
acf2e41312 docs: updates verify to verifyEmail in local api (#4728) 2024-01-09 13:15:31 -05:00
Dan Ribbens
6acfae8ee7 fix(db-postgres): migrate down only runs latest batch size 2024-01-09 10:21:45 -05:00
Alessio Gravili
20bdd91da4 chore: upgrade @types/nodemailer from v6.4.8 to v6.4.14 (#4733) 2024-01-09 14:19:45 +01:00
Alessio Gravili
50502834c9 chore(richtext-lexical): upgrade lexical from v0.12.5 to v0.12.6 (#4732)
* chore(richtext-lexical): upgrade all lexical packages from 0.12.5 to 0.12.6

* fix(richtext-lexical): fix TypeScript errors

* fix indenting
2024-01-09 09:35:18 +01:00
Paul Popus
2b731c1088 feat(plugin-form-builder):Add validation for form ID when creating a submission 2024-01-08 20:35:52 -03:00
Dan Ribbens
983733ad74 merge main 2024-01-08 17:12:02 -05:00
Dan Ribbens
555d02769a feat(db-postgres): improve transaction support by passing req to migrations 2024-01-08 15:50:22 -05:00
Dan Ribbens
682eca2186 feat(db-mongodb): improve transaction support by passing req to migrations 2024-01-08 15:50:09 -05:00
Paul Popus
6affa1c304 Removed fallback for interfaceName 2024-01-08 15:27:17 -03:00
Dan Ribbens
1d14d9f8b8 feat: improve transaction support by passing req to migrations 2024-01-08 12:34:55 -05:00
Dan Ribbens
0abaddc2ef chore: remove payload migration endpoints 2024-01-08 12:24:53 -05:00
Paul Popus
57dc93da5d Fix missing spread operator in generator function 2024-01-08 14:07:35 -03:00
Dan Ribbens
21b9453cf4 fix(db-mongodb): migration error calling beginTransaction with transactionOptions false 2024-01-08 12:03:45 -05:00
Alessio Gravili
136993ec2b chore: undo adding DocumentInfo state to ActionsProvider (#4707) 2024-01-05 22:58:16 +01:00
Dan Ribbens
63bc4cabe1 fix(db-mongodb): querying plan for collections ignoring indexes (#4655)
* fix(db-mongodb): querying plan for collections ignoring indexes

* chore(db-mongodb): improve index hint comment
2024-01-05 16:21:19 -05:00
Alessio Gravili
6a8a6e4ef4 feat: provide document info to ActionsProvider (#4696) 2024-01-05 21:12:21 +01:00
Jessica Chowdhury
9828772890 fix: prevents row overflow (#4704) 2024-01-05 15:04:30 -05:00
Jessica Chowdhury
6116573164 docs: corrects type in useField example (#4705) 2024-01-05 15:03:38 -05:00
Dan Ribbens
cab6babd60 fix(db-postgres): validation prevents group fields in blocks (#4699)
* fix(db-postgres): validation prevents using group fields within blocks

* fix(db-postgres): validation of non-matching blocks in reverse order
2024-01-05 15:03:08 -05:00
Paul
55399424a1 fix(plugin-nested-docs): children wrongly publishing draft data (#4692)
* fix(plugin-nested-docs): handles child parent doc publishing

* Add tests

* Fix error failing on save hook

---------

Co-authored-by: Jessica Chowdhury <jessica@trbl.design>
2024-01-05 15:02:15 -05:00
Paul Popus
28d3f73c2a Fix integration test 2024-01-05 15:23:57 -03:00
Jessica Chowdhury
28a30120dd fix(plugin-form-builder): slate serializer should replace curly braces in links (#4703) 2024-01-05 13:01:03 -05:00
Elliot DeNolf
40a0921597 docs: update 'accessing files outside of payload cloud' 2024-01-05 11:53:51 -05:00
Paul Popus
7eae86bcb3 Add changes from previous branch and update docs 2024-01-05 12:45:03 -03:00
Paul
0b80e4a403 chore: bump the mongodb-memory-server dependency to 9.x (#4693) 2024-01-05 09:35:35 -05:00
Seied Ali Mirkarimi
b378532ddf chore: rtl locale selector and sidebar button (#4684)
* chore: rtl locale popup selector and sidebar button

* chore(plugin-seo): add persian translation
2024-01-04 21:45:39 -05:00
Patrik
d419275fb5 fix: adds objectID validation to isValidID if of type text (#4689)
* fix: adds updated object-id validation to isValidID

* chore: adds check to see if value is of type string or object

* chore: needs to return false if value not of type object or string
2024-01-04 15:08:55 -05:00
Jessica Chowdhury
0fb3a9ca89 fix: allow json field to be saved empty and reflect value changes (#4687)
* fix: allow json field to be saved empty and reflect value changes

* fix: reverts change to json field validation

* chore: wraps more JSON field logic with a try/catch
2024-01-04 14:47:10 -05:00
Gokulsck
f43cf185d4 feat: hasMany property for text fields (#4605)
* fix for supporting hasMany property in text field

* Updated docs

* handle text case types for schema and graphql schema

* fix unit test for required failing

* add unit test for has many text field

* add end to end test for has many on text field creation

* support has many feature for text field on postgres

---------

Co-authored-by: Chris Heinz <chrisi.heinz@web.de>
2024-01-04 14:45:00 -05:00
Dan Ribbens
5d15955f83 fix: custom ids in versions (#4680)
* chore: scaffolds out fix for postgres issues with custom ids in versions

* fix(db-postgres): queryDrafts returns undefined doc.id

* chore(db-postgres): fix build

* fix: removes extra custom id field from  versions buildCollectionFields

* chore: comments test/versions seeding back in

* fix buildCollectionFields version group fields

* fix: id field can be edited after saving a document with custom ids

* chore: updates versions custom ID test

---------

Co-authored-by: PatrikKozak <patrik@payloadcms.com>
2024-01-04 13:05:10 -05:00
Elliot DeNolf
2d35e06667 ci(templates): generate types in ci (#4685) 2024-01-04 10:04:44 -05:00
Elliot DeNolf
d2de6db449 chore(release): eslint-config-payload/1.1.0 2024-01-04 09:56:42 -05:00
Alessio Gravili
a3e78161b5 fix: non-boolean condition result causes infinite looping (#4579) 2024-01-04 09:51:08 -05:00
Hulpoi George-Valentin
d543665995 fix: unlock user condition always passes due to seconds conversion (#4610)
* fix: unlock condition is always true

* test: extra call for locking user, therefor won't be a condition issue
2024-01-04 09:43:10 -05:00
Alessio Gravili
db7dddf1c5 chore: commit intellij run configurations (#4653)
* chore: update .gitignore

* chore: update .gitignore

* chore: commit IntelliJ run configurations
2024-01-04 09:35:01 -05:00
Paul
3027a03ad1 feat(plugin-seo): add i18n (#4665)
* Add i18n to plugin SEO

* Add new translations and e2e tests for the SEO plugin

* Update e2e tests to utilise a shared page ID from a create function
2024-01-04 09:18:09 -05:00
Paul
85e38b7cfd fix: sidebar fields not disabled by access permissions (#4682)
* Pass operation to sidebar fields too

* Add a test for sidebar field update permission
2024-01-03 20:04:40 -05:00
Elliot DeNolf
9090540ece chore(release): richtext-lexical/0.5.1 [skip ci] 2024-01-03 15:58:05 -05:00
Elliot DeNolf
46ef284f6b chore(release): db-postgres/0.2.3 [skip ci] 2024-01-03 15:57:54 -05:00
Elliot DeNolf
0727dcd963 chore(release): db-mongodb/1.2.0 [skip ci] 2024-01-03 15:57:22 -05:00
Elliot DeNolf
52f8d4f9f0 chore(release): payload/2.6.0 [skip ci] 2024-01-03 15:55:34 -05:00
Jessica Chowdhury
f1fa374ed1 fix: tab field error when using the same interface name (#4657)
* fix: tab field error when using the same interface name

* fix: removes unused tab types
2024-01-03 15:50:07 -05:00
Alessio Gravili
6b691eee43 chore(eslint-config-payload): improve perfectionist object sort order (#4678) 2024-01-03 21:45:34 +01:00
Paul
be3beabb9b fix: navigation locks when modal is closed with esc (#4664) 2024-01-03 12:06:09 -05:00
Seied Ali Mirkarimi
1fa00cc25c chore: rtl header locale selector (#4670) 2024-01-03 12:04:39 -05:00
James
f70943524b fix(templates): #4662, templates not building after having types generated 2024-01-02 19:49:09 -05:00
Jessica Chowdhury
a67080a291 Merge pull request #4574 from jschuur/patch-1
fix: adjusts json field joi schema to allow editorOptions
2024-01-02 21:58:34 +00:00
Jarrod Flesch
69a99445c9 fix: detect language from request headers accept-language (#4656) 2024-01-02 15:17:00 -05:00
Alessio Gravili
00d8480062 fix: "The punycode module is deprecated" warning by updating nodemailer 2024-01-02 18:26:52 +01:00
Dan Ribbens
7424ba9090 test: e2e await fix (#4646) 2024-01-01 14:09:48 -05:00
Dan Ribbens
ec4d2f97cb fix(db-postgres): query on json properties 2023-12-29 16:42:32 -05:00
Dan Ribbens
9d9ac0ec28 fix(db-postgres): incorrect results querying json field using exists operator 2023-12-29 11:35:12 -05:00
Dan Ribbens
635e7c26e8 fix(plugin-nested-docs): custom parent field slug 2023-12-28 14:30:36 -05:00
Dan Ribbens
c4a4678afb fix(plugin-nested-docs): parent filterOptions errors when specifying breadcrumbsFieldSlug 2023-12-28 14:01:31 -05:00
Dan Ribbens
a5a91c08a9 fix(plugin-nested-docs): breadcrumbsFieldSlug used in resaveSelfAfterCreate hook 2023-12-28 13:05:53 -05:00
Dan Ribbens
7db58b482b fix: custom overrides of breadcrumb and parent fields 2023-12-28 12:56:30 -05:00
Dan Ribbens
1b914083c8 fix: relations with number based ids (postgres) show untitled ID: x 2023-12-27 15:30:30 -05:00
Anthony Bouch
657d14c07b chore(plugin-search): adjusts code comment when attaching hooks (#4595) 2023-12-23 19:24:33 -05:00
yuc
fbf8ab72a4 docs: fix typo in Select Field example (#4593) 2023-12-23 19:15:44 -05:00
Zakher Masri
997f158149 chore(plugin-stripe): fixes broken link in README (#4602) 2023-12-23 19:08:25 -05:00
James Mikrut
c3be5d1d5e Merge pull request #4560 from payloadcms/fix/#4484-graphql-multiple-locales
fix: graphql cannot query multiple locales
2023-12-21 15:29:14 -05:00
James Mikrut
250bcd8189 Merge pull request #4526 from payloadcms/feat/locale-specific-fallbacks
feat: extend locales to have fallbackLocales
2023-12-21 15:25:55 -05:00
Jesse Sivonen
a71d37b398 fix(db-postgres): Wait for transaction to complete on commit (#4582)
* fix(db-postgres): Wait for transaction to complete on commit
* fix session types
2023-12-21 11:03:27 -05:00
Patrik
5c5523195c fix: resets actions array when navigating out of view with actions (#4585) 2023-12-21 10:48:04 -05:00
Joost Schuur
bff4cf518f fix: adjusts json field joi schema to allow editorOptions
Previous fix was not applied to json fields: https://github.com/payloadcms/payload/pull/2731/files
2023-12-21 00:47:14 +08:00
Alessio Gravili
8015e999cd fix(richtext-lexical): z-index issues (#4570) 2023-12-20 15:10:18 +01:00
Sajarin M
0c905f0da7 docs: typo in transactions page (#4565) 2023-12-20 01:31:50 -05:00
Dan Ribbens
e691a90a4c chore: fix failed test 2023-12-19 15:53:20 -05:00
James Mikrut
0b2da4fba7 Merge pull request #4467 from payloadcms/feat/mongodb-transaction-options
feat(db-mongodb): add transactionOptions
2023-12-19 15:30:23 -05:00
Elliot DeNolf
1c6d6788a3 chore: update changelog [skip ci] 2023-12-19 15:03:44 -05:00
Elliot DeNolf
ecc7978184 chore(release): plugin-nested-docs/1.0.10 [skip ci] 2023-12-19 14:49:38 -05:00
Elliot DeNolf
1b9ee64a67 chore(release): live-preview/0.2.2 [skip ci] 2023-12-19 14:48:20 -05:00
Elliot DeNolf
22b02226c3 chore(release): db-postgres/0.2.2 [skip ci] 2023-12-19 14:48:08 -05:00
Elliot DeNolf
e4102b88d8 chore(release): db-mongodb/1.1.1 [skip ci] 2023-12-19 14:47:41 -05:00
Elliot DeNolf
a099f55a69 chore(release): plugin-form-builder/1.1.0 [skip ci] 2023-12-19 14:46:49 -05:00
Elliot DeNolf
1f1445c798 chore(release): richtext-lexical/0.5.0 [skip ci] 2023-12-19 14:45:27 -05:00
Elliot DeNolf
741a5e3650 chore(release): payload/2.5.0 [skip ci] 2023-12-19 14:41:55 -05:00
Dan Ribbens
365047a3fb Merge branch 'feat/locale-specific-fallbacks' into fix/#4484-graphql-multiple-locales 2023-12-19 14:22:09 -05:00
Dan Ribbens
42c06acd18 docs: transaction options 2023-12-19 14:19:28 -05:00
Dan Ribbens
f2c8ac4a9a feat(db-mongodb): add transactionOptions 2023-12-19 14:19:12 -05:00
Dan Ribbens
05e8914db7 fix(db-mongodb): documentDB unique constraint throws incorrect error (#4513) 2023-12-19 14:14:51 -05:00
Dan Ribbens
35191bdd66 docs: improve docs for locales 2023-12-19 14:11:35 -05:00
Dan Ribbens
98890eee1f fix: graphql multiple locales 2023-12-19 14:00:06 -05:00
Ritsu
ef43629502 fix(db-postgres) incorrect currentTableName in find for blocks (#4524) 2023-12-19 10:30:13 -05:00
Dan Ribbens
c703497924 test: improve e2e locale change selector 2023-12-19 09:57:46 -05:00
Dan Ribbens
5caad706bb chore: consistent locale and fallback locale for globals 2023-12-19 09:40:26 -05:00
Dan Ribbens
aa048d5409 fix: req.locale and req.fallbackLocale get reassigned in local operations 2023-12-18 16:50:17 -05:00
Dan Ribbens
aafd538cf8 fix failing e2e test 2023-12-16 00:49:04 -05:00
Dan Ribbens
1b42bd207d fix failing tests 2023-12-16 00:18:59 -05:00
Dan Ribbens
9fac2ef24e feat: extend locales to have fallbackLocales 2023-12-15 23:52:12 -05:00
2479 changed files with 36754 additions and 58723 deletions

View File

@@ -1,4 +0,0 @@
DATABASE_URI=mongodb://127.0.0.1/payloadtests
PAYLOAD_SECRET=laijflieawfjlweifjewalifjwe
# PAYLOAD_CONFIG_PATH=MUST BE SET PROGRAMMATICALLY
PAYLOAD_DROP_DATABASE=true

View File

@@ -1,51 +0,0 @@
module.exports = {
extends: ['@payloadcms'],
overrides: [
{
files: ['scripts/**'],
rules: {
'@typescript-eslint/no-unused-vars': 'off',
'no-console': 'off',
'perfectionist/sort-object-types': 'off',
'perfectionist/sort-objects': 'off',
},
},
{
extends: ['plugin:@typescript-eslint/disable-type-checked'],
files: ['*.js', '*.cjs', '*.json', '*.md', '*.yml', '*.yaml'],
},
{
files: ['packages/eslint-config-payload/**'],
rules: {
'perfectionist/sort-objects': 'off',
},
},
{
files: ['package.json', 'tsconfig.json'],
rules: {
'perfectionist/sort-array-includes': 'off',
'perfectionist/sort-astro-attributes': 'off',
'perfectionist/sort-classes': 'off',
'perfectionist/sort-enums': 'off',
'perfectionist/sort-exports': 'off',
'perfectionist/sort-imports': 'off',
'perfectionist/sort-interfaces': 'off',
'perfectionist/sort-jsx-props': 'off',
'perfectionist/sort-keys': 'off',
'perfectionist/sort-maps': 'off',
'perfectionist/sort-named-exports': 'off',
'perfectionist/sort-named-imports': 'off',
'perfectionist/sort-object-types': 'off',
'perfectionist/sort-objects': 'off',
'perfectionist/sort-svelte-attributes': 'off',
'perfectionist/sort-union-types': 'off',
'perfectionist/sort-vue-attributes': 'off',
},
},
],
parserOptions: {
project: ['./tsconfig.json'],
tsconfigRootDir: __dirname,
},
root: true,
}

View File

@@ -5,6 +5,12 @@ module.exports = {
extends: ['plugin:@typescript-eslint/disable-type-checked'],
files: ['*.js', '*.cjs', '*.json', '*.md', '*.yml', '*.yaml'],
},
{
files: ['packages/eslint-config-payload/**'],
rules: {
'perfectionist/sort-objects': 'off',
},
},
{
files: ['package.json', 'tsconfig.json'],
rules: {
@@ -28,9 +34,5 @@ module.exports = {
},
},
],
parserOptions: {
project: ['./tsconfig.json'],
tsconfigRootDir: __dirname,
},
root: true,
}

View File

@@ -4,7 +4,7 @@ on:
pull_request:
types: [ opened, reopened, synchronize ]
push:
branches: ['main', 'feat/next-poc']
branches: [ 'main' ]
jobs:
changes:
@@ -71,7 +71,7 @@ jobs:
${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
- run: pnpm install
- run: pnpm run build:core
- run: pnpm run build
- name: Cache build
uses: actions/cache@v3
@@ -79,44 +79,6 @@ jobs:
path: ./*
key: ${{ github.sha }}-${{ github.run_number }}
plugins-build:
needs: changes
if: ${{ needs.changes.outputs.needs_build == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 25
- name: Use Node.js 18
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8
run_install: false
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
- run: pnpm install
- run: pnpm run build:plugins
tests:
runs-on: ubuntu-latest
needs: core-build
@@ -275,6 +237,43 @@ jobs:
- name: Generate GraphQL schema file
run: pnpm dev:generate-graphql-schema graphql-schema-gen
build-packages:
runs-on: ubuntu-latest
needs: core-build
strategy:
fail-fast: false
matrix:
pkg:
- db-mongodb
- db-postgres
- bundler-webpack
- bundler-vite
- richtext-slate
- richtext-lexical
- live-preview
- live-preview-react
steps:
- name: Use Node.js 18
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8
run_install: false
- name: Restore build
uses: actions/cache@v3
with:
path: ./*
key: ${{ github.sha }}-${{ github.run_number }}
- name: Build ${{ matrix.pkg }}
run: pnpm turbo run build --filter=${{ matrix.pkg }}
plugins:
runs-on: ubuntu-latest
needs: core-build

4
.gitignore vendored
View File

@@ -8,11 +8,7 @@ test-results
.devcontainer
.localstack
/migrations
/media
.localstack
.turbo
.turbo
# Created by https://www.toptal.com/developers/gitignore/api/node,macos,windows,webstorm,sublimetext,visualstudiocode
# Edit at https://www.toptal.com/developers/gitignore?templates=node,macos,windows,webstorm,sublimetext,visualstudiocode

View File

@@ -1 +1 @@
v18.19.1
v18.17.1

2
.nvmrc
View File

@@ -1 +1 @@
v18.19.1
v18.17.1

8
.vscode/launch.json vendored
View File

@@ -2,12 +2,6 @@
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
"configurations": [
{
"command": "pnpm dev",
"name": "Run Dev 3.0",
"request": "launch",
"type": "node-terminal"
},
{
"command": "pnpm run dev _community",
"cwd": "${workspaceFolder}",
@@ -33,7 +27,7 @@
"type": "node-terminal"
},
{
"command": "pnpm run dev:postgres versions",
"command": "pnpm run dev:postgres fields",
"cwd": "${workspaceFolder}",
"name": "Run Dev Postgres",
"request": "launch",

33
.vscode/settings.json vendored
View File

@@ -5,21 +5,21 @@
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
"source.fixAll.eslint": true
}
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
"source.fixAll.eslint": true
}
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
"source.fixAll.eslint": true
}
},
"[json]": {
@@ -35,30 +35,5 @@
"eslint.rules.customizations": [{ "rule": "*", "severity": "warn" }],
"typescript.tsdk": "node_modules/typescript/lib",
// Load .git-blame-ignore-revs file
"gitlens.advanced.blame.customArguments": ["--ignore-revs-file", ".git-blame-ignore-revs"],
"[javascript][typescript][typescriptreact]": {
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
}
},
"workbench.colorCustomizations": {
"activityBar.activeBackground": "#8cb5b6",
"activityBar.background": "#8cb5b6",
"activityBar.foreground": "#15202b",
"activityBar.inactiveForeground": "#15202b99",
"activityBarBadge.background": "#9c639b",
"activityBarBadge.foreground": "#e7e7e7",
"commandCenter.border": "#15202b99",
"sash.hoverBorder": "#8cb5b6",
"statusBar.background": "#6da1a2",
"statusBar.foreground": "#15202b",
"statusBarItem.hoverBackground": "#568586",
"statusBarItem.remoteBackground": "#6da1a2",
"statusBarItem.remoteForeground": "#15202b",
"titleBar.activeBackground": "#6da1a2",
"titleBar.activeForeground": "#15202b",
"titleBar.inactiveBackground": "#6da1a299",
"titleBar.inactiveForeground": "#15202b99"
},
"peacock.color": "#6da1a2"
"gitlens.advanced.blame.customArguments": ["--ignore-revs-file", ".git-blame-ignore-revs"]
}

View File

@@ -1,17 +0,0 @@
/* 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 { NotFoundView } from '@payloadcms/next/views/NotFound/index'
type Args = {
params: {
segments: string[]
}
searchParams: {
[key: string]: string | string[]
}
}
const NotFound = ({ params, searchParams }: Args) => NotFoundView({ config, params, searchParams })
export default NotFound

View File

@@ -1,20 +0,0 @@
/* 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, generatePageMetadata } from '@payloadcms/next/views/Root/index'
type Args = {
params: {
segments: string[]
}
searchParams: {
[key: string]: string | string[]
}
}
export const generateMetadata = ({ params, searchParams }: Args) =>
generatePageMetadata({ config, params, searchParams })
const Page = ({ params, searchParams }: Args) => RootPage({ config, params, searchParams })
export default Page

View File

@@ -1,9 +0,0 @@
/* 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

@@ -1,6 +0,0 @@
/* 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 { GET_STATIC_FILE } from '@payloadcms/next/routes'
export const GET = GET_STATIC_FILE(config)

View File

@@ -1,6 +0,0 @@
/* 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

@@ -1,6 +0,0 @@
/* 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

@@ -1,15 +0,0 @@
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
import configPromise from '@payload-config'
import { RootLayout } from '@payloadcms/next/layouts/Root/index'
/* 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,5 +0,0 @@
export const GET = () => {
return Response.json({
hello: 'elliot',
})
}

View File

@@ -11,7 +11,7 @@ keywords: documentation, getting started, guide, Content Management System, cms,
Payload requires the following software:
- Any JavaScript package manager (Yarn, NPM, or pnpm)
- Node.js version 18+
- Node.js version 16+
- Any [compatible database](/docs/database/overview) (MongoDB or Postgres)
<Banner type="warning">

View File

@@ -292,13 +292,11 @@ For auth-enabled Collections, this hook runs after successful `forgotPassword` o
```ts
import { CollectionAfterForgotPasswordHook } from 'payload/types'
const afterLoginHook: CollectionAfterForgotPasswordHook = async ({
req, // full express request
user, // user being logged in
token, // user token
}) => {
return user
}
const afterForgotPasswordHook: CollectionAfterForgotPasswordHook = async ({
args, // arguments passed into the operation
context,
collection, // The collection which this hook is being run on
}) => {...}
```
## TypeScript

View File

@@ -290,5 +290,5 @@ If you&apos;ve configured tests for your package, integrate them into your workf
The best way to share and allow others to use your plugin once it is complete is to publish an NPM package. This process is straightforward and well documented, find out more about [creating and publishing a NPM package here](https://docs.npmjs.com/creating-and-publishing-scoped-public-packages/).
##### Add payload-plugin topic tag:
Apply the tag **payload-plugin** to your GitHub repository. This will boost the visibility of your plugin and ensure it gets listed with [existing payload plugins](https://github.com/topics/payload-plugin).
##### Use [Semantic Versioning](https://semver.org/) (SemVar):
With the SemVar system you release version numbers that reflect the nature of changes (major, minor, patch). Ensure all major versions reference their Payload compatibility.
##### Use [Semantic Versioning](https://semver.org/) (SemVer):
With the SemVer system you release version numbers that reflect the nature of changes (major, minor, patch). Ensure all major versions reference their Payload compatibility.

View File

@@ -11,7 +11,7 @@
"dependencies": {
"@apollo/client": "^3.7.0",
"@faceless-ui/css-grid": "^1.2.0",
"@faceless-ui/modal": "^2.0.2",
"@faceless-ui/modal": "^2.0.1",
"escape-html": "^1.0.3",
"graphql": "^16.8.1",
"next": "^13.5.6",

View File

@@ -18,7 +18,7 @@
"@payloadcms/bundler-webpack": "latest",
"@payloadcms/db-mongodb": "latest",
"@payloadcms/richtext-slate": "latest",
"@faceless-ui/modal": "^2.0.2",
"@faceless-ui/modal": "^2.0.1",
"@payloadcms/plugin-form-builder": "^1.0.12",
"@payloadcms/plugin-seo": "^1.0.8",
"dotenv": "^8.2.0",

View File

@@ -69,7 +69,7 @@ For more details on this, see the [CORS](https://payloadcms.com/docs/production/
## Front-end
If you're building a website or other front-end for your tenant, you will need specify the `tenant` in your requests. For example, if you wanted to fetch all pages for the tenant `ABC`, you would make a request to `/api/pages?where[tenant][slug][equals]=abc`.
If you're building a website or other front-end for your tenant, you will need specify the `tenant` in your requests. For example, if you wanted to fetch all pages for the tenant `ABC`, you would make a request to `/api/pages?where[tenant.name][equals]=ABC`.
For a head start on building a website for your tenant(s), check out the official [Website Template](https://github.com/payloadcms/template-website). It includes a page layout builder, preview, SEO, and much more. It is not multi-tenant, though, but you can easily take the concepts from that example and apply them here.

View File

@@ -19,7 +19,6 @@ app.get('/', (_, res) => {
const start = async (): Promise<void> => {
await payload.init({
secret: process.env.PAYLOAD_SECRET,
mongoURL: process.env.MONGODB_URI,
express: app,
onInit: () => {
payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`)

View File

@@ -16,6 +16,7 @@
"@swc/core": "^1.3.84",
"@swc/jest": "^0.2.29",
"@types/jest": "^29.5.4",
"isomorphic-fetch": "^3.0.0",
"jest": "^29.7.0",
"mongodb-memory-server": "^8.15.1",
"nodemon": "^3.0.1",

View File

@@ -1,11 +1,4 @@
// const nextJest = require('next/jest.js')
// const createJestConfig = nextJest({
// // Provide the path to your Next.js app to load next.config.js and .env files in your test environment
// dir: './',
// })
const customJestConfig = {
module.exports = {
globalSetup: './test/jest.setup.ts',
moduleNameMapper: {
'\\.(css|scss)$': '<rootDir>/packages/payload/src/bundlers/mocks/emptyModule.js',
@@ -20,6 +13,3 @@ const customJestConfig = {
},
verbose: true,
}
// module.exports = createJestConfig(customJestConfig)
export default customJestConfig

5
next-env.d.ts vendored
View File

@@ -1,5 +0,0 @@
/// <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,21 +0,0 @@
import withPayload from './packages/next/src/withPayload.js'
import bundleAnalyzer from '@next/bundle-analyzer'
const withBundleAnalyzer = bundleAnalyzer({
enabled: process.env.ANALYZE === 'true',
})
export default withBundleAnalyzer(
withPayload({
reactStrictMode: false,
async redirects() {
return [
{
destination: '/admin',
permanent: true,
source: '/',
},
]
},
}),
)

View File

@@ -1,45 +1,19 @@
{
"name": "payload-monorepo",
"version": "3.0.0-alpha.23",
"version": "0.0.1",
"private": true,
"type": "module",
"workspaces:": [
"packages/*"
],
"scripts": {
"build": "pnpm run build:core",
"build": "pnpm --filter payload run build",
"build:all": "turbo build",
"build:core": "turbo build --filter \"!@payloadcms/plugin-*\"",
"build:plugins": "turbo build --filter \"@payloadcms/plugin-*\" --filter \"!@payloadcms/plugin-search\" --filter \"!@payloadcms/plugin-redirects\" --filter \"!@payloadcms/plugin-nested-docs\"",
"build:app": "next build",
"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",
"build:eslint-config-payload": "turbo build --filter eslint-config-payload",
"build:graphql": "turbo build --filter graphql",
"build:live-preview": "turbo build --filter live-preview",
"build:live-preview-react": "turbo build --filter live-preview-react",
"build:next": "turbo build --filter next",
"build:payload": "turbo build --filter payload",
"build:plugin-cloud": "turbo build --filter plugin-cloud",
"build:plugin-cloud-storage": "turbo build --filter plugin-cloud-storage",
"build:plugin-form-builder": "turbo build --filter plugin-form-builder",
"build:plugin-nested-docs": "turbo build --filter plugin-nested-docs",
"build:plugin-redirects": "turbo build --filter plugin-redirects",
"build:plugin-search": "turbo build --filter plugin-search",
"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:richtext-lexical": "turbo build --filter richtext-lexical",
"build:richtext-slate": "turbo build --filter richtext-slate",
"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:all": "find . \\( -type d \\( -name node_modules -o -name dist -o -name .cache \\) -o -type f -name tsconfig.tsbuildinfo \\) -exec rm -rf {} +",
"dev": "cross-env node --no-deprecation ./test/dev.js",
"dev:generate-graphql-schema": "NODE_OPTIONS=--no-deprecation ts-node -T ./test/generateGraphQLSchema.ts",
"dev:generate-types": "NODE_OPTIONS=--no-deprecation ts-node -T ./test/generateTypes.ts",
"clean": "rimraf dist && rimraf packages/payload/dist",
"clean:cache": "rimraf node_modules/.cache && rimraf packages/payload/node_modules/.cache",
"clean:unix": "find . \\( -type d \\( -name node_modules -o -name dist -o -name .cache \\) -o -type f -name tsconfig.tsbuildinfo \\) -exec rm -rf {} +",
"dev": "nodemon",
"dev:generate-graphql-schema": "ts-node -T ./test/generateGraphQLSchema.ts",
"dev:generate-types": "ts-node -T ./test/generateTypes.ts",
"dev:postgres": "pnpm --filter payload run dev:postgres",
"docker:restart": "pnpm docker:stop --remove-orphans && pnpm docker:start",
"docker:start": "docker-compose -f packages/plugin-cloud-storage/docker-compose.yml up -d",
@@ -49,23 +23,20 @@
"lint-staged": "lint-staged",
"prepare": "husky install",
"pretest": "pnpm build",
"reinstall": "pnpm clean:all && pnpm install",
"reinstall": "pnpm clean:unix && pnpm install",
"script:list-packages": "tsx ./scripts/list-packages.ts",
"release:alpha": "tsx ./scripts/release.ts --bump prerelease --tag alpha",
"release:beta": "tsx ./scripts/release.ts --bump prerelease --tag beta",
"script:release": "tsx ./scripts/release.ts",
"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": "NODE_OPTIONS=--no-deprecation npx playwright install --with-deps chromium && NODE_OPTIONS=--no-deprecation ts-node -T ./test/runE2E.ts",
"test:e2e:debug": "cross-env NODE_OPTIONS=--no-deprecation PWDEBUG=1 DISABLE_LOGGING=true playwright test",
"test:e2e:headed": "cross-env NODE_OPTIONS=--no-deprecation DISABLE_LOGGING=true playwright test --headed",
"test:int:postgres": "cross-env NODE_OPTIONS=--no-deprecation PAYLOAD_DATABASE=postgres DISABLE_LOGGING=true jest --forceExit --detectOpenHandles",
"test:int": "cross-env NODE_OPTIONS=--no-deprecation DISABLE_LOGGING=true jest --forceExit --detectOpenHandles",
"test:components": "cross-env jest --config=jest.components.config.js",
"test:e2e": "npx playwright install --with-deps chromium && ts-node -T ./test/runE2E.ts",
"test:e2e:debug": "cross-env PWDEBUG=1 DISABLE_LOGGING=true playwright test",
"test:e2e:headed": "cross-env DISABLE_LOGGING=true playwright test --headed",
"test:int:postgres": "cross-env PAYLOAD_DATABASE=postgres DISABLE_LOGGING=true jest --forceExit --detectOpenHandles",
"test:int": "cross-env DISABLE_LOGGING=true jest --forceExit --detectOpenHandles",
"translateNewKeys": "pnpm --filter payload run translateNewKeys"
},
"devDependencies": {
"@aws-sdk/client-s3": "^3.142.0",
"@next/bundle-analyzer": "^14.1.0",
"@octokit/core": "^5.1.0",
"@payloadcms/eslint-config": "workspace:*",
"@playwright/test": "1.40.1",
"@swc/cli": "^0.1.62",
@@ -77,7 +48,6 @@
"@types/conventional-changelog": "^3.1.4",
"@types/conventional-changelog-core": "^4.2.5",
"@types/conventional-changelog-preset-loader": "^2.3.4",
"@types/conventional-changelog-writer": "^4.0.10",
"@types/fs-extra": "^11.0.2",
"@types/jest": "29.5.7",
"@types/minimist": "1.2.2",
@@ -89,66 +59,67 @@
"@types/shelljs": "0.8.12",
"@types/testing-library__jest-dom": "5.14.8",
"add-stream": "^1.0.0",
"chalk": "^4.1.2",
"comment-json": "^4.2.3",
"chalk": "^5.3.0",
"chalk-template": "1.1.0",
"concat-stream": "^2.0.0",
"conventional-changelog": "^5.1.0",
"conventional-changelog-conventionalcommits": "^7.0.2",
"conventional-changelog-core": "^7.0.0",
"conventional-changelog-preset-loader": "^4.1.0",
"conventional-changelog-writer": "^7.0.1",
"copyfiles": "2.4.1",
"cross-env": "7.0.3",
"dotenv": "8.6.0",
"drizzle-orm": "0.29.4",
"execa": "5.1.1",
"drizzle-orm": "0.29.3",
"express": "4.18.2",
"form-data": "3.0.1",
"fs-extra": "10.1.0",
"get-port": "5.1.1",
"get-stream": "6.0.1",
"glob": "8.1.0",
"graphql-request": "6.1.0",
"husky": "^8.0.3",
"isomorphic-fetch": "3.0.0",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"json5": "^2.2.3",
"jwt-decode": "3.1.2",
"lexical": "0.13.1",
"lint-staged": "^14.0.1",
"minimist": "1.2.8",
"mongodb-memory-server": "^9",
"next": "14.1.2",
"node-mocks-http": "^1.14.1",
"node-fetch": "2.6.12",
"nodemon": "3.0.3",
"pino": "8.15.0",
"pino-pretty": "10.2.0",
"prettier": "^3.0.3",
"prompts": "2.4.2",
"qs": "6.11.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"read-stream": "^2.1.1",
"rimraf": "3.0.2",
"semver": "^7.5.4",
"sharp": "0.32.6",
"shelljs": "0.8.5",
"simple-git": "^3.20.0",
"slash": "3.0.0",
"slate": "0.91.4",
"tempfile": "^3.0.0",
"ts-node": "10.9.2",
"tsx": "^4.7.1",
"turbo": "^1.12.4",
"turbo": "^1.11.1",
"typescript": "5.2.2",
"uuid": "^9.0.1",
"yocto-queue": "^1.0.0"
"uuid": "^9.0.1"
},
"peerDependencies": {
"react": "18.2.0",
"react-i18next": "11.18.6",
"react-router-dom": "5.3.4"
},
"pnpm": {
"overrides": {
"copyfiles": "$copyfiles",
"cross-env": "$cross-env",
"dotenv": "$dotenv",
"drizzle-orm": "$drizzle-orm",
"ts-node": "$ts-node",
"typescript": "$typescript"
}
},
"engines": {
"node": ">=18.17.0",
"node": ">=14",
"pnpm": ">=8"
},
"lint-staged": {
@@ -157,25 +128,6 @@
]
},
"dependencies": {
"@sentry/react": "^7.77.0",
"passport-strategy": "1.0.0"
},
"pnpm": {
"overrides": {
"copyfiles": "$copyfiles",
"cross-env": "$cross-env",
"dotenv": "$dotenv",
"drizzle-orm": "$drizzle-orm",
"graphql": "^16.8.1",
"react": "$react",
"react-dom": "$react-dom",
"ts-node": "$ts-node",
"typescript": "$typescript"
},
"allowedDeprecatedVersions": {
"uuid": "3.4.0",
"abab": "2",
"domexception": "4"
}
"@sentry/react": "^7.77.0"
}
}

View File

@@ -10,6 +10,6 @@
}
},
"module": {
"type": "es6"
"type": "commonjs"
}
}

View File

@@ -0,0 +1,28 @@
# Payload Vite Adapter
Official Vite adapter for [Payload](https://payloadcms.com).
- [Main Repository](https://github.com/payloadcms/payload)
- [Payload Docs](https://payloadcms.com/docs)
## Installation
```bash
npm install @payloadcms/bundler-vite
```
## Usage
```ts
import { buildConfig } from 'payload/config'
import { viteBundler } from '@payloadcms/bundler-vite'
export default buildConfig({
bundler: viteBundler(),
// ...rest of config
})
```
More detailed usage can be found in the [Payload Docs](https://payloadcms.com/docs/configuration/overview).

View File

@@ -0,0 +1,3 @@
export const viteBundler = () => {}
export const mongooseAdapter = () => ({})
export const postgresAdapter = () => ({})

View File

@@ -0,0 +1,51 @@
{
"name": "@payloadcms/bundler-vite",
"version": "0.1.6",
"description": "The officially supported Vite bundler adapter for Payload",
"repository": "https://github.com/payloadcms/payload",
"license": "MIT",
"homepage": "https://payloadcms.com",
"author": {
"email": "info@payloadcms.com",
"name": "Payload",
"url": "https://payloadcms.com"
},
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"scripts": {
"build": "pnpm copyfiles && pnpm build:swc && pnpm build:types && pnpm copyTsx",
"build:swc": "swc ./src -d ./dist --config-file .swcrc",
"build:types": "tsc --emitDeclarationOnly --outDir dist",
"clean": "rimraf {dist,*.tsbuildinfo}",
"copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/",
"copyTsx": "copyfiles -u 1 \"src/entry.tsx\" dist/",
"prepublishOnly": "pnpm clean && pnpm build"
},
"dependencies": {
"@rollup/plugin-image": "^3.0.2",
"@vitejs/plugin-react": "^4.0.4",
"compression": "1.7.4",
"connect-history-api-fallback": "1.6.0",
"get-port": "5.1.1",
"path-browserify": "1.0.1",
"vite": "^4.4.9",
"vite-plugin-virtual": "^0.2.0"
},
"devDependencies": {
"@payloadcms/eslint-config": "workspace:*",
"payload": "workspace:*"
},
"peerDependencies": {
"payload": "^2.0.0",
"react-dom": "18.2.0"
},
"publishConfig": {
"main": "./dist/index.js",
"registry": "https://registry.npmjs.org/",
"types": "./dist/index.d.ts"
},
"files": [
"dist",
"mock.js"
]
}

View File

@@ -0,0 +1,157 @@
/* eslint-disable no-param-reassign */
import type { SanitizedConfig } from 'payload/config'
// @ts-expect-error
import type { InlineConfig } from 'vite'
import image from '@rollup/plugin-image'
import react from '@vitejs/plugin-react'
import getPort from 'get-port'
import path from 'path'
import virtual from 'vite-plugin-virtual'
const mockModulePath = path.resolve(__dirname, './mocks/emptyModule.js')
const mockDotENVPath = path.resolve(__dirname, './mocks/dotENV.js')
export const getViteConfig = async (payloadConfig: SanitizedConfig): Promise<InlineConfig> => {
const { createLogger, searchForWorkspaceRoot } = await import('vite')
const logger = createLogger('warn', { allowClearScreen: false, prefix: '[VITE-WARNING]' })
const originalWarning = logger.warn
logger.warn = (msg, options) => {
// TODO: fix this? removed these warnings to make debugging easier
if (msg.includes('Default and named imports from CSS files are deprecated')) return
originalWarning(msg, options)
}
const hmrPort = await getPort()
const absoluteAliases = {}
const alias = [
{ find: '@payloadcms/bundler-vite', replacement: path.resolve(__dirname, '../mock.js') },
{ find: '@payloadcms/db-mongodb', replacement: path.resolve(__dirname, '../mock.js') },
{ find: '@payloadcms/db-postgres', replacement: path.resolve(__dirname, '../mock.js') },
{ find: 'path', replacement: require.resolve('path-browserify') },
{ find: 'payload-config', replacement: payloadConfig.paths.rawConfig },
{ find: /payload$/, replacement: mockModulePath },
{ find: '~payload-user-css', replacement: payloadConfig.admin.css },
{ find: '~react-toastify', replacement: 'react-toastify' },
{ find: 'dotenv', replacement: mockDotENVPath },
]
if (payloadConfig.admin.webpack && typeof payloadConfig.admin.webpack === 'function') {
const webpackConfig = payloadConfig.admin.webpack({
resolve: {
alias: {},
},
})
if (Object.keys(webpackConfig.resolve.alias).length > 0) {
Object.entries(webpackConfig.resolve.alias).forEach(([source, target]) => {
if (path.isAbsolute(source)) {
absoluteAliases[source] = target
} else {
alias.push({
find: source,
replacement: target,
})
}
})
}
}
const define = {
__dirname: '"/"',
'module.hot': 'undefined',
'process.argv': '[]',
'process.cwd': 'function () { return "/" }',
'process?.cwd': 'function () { return "/" }',
}
Object.entries(process.env).forEach(([key, val]) => {
if (key.indexOf('PAYLOAD_PUBLIC_') === 0) {
define[`process.env.${key}`] = `'${val}'`
} else {
define[`process.env.${key}`] = `''`
}
})
let viteConfig: InlineConfig = {
base: payloadConfig.routes.admin,
build: {
chunkSizeWarningLimit: 4000,
emptyOutDir: true,
outDir: payloadConfig.admin.buildPath,
rollupOptions: {
plugins: [image()],
treeshake: true,
},
},
customLogger: logger,
define,
optimizeDeps: {
exclude: [
// Dependencies that need aliases should be excluded
// from pre-bundling
'@payloadcms/bundler-vite',
'@payloadcms/db-mongodb',
'@payloadcms/db-postgres',
...(Object.keys(absoluteAliases) || []),
],
include: ['payload/components/root', 'react-dom/client'],
},
plugins: [
{
name: 'absolute-aliases',
enforce: 'pre',
resolveId(source, importer) {
let fullSourcePath: string
// TODO: need to handle this better. This is overly simple.
if (source.startsWith('.')) {
fullSourcePath = path.resolve(path.dirname(importer), source)
if (fullSourcePath) {
const exactMatch = absoluteAliases[fullSourcePath]
if (exactMatch) return exactMatch
const indexMatch = absoluteAliases[`${fullSourcePath}/index`]
if (indexMatch) return indexMatch
const withoutFileExtensionMatch =
absoluteAliases[`${fullSourcePath.replace(/\.[^/.]+$/, '')}`]
if (withoutFileExtensionMatch) return withoutFileExtensionMatch
}
}
return null
},
},
virtual({
crypto: 'export default {}',
http: 'export default {}',
https: 'export default {}',
}),
react(),
],
resolve: {
alias,
},
root: path.resolve(__dirname, './'),
server: {
fs: {
allow: [searchForWorkspaceRoot(process.cwd()), path.resolve(__dirname, '../../../payload')],
},
hmr: {
port: hmrPort,
},
middlewareMode: true,
},
}
if (payloadConfig.admin.vite && typeof payloadConfig.admin.vite === 'function') {
viteConfig = payloadConfig.admin.vite(viteConfig)
}
return viteConfig
}

View File

@@ -0,0 +1,9 @@
import { Root } from 'payload/components/root'
// @ts-expect-error
import config from 'payload-config'
import React from 'react'
import { createRoot } from 'react-dom/client'
const container = document.getElementById('app')
const root = createRoot(container)
root.render(<Root config={config} />)

View File

@@ -0,0 +1,14 @@
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<link rel="icon" href="data:," data-placeholder-favicon />
</head>
<body>
<div id="app"></div>
<div id="portal"></div>
<script type="module" src="./entry.tsx"></script>
</body>
</html>

View File

@@ -0,0 +1,14 @@
// @ts-expect-error
import type { InlineConfig } from 'vite'
import type { PayloadBundler } from './types'
import { buildAdmin } from './scripts/build'
import { devAdmin } from './scripts/dev'
import { serveAdmin } from './scripts/serve'
export const viteBundler: (viteConfig?: InlineConfig) => PayloadBundler = (viteConfig) => ({
build: async (payloadConfig) => buildAdmin({ payloadConfig, viteConfig }),
dev: async (payload) => devAdmin({ payload, viteConfig }),
serve: async (payload) => serveAdmin({ payload }),
})

View File

@@ -0,0 +1,3 @@
export default {
config: () => null,
}

View File

@@ -0,0 +1 @@
export default () => {}

View File

@@ -0,0 +1 @@
export default 'file-stub'

View File

@@ -0,0 +1,21 @@
import type { SanitizedConfig } from 'payload/config'
// @ts-expect-error
import type { InlineConfig } from 'vite'
import { getViteConfig } from '../config'
type BuildAdminType = (options: {
payloadConfig: SanitizedConfig
viteConfig: InlineConfig
}) => Promise<void>
export const buildAdmin: BuildAdminType = async ({ payloadConfig, viteConfig: viteConfigArg }) => {
const vite = await import('vite')
const viteConfig = await getViteConfig(payloadConfig)
try {
await vite.build(viteConfig)
} catch (e) {
console.error(e)
throw new Error('Error: there was an error building the vite prod config.')
}
}

View File

@@ -0,0 +1,31 @@
import type { PayloadHandler } from 'payload/config'
// @ts-expect-error
import type { InlineConfig } from 'vite'
import express from 'express'
import type { Payload } from '../../../payload'
import { getViteConfig } from '../config'
const router = express.Router()
type DevAdminType = (options: {
payload: Payload
viteConfig: InlineConfig
}) => Promise<PayloadHandler>
export const devAdmin: DevAdminType = async ({ payload, viteConfig: viteConfigArg }) => {
const vite = await import('vite')
try {
const viteConfig = await getViteConfig(payload.config)
const viteServer = await vite.createServer(viteConfig)
router.use(viteServer.middlewares)
} catch (err) {
console.error(err)
throw new Error('Error: there was an error creating the vite dev server.')
}
return router
}

View File

@@ -0,0 +1,28 @@
import type { Payload } from 'payload'
import type { PayloadHandler } from 'payload/config'
import compression from 'compression'
import history from 'connect-history-api-fallback'
import express from 'express'
const router = express.Router()
type ServeAdminType = (options: { payload: Payload }) => Promise<PayloadHandler>
export const serveAdmin: ServeAdminType = async ({ payload }) => {
router.use(history())
router.get('*', (req, res, next) => {
if (req.path.substr(-1) === '/' && req.path.length > 1) {
const query = req.url.slice(req.path.length)
res.redirect(301, req.path.slice(0, -1) + query)
} else {
next()
}
})
router.use(compression(payload.config.express.compression))
router.use(express.static(payload.config.admin.buildPath, { redirect: false }))
return router
}

View File

@@ -0,0 +1,8 @@
import type { Payload } from 'payload'
import type { PayloadHandler, SanitizedConfig } from 'payload/config'
export interface PayloadBundler {
build: (payloadConfig: SanitizedConfig) => Promise<void> // used in `payload build`
dev: (payload: Payload) => Promise<PayloadHandler> // this would be a typical Express middleware handler
serve: (payload: Payload) => Promise<PayloadHandler> // serve built files in production
}

View File

@@ -5,21 +5,9 @@
"noEmit": false /* Do not emit outputs. */,
"emitDeclarationOnly": true,
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
"rootDir": "./src" /* Specify the root folder within your source files. */,
"allowImportingTsExtensions": true
"rootDir": "./src" /* Specify the root folder within your source files. */
},
"exclude": [
"dist",
"build",
"tests",
"test",
"node_modules",
".eslintrc.js",
"src/**/*.spec.js",
"src/**/*.spec.jsx",
"src/**/*.spec.ts",
"src/**/*.spec.tsx"
],
"exclude": ["dist", "node_modules", ".eslintrc.js"],
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.d.ts", "src/**/*.json"],
"references": [{ "path": "../payload" }]
}

View File

@@ -0,0 +1,10 @@
.tmp
**/.git
**/.hg
**/.pnp.*
**/.svn
**/.yarn/**
**/build
**/dist/**
**/node_modules
**/temp

View File

@@ -0,0 +1,43 @@
/** @type {import('prettier').Config} */
module.exports = {
extends: ['@payloadcms'],
overrides: [
{
extends: ['plugin:@typescript-eslint/disable-type-checked'],
files: ['*.js', '*.cjs', '*.json', '*.md', '*.yml', '*.yaml'],
},
{
files: ['**/*.ts'],
rules: {
'@typescript-eslint/no-redundant-type-constituents': 'off',
},
},
{
files: ['package.json', 'tsconfig.json'],
rules: {
'perfectionist/sort-array-includes': 'off',
'perfectionist/sort-astro-attributes': 'off',
'perfectionist/sort-classes': 'off',
'perfectionist/sort-enums': 'off',
'perfectionist/sort-exports': 'off',
'perfectionist/sort-imports': 'off',
'perfectionist/sort-interfaces': 'off',
'perfectionist/sort-jsx-props': 'off',
'perfectionist/sort-keys': 'off',
'perfectionist/sort-maps': 'off',
'perfectionist/sort-named-exports': 'off',
'perfectionist/sort-named-imports': 'off',
'perfectionist/sort-object-types': 'off',
'perfectionist/sort-objects': 'off',
'perfectionist/sort-svelte-attributes': 'off',
'perfectionist/sort-union-types': 'off',
'perfectionist/sort-vue-attributes': 'off',
},
},
],
parserOptions: {
project: ['./tsconfig.json'],
tsconfigRootDir: __dirname,
},
root: true,
}

View File

@@ -0,0 +1,10 @@
.tmp
**/.git
**/.hg
**/.pnp.*
**/.svn
**/.yarn/**
**/build
**/dist/**
**/node_modules
**/temp

View File

@@ -10,6 +10,6 @@
}
},
"module": {
"type": "es6"
"type": "commonjs"
}
}

View File

@@ -0,0 +1,28 @@
# Payload Webpack Adapter
Official Webpack adapter for [Payload](https://payloadcms.com).
- [Main Repository](https://github.com/payloadcms/payload)
- [Payload Docs](https://payloadcms.com/docs)
## Installation
```bash
npm install @payloadcms/bundler-webpack
```
## Usage
```ts
import { buildConfig } from 'payload/config'
import { webpackBundler } from '@payloadcms/bundler-webpack'
export default buildConfig({
bundler: webpackBundler()
// ...rest of config
})
```
More detailed usage can be found in the [Payload Docs](https://payloadcms.com/docs/configuration/overview).

View File

@@ -0,0 +1,72 @@
{
"name": "@payloadcms/bundler-webpack",
"version": "1.0.6",
"description": "The officially supported Webpack bundler adapter for Payload",
"repository": "https://github.com/payloadcms/payload",
"license": "MIT",
"homepage": "https://payloadcms.com",
"author": {
"email": "info@payloadcms.com",
"name": "Payload",
"url": "https://payloadcms.com"
},
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"scripts": {
"build": "pnpm build:swc && pnpm build:types",
"build:swc": "swc ./src -d ./dist --config-file .swcrc",
"build:types": "tsc --emitDeclarationOnly --outDir dist",
"clean": "rimraf {dist,*.tsbuildinfo}",
"prepublishOnly": "pnpm clean && pnpm build"
},
"dependencies": {
"compression": "1.7.4",
"connect-history-api-fallback": "1.6.0",
"css-loader": "5.2.7",
"css-minimizer-webpack-plugin": "^5.0.0",
"file-loader": "6.2.0",
"find-node-modules": "^2.1.3",
"html-webpack-plugin": "^5.5.0",
"md5": "2.3.0",
"mini-css-extract-plugin": "1.6.2",
"path-browserify": "1.0.1",
"postcss": "8.4.31",
"postcss-loader": "6.2.1",
"postcss-preset-env": "9.0.0",
"process": "0.11.10",
"sass-loader": "12.6.0",
"style-loader": "^2.0.0",
"swc-loader": "^0.2.3",
"swc-minify-webpack-plugin": "^2.1.0",
"terser-webpack-plugin": "^5.3.6",
"url-loader": "4.1.1",
"webpack": "^5.78.0",
"webpack-bundle-analyzer": "^4.8.0",
"webpack-cli": "^4.10.0",
"webpack-dev-middleware": "6.0.1",
"webpack-hot-middleware": "^2.25.3"
},
"devDependencies": {
"@payloadcms/eslint-config": "workspace:*",
"@types/extract-text-webpack-plugin": "^3.0.7",
"@types/find-node-modules": "^2.1.0",
"@types/html-webpack-plugin": "^3.2.6",
"@types/mini-css-extract-plugin": "^1.4.3",
"@types/optimize-css-assets-webpack-plugin": "^5.0.5",
"@types/webpack-bundle-analyzer": "^4.6.0",
"@types/webpack-env": "^1.18.0",
"@types/webpack-hot-middleware": "2.25.6",
"payload": "workspace:*"
},
"peerDependencies": {
"payload": "^2.0.0"
},
"publishConfig": {
"main": "./dist/index.js",
"registry": "https://registry.npmjs.org/",
"types": "./dist/index.d.ts"
},
"files": [
"dist"
]
}

View File

@@ -0,0 +1,105 @@
import type { SanitizedConfig } from 'payload/config'
import type { Configuration } from 'webpack'
import findNodeModules from 'find-node-modules'
import fs from 'fs'
import HtmlWebpackPlugin from 'html-webpack-plugin'
import path from 'path'
import webpack from 'webpack'
const mockModulePath = path.resolve(__dirname, '../mocks/emptyModule.js')
const mockDotENVPath = path.resolve(__dirname, '../mocks/dotENV.js')
const mockDBAdapterPath = path.resolve(__dirname, '../mocks/db-adapters.js')
const nodeModulesPaths = findNodeModules({ cwd: process.cwd(), relative: false })
export const getBaseConfig = (payloadConfig: SanitizedConfig): Configuration => {
let nodeModulesPath = nodeModulesPaths.find((p) => {
const guess = path.resolve(p, 'payload/dist/admin')
if (fs.existsSync(guess)) {
return true
}
return false
})
if (!nodeModulesPath) {
nodeModulesPath = process.cwd()
}
const adminFolderPath = path.resolve(nodeModulesPath, 'payload/dist/admin')
const config: Configuration = {
entry: {
main: [adminFolderPath],
},
module: {
rules: [
{
exclude: /\/node_modules\/(?!.+\.tsx?$).*$/,
test: /\.(t|j)sx?$/,
use: [
{
loader: require.resolve('swc-loader'),
options: {
jsc: {
parser: {
syntax: 'typescript',
tsx: true,
},
},
},
},
],
},
{
oneOf: [
{
test: /\.(?:ico|gif|png|jpg|jpeg|woff(2)?|eot|ttf|otf|svg)$/i,
type: 'asset/resource',
},
],
},
],
},
plugins: [
new webpack.ProvidePlugin({ process: require.resolve('process/browser') }),
new webpack.DefinePlugin(
Object.entries(process.env).reduce((values, [key, val]) => {
if (key.indexOf('PAYLOAD_PUBLIC_') === 0) {
return {
...values,
[`process.env.${key}`]: `'${val}'`,
}
}
return values
}, {}),
),
new HtmlWebpackPlugin({
filename: path.normalize('./index.html'),
template: payloadConfig.admin.indexHTML,
}),
],
resolve: {
alias: {
'@payloadcms/bundler-webpack': mockModulePath,
'@payloadcms/db-mongodb': mockDBAdapterPath,
'@payloadcms/db-postgres': mockDBAdapterPath,
dotenv: mockDotENVPath,
path: require.resolve('path-browserify'),
payload$: mockModulePath,
'payload-config': payloadConfig.paths.rawConfig,
'payload-user-css': payloadConfig.admin.css,
},
extensions: ['.ts', '.tsx', '.js', '.json'],
fallback: {
crypto: false,
http: false,
https: false,
},
modules: ['node_modules', nodeModulesPath, path.resolve(__dirname, '../../node_modules')],
},
}
return config
}

View File

@@ -0,0 +1,82 @@
import type { SanitizedConfig } from 'payload/config'
import type { Configuration } from 'webpack'
import md5 from 'md5'
import webpack from 'webpack'
import { getBaseConfig } from './base'
export const getDevConfig = (payloadConfig: SanitizedConfig): Configuration => {
const baseConfig = getBaseConfig(payloadConfig) as any
let webpackConfig: Configuration = {
...baseConfig,
cache: {
type: 'filesystem',
// version cache when there are changes to aliases
buildDependencies: {
config: [__filename],
},
version: md5(Object.entries(baseConfig.resolve.alias).join()),
},
devtool: 'inline-source-map',
entry: {
...baseConfig.entry,
main: [
`${require.resolve('webpack-hot-middleware/client')}?path=${
payloadConfig.routes.admin
}/__webpack_hmr`,
...(baseConfig.entry.main as string[]),
],
},
mode: 'development',
module: {
...baseConfig.module,
rules: [
...baseConfig.module.rules,
{
sideEffects: true,
test: /\.(scss|css)$/,
/*
* The loaders here are run in reverse order. Here is how your loaders are being processed:
* 1. sass-loader: This loader compiles your SCSS into CSS.
* 2. postcss-loader: This loader applies postcss transformations (with preset-env plugin in your case).
* 3. css-loader: This loader interprets @import and url() like import/require() and will resolve them.
* 4. style-loader: This loader injects CSS into the DOM.
*/
use: [
require.resolve('style-loader'),
{
loader: require.resolve('css-loader'),
options: {
url: (url) => !url.startsWith('/'),
},
},
{
loader: require.resolve('postcss-loader'),
options: {
postcssOptions: {
plugins: [require.resolve('postcss-preset-env')],
},
},
},
require.resolve('sass-loader'),
],
},
],
},
output: {
filename: '[name].js',
path: '/',
publicPath: `${payloadConfig.routes.admin}/`,
},
plugins: [...baseConfig.plugins, new webpack.HotModuleReplacementPlugin()],
stats: 'errors-warnings',
}
if (payloadConfig.admin.webpack && typeof payloadConfig.admin.webpack === 'function') {
webpackConfig = payloadConfig.admin.webpack(webpackConfig)
}
return webpackConfig
}

View File

@@ -0,0 +1,80 @@
import type { SanitizedConfig } from 'payload/config'
import type { Configuration } from 'webpack'
import MiniCSSExtractPlugin from 'mini-css-extract-plugin'
import { SwcMinifyWebpackPlugin } from 'swc-minify-webpack-plugin'
import { WebpackPluginInstance } from 'webpack'
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'
import { getBaseConfig } from './base'
export const getProdConfig = (payloadConfig: SanitizedConfig): Configuration => {
const baseConfig = getBaseConfig(payloadConfig) as any
let webpackConfig: Configuration = {
...baseConfig,
mode: 'production',
module: {
...baseConfig.module,
rules: [
...baseConfig.module.rules,
{
sideEffects: true,
test: /\.(scss|css)$/,
use: [
MiniCSSExtractPlugin.loader,
{
loader: require.resolve('css-loader'),
options: {
url: (url) => !url.startsWith('/'),
},
},
{
loader: require.resolve('postcss-loader'),
options: {
postcssOptions: {
plugins: [require.resolve('postcss-preset-env')],
},
},
},
require.resolve('sass-loader'),
],
},
],
},
optimization: {
minimizer: [new SwcMinifyWebpackPlugin()],
splitChunks: {
cacheGroups: {
styles: {
name: 'styles',
chunks: 'all',
enforce: true,
test: /\.(sa|sc|c)ss$/,
},
},
},
},
output: {
chunkFilename: '[name].[chunkhash].js',
filename: '[name].[chunkhash].js',
path: payloadConfig.admin.buildPath,
publicPath: `${payloadConfig.routes.admin}/`,
},
plugins: [
...baseConfig.plugins,
new MiniCSSExtractPlugin({
filename: '[name].[contenthash].css',
ignoreOrder: true,
}),
...(process.env.PAYLOAD_ANALYZE_BUNDLE ? [new BundleAnalyzerPlugin()] : []),
],
stats: 'errors-only',
}
if (payloadConfig.admin.webpack && typeof payloadConfig.admin.webpack === 'function') {
webpackConfig = payloadConfig.admin.webpack(webpackConfig)
}
return webpackConfig
}

View File

@@ -0,0 +1,12 @@
/* eslint-disable @typescript-eslint/no-var-requires */
import type { PayloadBundler } from '../../payload/dist/bundlers/types'
import { buildAdmin } from './scripts/build'
import { devAdmin } from './scripts/dev'
import { serveAdmin } from './scripts/serve'
export const webpackBundler: () => PayloadBundler = () => ({
build: async (payloadConfig) => buildAdmin({ payloadConfig }),
dev: async (payload) => devAdmin({ payload }),
serve: async (payload) => serveAdmin({ payload }),
})

View File

@@ -0,0 +1,2 @@
export const mongooseAdapter = () => ({})
export const postgresAdapter = () => ({})

View File

@@ -0,0 +1,3 @@
export default {
config: () => null,
}

View File

@@ -0,0 +1,3 @@
export const webpackBundler = () => {}
export default () => {}

View File

@@ -0,0 +1 @@
export default 'file-stub'

View File

@@ -0,0 +1,31 @@
import type { SanitizedConfig } from 'payload/config'
import webpack from 'webpack'
import { getProdConfig } from '../configs/prod'
type BuildAdminType = (options: { payloadConfig: SanitizedConfig }) => Promise<void>
export const buildAdmin: BuildAdminType = async ({ payloadConfig }) => {
try {
const webpackConfig = getProdConfig(payloadConfig)
webpack(webpackConfig, (err, stats) => {
if (err || stats.hasErrors()) {
// Handle errors here
if (stats) {
console.error(
stats.toString({
chunks: false,
colors: true,
}),
)
} else {
console.error(err.message)
}
}
})
} catch (err) {
console.error(err)
throw new Error('Error: there was an error building the webpack prod config.')
}
}

View File

@@ -0,0 +1,35 @@
import type { Payload } from 'payload'
import type { PayloadHandler } from 'payload/config'
import history from 'connect-history-api-fallback'
import express from 'express'
import webpack from 'webpack'
import webpackDevMiddleware from 'webpack-dev-middleware'
import webpackHotMiddleware from 'webpack-hot-middleware'
import { getDevConfig } from '../configs/dev'
const router = express.Router()
type DevAdminType = (options: { payload: Payload }) => Promise<PayloadHandler>
export const devAdmin: DevAdminType = async ({ payload }) => {
router.use(history())
try {
const webpackConfig = getDevConfig(payload.config)
const compiler = webpack(webpackConfig)
router.use(
webpackDevMiddleware(compiler, {
publicPath: '/',
}),
)
router.use(webpackHotMiddleware(compiler))
} catch (err) {
console.error(err)
throw new Error('Error: there was an error creating the webpack dev server.')
}
return router
}

View File

@@ -0,0 +1,41 @@
import type { Payload } from 'payload'
import type { PayloadHandler } from 'payload/config'
import compression from 'compression'
import history from 'connect-history-api-fallback'
import express from 'express'
const router = express.Router()
type ServeAdminType = (options: { payload: Payload }) => Promise<PayloadHandler>
export const serveAdmin: ServeAdminType = async ({ payload }) => {
router.use(history())
router.get('*', (req, res, next) => {
if (req.path.substr(-1) === '/' && req.path.length > 1) {
const query = req.url.slice(req.path.length)
res.redirect(301, req.path.slice(0, -1) + query)
} else {
next()
}
})
router.use(compression(payload.config.express.compression))
router.use(
express.static(payload.config.admin.buildPath, {
redirect: false,
setHeaders: (res, path) => {
const staticFilesRegex = new RegExp(
'.(svg|css|js|jp(e)?g|png|avif|webp|webm|gif|ico|woff|woff2|ttf|otf)$',
'i',
)
if (path.match(staticFilesRegex)) {
res.set('Cache-Control', `public, max-age=${60 * 60 * 24 * 365}, immutable`)
}
},
}),
)
return router
}

View File

@@ -2,14 +2,12 @@
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true, // Make sure typescript knows that this module depends on their references
"esModuleInterop": true,
"resolveJsonModule": true,
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
"rootDir": "./src",
"lib": ["dom", "dom.iterable", "esnext"],
"noEmit": false /* Do not emit outputs. */,
"emitDeclarationOnly": true
"emitDeclarationOnly": true,
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
"rootDir": "./src" /* Specify the root folder within your source files. */
},
"include": ["src/**/*.ts", "src/**/*.json"],
"exclude": ["src/all"]
"exclude": ["dist", "node_modules", ".eslintrc.js"],
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.d.ts", "src/**/*.json"],
"references": [{ "path": "../payload" }]
}

View File

@@ -6,8 +6,7 @@
"create-payload-app": "bin/cli.js"
},
"scripts": {
"build": "pnpm copyfiles && pnpm build:swc",
"copyfiles": "copyfiles -u 2 \"../../app/(payload)/**\" \"dist\"",
"build": "pnpm build:swc",
"build:swc": "swc ./src -d ./dist --config-file .swcrc",
"clean": "rimraf {dist,*.tsbuildinfo}",
"test": "jest",
@@ -23,13 +22,10 @@
"arg": "^5.0.0",
"chalk": "^4.1.0",
"command-exists": "^1.2.9",
"comment-json": "^4.2.3",
"degit": "^2.8.4",
"detect-package-manager": "^3.0.1",
"execa": "^5.0.0",
"figures": "^3.2.0",
"fs-extra": "^9.0.1",
"globby": "11.1.0",
"handlebars": "^4.7.7",
"ora": "^5.1.0",
"prompts": "^2.4.2",

View File

@@ -1,219 +0,0 @@
import type { CompilerOptions } from 'typescript'
import chalk from 'chalk'
import * as CommentJson from 'comment-json'
import { detect } from 'detect-package-manager'
import execa from 'execa'
import fs from 'fs'
import fse from 'fs-extra'
import globby from 'globby'
import path from 'path'
import type { CliArgs } from '../types'
import { copyRecursiveSync } from '../utils/copy-recursive-sync'
import { error, info, debug as origDebug, success, warning } from '../utils/log'
type InitNextArgs = Pick<CliArgs, '--debug'> & {
projectDir?: string
useDistFiles?: boolean
}
type InitNextResult = { reason?: string; success: boolean; userAppDir?: string }
export async function initNext(args: InitNextArgs): Promise<InitNextResult> {
args.projectDir = args.projectDir || process.cwd()
const { projectDir } = args
const templateResult = await applyPayloadTemplateFiles(args)
if (!templateResult.success) return templateResult
const { success: installSuccess } = await installDeps(projectDir)
if (!installSuccess) {
return { ...templateResult, reason: 'Failed to install dependencies', success: false }
}
// Create or find payload.config.ts
const createConfigResult = findOrCreatePayloadConfig(projectDir)
if (!createConfigResult.success) {
return { ...templateResult, ...createConfigResult }
}
// Add `@payload-config` to tsconfig.json `paths`
await addPayloadConfigToTsConfig(projectDir)
// Output directions for user to update next.config.js
const withPayloadMessage = `
${chalk.bold(`Wrap your existing next.config.js with the withPayload function. Here is an example:`)}
const { withPayload } = require("@payloadcms/next");
const nextConfig = {
// Your Next.js config
};
module.exports = withPayload(nextConfig);
`
console.log(withPayloadMessage)
return templateResult
}
async function addPayloadConfigToTsConfig(projectDir: string) {
const tsConfigPath = path.resolve(projectDir, 'tsconfig.json')
const userTsConfigContent = await fse.readFile(tsConfigPath, {
encoding: 'utf8',
})
const userTsConfig = CommentJson.parse(userTsConfigContent) as {
compilerOptions?: CompilerOptions
}
if (!userTsConfig.compilerOptions && !('extends' in userTsConfig)) {
userTsConfig.compilerOptions = {}
}
if (!userTsConfig.compilerOptions.paths?.['@payload-config']) {
userTsConfig.compilerOptions.paths = {
...(userTsConfig.compilerOptions.paths || {}),
'@payload-config': ['./payload.config.ts'],
}
await fse.writeFile(tsConfigPath, CommentJson.stringify(userTsConfig, null, 2))
}
}
async function applyPayloadTemplateFiles(args: InitNextArgs): Promise<InitNextResult> {
const { '--debug': debug, projectDir, useDistFiles } = args
info('Initializing Payload app in Next.js project', 1)
const logDebug = (message: string) => {
if (debug) origDebug(message)
}
if (!fs.existsSync(projectDir)) {
return { reason: `Could not find specified project directory at ${projectDir}`, success: false }
}
// Next.js configs can be next.config.js, next.config.mjs, etc.
const foundConfig = (await globby('next.config.*js', { cwd: projectDir }))?.[0]
const nextConfigPath = path.resolve(projectDir, foundConfig)
if (!fs.existsSync(nextConfigPath)) {
return {
reason: `No next.config.js found at ${nextConfigPath}. Ensure you are in a Next.js project directory.`,
success: false,
}
} else {
if (debug) logDebug(`Found Next config at ${nextConfigPath}`)
}
const templateFilesPath =
__dirname.endsWith('dist') || useDistFiles
? path.resolve(__dirname, '../..', 'dist/app')
: path.resolve(__dirname, '../../../../app')
if (debug) logDebug(`Using template files from: ${templateFilesPath}`)
if (!fs.existsSync(templateFilesPath)) {
return {
reason: `Could not find template source files from ${templateFilesPath}`,
success: false,
}
} else {
if (debug) logDebug('Found template source files')
}
// src/app or app
const userAppDirGlob = await globby(['**/app'], {
cwd: projectDir,
onlyDirectories: true,
})
const userAppDir = path.resolve(projectDir, userAppDirGlob?.[0])
if (!fs.existsSync(userAppDir)) {
return { reason: `Could not find user app directory inside ${projectDir}`, success: false }
} else {
logDebug(`Found user app directory: ${userAppDir}`)
}
logDebug(`Copying template files from ${templateFilesPath} to ${userAppDir}`)
copyRecursiveSync(templateFilesPath, userAppDir, debug)
success('Successfully initialized.')
return { success: true, userAppDir }
}
async function installDeps(projectDir: string) {
const packageManager = await detect({ cwd: projectDir })
if (!packageManager) {
throw new Error('Could not detect package manager')
}
info(`Installing dependencies with ${packageManager}`, 1)
const packagesToInstall = [
'payload',
'@payloadcms/db-mongodb',
'@payloadcms/next',
'@payloadcms/richtext-slate',
'@payloadcms/ui',
].map((pkg) => `${pkg}@alpha`)
let exitCode = 0
switch (packageManager) {
case 'npm': {
;({ exitCode } = await execa('npm', ['install', '--save', ...packagesToInstall], {
cwd: projectDir,
}))
break
}
case 'yarn':
case 'pnpm': {
;({ exitCode } = await execa(packageManager, ['add', ...packagesToInstall], {
cwd: projectDir,
}))
break
}
case 'bun': {
warning('Bun support is untested.')
;({ exitCode } = await execa('bun', ['add', ...packagesToInstall], { cwd: projectDir }))
break
}
}
if (exitCode !== 0) {
error(`Failed to install dependencies with ${packageManager}`)
} else {
success(`Successfully installed dependencies`)
}
return { success: exitCode === 0 }
}
function findOrCreatePayloadConfig(projectDir: string) {
const configPath = path.resolve(projectDir, 'payload.config.ts')
if (fs.existsSync(configPath)) {
return { message: 'Found existing payload.config.ts', success: true }
} else {
// Create default config
// TODO: Pull this from templates
const defaultConfig = `import path from "path";
import { mongooseAdapter } from "@payloadcms/db-mongodb"; // database-adapter-import
import { slateEditor } from "@payloadcms/richtext-slate"; // editor-import
import { buildConfig } from "payload/config";
export default buildConfig({
editor: slateEditor({}), // editor-config
collections: [],
secret: "asdfasdf",
typescript: {
outputFile: path.resolve(__dirname, "payload-types.ts"),
},
graphQL: {
schemaOutputFile: path.resolve(__dirname, "generated-schema.graphql"),
},
db: mongooseAdapter({
url: "mongodb://localhost:27017/next-payload-3",
}),
});
`
fse.writeFileSync(configPath, defaultConfig)
return { message: 'Created default payload.config.ts', success: true }
}
}

View File

@@ -6,13 +6,12 @@ import type { CliArgs, PackageManager } from './types'
import { createProject } from './lib/create-project'
import { generateSecret } from './lib/generate-secret'
import { initNext } from './lib/init-next'
import { parseProjectName } from './lib/parse-project-name'
import { parseTemplate } from './lib/parse-template'
import { selectDb } from './lib/select-db'
import { getValidTemplates, validateTemplate } from './lib/templates'
import { writeEnvFile } from './lib/write-env-file'
import { error, success } from './utils/log'
import { success } from './utils/log'
import { helpMessage, successMessage, welcomeMessage } from './utils/messages'
export class Main {
@@ -28,9 +27,6 @@ export class Main {
'--secret': String,
'--template': String,
// Next.js
'--init-next': Boolean,
// Package manager
'--no-deps': Boolean,
'--use-npm': Boolean,
@@ -39,7 +35,6 @@ export class Main {
// Flags
'--beta': Boolean,
'--debug': Boolean,
'--dry-run': Boolean,
// Aliases
@@ -58,17 +53,6 @@ export class Main {
console.log(helpMessage())
process.exit(0)
}
if (this.args['--init-next']) {
const result = await initNext(this.args)
if (!result.success) {
error(result.reason || 'Failed to initialize Payload app in Next.js project')
} else {
success('Payload app successfully initialized in Next.js project')
}
process.exit(result.success ? 0 : 1)
}
const templateArg = this.args['--template']
if (templateArg) {
const valid = validateTemplate(templateArg)

View File

@@ -3,10 +3,8 @@ import type arg from 'arg'
export interface Args extends arg.Spec {
'--beta': BooleanConstructor
'--db': StringConstructor
'--debug': BooleanConstructor
'--dry-run': BooleanConstructor
'--help': BooleanConstructor
'--init-next': BooleanConstructor
'--name': StringConstructor
'--no-deps': BooleanConstructor
'--secret': StringConstructor
@@ -14,9 +12,6 @@ export interface Args extends arg.Spec {
'--use-npm': BooleanConstructor
'--use-pnpm': BooleanConstructor
'--use-yarn': BooleanConstructor
// Aliases
'-h': string
'-n': string
'-t': string

View File

@@ -1,19 +0,0 @@
import fs from 'fs'
import path from 'path'
/**
* Recursively copy files from src to dest
*/
export function copyRecursiveSync(src: string, dest: string, debug?: boolean) {
const exists = fs.existsSync(src)
const stats = exists && fs.statSync(src)
const isDirectory = exists && stats.isDirectory()
if (isDirectory) {
fs.mkdirSync(dest, { recursive: true })
fs.readdirSync(src).forEach((childItemName) => {
copyRecursiveSync(path.join(src, childItemName), path.join(dest, childItemName))
})
} else {
fs.copyFileSync(src, dest)
}
}

View File

@@ -9,18 +9,10 @@ export const warning = (message: string): void => {
console.log(chalk.yellow('? ') + chalk.bold(message))
}
export const info = (message: string, paddingTop?: number): void => {
console.log(
`${'\n'.repeat(paddingTop || 0)}${chalk.green(figures.pointerSmall)} ${chalk.bold(message)}`,
)
export const info = (message: string): void => {
console.log(`${chalk.yellow(figures.info)} ${chalk.bold(message)}`)
}
export const error = (message: string): void => {
console.log(`${chalk.red(figures.cross)} ${chalk.bold(message)}`)
}
export const debug = (message: string): void => {
console.log(
`${chalk.gray(figures.pointerSmall)} ${chalk.bgGray('[DEBUG]')} ${chalk.gray(message)}`,
)
}

View File

@@ -10,6 +10,6 @@
}
},
"module": {
"type": "es6"
"type": "commonjs"
}
}

View File

@@ -1,11 +1,10 @@
{
"name": "@payloadcms/db-mongodb",
"version": "3.0.0-alpha.23",
"description": "The officially supported MongoDB database adapter for Payload - Update 2",
"version": "1.4.3",
"description": "The officially supported MongoDB database adapter for Payload",
"repository": "https://github.com/payloadcms/payload",
"license": "MIT",
"homepage": "https://payloadcms.com",
"type": "module",
"author": {
"email": "info@payloadcms.com",
"name": "Payload",
@@ -18,17 +17,17 @@
"build:swc": "swc ./src -d ./dist --config-file .swcrc",
"build:types": "tsc --emitDeclarationOnly --outDir dist",
"clean": "rimraf {dist,*.tsbuildinfo}",
"prepublishOnly": "pnpm clean && pnpm turbo build"
"prepublishOnly": "pnpm clean && pnpm build"
},
"dependencies": {
"bson-objectid": "2.0.4",
"deepmerge": "4.3.1",
"get-port": "5.1.1",
"http-status": "1.6.2",
"mongoose": "6.12.3",
"mongoose-aggregate-paginate-v2": "1.0.6",
"mongoose-paginate-v2": "1.7.22",
"prompts": "2.4.2",
"http-status": "1.6.2",
"uuid": "9.0.0"
},
"devDependencies": {
@@ -39,7 +38,7 @@
"payload": "workspace:*"
},
"peerDependencies": {
"payload": "workspace:*"
"payload": "^2.0.0"
},
"publishConfig": {
"main": "./dist/index.js",

View File

@@ -4,26 +4,19 @@ import type { Connect } from 'payload/database'
import mongoose from 'mongoose'
import type { MongooseAdapter } from './index.d.ts'
export const connect: Connect = async function connect(
this: MongooseAdapter,
options = {
hotReload: false,
},
) {
const { hotReload } = options
import type { MongooseAdapter } from '.'
export const connect: Connect = async function connect(this: MongooseAdapter, payload) {
if (this.url === false) {
return
}
if (typeof this.url !== 'string') {
if (!payload.local && typeof this.url !== 'string') {
throw new Error('Error: missing MongoDB connection URL.')
}
const urlToConnect = this.url
const successfulConnectionMessage = 'Connected to MongoDB server successfully!'
let urlToConnect = this.url
let successfulConnectionMessage = 'Connected to MongoDB server successfully!'
const connectionOptions: ConnectOptions & { useFacet: undefined } = {
autoIndex: true,
@@ -31,7 +24,29 @@ export const connect: Connect = async function connect(
useFacet: undefined,
}
if (hotReload) connectionOptions.autoIndex = false
if (process.env.NODE_ENV === 'test') {
if (process.env.PAYLOAD_TEST_MONGO_URL) {
urlToConnect = process.env.PAYLOAD_TEST_MONGO_URL
} else {
connectionOptions.dbName = 'payloadmemory'
const { MongoMemoryReplSet } = require('mongodb-memory-server')
const getPort = require('get-port')
const port = await getPort()
this.mongoMemoryServer = await MongoMemoryReplSet.create({
instance: {
dbName: 'payloadmemory',
port,
},
replSet: {
count: 3,
},
})
urlToConnect = this.mongoMemoryServer.getUri()
successfulConnectionMessage = 'Connected to in-memory MongoDB server successfully!'
}
}
try {
this.connection = (await mongoose.connect(urlToConnect, connectionOptions)).connection
@@ -43,15 +58,12 @@ export const connect: Connect = async function connect(
this.beginTransaction = undefined
}
if (!hotReload) {
if (process.env.PAYLOAD_DROP_DATABASE === 'true') {
this.payload.logger.info('---- DROPPING DATABASE ----')
await mongoose.connection.dropDatabase()
this.payload.logger.info('---- DROPPED DATABASE ----')
}
this.payload.logger.info(successfulConnectionMessage)
if (process.env.PAYLOAD_DROP_DATABASE === 'true') {
this.payload.logger.info('---- DROPPING DATABASE ----')
await mongoose.connection.dropDatabase()
this.payload.logger.info('---- DROPPED DATABASE ----')
}
this.payload.logger.info(successfulConnectionMessage)
} catch (err) {
this.payload.logger.error(`Error: cannot connect to MongoDB. Details: ${err.message}`, err)
process.exit(1)

View File

@@ -1,10 +1,10 @@
import type { Create } from 'payload/database'
import type { Document, PayloadRequest } from 'payload/types'
import type { MongooseAdapter } from './index.d.ts'
import type { MongooseAdapter } from '.'
import handleError from './utilities/handleError.js'
import { withSession } from './withSession.js'
import handleError from './utilities/handleError'
import { withSession } from './withSession'
export const create: Create = async function create(
this: MongooseAdapter,

View File

@@ -1,10 +1,10 @@
import type { CreateGlobal } from 'payload/database'
import type { PayloadRequest } from 'payload/types'
import type { MongooseAdapter } from './index.d.ts'
import type { MongooseAdapter } from '.'
import sanitizeInternalFields from './utilities/sanitizeInternalFields.js'
import { withSession } from './withSession.js'
import sanitizeInternalFields from './utilities/sanitizeInternalFields'
import { withSession } from './withSession'
export const createGlobal: CreateGlobal = async function createGlobal(
this: MongooseAdapter,

View File

@@ -2,9 +2,9 @@ import type { CreateGlobalVersion } from 'payload/database'
import type { PayloadRequest } from 'payload/types'
import type { Document } from 'payload/types'
import type { MongooseAdapter } from './index.d.ts'
import type { MongooseAdapter } from '.'
import { withSession } from './withSession.js'
import { withSession } from './withSession'
export const createGlobalVersion: CreateGlobalVersion = async function createGlobalVersion(
this: MongooseAdapter,

View File

@@ -41,7 +41,7 @@ export const createMigration: CreateMigration = async function createMigration({
// Check if predefined migration exists
if (fs.existsSync(cleanPath)) {
const { down, up } = eval(`require(${cleanPath})`)
const { down, up } = require(cleanPath)
migrationFileContent = migrationTemplate(up, down)
} else {
payload.logger.error({

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