Home

>

Tools

>

Payload CMS

>

Releases

>

3.0.0-beta.57

Payload CMS Release: 3.0.0-beta.57

Pre Release

Tag Name: v3.0.0-beta.57

Release Date: 7/2/2024

Payload CMS LogoPayload CMS

Payload CMS is a modern, self-hosted headless content management system built with TypeScript, Node.js, and MongoDB. It's designed specifically for developers who want full control over their content management system while maintaining a powerful admin interface for content editors.

TL;DR

PayloadCMS v3.0.0-beta.57 brings significant enhancements to the developer experience with new features like username-based login, improved filtering capabilities for group and tab fields, and better TypeScript support. This release also includes important exports from the SEO plugin, fixes for translation fallbacks and UI alignment issues, and introduces breaking changes to API handlers and Lexical rich text editor. Developers should review the migration guide before upgrading, especially if they're using the Lexical API directly or the modified request handling functions.

Highlight of the Release

    • New loginWithUsername option for authentication configuration
    • Ability to filter by fields within groups and named tabs in list views
    • Exported SEO plugin fields for flexible implementation in collections
    • Improved TypeScript support with JSON field type generation and schema customization
    • Lexical rich text editor upgraded from 0.16.0 to 0.16.1
    • Simplified API handler with streamlined request handling

Migration Guide

Breaking Changes Migration

API Handler Changes

If you're using PayloadRequestWithData or the related request handling functions, you'll need to update your code:

// Before
await addDataAndFileToRequest({ request: req })
addLocalesToRequestFromData({ request: req })

// After
await addDataAndFileToRequest(req)
addLocalesToRequestFromData(req)

Also note that PayloadRequestWithData has been removed in favor of PayloadRequest with optional types for data and locale.

Lexical Rich Text Editor Upgrade

If you're using the Lexical API directly, be aware that the upgrade from 0.16.0 to 0.16.1 may include undocumented breaking changes. Please review the Lexical changelog for details.

New Features Implementation

Username-based Login

To implement username-based login:

const config = buildConfig({
  collections: [
    {
      slug: 'users',
      auth: {
        loginWithUsername: true,
        // username field will be automatically injected
        // email field will still be required but not unique
      },
    },
  ],
})

Using SEO Plugin Fields

To use the exported SEO plugin fields:

import { 
  MetaDescriptionField, 
  MetaImageField, 
  MetaTitleField, 
  OverviewField, 
  PreviewField 
} from '@payloadcms/plugin-seo/fields'

const collection = {
  slug: 'pages',
  fields: [
    // Other fields...
    MetaTitleField({
      hasGenerateFn: true,
    }),
    MetaDescriptionField({
      hasGenerateFn: true,
    }),
    MetaImageField({
      relationTo: 'media',
      hasGenerateFn: true,
    }),
  ]
}

Custom TypeScript Schema

To customize TypeScript type generation:

const config = buildConfig({
  typescript: {
    schema: (generatedSchema) => {
      // Modify the generated schema
      return {
        ...generatedSchema,
        // Your customizations
      }
    }
  }
})

Upgrade Recommendations

For Development Environments

We recommend upgrading to v3.0.0-beta.57 in development environments to test the new features and ensure compatibility with your codebase, especially if you're using:

  1. Custom API handlers with PayloadRequestWithData
  2. Direct Lexical API integrations
  3. TypeScript with custom field types

For Production Environments

As this is still a beta release, exercise caution when upgrading production environments. If you need the specific features or bug fixes in this release, consider:

  1. Creating a staging environment to test the upgrade first
  2. Reviewing the breaking changes and ensuring your codebase is compatible
  3. Having a rollback plan in case of unexpected issues

Upgrade Steps

  1. Update your package.json:

    npm install @payloadcms/[email protected]
    

    or

    yarn add @payloadcms/[email protected]
    
  2. If using the SEO plugin or Lexical rich text editor, update those packages as well:

    npm install @payloadcms/plugin-seo@latest @payloadcms/richtext-lexical@latest
    
  3. Review your codebase for any usage of the changed APIs mentioned in the migration guide

  4. Run your test suite to ensure compatibility

Bug Fixes

UI Fixes

  • Fixed content alignment issues in modal windows (issue #6936)
  • Fixed auto link node escaping on second "." in Lexical rich text editor

Translation Fixes

  • Fixed translation fallback language returning the label instead of the language key (issue #6986)
  • This ensures proper language key usage in fallback scenarios

Other Fixes

  • Added user type argument to generate email HTML and subject types (issue #6953)
  • The following types now accept User type arguments:
    • GenerateVerifyEmailHTML<User>
    • GenerateVerifyEmailSubject<User>
    • GenerateForgotPasswordEmailHTML<User>
    • GenerateForgotPasswordEmailSubject<User>
  • Added threads for customActions through to FileDetails component

New Features

Authentication Enhancements

  • Added loginWithUsername option to auth config, allowing username-based login instead of email-based authentication
  • Email field remains required but no longer needs to be unique when username login is enabled
  • Username field can be extended by passing a custom field configuration

Improved Filtering

  • Added ability to filter by fields within group and named tab fields via list controls
  • Added missing translations for within and intersects operator options for point and JSON fields

TypeScript Improvements

  • Added typescriptSchema property to fields for overriding default type generation
  • Added typescript.schema property in payload config for modifying type schemas
  • Improved type for jsonSchema property of JSON field
  • Added type generation for JSON field with jsonSchema

SEO Plugin Enhancements

  • Added Russian translations for the SEO plugin
  • Exported individual fields from the SEO plugin for flexible implementation:
    • MetaDescriptionField
    • MetaImageField
    • MetaTitleField
    • OverviewField
    • PreviewField

Exported Utilities

  • Exported iterateFields function from @payloadcms/ui/forms/buildStateFromSchema
  • Exported various missing utilities and types from PayloadCMS core

Rich Text Editor Updates

  • Upgraded Lexical rich text editor from 0.16.0 to 0.16.1
  • Fixed auto link node escaping on second "." character

Security Updates

No specific security fixes were mentioned in this release.

Performance Improvements

API Handler Optimization

  • Simplified API handler by removing PayloadRequestWithData in favor of just PayloadRequest with optional types for data and locale
  • Streamlined request handling functions to take a single argument instead of an object, reducing overhead

Type Generation Improvements

  • Enhanced TypeScript type generation for JSON fields, improving development experience and type safety
  • Added ability to customize and extend generated types, which can lead to better IDE performance with more accurate types

Impact Summary

PayloadCMS v3.0.0-beta.57 delivers substantial improvements to developer experience and content management capabilities. The introduction of username-based authentication provides more flexibility in user management, while the ability to filter by fields within groups and tabs significantly enhances content discovery for editors.

For developers, the release offers better TypeScript support with customizable type generation and improved JSON field typing. The exported SEO plugin fields enable more modular and flexible implementation of SEO features across collections. The simplified API handler improves code clarity, though it introduces breaking changes that require attention during upgrade.

Content editors will benefit from UI improvements, including better modal alignment and enhanced filtering capabilities. International users gain Russian translations for the SEO plugin and improved translation fallback behavior.

The Lexical rich text editor upgrade brings the latest improvements but may introduce breaking changes for those using the Lexical API directly. Overall, this release balances new features with important bug fixes and performance improvements, making it a valuable update for most PayloadCMS users, though the breaking changes require careful consideration during the upgrade process.

Full Release Notes

v3.0.0-beta.57 (2024-07-02)

Features

  • ui: allows filtering on group and tab fields from list controls (#6647) (d4d4101)
  • richtext-lexical: upgrade lexical from 0.16.0 to 0.16.1 (#7009) (2a2ab53)
  • allow users/plugins to modify and extend generated types for fields & config, add generated types for json field (#6984) (eb2f763)
  • adds loginWithUsername option to auth config (#7000) (955b845)
  • plugin-seo: export fields from plugin seo so that they can be imported freely in a collection fields config (#6996) (25d368a)
  • ui: export iterateFields function (#6995) (cce1397)
  • export missing utilities and types from payload (#6993) (d05a033)
  • plugin-seo: russian translations (#6987) (2285624)

Bug Fixes

  • richtext-lexical: auto link node escapes on second "." (98ff746)
  • ui: content alignment in modal (#7003) (fd7d500)
  • translation fallback language returning the label and not the language key (#7001) (9ab057d)

BREAKING CHANGES

  • richtext-lexical: upgrade lexical from 0.16.0 to 0.16.1 (#7009) (2a2ab53)

BREAKING: Lexical may introduce undocumented breaking changes, if
you use the lexical API directly. Please consult their changelog:
https://github.com/facebook/lexical/releases/tag/v0.16.1

Removes PayloadRequestWithData in favour of just PayloadRequest with
optional types for data and locale

addDataAndFileToRequest and addLocalesToRequestFromData now takes in
a single argument instead of an object

// before
await addDataAndFileToRequest({ request: req })
addLocalesToRequestFromData({ request: req })

// current
await addDataAndFileToRequest(req)
addLocalesToRequestFromData(req)

Contributors

Statistics:

File Changed300
Line Additions2,107
Line Deletions1,310
Line Changes3,417
Total Commits16

User Affected:

  • Can now use username-based login instead of email-based authentication
  • Have access to exported utilities and types from PayloadCMS core
  • Can modify and extend generated TypeScript types for fields and configurations
  • Need to update code if using PayloadRequestWithData or related functions due to breaking changes
  • Can use exported SEO plugin fields in custom collection configurations

Contributors:

HarleySalasAlessioGrJarrodMFleschpaulpopusjessrynkarr1tsuudenolfe