payload

The best way to build a modern backend + admin UI. No black magic, all TypeScript, and fully open-source, Payload is both an app framework and a headless CMS.

MIT License

Downloads
1.5M
Stars
19.2K
Committers
263

Bot releases are hidden (Show)

payload - Release 1.6.10

Published by DanRibbens over 1 year ago

1.6.10 (2023-02-14)

Bug Fixes

  • #2077 useAPIKey UI missing with disableLocalStrategy (#2084) (586b25a)
  • Add missing Spanish translations and fix typos (c4742e5)
  • document type in update request handler (d5cd970)
  • ensures versions createdAt matches the original doc (8c7e37c)
  • globals not saving drafts unless published first (#2082) (4999fba)
  • Use the user's AdminUI locale for the DatePicker (#2046) (#2057) (b4a7e91)
  • validate type (7bb0984)

Features

payload - Release 1.6.9

Published by jmikrut over 1 year ago

1.6.9 (2023-02-10)

Bug Fixes

  • adds query constraint to ensureMaxVersions query (30688bb)
  • translation of "or" -> "ou" in french (#2047) (dddbec2)

Features

  • allows customization of the folder used to serve admin bundled files in production (4d259a6)
payload - Release 1.6.7

Published by jmikrut over 1 year ago

1.6.7 (2023-02-08)

Bug Fixes

  • drawer state was not set when opened (e6ac872)
payload - Release 1.6.6

Published by jmikrut over 1 year ago

1.6.6 (2023-02-07)

Bug Fixes

  • #1887, dataloader rich text population infinite loop (ac2e174)
  • enables locales with date field (aefb655)
payload - Release 1.6.5

Published by jmikrut over 1 year ago

1.6.5 (2023-02-07)

Bug Fixes

  • allows radio input to be tabbable (b5880f2)
  • auth type leaking into type gen (1f0a1c7)
  • corrects keyboard accessibility for checkbox field (65b8fd2)
  • ensures preview is enabled before rendering button (e968f40)
  • local API update typing (#2010) (4b0d4f4), closes #2009
  • max versions incorrectly sorting, causing incorrect versions to be held onto (2e4f7ab)
  • named tabs not displaying data in versions view (a41e295)
  • replaced media not rendering after document save (827428d)
  • webpack css-loader resolve urls (ade4c01)

Features

payload - Release 1.6.4

Published by jmikrut over 1 year ago

1.6.4 (2023-02-03)

Bug Fixes

  • only hoists localized values if localization is enabled (8c65f6a)

Features

payload - Release 1.6.3

Published by jmikrut over 1 year ago

1.6.3 (2023-02-01)

Bug Fixes

  • properly await graphql schema generation (888b3a2)
payload - Release 1.6.2

Published by jmikrut over 1 year ago

1.6.2 (2023-02-01)

payload - Release 1.6.1

Published by jmikrut over 1 year ago

1.6.1 (2023-02-01)

Bug Fixes

  • #1870 and #1859 (c0ac155)
  • aligns global preview config with the docs (#1940) (e7908b7)
  • collection view pagination with limits resulting in empty list (8b778b6)
  • corrects type for required named tab fields (#1939) (3058eb5)
  • creates backup of latest version after restoring draft #1873 (bd4da37)
  • disables escapeValue for i18n (#1886) (eec4b3a)
  • ensures loader disappears after unsuccessful login, adjusts mobile loader styles (#1948) (3d854f7)
  • hides fallback locale checkbox when field localization is set to false (#1893) (0623039)
  • limits and sorts within pagination and not on initial aggregation (9b613ee)
  • relation to many index unique fields (#1979) (453a903)
  • updated nl i18n typos (cc7257e)
  • versions error on cosmos db (338c4e2)

Features

  • add Chinese translation (#1926) (7c6ff89)
  • add Croatian translation (#1982) (dfa47a0)
  • allows versions to be deleted alongside of main document deletion (a5c76d4)
  • blocks drawer #1909 (339cee4)
  • explicitly exports utilities (1efc6f5)
  • isolates local api to local-only functions, converts it to ts generic for stronger typing (d3d367c)
  • requires ts-node to start a project for any config that uses ts or jsx (f1c342e)
  • simplifies versions logic (8cfa550)

🚨 BREAKING CHANGES

βœ‹ Payload now no longer transpiles your config for you

This release removes the need to use @swc/register to automatically transpile Payload configs, which dramatically improves Payload initialization speeds and simplifies the core Payload logic significantly. More info in the PR here.

If you are not using TypeScript, this will be a breaking change. There are many ways to mitigate this - but the best way is to just quickly scaffold a barebones TS implementation. You can still write JavaScript, and this PR does not require you to write TS, but handling transpilation with TypeScript will be an easy way forward and can set you up to opt-in to TS over time as well.

For instructions regarding how to migrate to TS, review the PR here.

βœ‹ Payload init is now always async, and payload.initAsync has been removed

We are pulling off a bandaid here and enforcing that payload.init is now asynchronous across the board. This will help prevent issues in the future and allow us to do more advanced things within init down the road. But this will be a breaking change if your project uses payload.init right now.

To migrate, you need to convert your code everywhere that you run payload.init to be asynchronous instead. For example, here is an example of a traditional payload.init call which needs to be migrated:

const express = require("express");
const payload = require("payload");

const app = express();

payload.init({
  secret: "SECRET_KEY",
  mongoURL: "mongodb://localhost/payload",
  express: app,
});

app.listen(3000, async () => {
  console.log(
    "Express is now listening for incoming connections on port 3000."
  );
});

Your payload.init call will need to be converted into the following:

const express = require("express");
const payload = require("payload");

const app = express();

const start = async () => {
  await payload.init({
    secret: "SECRET_KEY",
    mongoURL: "mongodb://localhost/payload",
    express: app,
  });

  app.listen(3000, async () => {
    console.log(
      "Express is now listening for incoming connections on port 3000."
    );
  });
};

start();

Notice that all we've done is wrapped the payload.init and app.listen calls with a start function that is asynchronous.

βœ‹ All Local API methods are no longer typed as generics, and instead will infer types for you automatically

Before this release, the Local API methods were configured as generics. For example, here is an example of the findByID method prior to this release:

const post = await payload.findByID<Post>({
  collection: "posts",
  id: "id-of-post-here",
});

Now, you don't need to pass your types and Payload will automatically infer them for you, as well as significantly improve typing throughout the local API. Here's an example:

const post = await payload.findByID({
  collection: "posts", // this is now auto-typed
  id: "id-of-post-here",
});

// `post` will be automatically typed as `Post`

To migrate, just remove the generic implementation!

But there's one more thing to do before Payload can automatically type your Local API. You need to add a path to your tsconfig.json file that matches your exported types from Payload:

{
  "compilerOptions": {
    // your compilerOptions here
    "paths": {
      // Tell TS where to find your generated types
      // This is the default location below
      "payload/generated-types": ["./src/payload-types.ts"]
    }
  }
}

Then go regenerate your types. We've extended the payload generate:types method a bit to be more complete. Upon regenerating types, you'll see a new Config export at the top of the file which contains a key - value pair of all your collection and global types, which Payload will automatically import.

βœ‹ JSX support must be defined in tsconfig.json

If not already defined, add the following to your compilerOptions:

  "compilerOptions": {
    "jsx": "react"
  }

βœ‹ Versions may need to be migrated

This release includes a substantial simplification / optimization of how Versions work within Payload. They are now significantly more performant and easier to understand behind-the-scenes. We've removed ~600 lines of code and have ensured that Payload can be compatible with all flavors of Mongo - including versions earlier than 4.0, Azure Cosmos MongoDB, AWS' DocumentDB and more.

But, some of your draft-enabled documents may need to be migrated.

If you are using versions and drafts on any collections, you can run a simple migration script to ensure that your drafts appear correctly in the Admin UI. Your data will never disappear from your database in any case if you update, but some drafts may not show in the List view anymore.

To migrate, create this file within the root of your Payload project:

migrateVersions.ts

const payload = require("payload");

require("dotenv").config();

const { PAYLOAD_SECRET, MONGODB_URI } = process.env;

// This function ensures that there is at least one corresponding version for any document
// within each of your draft-enabled collections.

const ensureAtLeastOneVersion = async () => {
  // Initialize Payload
  // IMPORTANT: make sure your ENV variables are filled properly here
  // as the below variable names are just for reference.
  await payload.init({
    secret: PAYLOAD_SECRET,
    mongoURL: MONGODB_URI,
    local: true,
  });

  // For each collection
  await Promise.all(
    payload.config.collections.map(async ({ slug, versions }) => {
      // If drafts are enabled
      if (versions?.drafts) {
        const { docs } = await payload.find({
          collection: slug,
          limit: 0,
          depth: 0,
          locale: "all",
        });

        const VersionsModel = payload.versions[slug];
        const existingCollectionDocIds: Array<string> = [];
        await Promise.all(
          docs.map(async (doc) => {
            existingCollectionDocIds.push(doc.id);
            // Find at least one version for the doc
            const versionDocs = await VersionsModel.find(
              {
                parent: doc.id,
                updatedAt: { $gte: doc.updatedAt },
              },
              null,
              { limit: 1 }
            ).lean();

            // If there are no corresponding versions,
            // we need to create one
            if (versionDocs.length === 0) {
              try {
                await VersionsModel.create({
                  parent: doc.id,
                  version: doc,
                  autosave: Boolean(versions?.drafts?.autosave),
                  updatedAt: doc.updatedAt,
                  createdAt: doc.createdAt,
                });
              } catch (e) {
                console.error(
                  `Unable to create version corresponding with collection ${slug} document ID ${doc.id}`,
                  e?.errors || e
                );
              }

              console.log(
                `Created version corresponding with ${slug} document ID ${doc.id}`
              );
            }
          })
        );

        const versionsWithoutParentDocs = await VersionsModel.deleteMany({
          parent: { $nin: existingCollectionDocIds },
        });

        if (versionsWithoutParentDocs.deletedCount > 0) {
          console.log(
            `Removing ${versionsWithoutParentDocs.deletedCount} versions for ${slug} collection - parent documents no longer exist`
          );
        }
      }
    })
  );

  console.log("Done!");
  process.exit(0);
};

ensureAtLeastOneVersion();

Make sure your environment variables match the script's values above and then run PAYLOAD_CONFIG_PATH=src/payload.config.ts npx ts-node -T migrateVersions.ts in your terminal. Make sure that you point the command to your Payload config.

This migration script will ensure that there is at least one corresponding version for each of your draft-enabled documents. It will also delete any versions that no longer have parent documents.

πŸ‘€ Example of a properly migrated project

For an example of how everything works with this update, go ahead and run npx create-payload-app. We've updated create-payload-app to reflect all the necessary changes here and you can use a new project to compare / contrast what you have in your current project with what Payload needs now in this release.

payload - Release 1.5.9

Published by jmikrut almost 2 years ago

1.5.9 (2023-01-15)

Bug Fixes

  • #1877, #1867 - mimeTypes and imageSizes no longer cause error in admin ui (b06ca70)
payload - Release 1.5.8

Published by jmikrut almost 2 years ago

1.5.8 (2023-01-12)

Features

  • throws descriptive error when collection or global slug not found (b847d85)
payload - Release 1.5.7

Published by jmikrut almost 2 years ago

1.5.7 (2023-01-12)

Bug Fixes

  • ensures find with draft=true does not improperly exclude draft ids (69026c5)
  • ensures querying with drafts works on both published and non-published posts (f018fc0)
payload - Release 1.5.6

Published by jmikrut almost 2 years ago

1.5.6 (2023-01-11)

Bug Fixes

  • ensures that find with draft=true returns ids with drafts (3f30b2f)
payload - Release 1.5.5

Published by jmikrut almost 2 years ago

1.5.5 (2023-01-11)

Bug Fixes

  • #1808, arrays and blocks now save localized nested field data upon reordering rows (ee54c14)
  • bug when clearing relationship field without hasMany: true (#1829) (ed7cfff)
  • ensures upload file data is available for conditions (d40e136)
  • fix miss typo in Thai translation (25e5ab7)
  • formats date when useAsTitle (086117d)
  • prevents uploads drawer from crashing when no uploads are enabled (84e1417)
  • rte link element initial state #1848 (1cde647)
  • updatesmargin for group field within a row (1c3a257)
  • upload field filterOptions (9483ccb)
  • wrong translation and punctuation spacing (bf1242a)

Features

  • adds translations for fallbackToDefaultLocale (c247f31)
  • ensures compatibility with azure cosmos and aws documentdb (73af283)
payload - Release 1.5.4

Published by jmikrut almost 2 years ago

1.5.4 (2023-01-06)

Features

  • allows init to accept a pre-built config (84e00bf)
payload - Release 1.5.3

Published by jmikrut almost 2 years ago

1.5.3 (2023-01-05)

Bug Fixes

  • theme flicker on code editor (6567454)
payload - Release 1.5.2

Published by jmikrut almost 2 years ago

1.5.2 (2023-01-04)

Bug Fixes

  • ignores admin and components from swc (7d27431)
payload - Release 1.5.1

Published by jmikrut almost 2 years ago

1.5.1 (2023-01-04)

Bug Fixes

  • reverts components directory back to ts (1bbf099)
payload - Release 1.5.0

Published by jmikrut almost 2 years ago

1.5.0 (2023-01-04)

Bug Fixes

Features

payload - Release 1.4.2

Published by jmikrut almost 2 years ago

1.4.2 (2023-01-03)

Bug Fixes

  • #1775 - siblingData for unnamed fields within array rows improperly formatted (d6fcd19)
  • #1786, relationship with hasMany no longer sets empty array as default value (ecfb363)
  • error clearing date field (883daf7)
  • select field crash on missing value option (ec9196e)

Features

  • add Ukrainian translation (#1767) (49fa5cb)
  • preview now exposes most recent draft data (54dadbe)