From f1c342e05eb84254c9d84a425b4f0da1249fcef3 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 10 Jan 2023 11:48:40 -0500 Subject: [PATCH 01/46] feat: requires ts-node to start a project for any config that uses ts or jsx --- nodemon.json | 2 +- package.json | 3 +-- src/config/load.ts | 19 ------------------ test/dev.js | 36 ----------------------------------- test/{devServer.ts => dev.ts} | 22 ++++++++++++++++++++- tsconfig.json | 3 +++ yarn.lock | 20 +++---------------- 7 files changed, 29 insertions(+), 76 deletions(-) delete mode 100644 test/dev.js rename test/{devServer.ts => dev.ts} (62%) diff --git a/nodemon.json b/nodemon.json index 75486eb218..e88a0eb694 100644 --- a/nodemon.json +++ b/nodemon.json @@ -12,5 +12,5 @@ "test/" ], "ext": "ts,js,json", - "exec": "node ./test/dev.js" + "exec": "ts-node ./test/dev.ts" } diff --git a/package.json b/package.json index dd29aed36a..b986a78066 100644 --- a/package.json +++ b/package.json @@ -88,7 +88,6 @@ "@faceless-ui/window-info": "^2.0.2", "@monaco-editor/react": "^4.4.6", "@swc/core": "^1.3.24", - "@swc/register": "^0.1.10", "body-parser": "^1.19.0", "bson-objectid": "^2.0.1", "compression": "^1.7.4", @@ -181,6 +180,7 @@ "swc-minify-webpack-plugin": "^1.0.1", "terser-webpack-plugin": "^5.0.3", "ts-essentials": "^7.0.1", + "ts-node": "^10.9.1", "url-loader": "^4.1.1", "use-context-selector": "^1.4.1", "uuid": "^8.1.0", @@ -284,7 +284,6 @@ "shelljs": "^0.8.5", "slash": "^3.0.0", "start-server-and-test": "^1.14.0", - "ts-node": "^10.9.1", "typescript": "^4.1.2" }, "files": [ diff --git a/src/config/load.ts b/src/config/load.ts index b5e62595c1..c55ba97710 100644 --- a/src/config/load.ts +++ b/src/config/load.ts @@ -1,7 +1,6 @@ /* eslint-disable import/no-dynamic-require */ /* eslint-disable global-require */ // eslint-disable-next-line import/no-extraneous-dependencies -import swcRegister from '@swc/register'; import path from 'path'; import pino from 'pino'; import Logger from '../utilities/logger'; @@ -15,24 +14,6 @@ const loadConfig = (logger?: pino.Logger): SanitizedConfig => { const configPath = findConfig(); - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - swcRegister({ - sourceMaps: 'inline', - jsc: { - parser: { - syntax: 'typescript', - tsx: true, - }, - }, - ignore: [ - /node_modules[\\/](?!.pnpm[\\/].*[\\/]node_modules[\\/])(?!payload[\\/]dist[\\/]admin|payload[\\/]components).*/, - ], - module: { - type: 'commonjs', - }, - }); - clientFiles.forEach((ext) => { require.extensions[ext] = () => null; }); diff --git a/test/dev.js b/test/dev.js deleted file mode 100644 index e45fa08cc8..0000000000 --- a/test/dev.js +++ /dev/null @@ -1,36 +0,0 @@ -const fs = require('fs'); -const path = require('path'); -const swcRegister = require('@swc/register'); - -const [testSuiteDir] = process.argv.slice(2); - -if (!testSuiteDir) { - console.error('ERROR: You must provide an argument for "testSuiteDir"'); - process.exit(1); -} - -const configPath = path.resolve(__dirname, testSuiteDir, 'config.ts'); - -if (!fs.existsSync(configPath)) { - console.error('ERROR: You must pass a valid directory under test/ that contains a config.ts'); - process.exit(1); -} - -process.env.PAYLOAD_CONFIG_PATH = configPath; - -process.env.PAYLOAD_DROP_DATABASE = 'true'; - -swcRegister({ - sourceMaps: 'inline', - jsc: { - parser: { - syntax: 'typescript', - tsx: true, - }, - }, - module: { - type: 'commonjs', - }, -}); - -require('./devServer'); diff --git a/test/devServer.ts b/test/dev.ts similarity index 62% rename from test/devServer.ts rename to test/dev.ts index 49138309ba..2e7bd06c69 100644 --- a/test/devServer.ts +++ b/test/dev.ts @@ -1,9 +1,29 @@ - +import fs from 'fs'; +import path from 'path'; import express from 'express'; import { v4 as uuid } from 'uuid'; import payload from '../src'; +const [testSuiteDir] = process.argv.slice(2); + +if (!testSuiteDir) { + console.error('ERROR: You must provide an argument for "testSuiteDir"'); + process.exit(1); +} + +const configPath = path.resolve(__dirname, testSuiteDir, 'config.ts'); + +if (!fs.existsSync(configPath)) { + console.error('ERROR: You must pass a valid directory under test/ that contains a config.ts'); + process.exit(1); +} + +process.env.PAYLOAD_CONFIG_PATH = configPath; + +process.env.PAYLOAD_DROP_DATABASE = 'true'; + const expressApp = express(); + const init = async () => { await payload.init({ secret: uuid(), diff --git a/tsconfig.json b/tsconfig.json index 9772585039..c24c245b3f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -30,6 +30,9 @@ "skipLibCheck": true, /* Skip type checking of declaration files. */ "forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */ }, + "ts-node": { + "swc": true, + }, "include": [ "src/" ], diff --git a/yarn.lock b/yarn.lock index ca47c70840..3cbbeca238 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1950,15 +1950,6 @@ "@jest/create-cache-key-function" "^27.4.2" jsonc-parser "^3.2.0" -"@swc/register@^0.1.10": - version "0.1.10" - resolved "https://registry.yarnpkg.com/@swc/register/-/register-0.1.10.tgz#74a20b7559669e03479b05e9e5c6d1524d4d92a2" - integrity sha512-6STwH/q4dc3pitXLVkV7sP0Hiy+zBsU2wOF1aXpXR95pnH3RYHKIsDC+gvesfyB7jxNT9OOZgcqOp9RPxVTx9A== - dependencies: - lodash.clonedeep "^4.5.0" - pirates "^4.0.1" - source-map-support "^0.5.13" - "@szmarczak/http-timer@^5.0.1": version "5.0.1" resolved "https://registry.yarnpkg.com/@szmarczak/http-timer/-/http-timer-5.0.1.tgz#c7c1bf1141cdd4751b0399c8fc7b8b664cd5be3a" @@ -8079,11 +8070,6 @@ locate-path@^5.0.0: dependencies: p-locate "^4.1.0" -lodash.clonedeep@^4.5.0: - version "4.5.0" - resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef" - integrity sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ== - lodash.get@^4.4.2: version "4.4.2" resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99" @@ -9353,7 +9339,7 @@ pino@^6.4.1: quick-format-unescaped "^4.0.3" sonic-boom "^1.0.2" -pirates@^4.0.1, pirates@^4.0.4: +pirates@^4.0.4: version "4.0.5" resolved "https://registry.yarnpkg.com/pirates/-/pirates-4.0.5.tgz#feec352ea5c3268fb23a37c702ab1699f35a5f3b" integrity sha512-8V9+HQPupnaXMA23c5hvl69zXvTwTzyAYasnkb0Tts4XvO4CliqONMOnvlq26rkhLC3nWDFBJf73LU1e1VZLaQ== @@ -11159,7 +11145,7 @@ source-map-support@0.5.13: buffer-from "^1.0.0" source-map "^0.6.0" -source-map-support@^0.5.13, source-map-support@~0.5.20: +source-map-support@~0.5.20: version "0.5.21" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== @@ -11773,7 +11759,7 @@ ts-essentials@^7.0.1: ts-node@^10.9.1: version "10.9.1" - resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.9.1.tgz#e73de9102958af9e1f0b168a6ff320e25adcff4b" + resolved "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz#e73de9102958af9e1f0b168a6ff320e25adcff4b" integrity sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw== dependencies: "@cspotcode/source-map-support" "^0.8.0" From 441eb2c20c9ea347473eb3ed9e161707fa21f963 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 10 Jan 2023 15:53:41 -0500 Subject: [PATCH 02/46] chore: keeps swc/register for playwright tests --- package.json | 5 +++-- test/helpers/configHelpers.ts | 14 ++++++++++++++ yarn.lock | 36 ++++++++++++++++++++++++----------- 3 files changed, 42 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index b986a78066..0ae1055552 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "build": "yarn copyfiles && yarn build:tsc && yarn build:components", "build:watch": "nodemon --watch 'src/**' --ext 'ts,tsx' --exec \"yarn build:tsc\"", "dev": "nodemon", - "dev:generate-types": "node ./test/generateTypes.js", + "dev:generate-types": "ts-node ./test/generateTypes.js", "pretest": "yarn build", "test": "yarn test:int && yarn test:components && yarn test:e2e", "test:int": "cross-env DISABLE_LOGGING=true jest --forceExit --detectOpenHandles", @@ -191,9 +191,10 @@ "webpack-hot-middleware": "^2.25.0" }, "devDependencies": { - "@playwright/test": "^1.23.1", + "@playwright/test": "^1.29.2", "@release-it/conventional-changelog": "^5.1.1", "@swc/jest": "^0.2.24", + "@swc/register": "^0.1.10", "@testing-library/jest-dom": "^5.11.4", "@testing-library/react": "^13.0.1", "@trbl/eslint-config": "^1.2.4", diff --git a/test/helpers/configHelpers.ts b/test/helpers/configHelpers.ts index bd1d30e5cc..20e386d3eb 100644 --- a/test/helpers/configHelpers.ts +++ b/test/helpers/configHelpers.ts @@ -1,4 +1,5 @@ import getPort from 'get-port'; +import swcRegister from '@swc/register'; import path from 'path'; import { v4 as uuid } from 'uuid'; import shelljs from 'shelljs'; @@ -40,6 +41,19 @@ export async function initPayloadTest(options: Options): Promise<{ serverURL: st initOptions.express = express(); } + swcRegister({ + sourceMaps: 'inline', + jsc: { + parser: { + syntax: 'typescript', + tsx: true, + }, + }, + module: { + type: 'commonjs', + }, + }); + await payload.init(initOptions); if (initOptions.express) { diff --git a/yarn.lock b/yarn.lock index 3cbbeca238..3d1117213a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1797,13 +1797,13 @@ dependencies: "@octokit/openapi-types" "^14.0.0" -"@playwright/test@^1.23.1": - version "1.29.1" - resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.29.1.tgz#f2ed4dc143b9c7825a7ad2703b2f1ac4354e1145" - integrity sha512-iQxk2DX5U9wOGV3+/Jh9OHPsw5H3mleUL2S4BgQuwtlAfK3PnKvn38m4Rg9zIViGHVW24opSm99HQm/UFLEy6w== +"@playwright/test@^1.29.2": + version "1.29.2" + resolved "https://registry.npmjs.org/@playwright/test/-/test-1.29.2.tgz#c48184721d0f0b7627a886e2ec42f1efb2be339d" + integrity sha512-+3/GPwOgcoF0xLz/opTnahel1/y42PdcgZ4hs+BZGIUjtmEFSXGg+nFoaH3NSmuc7a6GSFwXDJ5L7VXpqzigNg== dependencies: "@types/node" "*" - playwright-core "1.29.1" + playwright-core "1.29.2" "@pnpm/network.ca-file@^1.0.1": version "1.0.2" @@ -1950,6 +1950,15 @@ "@jest/create-cache-key-function" "^27.4.2" jsonc-parser "^3.2.0" +"@swc/register@^0.1.10": + version "0.1.10" + resolved "https://registry.npmjs.org/@swc/register/-/register-0.1.10.tgz#74a20b7559669e03479b05e9e5c6d1524d4d92a2" + integrity sha512-6STwH/q4dc3pitXLVkV7sP0Hiy+zBsU2wOF1aXpXR95pnH3RYHKIsDC+gvesfyB7jxNT9OOZgcqOp9RPxVTx9A== + dependencies: + lodash.clonedeep "^4.5.0" + pirates "^4.0.1" + source-map-support "^0.5.13" + "@szmarczak/http-timer@^5.0.1": version "5.0.1" resolved "https://registry.yarnpkg.com/@szmarczak/http-timer/-/http-timer-5.0.1.tgz#c7c1bf1141cdd4751b0399c8fc7b8b664cd5be3a" @@ -8070,6 +8079,11 @@ locate-path@^5.0.0: dependencies: p-locate "^4.1.0" +lodash.clonedeep@^4.5.0: + version "4.5.0" + resolved "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef" + integrity sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ== + lodash.get@^4.4.2: version "4.4.2" resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99" @@ -9339,7 +9353,7 @@ pino@^6.4.1: quick-format-unescaped "^4.0.3" sonic-boom "^1.0.2" -pirates@^4.0.4: +pirates@^4.0.1, pirates@^4.0.4: version "4.0.5" resolved "https://registry.yarnpkg.com/pirates/-/pirates-4.0.5.tgz#feec352ea5c3268fb23a37c702ab1699f35a5f3b" integrity sha512-8V9+HQPupnaXMA23c5hvl69zXvTwTzyAYasnkb0Tts4XvO4CliqONMOnvlq26rkhLC3nWDFBJf73LU1e1VZLaQ== @@ -9358,10 +9372,10 @@ pkg-up@^3.1.0: dependencies: find-up "^3.0.0" -playwright-core@1.29.1: - version "1.29.1" - resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.29.1.tgz#9ec15d61c4bd2f386ddf6ce010db53a030345a47" - integrity sha512-20Ai3d+lMkWpI9YZYlxk8gxatfgax5STW8GaMozAHwigLiyiKQrdkt7gaoT9UQR8FIVDg6qVXs9IoZUQrDjIIg== +playwright-core@1.29.2: + version "1.29.2" + resolved "https://registry.npmjs.org/playwright-core/-/playwright-core-1.29.2.tgz#2e8347e7e8522409f22b244e600e703b64022406" + integrity sha512-94QXm4PMgFoHAhlCuoWyaBYKb92yOcGVHdQLoxQ7Wjlc7Flg4aC/jbFW7xMR52OfXMVkWicue4WXE7QEegbIRA== pluralize@^8.0.0: version "8.0.0" @@ -11145,7 +11159,7 @@ source-map-support@0.5.13: buffer-from "^1.0.0" source-map "^0.6.0" -source-map-support@~0.5.20: +source-map-support@^0.5.13, source-map-support@~0.5.20: version "0.5.21" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== From b4ffeaf0343279b82e46af98422a8f10c9a865cf Mon Sep 17 00:00:00 2001 From: Jessica Boezwinkle Date: Wed, 11 Jan 2023 16:36:52 +0000 Subject: [PATCH 03/46] chore: converts exported ts files to js --- components/{elements.ts => elements.d.ts} | 0 components/elements.js | 5 +++ components/{forms.ts => forms.d.ts} | 0 components/forms.js | 42 +++++++++++++++++++ components/{hooks.ts => hooks.d.ts} | 0 components/hooks.js | 1 + components/icons.d.ts | 2 + components/icons.js | 2 + components/icons.ts | 2 - .../{preferences.ts => preferences.d.ts} | 0 components/preferences.js | 1 + components/{rich-text.ts => rich-text.d.ts} | 0 components/rich-text.js | 3 ++ components/{templates.ts => templates.d.ts} | 0 components/templates.js | 2 + components/{utilities.ts => utilities.d.ts} | 0 components/utilities.js | 6 +++ components/views/{Cell.ts => Cell.d.ts} | 0 components/views/Cell.js | 1 + .../views/{Dashboard.ts => Dashboard.d.ts} | 0 components/views/Dashboard.js | 1 + components/views/{Edit.ts => Edit.d.ts} | 0 components/views/Edit.js | 1 + components/views/{List.ts => List.d.ts} | 0 components/views/List.js | 1 + fields/validations.d.ts | 1 + fields/validations.js | 2 +- 27 files changed, 70 insertions(+), 3 deletions(-) rename components/{elements.ts => elements.d.ts} (100%) create mode 100644 components/elements.js rename components/{forms.ts => forms.d.ts} (100%) create mode 100644 components/forms.js rename components/{hooks.ts => hooks.d.ts} (100%) create mode 100644 components/hooks.js create mode 100644 components/icons.d.ts create mode 100644 components/icons.js delete mode 100644 components/icons.ts rename components/{preferences.ts => preferences.d.ts} (100%) create mode 100644 components/preferences.js rename components/{rich-text.ts => rich-text.d.ts} (100%) create mode 100644 components/rich-text.js rename components/{templates.ts => templates.d.ts} (100%) create mode 100644 components/templates.js rename components/{utilities.ts => utilities.d.ts} (100%) create mode 100644 components/utilities.js rename components/views/{Cell.ts => Cell.d.ts} (100%) create mode 100644 components/views/Cell.js rename components/views/{Dashboard.ts => Dashboard.d.ts} (100%) create mode 100644 components/views/Dashboard.js rename components/views/{Edit.ts => Edit.d.ts} (100%) create mode 100644 components/views/Edit.js rename components/views/{List.ts => List.d.ts} (100%) create mode 100644 components/views/List.js create mode 100644 fields/validations.d.ts diff --git a/components/elements.ts b/components/elements.d.ts similarity index 100% rename from components/elements.ts rename to components/elements.d.ts diff --git a/components/elements.js b/components/elements.js new file mode 100644 index 0000000000..e1de4dca94 --- /dev/null +++ b/components/elements.js @@ -0,0 +1,5 @@ +exports.Button = require('../dist/admin/components/elements/Button').default; +exports.Card = require('../dist/admin/components/elements/Card').default; +exports.Eyebrow = require('../dist/admin/components/elements/Eyebrow').default; +exports.Nav = require('../dist/admin/components/elements/Nav').default; +exports.Gutter = require('../dist/admin/components/elements/Gutter').Gutter; diff --git a/components/forms.ts b/components/forms.d.ts similarity index 100% rename from components/forms.ts rename to components/forms.d.ts diff --git a/components/forms.js b/components/forms.js new file mode 100644 index 0000000000..500f6ed392 --- /dev/null +++ b/components/forms.js @@ -0,0 +1,42 @@ +exports.useForm = require('../dist/admin/components/forms/Form/context').useForm; + +/** + * @deprecated useWatchForm is no longer preferred. If you need all form fields, prefer `useAllFormFields`. + */ +exports.useWatchForm = require('../dist/admin/components/forms/Form/context').useWatchForm; + +exports.useFormFields = require('../dist/admin/components/forms/Form/context').useFormFields; + +exports.useAllFormFields = require('../dist/admin/components/forms/Form/context').useAllFormFields; + +exports.useFormSubmitted = require('../dist/admin/components/forms/Form/context').useFormSubmitted; + +exports.useFormProcessing = require('../dist/admin/components/forms/Form/context').useFormProcessing; + +exports.useFormModified = require('../dist/admin/components/forms/Form/context').useFormModified; + +exports.useField = require('../dist/admin/components/forms/useField').default; + +/** + * @deprecated This method is now called useField. The useFieldType alias will be removed in an upcoming version. + */ +exports.useFieldType = require('../dist/admin/components/forms/useField').default; + +exports.Form = require('../dist/admin/components/forms/Form').default; + +exports.Text = require('../dist/admin/components/forms/field-types/Text').default; +exports.TextInput = require('../dist/admin/components/forms/field-types/Text/Input').default; + +exports.Group = require('../dist/admin/components/forms/field-types/Group').default; + +exports.Select = require('../dist/admin/components/forms/field-types/Select').default; +exports.SelectInput = require('../dist/admin/components/forms/field-types/Select/Input').default; + +exports.Checkbox = require('../dist/admin/components/forms/field-types/Checkbox').default; +exports.Submit = require('../dist/admin/components/forms/Submit').default; +exports.Label = require('../dist/admin/components/forms/Label').default; + +exports.reduceFieldsToValues = require('../dist/admin/components/forms/Form/reduceFieldsToValues').default; +exports.getSiblingData = require('../dist/admin/components/forms/Form/getSiblingData').default; + +exports.withCondition = require('../dist/admin/components/forms/withCondition').default; diff --git a/components/hooks.ts b/components/hooks.d.ts similarity index 100% rename from components/hooks.ts rename to components/hooks.d.ts diff --git a/components/hooks.js b/components/hooks.js new file mode 100644 index 0000000000..dca5507fac --- /dev/null +++ b/components/hooks.js @@ -0,0 +1 @@ +exports.useStepNav = require('../dist/admin/components/elements/StepNav').useStepNav; diff --git a/components/icons.d.ts b/components/icons.d.ts new file mode 100644 index 0000000000..cd0c56b272 --- /dev/null +++ b/components/icons.d.ts @@ -0,0 +1,2 @@ +export { default as Chevron } from '../dist/admin/components/icons/Chevron'; +export { default as X } from '../dist/admin/components/icons/X'; diff --git a/components/icons.js b/components/icons.js new file mode 100644 index 0000000000..8a671a5ed4 --- /dev/null +++ b/components/icons.js @@ -0,0 +1,2 @@ +exports.Chevron = require('../dist/admin/components/icons/Chevron').default; +exports.X = require('../dist/admin/components/icons/X').default; diff --git a/components/icons.ts b/components/icons.ts deleted file mode 100644 index a969a99d70..0000000000 --- a/components/icons.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { default as Chevron } from '../src/admin/components/icons/Chevron'; -export { default as X } from '../src/admin/components/icons/X'; diff --git a/components/preferences.ts b/components/preferences.d.ts similarity index 100% rename from components/preferences.ts rename to components/preferences.d.ts diff --git a/components/preferences.js b/components/preferences.js new file mode 100644 index 0000000000..533da4f880 --- /dev/null +++ b/components/preferences.js @@ -0,0 +1 @@ +exports.usePreferences = require('../dist/admin/components/utilities/Preferences').usePreferences; diff --git a/components/rich-text.ts b/components/rich-text.d.ts similarity index 100% rename from components/rich-text.ts rename to components/rich-text.d.ts diff --git a/components/rich-text.js b/components/rich-text.js new file mode 100644 index 0000000000..145e8608c2 --- /dev/null +++ b/components/rich-text.js @@ -0,0 +1,3 @@ +exports.LeafButton = require('../dist/admin/components/forms/field-types/RichText/leaves/Button').default; +exports.ElementButton = require('../dist/admin/components/forms/field-types/RichText/elements/Button').default; +exports.toggleElement = require('../dist/admin/components/forms/field-types/RichText/elements/toggle').default; diff --git a/components/templates.ts b/components/templates.d.ts similarity index 100% rename from components/templates.ts rename to components/templates.d.ts diff --git a/components/templates.js b/components/templates.js new file mode 100644 index 0000000000..11246d6f0a --- /dev/null +++ b/components/templates.js @@ -0,0 +1,2 @@ +exports.DefaultTemplate = require('../dist/admin/components/templates/Default').default; +exports.MinimalTemplate = require('../dist/admin/components/templates/Minimal').default; \ No newline at end of file diff --git a/components/utilities.ts b/components/utilities.d.ts similarity index 100% rename from components/utilities.ts rename to components/utilities.d.ts diff --git a/components/utilities.js b/components/utilities.js new file mode 100644 index 0000000000..f19df00f9f --- /dev/null +++ b/components/utilities.js @@ -0,0 +1,6 @@ +exports.Meta = require('../dist/admin/components/utilities/Meta').default; +exports.useLocale = require('../dist/admin/components/utilities/Locale').useLocale; +exports.useDocumentInfo = require('../dist/admin/components/utilities/DocumentInfo').useDocumentInfo; +exports.useConfig = require('../dist/admin/components/utilities/Config').useConfig; +exports.useAuth = require('../dist/admin/components/utilities/Auth').useAuth; +exports.useEditDepth = require('../dist/admin/components/utilities/EditDepth').useEditDepth; diff --git a/components/views/Cell.ts b/components/views/Cell.d.ts similarity index 100% rename from components/views/Cell.ts rename to components/views/Cell.d.ts diff --git a/components/views/Cell.js b/components/views/Cell.js new file mode 100644 index 0000000000..d2ee71c1de --- /dev/null +++ b/components/views/Cell.js @@ -0,0 +1 @@ +exports.Cell = require('../../dist/admin/components/views/collections/List/Cell').default; diff --git a/components/views/Dashboard.ts b/components/views/Dashboard.d.ts similarity index 100% rename from components/views/Dashboard.ts rename to components/views/Dashboard.d.ts diff --git a/components/views/Dashboard.js b/components/views/Dashboard.js new file mode 100644 index 0000000000..53693cf528 --- /dev/null +++ b/components/views/Dashboard.js @@ -0,0 +1 @@ +exports.Dashboard = required('../../dist/admin/components/views/Dashboard/Default').default; diff --git a/components/views/Edit.ts b/components/views/Edit.d.ts similarity index 100% rename from components/views/Edit.ts rename to components/views/Edit.d.ts diff --git a/components/views/Edit.js b/components/views/Edit.js new file mode 100644 index 0000000000..79350aa6e0 --- /dev/null +++ b/components/views/Edit.js @@ -0,0 +1 @@ +exports.Edit = require('../../dist/admin/components/views/collections/Edit/Default').default; diff --git a/components/views/List.ts b/components/views/List.d.ts similarity index 100% rename from components/views/List.ts rename to components/views/List.d.ts diff --git a/components/views/List.js b/components/views/List.js new file mode 100644 index 0000000000..6ec8ce8b7d --- /dev/null +++ b/components/views/List.js @@ -0,0 +1 @@ +exports.List = require('../../dist/admin/components/views/collections/List/Default').default; diff --git a/fields/validations.d.ts b/fields/validations.d.ts new file mode 100644 index 0000000000..b24ba908b1 --- /dev/null +++ b/fields/validations.d.ts @@ -0,0 +1 @@ +export * from '../dist/fields/validations'; diff --git a/fields/validations.js b/fields/validations.js index b24ba908b1..b4b8821198 100644 --- a/fields/validations.js +++ b/fields/validations.js @@ -1 +1 @@ -export * from '../dist/fields/validations'; +module.exports = require('../dist/fields/validations'); From 84e03893fd737c09f755605e37927262b83e2960 Mon Sep 17 00:00:00 2001 From: James Date: Wed, 11 Jan 2023 15:58:58 -0500 Subject: [PATCH 04/46] chore: begins local api abstraction --- src/collections/initHTTP.ts | 41 +++ src/collections/{init.ts => initLocal.ts} | 38 +-- src/globals/initHTTP.ts | 19 ++ src/globals/{init.ts => initLocal.ts} | 21 +- src/index.ts | 279 +--------------- src/init.ts | 178 ----------- src/initHTTP.ts | 84 +++++ src/payload.ts | 373 ++++++++++++++++++++++ src/preferences/init.ts | 5 +- test/devServer.ts | 8 +- 10 files changed, 533 insertions(+), 513 deletions(-) create mode 100644 src/collections/initHTTP.ts rename src/collections/{init.ts => initLocal.ts} (68%) create mode 100644 src/globals/initHTTP.ts rename src/globals/{init.ts => initLocal.ts} (64%) delete mode 100644 src/init.ts create mode 100644 src/initHTTP.ts create mode 100644 src/payload.ts diff --git a/src/collections/initHTTP.ts b/src/collections/initHTTP.ts new file mode 100644 index 0000000000..038e451258 --- /dev/null +++ b/src/collections/initHTTP.ts @@ -0,0 +1,41 @@ +import express from 'express'; +import passport from 'passport'; +import apiKeyStrategy from '../auth/strategies/apiKey'; +import bindCollectionMiddleware from './bindCollection'; +import { SanitizedCollectionConfig } from './config/types'; +import mountEndpoints from '../express/mountEndpoints'; +import buildEndpoints from './buildEndpoints'; +import { PayloadHTTP } from '..'; + +export default function initCollectionsHTTP(ctx: PayloadHTTP): void { + ctx.config.collections = ctx.config.collections.map((collection: SanitizedCollectionConfig) => { + const formattedCollection = collection; + + const router = express.Router(); + const { slug } = collection; + + router.all('*', bindCollectionMiddleware(ctx.collections[formattedCollection.slug])); + + if (collection.auth) { + const AuthCollection = ctx.collections[formattedCollection.slug]; + + if (collection.auth.useAPIKey) { + passport.use(`${AuthCollection.config.slug}-api-key`, apiKeyStrategy(ctx, AuthCollection)); + } + + if (Array.isArray(collection.auth.strategies)) { + collection.auth.strategies.forEach(({ name, strategy }, index) => { + const passportStrategy = typeof strategy === 'object' ? strategy : strategy(ctx); + passport.use(`${AuthCollection.config.slug}-${name ?? index}`, passportStrategy); + }); + } + } + + const endpoints = buildEndpoints(collection); + mountEndpoints(ctx.express, router, endpoints); + + ctx.router.use(`/${slug}`, router); + + return formattedCollection; + }); +} diff --git a/src/collections/init.ts b/src/collections/initLocal.ts similarity index 68% rename from src/collections/init.ts rename to src/collections/initLocal.ts index 00626d1252..cfb2f0d43c 100644 --- a/src/collections/init.ts +++ b/src/collections/initLocal.ts @@ -1,21 +1,15 @@ import mongoose, { UpdateAggregationStage, UpdateQuery } from 'mongoose'; import paginate from 'mongoose-paginate-v2'; -import express from 'express'; -import passport from 'passport'; import passportLocalMongoose from 'passport-local-mongoose'; import { buildVersionCollectionFields } from '../versions/buildCollectionFields'; import buildQueryPlugin from '../mongoose/buildQuery'; -import apiKeyStrategy from '../auth/strategies/apiKey'; import buildCollectionSchema from './buildSchema'; import buildSchema from '../mongoose/buildSchema'; -import bindCollectionMiddleware from './bindCollection'; import { CollectionModel, SanitizedCollectionConfig } from './config/types'; -import { Payload } from '../index'; +import { Payload } from '../payload'; import { getVersionsModelName } from '../versions/getVersionsModelName'; -import mountEndpoints from '../express/mountEndpoints'; -import buildEndpoints from './buildEndpoints'; -export default function registerCollections(ctx: Payload): void { +export default function initCollectionsLocal(ctx: Payload): void { ctx.config.collections = ctx.config.collections.map((collection: SanitizedCollectionConfig) => { const formattedCollection = collection; @@ -91,34 +85,6 @@ export default function registerCollections(ctx: Payload): void { config: formattedCollection, }; - // If not local, open routes - if (!ctx.local) { - const router = express.Router(); - const { slug } = collection; - - router.all('*', bindCollectionMiddleware(ctx.collections[formattedCollection.slug])); - - if (collection.auth) { - const AuthCollection = ctx.collections[formattedCollection.slug]; - - if (collection.auth.useAPIKey) { - passport.use(`${AuthCollection.config.slug}-api-key`, apiKeyStrategy(ctx, AuthCollection)); - } - - if (Array.isArray(collection.auth.strategies)) { - collection.auth.strategies.forEach(({ name, strategy }, index) => { - const passportStrategy = typeof strategy === 'object' ? strategy : strategy(ctx); - passport.use(`${AuthCollection.config.slug}-${name ?? index}`, passportStrategy); - }); - } - } - - const endpoints = buildEndpoints(collection); - mountEndpoints(ctx.express, router, endpoints); - - ctx.router.use(`/${slug}`, router); - } - return formattedCollection; }); } diff --git a/src/globals/initHTTP.ts b/src/globals/initHTTP.ts new file mode 100644 index 0000000000..fb9e80c13a --- /dev/null +++ b/src/globals/initHTTP.ts @@ -0,0 +1,19 @@ +import express from 'express'; +import mountEndpoints from '../express/mountEndpoints'; +import buildEndpoints from './buildEndpoints'; +import { SanitizedGlobalConfig } from './config/types'; +import { PayloadHTTP } from '..'; + +export default function initGlobals(ctx: PayloadHTTP): void { + if (ctx.config.globals) { + ctx.config.globals.forEach((global: SanitizedGlobalConfig) => { + const router = express.Router(); + const { slug } = global; + + const endpoints = buildEndpoints(global); + mountEndpoints(ctx.express, router, endpoints); + + ctx.router.use(`/globals/${slug}`, router); + }); + } +} diff --git a/src/globals/init.ts b/src/globals/initLocal.ts similarity index 64% rename from src/globals/init.ts rename to src/globals/initLocal.ts index 8558aa2cbf..15175a891e 100644 --- a/src/globals/init.ts +++ b/src/globals/initLocal.ts @@ -1,18 +1,14 @@ -import express from 'express'; import mongoose from 'mongoose'; import paginate from 'mongoose-paginate-v2'; import buildQueryPlugin from '../mongoose/buildQuery'; import buildModel from './buildModel'; -import { Payload } from '../index'; +import { Payload } from '../payload'; import { getVersionsModelName } from '../versions/getVersionsModelName'; import { buildVersionGlobalFields } from '../versions/buildGlobalFields'; import buildSchema from '../mongoose/buildSchema'; import { CollectionModel } from '../collections/config/types'; -import mountEndpoints from '../express/mountEndpoints'; -import buildEndpoints from './buildEndpoints'; -import { SanitizedGlobalConfig } from './config/types'; -export default function initGlobals(ctx: Payload): void { +export default function initGlobalsLocal(ctx: Payload): void { if (ctx.config.globals) { ctx.globals = { Model: buildModel(ctx.config), @@ -41,18 +37,5 @@ export default function initGlobals(ctx: Payload): void { ctx.versions[global.slug] = mongoose.model(versionModelName, versionSchema) as CollectionModel; } }); - - // If not local, open routes - if (!ctx.local) { - ctx.config.globals.forEach((global: SanitizedGlobalConfig) => { - const router = express.Router(); - const { slug } = global; - - const endpoints = buildEndpoints(global); - mountEndpoints(ctx.express, router, endpoints); - - ctx.router.use(`/globals/${slug}`, router); - }); - } } } diff --git a/src/index.ts b/src/index.ts index 319a5e9fc5..5c73e690a6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,280 +1,13 @@ -import { Express, Router } from 'express'; -import pino from 'pino'; -import { GraphQLError, GraphQLFormattedError, GraphQLSchema } from 'graphql'; import { - TypeWithID, - Collection, - CollectionModel, -} from './collections/config/types'; -import { - SanitizedConfig, - EmailOptions, InitOptions, } from './config/types'; -import { TypeWithVersion } from './versions/types'; -import { PaginatedDocs } from './mongoose/types'; - -import { PayloadAuthenticate } from './express/middleware/authenticate'; -import { Globals, TypeWithID as GlobalTypeWithID } from './globals/config/types'; -import { ErrorHandler } from './express/middleware/errorHandler'; -import localOperations from './collections/operations/local'; -import localGlobalOperations from './globals/operations/local'; -import { encrypt, decrypt } from './auth/crypto'; -import { BuildEmailResult, Message } from './email/types'; -import { Preferences } from './preferences/types'; - -import { Options as CreateOptions } from './collections/operations/local/create'; -import { Options as FindOptions } from './collections/operations/local/find'; -import { Options as FindByIDOptions } from './collections/operations/local/findByID'; -import { Options as UpdateOptions } from './collections/operations/local/update'; -import { Options as DeleteOptions } from './collections/operations/local/delete'; -import { Options as FindVersionsOptions } from './collections/operations/local/findVersions'; -import { Options as FindVersionByIDOptions } from './collections/operations/local/findVersionByID'; -import { Options as RestoreVersionOptions } from './collections/operations/local/restoreVersion'; -import { Options as FindGlobalVersionsOptions } from './globals/operations/local/findVersions'; -import { Options as FindGlobalVersionByIDOptions } from './globals/operations/local/findVersionByID'; -import { Options as RestoreGlobalVersionOptions } from './globals/operations/local/restoreVersion'; -import { Options as ForgotPasswordOptions } from './auth/operations/local/forgotPassword'; -import { Options as LoginOptions } from './auth/operations/local/login'; -import { Options as ResetPasswordOptions } from './auth/operations/local/resetPassword'; -import { Options as UnlockOptions } from './auth/operations/local/unlock'; -import { Options as VerifyEmailOptions } from './auth/operations/local/verifyEmail'; -import { Result as ForgotPasswordResult } from './auth/operations/forgotPassword'; -import { Result as ResetPasswordResult } from './auth/operations/resetPassword'; -import { Result as LoginResult } from './auth/operations/login'; -import { Options as FindGlobalOptions } from './globals/operations/local/findOne'; -import { Options as UpdateGlobalOptions } from './globals/operations/local/update'; -import { initSync, initAsync } from './init'; +import { initHTTP } from './initHTTP'; +import { Payload, getPayload } from './payload'; require('isomorphic-fetch'); -/** - * @description Payload - */ -export class Payload { - config: SanitizedConfig; +export const init = async (options: InitOptions): Promise> => { + return initHTTP(options); +}; - collections: { - [slug: string]: Collection; - } = {} - - versions: { - [slug: string]: CollectionModel; - } = {} - - preferences: Preferences; - - globals: Globals; - - logger: pino.Logger; - - express: Express - - router: Router; - - emailOptions: EmailOptions; - - email: BuildEmailResult; - - sendEmail: (message: Message) => Promise; - - secret: string; - - mongoURL: string | false; - - mongoMemoryServer: any - - local: boolean; - - encrypt = encrypt; - - decrypt = decrypt; - - errorHandler: ErrorHandler; - - authenticate: PayloadAuthenticate; - - types: { - blockTypes: any; - blockInputTypes: any; - localeInputType?: any; - fallbackLocaleInputType?: any; - }; - - Query: { name: string; fields: { [key: string]: any } } = { name: 'Query', fields: {} }; - - Mutation: { name: string; fields: { [key: string]: any } } = { name: 'Mutation', fields: {} }; - - schema: GraphQLSchema; - - extensions: (info: any) => Promise; - - customFormatErrorFn: (error: GraphQLError) => GraphQLFormattedError; - - validationRules: any; - - errorResponses: GraphQLFormattedError[] = []; - - errorIndex: number; - - /** - * @description Initializes Payload - * @param options - */ - init(options: InitOptions): void { - initSync(this, options); - } - - async initAsync(options: InitOptions): Promise { - await initAsync(this, options); - } - - getAdminURL = (): string => `${this.config.serverURL}${this.config.routes.admin}`; - - getAPIURL = (): string => `${this.config.serverURL}${this.config.routes.api}`; - - /** - * @description Performs create operation - * @param options - * @returns created document - */ - create = async (options: CreateOptions): Promise => { - const { create } = localOperations; - return create(this, options); - } - - /** - * @description Find documents with criteria - * @param options - * @returns documents satisfying query - */ - find = async (options: FindOptions): Promise> => { - const { find } = localOperations; - return find(this, options); - } - - findGlobal = async (options: FindGlobalOptions): Promise => { - const { findOne } = localGlobalOperations; - return findOne(this, options); - } - - updateGlobal = async (options: UpdateGlobalOptions): Promise => { - const { update } = localGlobalOperations; - return update(this, options); - } - - /** - * @description Find global versions with criteria - * @param options - * @returns versions satisfying query - */ - findGlobalVersions = async = any>(options: FindGlobalVersionsOptions): Promise> => { - const { findVersions } = localGlobalOperations; - return findVersions(this, options); - } - - /** - * @description Find global version by ID - * @param options - * @returns global version with specified ID - */ - findGlobalVersionByID = async = any>(options: FindGlobalVersionByIDOptions): Promise => { - const { findVersionByID } = localGlobalOperations; - return findVersionByID(this, options); - } - - /** - * @description Restore global version by ID - * @param options - * @returns version with specified ID - */ - restoreGlobalVersion = async = any>(options: RestoreGlobalVersionOptions): Promise => { - const { restoreVersion } = localGlobalOperations; - return restoreVersion(this, options); - } - - /** - * @description Find document by ID - * @param options - * @returns document with specified ID - */ - findByID = async (options: FindByIDOptions): Promise => { - const { findByID } = localOperations; - return findByID(this, options); - } - - /** - * @description Update document - * @param options - * @returns Updated document - */ - update = async (options: UpdateOptions): Promise => { - const { update } = localOperations; - return update(this, options); - } - - delete = async (options: DeleteOptions): Promise => { - const { localDelete } = localOperations; - return localDelete(this, options); - } - - /** - * @description Find versions with criteria - * @param options - * @returns versions satisfying query - */ - findVersions = async = any>(options: FindVersionsOptions): Promise> => { - const { findVersions } = localOperations; - return findVersions(this, options); - } - - /** - * @description Find version by ID - * @param options - * @returns version with specified ID - */ - findVersionByID = async = any>(options: FindVersionByIDOptions): Promise => { - const { findVersionByID } = localOperations; - return findVersionByID(this, options); - } - - /** - * @description Restore version by ID - * @param options - * @returns version with specified ID - */ - restoreVersion = async = any>(options: RestoreVersionOptions): Promise => { - const { restoreVersion } = localOperations; - return restoreVersion(this, options); - } - - login = async (options: LoginOptions): Promise => { - const { login } = localOperations.auth; - return login(this, options); - } - - forgotPassword = async (options: ForgotPasswordOptions): Promise => { - const { forgotPassword } = localOperations.auth; - return forgotPassword(this, options); - } - - resetPassword = async (options: ResetPasswordOptions): Promise => { - const { resetPassword } = localOperations.auth; - return resetPassword(this, options); - } - - unlock = async (options: UnlockOptions): Promise => { - const { unlock } = localOperations.auth; - return unlock(this, options); - } - - verifyEmail = async (options: VerifyEmailOptions): Promise => { - const { verifyEmail } = localOperations.auth; - return verifyEmail(this, options); - } -} - -const payload = new Payload(); - -export default payload; -module.exports = payload; +export default getPayload; diff --git a/src/init.ts b/src/init.ts deleted file mode 100644 index fb1f2e61e5..0000000000 --- a/src/init.ts +++ /dev/null @@ -1,178 +0,0 @@ -/* eslint-disable no-param-reassign */ -import express, { NextFunction, Response } from 'express'; -import crypto from 'crypto'; -import path from 'path'; -import mongoose from 'mongoose'; -import { InitOptions } from './config/types'; - -import authenticate from './express/middleware/authenticate'; -import connectMongoose from './mongoose/connect'; -import expressMiddleware from './express/middleware'; -import initAdmin from './express/admin'; -import initAuth from './auth/init'; -import access from './auth/requestHandlers/access'; -import initCollections from './collections/init'; -import initPreferences from './preferences/init'; -import initGlobals from './globals/init'; -import initGraphQLPlayground from './graphql/initPlayground'; -import initStatic from './express/static'; -import registerSchema from './graphql/registerSchema'; -import graphQLHandler from './graphql/graphQLHandler'; -import buildEmail from './email/build'; -import identifyAPI from './express/middleware/identifyAPI'; -import errorHandler from './express/middleware/errorHandler'; -import { PayloadRequest } from './express/types'; -import sendEmail from './email/sendEmail'; - -import { serverInit as serverInitTelemetry } from './utilities/telemetry/events/serverInit'; -import { Payload } from '.'; -import loadConfig from './config/load'; -import Logger from './utilities/logger'; -import { getDataLoader } from './collections/dataloader'; -import mountEndpoints from './express/mountEndpoints'; -import PreferencesModel from './preferences/model'; -import findConfig from './config/find'; - -export const init = (payload: Payload, options: InitOptions): void => { - payload.logger.info('Starting Payload...'); - if (!options.secret) { - throw new Error( - 'Error: missing secret key. A secret key is needed to secure Payload.', - ); - } - - if (options.mongoURL !== false && typeof options.mongoURL !== 'string') { - throw new Error('Error: missing MongoDB connection URL.'); - } - - payload.emailOptions = { ...(options.email) }; - payload.secret = crypto - .createHash('sha256') - .update(options.secret) - .digest('hex') - .slice(0, 32); - - payload.local = options.local; - - if (options.config) { - payload.config = options.config; - const configPath = findConfig(); - - payload.config = { - ...options.config, - paths: { - configDir: path.dirname(configPath), - config: configPath, - rawConfig: configPath, - }, - }; - } else { - payload.config = loadConfig(payload.logger); - } - - // If not initializing locally, scaffold router - if (!payload.local) { - payload.router = express.Router(); - payload.router.use(...expressMiddleware(payload)); - initAuth(payload); - } - - // Configure email service - payload.email = buildEmail(payload.emailOptions, payload.logger); - payload.sendEmail = sendEmail.bind(payload); - - // Initialize collections & globals - initCollections(payload); - initGlobals(payload); - - if (!payload.config.graphQL.disable) { - registerSchema(payload); - } - - payload.preferences = { Model: PreferencesModel }; - - // If not initializing locally, set up HTTP routing - if (!payload.local) { - options.express.use((req: PayloadRequest, res, next) => { - req.payload = payload; - next(); - }); - - options.express.use((req: PayloadRequest, res: Response, next: NextFunction): void => { - req.payloadDataLoader = getDataLoader(req); - return next(); - }); - - payload.express = options.express; - - if (payload.config.rateLimit.trustProxy) { - payload.express.set('trust proxy', 1); - } - - initAdmin(payload); - initPreferences(payload); - - payload.router.get('/access', access); - - if (!payload.config.graphQL.disable) { - payload.router.use( - payload.config.routes.graphQL, - (req, res, next): void => { - if (req.method === 'OPTIONS') { - res.sendStatus(204); - } else { - next(); - } - }, - identifyAPI('GraphQL'), - (req: PayloadRequest, res: Response) => graphQLHandler(req, res)(req, res), - ); - initGraphQLPlayground(payload); - } - - mountEndpoints(options.express, payload.router, payload.config.endpoints); - - // Bind router to API - payload.express.use(payload.config.routes.api, payload.router); - - // Enable static routes for all collections permitting upload - initStatic(payload); - - payload.errorHandler = errorHandler(payload.config, payload.logger); - payload.router.use(payload.errorHandler); - - payload.authenticate = authenticate(payload.config); - } - - serverInitTelemetry(payload); -}; - -export const initAsync = async (payload: Payload, options: InitOptions): Promise => { - payload.logger = Logger('payload', options.loggerOptions); - payload.mongoURL = options.mongoURL; - - if (payload.mongoURL) { - mongoose.set('strictQuery', false); - payload.mongoMemoryServer = await connectMongoose(payload.mongoURL, options.mongoOptions, payload.logger); - } - - init(payload, options); - - if (typeof options.onInit === 'function') await options.onInit(payload); - if (typeof payload.config.onInit === 'function') await payload.config.onInit(payload); -}; - -export const initSync = (payload: Payload, options: InitOptions): void => { - payload.logger = Logger('payload', options.loggerOptions); - payload.mongoURL = options.mongoURL; - - if (payload.mongoURL) { - mongoose.set('strictQuery', false); - connectMongoose(payload.mongoURL, options.mongoOptions, payload.logger); - } - - init(payload, options); - - if (typeof options.onInit === 'function') options.onInit(payload); - if (typeof payload.config.onInit === 'function') payload.config.onInit(payload); -}; diff --git a/src/initHTTP.ts b/src/initHTTP.ts new file mode 100644 index 0000000000..46ae02b7f1 --- /dev/null +++ b/src/initHTTP.ts @@ -0,0 +1,84 @@ +/* eslint-disable no-param-reassign */ +import express, { NextFunction, Response } from 'express'; +import { InitOptions } from './config/types'; + +import authenticate from './express/middleware/authenticate'; +import expressMiddleware from './express/middleware'; +import initAdmin from './express/admin'; +import initAuth from './auth/init'; +import access from './auth/requestHandlers/access'; +import initCollectionsHTTP from './collections/initHTTP'; +import initPreferences from './preferences/init'; +import initGlobalsHTTP from './globals/initHTTP'; +import initGraphQLPlayground from './graphql/initPlayground'; +import initStatic from './express/static'; +import graphQLHandler from './graphql/graphQLHandler'; +import identifyAPI from './express/middleware/identifyAPI'; +import errorHandler from './express/middleware/errorHandler'; +import { PayloadRequest } from './express/types'; +import { getDataLoader } from './collections/dataloader'; +import mountEndpoints from './express/mountEndpoints'; +import { Payload, getPayload } from './payload'; + +export const initHTTP = async (options: InitOptions): Promise> => { + const payload = await getPayload(options); + + payload.router = express.Router(); + payload.router.use(...expressMiddleware(payload)); + initAuth(payload); + + initCollectionsHTTP(payload); + initGlobalsHTTP(payload); + + options.express.use((req: PayloadRequest, res, next) => { + req.payload = payload; + next(); + }); + + options.express.use((req: PayloadRequest, res: Response, next: NextFunction): void => { + req.payloadDataLoader = getDataLoader(req); + return next(); + }); + + payload.express = options.express; + + if (payload.config.rateLimit.trustProxy) { + payload.express.set('trust proxy', 1); + } + + initAdmin(payload); + initPreferences(payload); + + payload.router.get('/access', access); + + if (!payload.config.graphQL.disable) { + payload.router.use( + payload.config.routes.graphQL, + (req, res, next): void => { + if (req.method === 'OPTIONS') { + res.sendStatus(204); + } else { + next(); + } + }, + identifyAPI('GraphQL'), + (req: PayloadRequest, res: Response) => graphQLHandler(req, res)(req, res), + ); + initGraphQLPlayground(payload); + } + + mountEndpoints(options.express, payload.router, payload.config.endpoints); + + // Bind router to API + payload.express.use(payload.config.routes.api, payload.router); + + // Enable static routes for all collections permitting upload + initStatic(payload); + + payload.errorHandler = errorHandler(payload.config, payload.logger); + payload.router.use(payload.errorHandler); + + payload.authenticate = authenticate(payload.config); + + return payload; +}; diff --git a/src/payload.ts b/src/payload.ts new file mode 100644 index 0000000000..02e0457e35 --- /dev/null +++ b/src/payload.ts @@ -0,0 +1,373 @@ +import pino from 'pino'; +import type { Express, Router } from 'express'; +import { GraphQLError, GraphQLFormattedError, GraphQLSchema } from 'graphql'; +import crypto from 'crypto'; +import path from 'path'; +import mongoose from 'mongoose'; +import { + TypeWithID, + Collection, + CollectionModel, +} from './collections/config/types'; +import { + SanitizedConfig, + EmailOptions, + InitOptions, +} from './config/types'; +import { TypeWithVersion } from './versions/types'; +import { PaginatedDocs } from './mongoose/types'; + +import { PayloadAuthenticate } from './express/middleware/authenticate'; +import { Globals, TypeWithID as GlobalTypeWithID } from './globals/config/types'; +import { ErrorHandler } from './express/middleware/errorHandler'; +import localOperations from './collections/operations/local'; +import localGlobalOperations from './globals/operations/local'; +import { encrypt, decrypt } from './auth/crypto'; +import { BuildEmailResult, Message } from './email/types'; +import { Preferences } from './preferences/types'; + +import { Options as CreateOptions } from './collections/operations/local/create'; +import { Options as FindOptions } from './collections/operations/local/find'; +import { Options as FindByIDOptions } from './collections/operations/local/findByID'; +import { Options as UpdateOptions } from './collections/operations/local/update'; +import { Options as DeleteOptions } from './collections/operations/local/delete'; +import { Options as FindVersionsOptions } from './collections/operations/local/findVersions'; +import { Options as FindVersionByIDOptions } from './collections/operations/local/findVersionByID'; +import { Options as RestoreVersionOptions } from './collections/operations/local/restoreVersion'; +import { Options as FindGlobalVersionsOptions } from './globals/operations/local/findVersions'; +import { Options as FindGlobalVersionByIDOptions } from './globals/operations/local/findVersionByID'; +import { Options as RestoreGlobalVersionOptions } from './globals/operations/local/restoreVersion'; +import { Options as ForgotPasswordOptions } from './auth/operations/local/forgotPassword'; +import { Options as LoginOptions } from './auth/operations/local/login'; +import { Options as ResetPasswordOptions } from './auth/operations/local/resetPassword'; +import { Options as UnlockOptions } from './auth/operations/local/unlock'; +import { Options as VerifyEmailOptions } from './auth/operations/local/verifyEmail'; +import { Result as ForgotPasswordResult } from './auth/operations/forgotPassword'; +import { Result as ResetPasswordResult } from './auth/operations/resetPassword'; +import { Result as LoginResult } from './auth/operations/login'; +import { Options as FindGlobalOptions } from './globals/operations/local/findOne'; +import { Options as UpdateGlobalOptions } from './globals/operations/local/update'; + +import connectMongoose from './mongoose/connect'; +import initCollections from './collections/initLocal'; +import initGlobals from './globals/initLocal'; +import registerSchema from './graphql/registerSchema'; +import buildEmail from './email/build'; +import sendEmail from './email/sendEmail'; + +import { serverInit as serverInitTelemetry } from './utilities/telemetry/events/serverInit'; +import loadConfig from './config/load'; +import Logger from './utilities/logger'; +import PreferencesModel from './preferences/model'; +import findConfig from './config/find'; + +/** + * @description Payload + */ +export class Payload { + config: SanitizedConfig; + + collections: { + [slug: string]: Collection; + } = {} + + versions: { + [slug: string]: CollectionModel; + } = {} + + preferences: Preferences; + + globals: Globals; + + logger: pino.Logger; + + emailOptions: EmailOptions; + + email: BuildEmailResult; + + sendEmail: (message: Message) => Promise; + + secret: string; + + mongoURL: string | false; + + mongoMemoryServer: any + + local: boolean; + + encrypt = encrypt; + + decrypt = decrypt; + + errorHandler: ErrorHandler; + + authenticate: PayloadAuthenticate; + + express?: Express + + router?: Router + + types: { + blockTypes: any; + blockInputTypes: any; + localeInputType?: any; + fallbackLocaleInputType?: any; + }; + + Query: { name: string; fields: { [key: string]: any } } = { name: 'Query', fields: {} }; + + Mutation: { name: string; fields: { [key: string]: any } } = { name: 'Mutation', fields: {} }; + + schema: GraphQLSchema; + + extensions: (info: any) => Promise; + + customFormatErrorFn: (error: GraphQLError) => GraphQLFormattedError; + + validationRules: any; + + errorResponses: GraphQLFormattedError[] = []; + + errorIndex: number; + + getAdminURL = (): string => `${this.config.serverURL}${this.config.routes.admin}`; + + getAPIURL = (): string => `${this.config.serverURL}${this.config.routes.api}`; + + /** + * @description Initializes Payload + * @param options + */ + async init(options: InitOptions): Promise> { + this.logger = Logger('payload', options.loggerOptions); + this.mongoURL = options.mongoURL; + + if (this.mongoURL) { + mongoose.set('strictQuery', false); + this.mongoMemoryServer = await connectMongoose(this.mongoURL, options.mongoOptions, this.logger); + } + + this.logger.info('Starting Payload...'); + if (!options.secret) { + throw new Error( + 'Error: missing secret key. A secret key is needed to secure Payload.', + ); + } + + if (options.mongoURL !== false && typeof options.mongoURL !== 'string') { + throw new Error('Error: missing MongoDB connection URL.'); + } + + this.emailOptions = { ...(options.email) }; + this.secret = crypto + .createHash('sha256') + .update(options.secret) + .digest('hex') + .slice(0, 32); + + this.local = options.local; + + if (options.config) { + this.config = options.config; + const configPath = findConfig(); + + this.config = { + ...options.config, + paths: { + configDir: path.dirname(configPath), + config: configPath, + rawConfig: configPath, + }, + }; + } else { + this.config = loadConfig(this.logger); + } + + // Configure email service + this.email = buildEmail(this.emailOptions, this.logger); + this.sendEmail = sendEmail.bind(this); + + // Initialize collections & globals + initCollections(this); + initGlobals(this); + + if (!this.config.graphQL.disable) { + registerSchema(this); + } + + this.preferences = { Model: PreferencesModel }; + + serverInitTelemetry(this); + + if (typeof options.onInit === 'function') await options.onInit(this); + if (typeof this.config.onInit === 'function') await this.config.onInit(this); + + return this; + } + + /** + * @description Performs create operation + * @param options + * @returns created document + */ + create = async (options: CreateOptions): Promise => { + const { create } = localOperations; + return create(this, options); + } + + /** + * @description Find documents with criteria + * @param options + * @returns documents satisfying query + */ + find = async (options: FindOptions): Promise> => { + const { find } = localOperations; + return find(this, options); + } + + findGlobal = async (options: FindGlobalOptions): Promise => { + const { findOne } = localGlobalOperations; + return findOne(this, options); + } + + updateGlobal = async (options: UpdateGlobalOptions): Promise => { + const { update } = localGlobalOperations; + return update(this, options); + } + + /** + * @description Find global versions with criteria + * @param options + * @returns versions satisfying query + */ + findGlobalVersions = async = any>(options: FindGlobalVersionsOptions): Promise> => { + const { findVersions } = localGlobalOperations; + return findVersions(this, options); + } + + /** + * @description Find global version by ID + * @param options + * @returns global version with specified ID + */ + findGlobalVersionByID = async = any>(options: FindGlobalVersionByIDOptions): Promise => { + const { findVersionByID } = localGlobalOperations; + return findVersionByID(this, options); + } + + /** + * @description Restore global version by ID + * @param options + * @returns version with specified ID + */ + restoreGlobalVersion = async = any>(options: RestoreGlobalVersionOptions): Promise => { + const { restoreVersion } = localGlobalOperations; + return restoreVersion(this, options); + } + + /** + * @description Find document by ID + * @param options + * @returns document with specified ID + */ + findByID = async (options: FindByIDOptions): Promise => { + const { findByID } = localOperations; + return findByID(this, options); + } + + /** + * @description Update document + * @param options + * @returns Updated document + */ + update = async (options: UpdateOptions): Promise => { + const { update } = localOperations; + return update(this, options); + } + + delete = async (options: DeleteOptions): Promise => { + const { localDelete } = localOperations; + return localDelete(this, options); + } + + /** + * @description Find versions with criteria + * @param options + * @returns versions satisfying query + */ + findVersions = async = any>(options: FindVersionsOptions): Promise> => { + const { findVersions } = localOperations; + return findVersions(this, options); + } + + /** + * @description Find version by ID + * @param options + * @returns version with specified ID + */ + findVersionByID = async = any>(options: FindVersionByIDOptions): Promise => { + const { findVersionByID } = localOperations; + return findVersionByID(this, options); + } + + /** + * @description Restore version by ID + * @param options + * @returns version with specified ID + */ + restoreVersion = async = any>(options: RestoreVersionOptions): Promise => { + const { restoreVersion } = localOperations; + return restoreVersion(this, options); + } + + login = async (options: LoginOptions): Promise => { + const { login } = localOperations.auth; + return login(this, options); + } + + forgotPassword = async (options: ForgotPasswordOptions): Promise => { + const { forgotPassword } = localOperations.auth; + return forgotPassword(this, options); + } + + resetPassword = async (options: ResetPasswordOptions): Promise => { + const { resetPassword } = localOperations.auth; + return resetPassword(this, options); + } + + unlock = async (options: UnlockOptions): Promise => { + const { unlock } = localOperations.auth; + return unlock(this, options); + } + + verifyEmail = async (options: VerifyEmailOptions): Promise => { + const { verifyEmail } = localOperations.auth; + return verifyEmail(this, options); + } +} + +let cached = global.payload; + +if (!cached) { + // eslint-disable-next-line no-multi-assign + cached = global.payload = { payload: null, promise: null }; +} + +export const getPayload = async (options: InitOptions): Promise> => { + if (cached.payload) { + return cached.payload; + } + + if (!cached.promise) { + cached.promise = new Payload().init(options); + } + + try { + cached.payload = await cached.promise; + } catch (e) { + cached.promise = null; + throw e; + } + + return cached.payload; +}; diff --git a/src/preferences/init.ts b/src/preferences/init.ts index 383b989ab2..67a8fad1cf 100644 --- a/src/preferences/init.ts +++ b/src/preferences/init.ts @@ -1,11 +1,10 @@ import express from 'express'; - -import { Payload } from '../index'; import findOne from './requestHandlers/findOne'; import update from './requestHandlers/update'; import deleteHandler from './requestHandlers/delete'; +import { PayloadHTTP } from '..'; -export default function initPreferences(ctx: Payload): void { +export default function initPreferences(ctx: PayloadHTTP): void { if (!ctx.local) { const router = express.Router(); router diff --git a/test/devServer.ts b/test/devServer.ts index 02c9b8778a..d2dd70c29f 100644 --- a/test/devServer.ts +++ b/test/devServer.ts @@ -1,12 +1,12 @@ import express from 'express'; import { v4 as uuid } from 'uuid'; -import payload from '../src'; +import { init as initPayload } from '../src'; const expressApp = express(); -const init = async () => { - await payload.initAsync({ +const startDev = async () => { + const payload = await initPayload({ secret: uuid(), mongoURL: process.env.MONGO_URL || 'mongodb://localhost/payload', express: expressApp, @@ -35,4 +35,4 @@ const init = async () => { }); }; -init(); +startDev(); From d3d367c635f72b7353ad9a6ff9ecad6a5f56dd08 Mon Sep 17 00:00:00 2001 From: James Date: Wed, 11 Jan 2023 17:03:10 -0500 Subject: [PATCH 05/46] feat: isolates local api to local-only functions, converts it to ts generic for stronger typing --- src/auth/graphql/resolvers/access.ts | 2 +- src/auth/init.ts | 2 +- src/auth/operations/local/forgotPassword.ts | 2 +- src/auth/operations/local/login.ts | 4 +- src/auth/operations/local/resetPassword.ts | 2 +- src/auth/operations/local/unlock.ts | 2 +- src/auth/operations/local/verifyEmail.ts | 2 +- src/auth/sendVerificationEmail.ts | 2 +- src/auth/strategies/apiKey.ts | 2 +- src/auth/strategies/jwt.ts | 2 +- src/auth/types.ts | 2 +- src/collections/graphql/init.ts | 2 +- src/collections/operations/local/create.ts | 2 +- src/collections/operations/local/delete.ts | 2 +- src/collections/operations/local/find.ts | 2 +- src/collections/operations/local/findByID.ts | 2 +- .../operations/local/findVersionByID.ts | 2 +- .../operations/local/findVersions.ts | 2 +- .../operations/local/restoreVersion.ts | 2 +- src/collections/operations/local/update.ts | 2 +- src/config/types.ts | 2 +- src/express/admin.ts | 2 +- src/express/middleware/index.ts | 2 +- src/express/static.ts | 2 +- src/express/types.ts | 2 +- src/fields/config/types.ts | 2 +- src/globals/graphql/init.ts | 2 +- src/globals/operations/local/findOne.ts | 2 +- .../operations/local/findVersionByID.ts | 2 +- src/globals/operations/local/findVersions.ts | 2 +- .../operations/local/restoreVersion.ts | 2 +- src/globals/operations/local/update.ts | 2 +- src/graphql/initPlayground.ts | 2 +- src/graphql/registerSchema.ts | 2 +- src/graphql/schema/buildBlockType.ts | 2 +- src/graphql/schema/buildMutationInputType.ts | 2 +- src/graphql/schema/buildObjectType.ts | 2 +- src/graphql/schema/buildPoliciesType.ts | 2 +- src/index.ts | 19 +++- src/initHTTP.ts | 102 +++++++++--------- src/preferences/graphql/init.ts | 2 +- src/uploads/uploadFiles.ts | 2 +- src/utilities/telemetry/events/serverInit.ts | 2 +- src/utilities/telemetry/index.ts | 6 +- src/versions/cleanUpFailedVersion.ts | 2 +- src/versions/drafts/mergeDrafts.ts | 2 +- .../drafts/replaceWithDraftIfAvailable.ts | 2 +- src/versions/drafts/saveCollectionDraft.ts | 4 +- src/versions/drafts/saveGlobalDraft.ts | 4 +- src/versions/enforceMaxVersions.ts | 2 +- .../ensurePublishedCollectionVersion.ts | 18 ++-- src/versions/ensurePublishedGlobalVersion.ts | 18 ++-- src/versions/getLatestCollectionVersion.ts | 2 +- src/versions/saveCollectionVersion.ts | 18 ++-- src/versions/saveGlobalVersion.ts | 18 ++-- test/auth/custom-strategy/config.ts | 31 +++--- test/devServer.ts | 4 +- test/helpers/configHelpers.ts | 2 +- test/hooks/collections/Users/index.ts | 2 +- 59 files changed, 175 insertions(+), 165 deletions(-) diff --git a/src/auth/graphql/resolvers/access.ts b/src/auth/graphql/resolvers/access.ts index 6c06064017..1e90ce6e3e 100644 --- a/src/auth/graphql/resolvers/access.ts +++ b/src/auth/graphql/resolvers/access.ts @@ -1,6 +1,6 @@ import formatName from '../../../graphql/utilities/formatName'; import access from '../../operations/access'; -import { Payload } from '../../..'; +import { Payload } from '../../../payload'; const formatConfigNames = (results, configs) => { const formattedResults = { ...results }; diff --git a/src/auth/init.ts b/src/auth/init.ts index cd914bdd82..97c4b8f4c3 100644 --- a/src/auth/init.ts +++ b/src/auth/init.ts @@ -1,6 +1,6 @@ import passport from 'passport'; import AnonymousStrategy from 'passport-anonymous'; -import { Payload } from '../index'; +import { Payload } from '../payload'; import jwtStrategy from './strategies/jwt'; function initAuth(ctx: Payload): void { diff --git a/src/auth/operations/local/forgotPassword.ts b/src/auth/operations/local/forgotPassword.ts index 612889267a..32735cd207 100644 --- a/src/auth/operations/local/forgotPassword.ts +++ b/src/auth/operations/local/forgotPassword.ts @@ -1,6 +1,6 @@ import { PayloadRequest } from '../../../express/types'; import forgotPassword, { Result } from '../forgotPassword'; -import { Payload } from '../../..'; +import { Payload } from '../../../payload'; import { getDataLoader } from '../../../collections/dataloader'; import i18n from '../../../translations/init'; diff --git a/src/auth/operations/local/login.ts b/src/auth/operations/local/login.ts index ef92235c08..3b891af8c8 100644 --- a/src/auth/operations/local/login.ts +++ b/src/auth/operations/local/login.ts @@ -2,7 +2,7 @@ import { Response } from 'express'; import login, { Result } from '../login'; import { PayloadRequest } from '../../../express/types'; import { TypeWithID } from '../../../collections/config/types'; -import { Payload } from '../../..'; +import { Payload } from '../../../payload'; import { getDataLoader } from '../../../collections/dataloader'; import i18n from '../../../translations/init'; @@ -21,7 +21,7 @@ export type Options = { showHiddenFields?: boolean } -async function localLogin(payload: Payload, options: Options): Promise { +async function localLogin(payload: Payload, options: Options): Promise { const { collection: collectionSlug, req = {} as PayloadRequest, diff --git a/src/auth/operations/local/resetPassword.ts b/src/auth/operations/local/resetPassword.ts index 55f3541159..99434ad3e4 100644 --- a/src/auth/operations/local/resetPassword.ts +++ b/src/auth/operations/local/resetPassword.ts @@ -1,4 +1,4 @@ -import { Payload } from '../../..'; +import { Payload } from '../../../payload'; import resetPassword, { Result } from '../resetPassword'; import { PayloadRequest } from '../../../express/types'; import { getDataLoader } from '../../../collections/dataloader'; diff --git a/src/auth/operations/local/unlock.ts b/src/auth/operations/local/unlock.ts index ace86d1087..e7b6a3c973 100644 --- a/src/auth/operations/local/unlock.ts +++ b/src/auth/operations/local/unlock.ts @@ -1,5 +1,5 @@ import { PayloadRequest } from '../../../express/types'; -import { Payload } from '../../..'; +import { Payload } from '../../../payload'; import unlock from '../unlock'; import { getDataLoader } from '../../../collections/dataloader'; import i18n from '../../../translations/init'; diff --git a/src/auth/operations/local/verifyEmail.ts b/src/auth/operations/local/verifyEmail.ts index 22228d5ac4..371cc184da 100644 --- a/src/auth/operations/local/verifyEmail.ts +++ b/src/auth/operations/local/verifyEmail.ts @@ -1,4 +1,4 @@ -import { Payload } from '../../../index'; +import { Payload } from '../../../payload'; import verifyEmail from '../verifyEmail'; export type Options = { diff --git a/src/auth/sendVerificationEmail.ts b/src/auth/sendVerificationEmail.ts index 77c972e1e0..871f5573fd 100644 --- a/src/auth/sendVerificationEmail.ts +++ b/src/auth/sendVerificationEmail.ts @@ -1,4 +1,4 @@ -import { Payload } from '..'; +import { Payload } from '../payload'; import { PayloadRequest } from '../express/types'; import { SanitizedConfig, EmailOptions } from '../config/types'; import { Collection } from '../collections/config/types'; diff --git a/src/auth/strategies/apiKey.ts b/src/auth/strategies/apiKey.ts index e6cb2b4a7c..b2e1a0fe12 100644 --- a/src/auth/strategies/apiKey.ts +++ b/src/auth/strategies/apiKey.ts @@ -1,7 +1,7 @@ import PassportAPIKey from 'passport-headerapikey'; import crypto from 'crypto'; import { PayloadRequest } from '../../express/types'; -import { Payload } from '../..'; +import { Payload } from '../../payload'; import find from '../../collections/operations/find'; export default (payload: Payload, { Model, config }): PassportAPIKey => { diff --git a/src/auth/strategies/jwt.ts b/src/auth/strategies/jwt.ts index 17b384e453..ecd32db9b0 100644 --- a/src/auth/strategies/jwt.ts +++ b/src/auth/strategies/jwt.ts @@ -1,7 +1,7 @@ import url from 'url'; import passportJwt, { StrategyOptions } from 'passport-jwt'; import { Strategy as PassportStrategy } from 'passport-strategy'; -import { Payload } from '../..'; +import { Payload } from '../../payload'; import getExtractJWT from '../getExtractJWT'; const JwtStrategy = passportJwt.Strategy; diff --git a/src/auth/types.ts b/src/auth/types.ts index 10cd92eacd..0d535c4578 100644 --- a/src/auth/types.ts +++ b/src/auth/types.ts @@ -2,7 +2,7 @@ import { Strategy } from 'passport'; import { DeepRequired } from 'ts-essentials'; import { PayloadRequest } from '../express/types'; import { Where, PayloadMongooseDocument } from '../types'; -import { Payload } from '..'; +import { Payload } from '../payload'; export type Permission = { permission: boolean diff --git a/src/collections/graphql/init.ts b/src/collections/graphql/init.ts index b1140b015f..179fc19485 100644 --- a/src/collections/graphql/init.ts +++ b/src/collections/graphql/init.ts @@ -28,7 +28,7 @@ import resetPassword from '../../auth/graphql/resolvers/resetPassword'; import verifyEmail from '../../auth/graphql/resolvers/verifyEmail'; import unlock from '../../auth/graphql/resolvers/unlock'; import refresh from '../../auth/graphql/resolvers/refresh'; -import { Payload } from '../..'; +import { Payload } from '../../payload'; import { Field, fieldAffectsData } from '../../fields/config/types'; import buildObjectType, { ObjectTypeConfig } from '../../graphql/schema/buildObjectType'; import buildWhereInputType from '../../graphql/schema/buildWhereInputType'; diff --git a/src/collections/operations/local/create.ts b/src/collections/operations/local/create.ts index e32a58e710..366fc9ca0a 100644 --- a/src/collections/operations/local/create.ts +++ b/src/collections/operations/local/create.ts @@ -1,5 +1,5 @@ import { UploadedFile } from 'express-fileupload'; -import { Payload } from '../../..'; +import { Payload } from '../../../payload'; import { PayloadRequest } from '../../../express/types'; import { Document } from '../../../types'; import getFileByPath from '../../../uploads/getFileByPath'; diff --git a/src/collections/operations/local/delete.ts b/src/collections/operations/local/delete.ts index 0b8a0188a8..562810de5b 100644 --- a/src/collections/operations/local/delete.ts +++ b/src/collections/operations/local/delete.ts @@ -1,7 +1,7 @@ import { TypeWithID } from '../../config/types'; import { Document } from '../../../types'; import { PayloadRequest } from '../../../express/types'; -import { Payload } from '../../../index'; +import { Payload } from '../../../payload'; import deleteOperation from '../delete'; import { getDataLoader } from '../../dataloader'; import i18n from '../../../translations/init'; diff --git a/src/collections/operations/local/find.ts b/src/collections/operations/local/find.ts index 342a91dcb6..9bf82337f1 100644 --- a/src/collections/operations/local/find.ts +++ b/src/collections/operations/local/find.ts @@ -1,7 +1,7 @@ import { TypeWithID } from '../../config/types'; import { PaginatedDocs } from '../../../mongoose/types'; import { Document, Where } from '../../../types'; -import { Payload } from '../../..'; +import { Payload } from '../../../payload'; import { PayloadRequest } from '../../../express/types'; import find from '../find'; import { getDataLoader } from '../../dataloader'; diff --git a/src/collections/operations/local/findByID.ts b/src/collections/operations/local/findByID.ts index ba3addeb1d..21d4090af9 100644 --- a/src/collections/operations/local/findByID.ts +++ b/src/collections/operations/local/findByID.ts @@ -2,7 +2,7 @@ import { TypeWithID } from '../../config/types'; import { PayloadRequest } from '../../../express/types'; import { Document } from '../../../types'; import findByID from '../findByID'; -import { Payload } from '../../..'; +import { Payload } from '../../../payload'; import { getDataLoader } from '../../dataloader'; import i18n from '../../../translations/init'; diff --git a/src/collections/operations/local/findVersionByID.ts b/src/collections/operations/local/findVersionByID.ts index 240ce53bd8..5119035a1d 100644 --- a/src/collections/operations/local/findVersionByID.ts +++ b/src/collections/operations/local/findVersionByID.ts @@ -1,4 +1,4 @@ -import { Payload } from '../../..'; +import { Payload } from '../../../payload'; import { Document } from '../../../types'; import { PayloadRequest } from '../../../express/types'; import { TypeWithVersion } from '../../../versions/types'; diff --git a/src/collections/operations/local/findVersions.ts b/src/collections/operations/local/findVersions.ts index 6d833cf976..0f688566c3 100644 --- a/src/collections/operations/local/findVersions.ts +++ b/src/collections/operations/local/findVersions.ts @@ -1,4 +1,4 @@ -import { Payload } from '../../..'; +import { Payload } from '../../../payload'; import { Document, Where } from '../../../types'; import { PaginatedDocs } from '../../../mongoose/types'; import { TypeWithVersion } from '../../../versions/types'; diff --git a/src/collections/operations/local/restoreVersion.ts b/src/collections/operations/local/restoreVersion.ts index f016468740..11d410801f 100644 --- a/src/collections/operations/local/restoreVersion.ts +++ b/src/collections/operations/local/restoreVersion.ts @@ -1,4 +1,4 @@ -import { Payload } from '../../..'; +import { Payload } from '../../../payload'; import { PayloadRequest } from '../../../express/types'; import { Document } from '../../../types'; import { TypeWithVersion } from '../../../versions/types'; diff --git a/src/collections/operations/local/update.ts b/src/collections/operations/local/update.ts index 57fd71a7ff..cdb807fd5a 100644 --- a/src/collections/operations/local/update.ts +++ b/src/collections/operations/local/update.ts @@ -1,4 +1,4 @@ -import { Payload } from '../../..'; +import { Payload } from '../../../payload'; import { Document } from '../../../types'; import getFileByPath from '../../../uploads/getFileByPath'; import update from '../update'; diff --git a/src/config/types.ts b/src/config/types.ts index 0b81ad5cfe..afbe5a1033 100644 --- a/src/config/types.ts +++ b/src/config/types.ts @@ -9,7 +9,7 @@ import { ConnectOptions } from 'mongoose'; import React from 'react'; import { LoggerOptions } from 'pino'; import type { InitOptions as i18nInitOptions } from 'i18next'; -import { Payload } from '..'; +import { Payload } from '../payload'; import { AfterErrorHook, CollectionConfig, diff --git a/src/express/admin.ts b/src/express/admin.ts index b997d11803..93b2307634 100644 --- a/src/express/admin.ts +++ b/src/express/admin.ts @@ -3,7 +3,7 @@ import compression from 'compression'; import history from 'connect-history-api-fallback'; import path from 'path'; import initWebpack from '../webpack/init'; -import { Payload } from '../index'; +import { Payload } from '../payload'; const router = express.Router(); diff --git a/src/express/middleware/index.ts b/src/express/middleware/index.ts index f213452b2a..8ae0ebc974 100644 --- a/src/express/middleware/index.ts +++ b/src/express/middleware/index.ts @@ -9,7 +9,7 @@ import rateLimit from 'express-rate-limit'; import localizationMiddleware from '../../localization/middleware'; import authenticate from './authenticate'; import identifyAPI from './identifyAPI'; -import { Payload } from '../..'; +import { Payload } from '../../payload'; import { PayloadRequest } from '../types'; import corsHeaders from './corsHeaders'; import convertPayload from './convertPayload'; diff --git a/src/express/static.ts b/src/express/static.ts index e73fa87e62..22744fe64c 100644 --- a/src/express/static.ts +++ b/src/express/static.ts @@ -3,7 +3,7 @@ import passport from 'passport'; import path from 'path'; import getExecuteStaticAccess from '../auth/getExecuteStaticAccess'; import authenticate from './middleware/authenticate'; -import { Payload } from '../index'; +import { Payload } from '../payload'; import corsHeaders from './middleware/corsHeaders'; function initStatic(ctx: Payload): void { diff --git a/src/express/types.ts b/src/express/types.ts index 8e363fcc60..549b555a89 100644 --- a/src/express/types.ts +++ b/src/express/types.ts @@ -2,7 +2,7 @@ import { Request } from 'express'; import type { i18n as Ii18n, TFunction } from 'i18next'; import DataLoader from 'dataloader'; import { UploadedFile } from 'express-fileupload'; -import { Payload } from '../index'; +import { Payload } from '../payload'; import { Collection } from '../collections/config/types'; import { User } from '../auth/types'; import { Document } from '../types'; diff --git a/src/fields/config/types.ts b/src/fields/config/types.ts index 6bdc16d905..177f92f040 100644 --- a/src/fields/config/types.ts +++ b/src/fields/config/types.ts @@ -9,7 +9,7 @@ import { PayloadRequest } from '../../express/types'; import { ConditionalDateProps } from '../../admin/components/elements/DatePicker/types'; import { Description } from '../../admin/components/forms/FieldDescription/types'; import { User } from '../../auth'; -import { Payload } from '../..'; +import { Payload } from '../../payload'; import { RowLabel } from '../../admin/components/forms/RowLabel/types'; export type FieldHookArgs = { diff --git a/src/globals/graphql/init.ts b/src/globals/graphql/init.ts index 05b931ad3f..87d1d431bf 100644 --- a/src/globals/graphql/init.ts +++ b/src/globals/graphql/init.ts @@ -9,7 +9,7 @@ import updateResolver from './resolvers/update'; import findVersionByIDResolver from './resolvers/findVersionByID'; import findVersionsResolver from './resolvers/findVersions'; import restoreVersionResolver from './resolvers/restoreVersion'; -import { Payload } from '../..'; +import { Payload } from '../../payload'; import buildObjectType from '../../graphql/schema/buildObjectType'; import buildMutationInputType from '../../graphql/schema/buildMutationInputType'; import buildWhereInputType from '../../graphql/schema/buildWhereInputType'; diff --git a/src/globals/operations/local/findOne.ts b/src/globals/operations/local/findOne.ts index 8d9f04cab7..a9092f65ed 100644 --- a/src/globals/operations/local/findOne.ts +++ b/src/globals/operations/local/findOne.ts @@ -1,4 +1,4 @@ -import { Payload } from '../../..'; +import { Payload } from '../../../payload'; import { getDataLoader } from '../../../collections/dataloader'; import { PayloadRequest } from '../../../express/types'; import { Document } from '../../../types'; diff --git a/src/globals/operations/local/findVersionByID.ts b/src/globals/operations/local/findVersionByID.ts index 8d9cf748a2..ba37edadda 100644 --- a/src/globals/operations/local/findVersionByID.ts +++ b/src/globals/operations/local/findVersionByID.ts @@ -1,4 +1,4 @@ -import { Payload } from '../../..'; +import { Payload } from '../../../payload'; import { getDataLoader } from '../../../collections/dataloader'; import { PayloadRequest } from '../../../express/types'; import { Document } from '../../../types'; diff --git a/src/globals/operations/local/findVersions.ts b/src/globals/operations/local/findVersions.ts index 321b153173..504a38f22e 100644 --- a/src/globals/operations/local/findVersions.ts +++ b/src/globals/operations/local/findVersions.ts @@ -1,7 +1,7 @@ import { Document, Where } from '../../../types'; import { PaginatedDocs } from '../../../mongoose/types'; import { TypeWithVersion } from '../../../versions/types'; -import { Payload } from '../../..'; +import { Payload } from '../../../payload'; import { PayloadRequest } from '../../../express/types'; import findVersions from '../findVersions'; import { getDataLoader } from '../../../collections/dataloader'; diff --git a/src/globals/operations/local/restoreVersion.ts b/src/globals/operations/local/restoreVersion.ts index 97a83bd03e..de2917d6f1 100644 --- a/src/globals/operations/local/restoreVersion.ts +++ b/src/globals/operations/local/restoreVersion.ts @@ -1,4 +1,4 @@ -import { Payload } from '../../..'; +import { Payload } from '../../../payload'; import { getDataLoader } from '../../../collections/dataloader'; import { PayloadRequest } from '../../../express/types'; import { Document } from '../../../types'; diff --git a/src/globals/operations/local/update.ts b/src/globals/operations/local/update.ts index 264235f1b9..ca155a2e68 100644 --- a/src/globals/operations/local/update.ts +++ b/src/globals/operations/local/update.ts @@ -1,4 +1,4 @@ -import { Payload } from '../../..'; +import { Payload } from '../../../payload'; import { Document } from '../../../types'; import { PayloadRequest } from '../../../express/types'; import { TypeWithID } from '../../config/types'; diff --git a/src/graphql/initPlayground.ts b/src/graphql/initPlayground.ts index ea606812ab..57305f389e 100644 --- a/src/graphql/initPlayground.ts +++ b/src/graphql/initPlayground.ts @@ -1,5 +1,5 @@ import graphQLPlayground from 'graphql-playground-middleware-express'; -import { Payload } from '../index'; +import { Payload } from '../payload'; function initPlayground(ctx: Payload): void { if ((!ctx.config.graphQL.disable && !ctx.config.graphQL.disablePlaygroundInProduction && process.env.NODE_ENV === 'production') || process.env.NODE_ENV !== 'production') { diff --git a/src/graphql/registerSchema.ts b/src/graphql/registerSchema.ts index d70ff09333..233c32a7fa 100644 --- a/src/graphql/registerSchema.ts +++ b/src/graphql/registerSchema.ts @@ -2,7 +2,7 @@ import * as GraphQL from 'graphql'; import { GraphQLObjectType, GraphQLSchema } from 'graphql'; import queryComplexity, { fieldExtensionsEstimator, simpleEstimator } from 'graphql-query-complexity'; -import { Payload } from '..'; +import { Payload } from '../payload'; import buildLocaleInputType from './schema/buildLocaleInputType'; import buildFallbackLocaleInputType from './schema/buildFallbackLocaleInputType'; import initCollections from '../collections/graphql/init'; diff --git a/src/graphql/schema/buildBlockType.ts b/src/graphql/schema/buildBlockType.ts index 512f6d6074..52ae1d4af2 100644 --- a/src/graphql/schema/buildBlockType.ts +++ b/src/graphql/schema/buildBlockType.ts @@ -1,5 +1,5 @@ /* eslint-disable no-param-reassign */ -import { Payload } from '../..'; +import { Payload } from '../../payload'; import { Block } from '../../fields/config/types'; import buildObjectType from './buildObjectType'; import { toWords } from '../../utilities/formatLabels'; diff --git a/src/graphql/schema/buildMutationInputType.ts b/src/graphql/schema/buildMutationInputType.ts index 5e07a2396c..3e0cab49ba 100644 --- a/src/graphql/schema/buildMutationInputType.ts +++ b/src/graphql/schema/buildMutationInputType.ts @@ -18,7 +18,7 @@ import formatName from '../utilities/formatName'; import combineParentName from '../utilities/combineParentName'; import { ArrayField, CodeField, JSONField, DateField, EmailField, Field, fieldAffectsData, GroupField, NumberField, PointField, RadioField, RelationshipField, RichTextField, RowField, SelectField, TextareaField, TextField, UploadField, CollapsibleField, TabsField, CheckboxField, BlockField, tabHasName } from '../../fields/config/types'; import { toWords } from '../../utilities/formatLabels'; -import { Payload } from '../../index'; +import { Payload } from '../../payload'; import { SanitizedCollectionConfig } from '../../collections/config/types'; import { groupOrTabHasRequiredSubfield } from '../../utilities/groupOrTabHasRequiredSubfield'; diff --git a/src/graphql/schema/buildObjectType.ts b/src/graphql/schema/buildObjectType.ts index f7addc253c..805701be25 100644 --- a/src/graphql/schema/buildObjectType.ts +++ b/src/graphql/schema/buildObjectType.ts @@ -46,7 +46,7 @@ import withNullableType from './withNullableType'; import { toWords } from '../../utilities/formatLabels'; import createRichTextRelationshipPromise from '../../fields/richText/richTextRelationshipPromise'; import formatOptions from '../utilities/formatOptions'; -import { Payload } from '../..'; +import { Payload } from '../../payload'; import buildWhereInputType from './buildWhereInputType'; import buildBlockType from './buildBlockType'; import isFieldNullable from './isFieldNullable'; diff --git a/src/graphql/schema/buildPoliciesType.ts b/src/graphql/schema/buildPoliciesType.ts index 6d4e576e54..e84ebe8cbd 100644 --- a/src/graphql/schema/buildPoliciesType.ts +++ b/src/graphql/schema/buildPoliciesType.ts @@ -5,7 +5,7 @@ import formatName from '../utilities/formatName'; import { CollectionConfig, SanitizedCollectionConfig } from '../../collections/config/types'; import { GlobalConfig, SanitizedGlobalConfig } from '../../globals/config/types'; import { Field } from '../../fields/config/types'; -import { Payload } from '../..'; +import { Payload } from '../../payload'; import { toWords } from '../../utilities/formatLabels'; type OperationType = 'create' | 'read' | 'update' | 'delete' | 'unlock' | 'readVersions'; diff --git a/src/index.ts b/src/index.ts index 5c73e690a6..fdfd4e2e54 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,12 +2,21 @@ import { InitOptions, } from './config/types'; import { initHTTP } from './initHTTP'; -import { Payload, getPayload } from './payload'; +import { Payload } from './payload'; + +export { getPayload } from './payload'; require('isomorphic-fetch'); -export const init = async (options: InitOptions): Promise> => { - return initHTTP(options); -}; +export class PayloadHTTP extends Payload { + async init(options: InitOptions): Promise> { + const payload = await initHTTP(options); + Object.assign(this, payload); + return payload; + } +} -export default getPayload; +const payload = new PayloadHTTP(); + +export default payload; +module.exports = payload; diff --git a/src/initHTTP.ts b/src/initHTTP.ts index 46ae02b7f1..6c0b916b13 100644 --- a/src/initHTTP.ts +++ b/src/initHTTP.ts @@ -23,62 +23,64 @@ import { Payload, getPayload } from './payload'; export const initHTTP = async (options: InitOptions): Promise> => { const payload = await getPayload(options); - payload.router = express.Router(); - payload.router.use(...expressMiddleware(payload)); - initAuth(payload); + if (!options.local) { + payload.router = express.Router(); + payload.router.use(...expressMiddleware(payload)); + initAuth(payload); - initCollectionsHTTP(payload); - initGlobalsHTTP(payload); + initCollectionsHTTP(payload); + initGlobalsHTTP(payload); - options.express.use((req: PayloadRequest, res, next) => { - req.payload = payload; - next(); - }); + options.express.use((req: PayloadRequest, res, next) => { + req.payload = payload; + next(); + }); - options.express.use((req: PayloadRequest, res: Response, next: NextFunction): void => { - req.payloadDataLoader = getDataLoader(req); - return next(); - }); + options.express.use((req: PayloadRequest, res: Response, next: NextFunction): void => { + req.payloadDataLoader = getDataLoader(req); + return next(); + }); - payload.express = options.express; + payload.express = options.express; - if (payload.config.rateLimit.trustProxy) { - payload.express.set('trust proxy', 1); + if (payload.config.rateLimit.trustProxy) { + payload.express.set('trust proxy', 1); + } + + initAdmin(payload); + initPreferences(payload); + + payload.router.get('/access', access); + + if (!payload.config.graphQL.disable) { + payload.router.use( + payload.config.routes.graphQL, + (req, res, next): void => { + if (req.method === 'OPTIONS') { + res.sendStatus(204); + } else { + next(); + } + }, + identifyAPI('GraphQL'), + (req: PayloadRequest, res: Response) => graphQLHandler(req, res)(req, res), + ); + initGraphQLPlayground(payload); + } + + mountEndpoints(options.express, payload.router, payload.config.endpoints); + + // Bind router to API + payload.express.use(payload.config.routes.api, payload.router); + + // Enable static routes for all collections permitting upload + initStatic(payload); + + payload.errorHandler = errorHandler(payload.config, payload.logger); + payload.router.use(payload.errorHandler); + + payload.authenticate = authenticate(payload.config); } - initAdmin(payload); - initPreferences(payload); - - payload.router.get('/access', access); - - if (!payload.config.graphQL.disable) { - payload.router.use( - payload.config.routes.graphQL, - (req, res, next): void => { - if (req.method === 'OPTIONS') { - res.sendStatus(204); - } else { - next(); - } - }, - identifyAPI('GraphQL'), - (req: PayloadRequest, res: Response) => graphQLHandler(req, res)(req, res), - ); - initGraphQLPlayground(payload); - } - - mountEndpoints(options.express, payload.router, payload.config.endpoints); - - // Bind router to API - payload.express.use(payload.config.routes.api, payload.router); - - // Enable static routes for all collections permitting upload - initStatic(payload); - - payload.errorHandler = errorHandler(payload.config, payload.logger); - payload.router.use(payload.errorHandler); - - payload.authenticate = authenticate(payload.config); - return payload; }; diff --git a/src/preferences/graphql/init.ts b/src/preferences/graphql/init.ts index eb7bcaa95e..071e553980 100644 --- a/src/preferences/graphql/init.ts +++ b/src/preferences/graphql/init.ts @@ -9,7 +9,7 @@ import { DateTimeResolver } from 'graphql-scalars'; import findOne from '../operations/findOne'; import update from '../operations/update'; import deleteOperation from '../operations/delete'; -import { Payload } from '../..'; +import { Payload } from '../../payload'; function initCollectionsGraphQL(payload: Payload): void { const valueType = GraphQLJSON; diff --git a/src/uploads/uploadFiles.ts b/src/uploads/uploadFiles.ts index a72f579fbb..0205b0e9bd 100644 --- a/src/uploads/uploadFiles.ts +++ b/src/uploads/uploadFiles.ts @@ -2,7 +2,7 @@ import type { TFunction } from 'i18next'; import { FileUploadError } from '../errors'; import saveBufferToFile from './saveBufferToFile'; import { FileToSave } from './types'; -import { Payload } from '..'; +import { Payload } from '../payload'; export const uploadFiles = async (payload: Payload, files: FileToSave[], t: TFunction): Promise => { try { diff --git a/src/utilities/telemetry/events/serverInit.ts b/src/utilities/telemetry/events/serverInit.ts index 0109491221..ca86c06039 100644 --- a/src/utilities/telemetry/events/serverInit.ts +++ b/src/utilities/telemetry/events/serverInit.ts @@ -1,5 +1,5 @@ import { sendEvent } from '..'; -import { Payload } from '../../..'; +import { Payload } from '../../../payload'; export type ServerInitEvent = { type: 'server-init' diff --git a/src/utilities/telemetry/index.ts b/src/utilities/telemetry/index.ts index 533044f2db..3642cb3b0d 100644 --- a/src/utilities/telemetry/index.ts +++ b/src/utilities/telemetry/index.ts @@ -3,7 +3,7 @@ import Conf from 'conf'; import { randomBytes } from 'crypto'; import findUp from 'find-up'; import fs from 'fs'; -import { Payload } from '../../index'; +import { Payload } from '../../payload'; import { ServerInitEvent } from './events/serverInit'; import { AdminInitEvent } from './events/adminInit'; import { oneWayHash } from './oneWayHash'; @@ -28,7 +28,7 @@ type Args = { event: TelemetryEvent } -export const sendEvent = async ({ payload, event } : Args): Promise => { +export const sendEvent = async ({ payload, event }: Args): Promise => { if (payload.config.telemetry !== false) { try { const packageJSON = await getPackageJSON(); @@ -49,7 +49,7 @@ export const sendEvent = async ({ payload, event } : Args): Promise => { body: JSON.stringify({ ...baseEvent, ...event }), }); } catch (_) { - // Eat any errors in sending telemetry event + // Eat any errors in sending telemetry event } } }; diff --git a/src/versions/cleanUpFailedVersion.ts b/src/versions/cleanUpFailedVersion.ts index 6767c02fa9..83746ae398 100644 --- a/src/versions/cleanUpFailedVersion.ts +++ b/src/versions/cleanUpFailedVersion.ts @@ -1,4 +1,4 @@ -import { Payload } from '..'; +import { Payload } from '../payload'; import { SanitizedCollectionConfig } from '../collections/config/types'; import { SanitizedGlobalConfig } from '../globals/config/types'; import { TypeWithVersion } from './types'; diff --git a/src/versions/drafts/mergeDrafts.ts b/src/versions/drafts/mergeDrafts.ts index dbd472d64f..1fcab53ca7 100644 --- a/src/versions/drafts/mergeDrafts.ts +++ b/src/versions/drafts/mergeDrafts.ts @@ -1,6 +1,6 @@ import { AccessResult } from '../../config/types'; import { Where } from '../../types'; -import { Payload } from '../..'; +import { Payload } from '../../payload'; import { PaginatedDocs } from '../../mongoose/types'; import { Collection, CollectionModel, TypeWithID } from '../../collections/config/types'; import { hasWhereAccessResult } from '../../auth'; diff --git a/src/versions/drafts/replaceWithDraftIfAvailable.ts b/src/versions/drafts/replaceWithDraftIfAvailable.ts index d8decffa7d..c133c404ef 100644 --- a/src/versions/drafts/replaceWithDraftIfAvailable.ts +++ b/src/versions/drafts/replaceWithDraftIfAvailable.ts @@ -1,4 +1,4 @@ -import { Payload } from '../..'; +import { Payload } from '../../payload'; import { docHasTimestamps, Where } from '../../types'; import { hasWhereAccessResult } from '../../auth'; import { AccessResult } from '../../config/types'; diff --git a/src/versions/drafts/saveCollectionDraft.ts b/src/versions/drafts/saveCollectionDraft.ts index bab2678f20..a3f303d9b1 100644 --- a/src/versions/drafts/saveCollectionDraft.ts +++ b/src/versions/drafts/saveCollectionDraft.ts @@ -1,4 +1,4 @@ -import { Payload } from '../..'; +import { Payload } from '../../payload'; import { SanitizedCollectionConfig } from '../../collections/config/types'; import { enforceMaxVersions } from '../enforceMaxVersions'; import { PayloadRequest } from '../../express/types'; @@ -46,7 +46,7 @@ export const saveCollectionDraft = async ({ }, { new: true, lean: true }, ); - // Otherwise, create a new one + // Otherwise, create a new one } else { result = await VersionsModel.create({ parent: id, diff --git a/src/versions/drafts/saveGlobalDraft.ts b/src/versions/drafts/saveGlobalDraft.ts index de38a9aadc..4d20d2fb87 100644 --- a/src/versions/drafts/saveGlobalDraft.ts +++ b/src/versions/drafts/saveGlobalDraft.ts @@ -1,4 +1,4 @@ -import { Payload } from '../..'; +import { Payload } from '../../payload'; import { enforceMaxVersions } from '../enforceMaxVersions'; import { SanitizedGlobalConfig } from '../../globals/config/types'; @@ -40,7 +40,7 @@ export const saveGlobalDraft = async ({ }, { new: true, lean: true }, ); - // Otherwise, create a new one + // Otherwise, create a new one } else { result = await VersionsModel.create({ version: dataAsDraft, diff --git a/src/versions/enforceMaxVersions.ts b/src/versions/enforceMaxVersions.ts index c3bb3684f3..ffee2025c8 100644 --- a/src/versions/enforceMaxVersions.ts +++ b/src/versions/enforceMaxVersions.ts @@ -1,4 +1,4 @@ -import { Payload } from '..'; +import { Payload } from '../payload'; import { CollectionModel } from '../collections/config/types'; type Args = { diff --git a/src/versions/ensurePublishedCollectionVersion.ts b/src/versions/ensurePublishedCollectionVersion.ts index d440871a6a..d8b92c6417 100644 --- a/src/versions/ensurePublishedCollectionVersion.ts +++ b/src/versions/ensurePublishedCollectionVersion.ts @@ -1,4 +1,4 @@ -import { Payload } from '..'; +import { Payload } from '../payload'; import { SanitizedCollectionConfig } from '../collections/config/types'; import { enforceMaxVersions } from './enforceMaxVersions'; import { PayloadRequest } from '../express/types'; @@ -34,14 +34,14 @@ export const ensurePublishedCollectionVersion = async ({ $gt: docWithLocales.updatedAt, }, }, - {}, - { - lean: true, - leanWithId: true, - sort: { - updatedAt: 'desc', - }, - }); + {}, + { + lean: true, + leanWithId: true, + sort: { + updatedAt: 'desc', + }, + }); if (moreRecentDrafts?.length === 0) { const version = await afterRead({ diff --git a/src/versions/ensurePublishedGlobalVersion.ts b/src/versions/ensurePublishedGlobalVersion.ts index c4b5b85a9a..080e691aaa 100644 --- a/src/versions/ensurePublishedGlobalVersion.ts +++ b/src/versions/ensurePublishedGlobalVersion.ts @@ -1,4 +1,4 @@ -import { Payload } from '..'; +import { Payload } from '../payload'; import { enforceMaxVersions } from './enforceMaxVersions'; import { PayloadRequest } from '../express/types'; import { SanitizedGlobalConfig } from '../globals/config/types'; @@ -29,14 +29,14 @@ export const ensurePublishedGlobalVersion = async ({ $gt: docWithLocales.updatedAt, }, }, - {}, - { - lean: true, - leanWithId: true, - sort: { - updatedAt: 'desc', - }, - }); + {}, + { + lean: true, + leanWithId: true, + sort: { + updatedAt: 'desc', + }, + }); if (moreRecentDrafts?.length === 0) { const version = await afterRead({ diff --git a/src/versions/getLatestCollectionVersion.ts b/src/versions/getLatestCollectionVersion.ts index c5fd1f98c2..0560ed8800 100644 --- a/src/versions/getLatestCollectionVersion.ts +++ b/src/versions/getLatestCollectionVersion.ts @@ -1,5 +1,5 @@ import { Document } from '../types'; -import { Payload } from '..'; +import { Payload } from '../payload'; import { Collection, TypeWithID } from '../collections/config/types'; type Args = { diff --git a/src/versions/saveCollectionVersion.ts b/src/versions/saveCollectionVersion.ts index 5ac722896b..5a1f4a0243 100644 --- a/src/versions/saveCollectionVersion.ts +++ b/src/versions/saveCollectionVersion.ts @@ -1,4 +1,4 @@ -import { Payload } from '..'; +import { Payload } from '../payload'; import { SanitizedCollectionConfig } from '../collections/config/types'; import { enforceMaxVersions } from './enforceMaxVersions'; import { PayloadRequest } from '../express/types'; @@ -33,14 +33,14 @@ export const saveCollectionVersion = async ({ $gt: docWithLocales.updatedAt, }, }, - {}, - { - lean: true, - leanWithId: true, - sort: { - updatedAt: 'desc', - }, - }); + {}, + { + lean: true, + leanWithId: true, + sort: { + updatedAt: 'desc', + }, + }); if (latestVersion) { // If the latest version is a draft, no need to re-save it diff --git a/src/versions/saveGlobalVersion.ts b/src/versions/saveGlobalVersion.ts index 176a9a2bce..2f6779b46c 100644 --- a/src/versions/saveGlobalVersion.ts +++ b/src/versions/saveGlobalVersion.ts @@ -1,4 +1,4 @@ -import { Payload } from '..'; +import { Payload } from '../payload'; import { enforceMaxVersions } from './enforceMaxVersions'; import { PayloadRequest } from '../express/types'; import { SanitizedGlobalConfig } from '../globals/config/types'; @@ -28,14 +28,14 @@ export const saveGlobalVersion = async ({ $gt: docWithLocales.updatedAt, }, }, - {}, - { - lean: true, - leanWithId: true, - sort: { - updatedAt: 'desc', - }, - }); + {}, + { + lean: true, + leanWithId: true, + sort: { + updatedAt: 'desc', + }, + }); if (latestVersion) { // If the latest version is a draft, no need to re-save it diff --git a/test/auth/custom-strategy/config.ts b/test/auth/custom-strategy/config.ts index 3c4d52e16b..8ecf33541d 100644 --- a/test/auth/custom-strategy/config.ts +++ b/test/auth/custom-strategy/config.ts @@ -1,13 +1,12 @@ import { Request } from 'express'; import { Strategy } from 'passport-strategy'; -import { Payload } from '../../../src'; +import { Payload } from '../../../src/payload'; import { buildConfig } from '../../buildConfig'; export const slug = 'users'; -export const strategyName = 'test-local' +export const strategyName = 'test-local'; export class CustomStrategy extends Strategy { - ctx: Payload; constructor(ctx: Payload) { @@ -16,29 +15,29 @@ export class CustomStrategy extends Strategy { } authenticate(req: Request, options?: any): void { - if(!req.headers.code && !req.headers.secret) { + if (!req.headers.code && !req.headers.secret) { return this.success(null); } this.ctx.find({ collection: slug, where: { code: { - equals: req.headers.code + equals: req.headers.code, }, secret: { - equals: req.headers.secret - } - } + equals: req.headers.secret, + }, + }, }).then((users) => { - if(users.docs && users.docs.length) { + if (users.docs && users.docs.length) { const user = users.docs[0]; user.collection = slug; user._strategy = `${slug}-${strategyName}`; - this.success(user) + this.success(user); } else { - this.error(null) + this.error(null); } - }) + }); } } @@ -54,12 +53,12 @@ export default buildConfig({ strategies: [ { name: strategyName, - strategy: (ctx) => new CustomStrategy(ctx) - } - ] + strategy: (ctx) => new CustomStrategy(ctx), + }, + ], }, access: { - create: () => true + create: () => true, }, fields: [ { diff --git a/test/devServer.ts b/test/devServer.ts index d2dd70c29f..f32298342f 100644 --- a/test/devServer.ts +++ b/test/devServer.ts @@ -1,12 +1,12 @@ import express from 'express'; import { v4 as uuid } from 'uuid'; -import { init as initPayload } from '../src'; +import payload from '../src'; const expressApp = express(); const startDev = async () => { - const payload = await initPayload({ + await payload.init({ secret: uuid(), mongoURL: process.env.MONGO_URL || 'mongodb://localhost/payload', express: expressApp, diff --git a/test/helpers/configHelpers.ts b/test/helpers/configHelpers.ts index 3144a8921e..bd1d30e5cc 100644 --- a/test/helpers/configHelpers.ts +++ b/test/helpers/configHelpers.ts @@ -40,7 +40,7 @@ export async function initPayloadTest(options: Options): Promise<{ serverURL: st initOptions.express = express(); } - await payload.initAsync(initOptions); + await payload.init(initOptions); if (initOptions.express) { initOptions.express.listen(port); diff --git a/test/hooks/collections/Users/index.ts b/test/hooks/collections/Users/index.ts index 6b9b7c7018..1bb1e634ba 100644 --- a/test/hooks/collections/Users/index.ts +++ b/test/hooks/collections/Users/index.ts @@ -1,4 +1,4 @@ -import { Payload } from '../../../../src'; +import { Payload } from '../../../../src/payload'; import { BeforeLoginHook, CollectionConfig } from '../../../../src/collections/config/types'; import { AuthenticationError } from '../../../../src/errors'; import { devUser, regularUser } from '../../../credentials'; From c0710a3b74b79259405c3211555628937d780ea3 Mon Sep 17 00:00:00 2001 From: James Date: Thu, 12 Jan 2023 13:22:15 -0500 Subject: [PATCH 06/46] chore: progress to ts improvements --- package.json | 2 +- src/bin/generateTypes.ts | 24 +++++++++- src/collections/operations/local/findByID.ts | 5 +- src/config/types.ts | 9 ++++ src/payload.ts | 8 ++-- src/versions/drafts/mergeDrafts.ts | 32 +++++++++++++ test/{generateTypes.js => generateTypes.ts} | 7 ++- test/versions/payload-types.ts | 50 ++++++++------------ 8 files changed, 95 insertions(+), 42 deletions(-) rename test/{generateTypes.js => generateTypes.ts} (87%) diff --git a/package.json b/package.json index a4521c0ce0..00eaf8bdb1 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "build": "yarn copyfiles && yarn build:tsc && yarn build:components", "build:watch": "nodemon --watch 'src/**' --ext 'ts,tsx' --exec \"yarn build:tsc\"", "dev": "nodemon", - "dev:generate-types": "node ./test/generateTypes.js", + "dev:generate-types": "ts-node -T ./test/generateTypes.ts", "pretest": "yarn build", "test": "yarn test:int && yarn test:components && yarn test:e2e", "test:int": "cross-env DISABLE_LOGGING=true jest --forceExit --detectOpenHandles", diff --git a/src/bin/generateTypes.ts b/src/bin/generateTypes.ts index 8dc14fde72..eded842908 100644 --- a/src/bin/generateTypes.ts +++ b/src/bin/generateTypes.ts @@ -411,8 +411,30 @@ function entityToJsonSchema(config: SanitizedConfig, incomingEntity: SanitizedCo }; } +function generateEntityObject(config: SanitizedConfig, type: 'collections' | 'globals'): JSONSchema4 { + return { + type: 'object', + properties: Object.fromEntries(config[type].map(({ slug }) => [ + slug, + { + $ref: `#/definitions/${slug}`, + }, + ])), + required: config[type].map(({ slug }) => slug), + additionalProperties: false, + }; +} + function configToJsonSchema(config: SanitizedConfig): JSONSchema4 { return { + title: 'Config', + type: 'object', + additionalProperties: false, + properties: { + collections: generateEntityObject(config, 'collections'), + globals: generateEntityObject(config, 'globals'), + }, + required: ['collections', 'globals'], definitions: Object.fromEntries( [ ...config.globals.map((global) => [ @@ -425,7 +447,6 @@ function configToJsonSchema(config: SanitizedConfig): JSONSchema4 { ]), ], ), - additionalProperties: false, }; } @@ -439,7 +460,6 @@ export function generateTypes(): void { const jsonSchema = configToJsonSchema(config); compile(jsonSchema, 'Config', { - unreachableDefinitions: true, bannerComment: '/* tslint:disable */\n/**\n* This file was automatically generated by Payload CMS.\n* DO NOT MODIFY IT BY HAND. Instead, modify your source Payload config,\n* and re-run `payload generate:types` to regenerate this file.\n*/', style: { singleQuote: true, diff --git a/src/collections/operations/local/findByID.ts b/src/collections/operations/local/findByID.ts index 21d4090af9..bc1a182129 100644 --- a/src/collections/operations/local/findByID.ts +++ b/src/collections/operations/local/findByID.ts @@ -1,3 +1,4 @@ +import { BaseConfig } from '../../../config/types'; import { TypeWithID } from '../../config/types'; import { PayloadRequest } from '../../../express/types'; import { Document } from '../../../types'; @@ -6,8 +7,8 @@ import { Payload } from '../../../payload'; import { getDataLoader } from '../../dataloader'; import i18n from '../../../translations/init'; -export type Options = { - collection: string +export type Options = { + collection: keyof Config['collections'] id: string depth?: number currentDepth?: number diff --git a/src/config/types.ts b/src/config/types.ts index afbe5a1033..8902566c28 100644 --- a/src/config/types.ts +++ b/src/config/types.ts @@ -20,6 +20,15 @@ import { PayloadRequest } from '../express/types'; import { Where } from '../types'; import { User } from '../auth/types'; +export interface BaseConfig { + collections: { + [slug: string]: Record + } + globals: { + [slug: string]: Record + } +} + type Email = { fromName: string; fromAddress: string; diff --git a/src/payload.ts b/src/payload.ts index 02e0457e35..74d6fc000b 100644 --- a/src/payload.ts +++ b/src/payload.ts @@ -4,6 +4,7 @@ import { GraphQLError, GraphQLFormattedError, GraphQLSchema } from 'graphql'; import crypto from 'crypto'; import path from 'path'; import mongoose from 'mongoose'; +import { ValueOf } from 'ts-essentials'; import { TypeWithID, Collection, @@ -13,6 +14,7 @@ import { SanitizedConfig, EmailOptions, InitOptions, + BaseConfig, } from './config/types'; import { TypeWithVersion } from './versions/types'; import { PaginatedDocs } from './mongoose/types'; @@ -64,7 +66,7 @@ import findConfig from './config/find'; /** * @description Payload */ -export class Payload { +export class Payload { config: SanitizedConfig; collections: { @@ -270,9 +272,9 @@ export class Payload { * @param options * @returns document with specified ID */ - findByID = async (options: FindByIDOptions): Promise => { + findByID = async (options: FindByIDOptions): Promise]> => { const { findByID } = localOperations; - return findByID(this, options); + return findByID(this, options); } /** diff --git a/src/versions/drafts/mergeDrafts.ts b/src/versions/drafts/mergeDrafts.ts index 1fcab53ca7..846e89dd70 100644 --- a/src/versions/drafts/mergeDrafts.ts +++ b/src/versions/drafts/mergeDrafts.ts @@ -51,6 +51,8 @@ export const mergeDrafts = async ({ return newMap; }, {})); + console.log({ mainCollectionMatchMap }); + // Query the versions collection with a version-specific query const VersionModel = payload.versions[collection.config.slug] as CollectionModel; @@ -100,6 +102,28 @@ export const mergeDrafts = async ({ createdAt: { $first: '$createdAt' }, }, }, + { + $addFields: { + id: { + $toObjectId: '$_id', + }, + }, + }, + { + $lookup: { + from: collection.config.slug, + localField: 'id', + foreignField: '_id', + as: 'parent', + }, + }, + { + $match: { + parent: { + $size: 1, + }, + }, + }, { $match: versionQuery }, { $limit: paginationOptions.limit }, ]).then((res) => res.reduce>((map, { _id, updatedAt, createdAt, version }) => { @@ -111,6 +135,9 @@ export const mergeDrafts = async ({ return newMap; }, {})); + console.log({ versionCollectionMatchMap }); + console.log({ includedParentIDs }); + // Now we need to explicitly exclude any parent matches that have newer versions // which did NOT appear in the versions query const excludedParentIDs = await Promise.all(Object.entries(mainCollectionMatchMap).map(async ([parentDocID, parentDocUpdatedAt]) => { @@ -125,6 +152,9 @@ export const mergeDrafts = async ({ updatedAt: { $gt: parentDocUpdatedAt, }, + parent: { + $eq: parentDocID, + }, }, {}, { limit: 1 }).lean(); // If there are, @@ -172,6 +202,8 @@ export const mergeDrafts = async ({ }); } + console.log({ finalQueryToBuild: JSON.stringify(finalQueryToBuild) }); + const finalQuery = await collection.Model.buildQuery(finalQueryToBuild, locale); let result = await collection.Model.paginate(finalQuery, paginationOptions); diff --git a/test/generateTypes.js b/test/generateTypes.ts similarity index 87% rename from test/generateTypes.js rename to test/generateTypes.ts index 8527a8056e..ce123ce313 100644 --- a/test/generateTypes.js +++ b/test/generateTypes.ts @@ -1,7 +1,6 @@ -const path = require('path'); -const fs = require('fs'); - -const { generateTypes } = require('../dist/bin/generateTypes'); +import path from 'path'; +import fs from 'fs'; +import { generateTypes } from '../src/bin/generateTypes'; const [testConfigDir] = process.argv.slice(2); diff --git a/test/versions/payload-types.ts b/test/versions/payload-types.ts index 0508755977..3b725acdc8 100644 --- a/test/versions/payload-types.ts +++ b/test/versions/payload-types.ts @@ -5,29 +5,17 @@ * and re-run `payload generate:types` to regenerate this file. */ -export interface Config {} -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "autosave-global". - */ -export interface AutosaveGlobal { - id: string; - title: string; - _status?: 'draft' | 'published'; +export interface Config { + collections: { + 'autosave-posts': AutosavePost; + 'draft-posts': DraftPost; + users: User; + }; + globals: { + 'autosave-global': AutosaveGlobal; + 'draft-global': DraftGlobal; + }; } -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "draft-global". - */ -export interface DraftGlobal { - id: string; - title: string; - _status?: 'draft' | 'published'; -} -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "autosave-posts". - */ export interface AutosavePost { id: string; title: string; @@ -36,10 +24,6 @@ export interface AutosavePost { createdAt: string; updatedAt: string; } -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "draft-posts". - */ export interface DraftPost { id: string; title: string; @@ -50,10 +34,6 @@ export interface DraftPost { createdAt: string; updatedAt: string; } -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "users". - */ export interface User { id: string; email?: string; @@ -64,3 +44,13 @@ export interface User { createdAt: string; updatedAt: string; } +export interface AutosaveGlobal { + id: string; + title: string; + _status?: 'draft' | 'published'; +} +export interface DraftGlobal { + id: string; + title: string; + _status?: 'draft' | 'published'; +} From d6d490614808baff4c719fef5e9c03056b2af661 Mon Sep 17 00:00:00 2001 From: James Date: Thu, 12 Jan 2023 13:56:19 -0500 Subject: [PATCH 07/46] chore(release): v1.5.8 --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fca8a67b59..4edaa5bdca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ +## [1.5.8](https://github.com/payloadcms/payload/compare/v1.5.7...v1.5.8) (2023-01-12) + + +### Features + +* throws descriptive error when collection or global slug not found ([b847d85](https://github.com/payloadcms/payload/commit/b847d85e60032b47a8eacc2c9426fdd373dff879)) + ## [1.5.7](https://github.com/payloadcms/payload/compare/v1.5.6...v1.5.7) (2023-01-12) diff --git a/package.json b/package.json index 6988fb38bc..5a1e5eb442 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "payload", - "version": "1.5.7", + "version": "1.5.8", "description": "Node, React and MongoDB Headless CMS and Application Framework", "license": "MIT", "engines": { From a5c76d4bd544190511e34820c1145ef26d85dc53 Mon Sep 17 00:00:00 2001 From: James Date: Thu, 12 Jan 2023 14:30:51 -0500 Subject: [PATCH 08/46] feat: allows versions to be deleted alongside of main document deletion --- src/collections/operations/delete.ts | 15 +++++++++++++- src/versions/defaults.ts | 2 +- src/versions/deleteCollectionVersions.ts | 25 ++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 src/versions/deleteCollectionVersions.ts diff --git a/src/collections/operations/delete.ts b/src/collections/operations/delete.ts index e0454ec1dc..bcd963c20a 100644 --- a/src/collections/operations/delete.ts +++ b/src/collections/operations/delete.ts @@ -11,6 +11,7 @@ import { hasWhereAccessResult } from '../../auth/types'; import { FileData } from '../../uploads/types'; import fileExists from '../../uploads/fileExists'; import { afterRead } from '../../fields/hooks/afterRead'; +import { deleteCollectionVersions } from '../../versions/deleteCollectionVersions'; export type Arguments = { depth?: number @@ -48,6 +49,7 @@ async function deleteOperation(incomingArgs: Arguments): Promise { req: { t, locale, + payload, payload: { config, preferences, @@ -164,6 +166,18 @@ async function deleteOperation(incomingArgs: Arguments): Promise { } await preferences.Model.deleteMany({ key: `collection-${collectionConfig.slug}-${id}` }); + // ///////////////////////////////////// + // Delete versions + // ///////////////////////////////////// + + if (!collectionConfig.versions.retainDeleted) { + deleteCollectionVersions({ + payload, + id, + slug: collectionConfig.slug, + }); + } + // ///////////////////////////////////// // afterDelete - Collection // ///////////////////////////////////// @@ -174,7 +188,6 @@ async function deleteOperation(incomingArgs: Arguments): Promise { result = await hook({ req, id, doc: result }) || result; }, Promise.resolve()); - // ///////////////////////////////////// // afterRead - Fields // ///////////////////////////////////// diff --git a/src/versions/defaults.ts b/src/versions/defaults.ts index 3d8be612a6..826c0f0347 100644 --- a/src/versions/defaults.ts +++ b/src/versions/defaults.ts @@ -6,7 +6,7 @@ export const versionCollectionDefaults: IncomingCollectionVersions = { interval: 2000, // in milliseconds }, }, - retainDeleted: true, + retainDeleted: false, }; export const versionGlobalDefaults: IncomingGlobalVersions = { diff --git a/src/versions/deleteCollectionVersions.ts b/src/versions/deleteCollectionVersions.ts new file mode 100644 index 0000000000..27a616f2c8 --- /dev/null +++ b/src/versions/deleteCollectionVersions.ts @@ -0,0 +1,25 @@ +import { Payload } from '..'; + +type Args = { + payload: Payload + slug: string + id?: string | number +} + +export const deleteCollectionVersions = async ({ + payload, + slug, + id, +}: Args): Promise => { + const VersionsModel = payload.versions[slug]; + + try { + await VersionsModel.deleteMany({ + parent: { + $eq: id, + }, + }); + } catch (err) { + payload.logger.error(`There was an error removing versions for the deleted ${slug} document with ID ${id}.`); + } +}; From 918f736141fc0e5d50543b2d2df46ae57d80d286 Mon Sep 17 00:00:00 2001 From: James Date: Fri, 13 Jan 2023 11:36:01 -0500 Subject: [PATCH 09/46] chore: begins ts improvements --- src/collections/operations/findByID.ts | 2 +- src/collections/operations/local/findByID.ts | 9 +- src/collections/operations/local/update.ts | 11 +- src/collections/operations/update.ts | 9 +- src/config/types.ts | 8 +- src/payload.ts | 13 +-- test/fields/payload-types.ts | 106 +++++-------------- 7 files changed, 53 insertions(+), 105 deletions(-) diff --git a/src/collections/operations/findByID.ts b/src/collections/operations/findByID.ts index 1412f0c6c4..38773a4a72 100644 --- a/src/collections/operations/findByID.ts +++ b/src/collections/operations/findByID.ts @@ -23,7 +23,7 @@ export type Arguments = { } // eslint-disable-next-line @typescript-eslint/no-explicit-any -async function findByID(incomingArgs: Arguments): Promise { +async function findByID(incomingArgs: Arguments): Promise { let args = incomingArgs; // ///////////////////////////////////// diff --git a/src/collections/operations/local/findByID.ts b/src/collections/operations/local/findByID.ts index bc1a182129..767b585572 100644 --- a/src/collections/operations/local/findByID.ts +++ b/src/collections/operations/local/findByID.ts @@ -1,5 +1,4 @@ import { BaseConfig } from '../../../config/types'; -import { TypeWithID } from '../../config/types'; import { PayloadRequest } from '../../../express/types'; import { Document } from '../../../types'; import findByID from '../findByID'; @@ -7,8 +6,8 @@ import { Payload } from '../../../payload'; import { getDataLoader } from '../../dataloader'; import i18n from '../../../translations/init'; -export type Options = { - collection: keyof Config['collections'] +export type Options = { + collection: T id: string depth?: number currentDepth?: number @@ -23,7 +22,7 @@ export type Options = { } // eslint-disable-next-line @typescript-eslint/no-explicit-any -export default async function findByIDLocal(payload: Payload, options: Options): Promise { +export default async function findByIDLocal(payload: Payload, options: Options): Promise { const { collection: collectionSlug, depth, @@ -53,7 +52,7 @@ export default async function findByIDLocal(payload: if (!req.t) req.t = req.i18n.t; if (!req.payloadDataLoader) req.payloadDataLoader = getDataLoader(req); - return findByID({ + return findByID({ depth, currentDepth, id, diff --git a/src/collections/operations/local/update.ts b/src/collections/operations/local/update.ts index cdb807fd5a..a5140fc067 100644 --- a/src/collections/operations/local/update.ts +++ b/src/collections/operations/local/update.ts @@ -6,11 +6,12 @@ import { PayloadRequest } from '../../../express/types'; import { getDataLoader } from '../../dataloader'; import { File } from '../../../uploads/types'; import i18nInit from '../../../translations/init'; +import { BaseConfig } from '../../../config/types'; -export type Options = { - collection: string +export type Options = { + collection: Slug id: string | number - data: Partial + data: Config['collections'][Slug] depth?: number locale?: string fallbackLocale?: string @@ -24,7 +25,7 @@ export type Options = { autosave?: boolean } -export default async function updateLocal(payload: Payload, options: Options): Promise { +export default async function updateLocal(payload: Payload, options: Options): Promise { const { collection: collectionSlug, depth, @@ -75,5 +76,5 @@ export default async function updateLocal(payload: Payload, options: Op req, }; - return update(args); + return update(args); } diff --git a/src/collections/operations/update.ts b/src/collections/operations/update.ts index 095081e3c7..3a201121b8 100644 --- a/src/collections/operations/update.ts +++ b/src/collections/operations/update.ts @@ -1,4 +1,5 @@ import httpStatus from 'http-status'; +import { BaseConfig } from '../../config/types'; import { Where, Document } from '../../types'; import { Collection } from '../config/types'; import sanitizeInternalFields from '../../utilities/sanitizeInternalFields'; @@ -18,11 +19,11 @@ import { afterRead } from '../../fields/hooks/afterRead'; import { generateFileData } from '../../uploads/generateFileData'; import { getLatestCollectionVersion } from '../../versions/getLatestCollectionVersion'; -export type Arguments = { +export type Arguments> = { collection: Collection req: PayloadRequest id: string | number - data: Record + data: T depth?: number disableVerificationEmail?: boolean overrideAccess?: boolean @@ -32,7 +33,9 @@ export type Arguments = { autosave?: boolean } -async function update(incomingArgs: Arguments): Promise { +async function update( + incomingArgs: Arguments, +): Promise { let args = incomingArgs; // ///////////////////////////////////// diff --git a/src/config/types.ts b/src/config/types.ts index 8902566c28..7815f6946e 100644 --- a/src/config/types.ts +++ b/src/config/types.ts @@ -22,10 +22,10 @@ import { User } from '../auth/types'; export interface BaseConfig { collections: { - [slug: string]: Record + [slug: string | number | symbol]: Record } globals: { - [slug: string]: Record + [slug: string | number | symbol]: Record } } @@ -109,7 +109,7 @@ export type InitOptions = { /** * A function that is called immediately following startup that receives the Payload instance as it's only argument. */ - onInit?: (payload: Payload) => Promise | void; + onInit?: (payload: Payload) => Promise | void; /** * Specify options for the built-in Pino logger that Payload uses for internal logging. @@ -541,7 +541,7 @@ export type Config = { /** Send anonymous telemetry data about general usage. */ telemetry?: boolean; /** A function that is called immediately following startup that receives the Payload instance as its only argument. */ - onInit?: (payload: Payload) => Promise | void; + onInit?: (payload: Payload) => Promise | void; }; export type SanitizedConfig = Omit< diff --git a/src/payload.ts b/src/payload.ts index 74d6fc000b..92fe298729 100644 --- a/src/payload.ts +++ b/src/payload.ts @@ -70,7 +70,7 @@ export class Payload { config: SanitizedConfig; collections: { - [slug: string]: Collection; + [slug: string | number | symbol]: Collection; } = {} versions: { @@ -272,9 +272,10 @@ export class Payload { * @param options * @returns document with specified ID */ - findByID = async (options: FindByIDOptions): Promise]> => { + + findByID = async (options: FindByIDOptions): Promise => { const { findByID } = localOperations; - return findByID(this, options); + return findByID(this, options); } /** @@ -282,9 +283,9 @@ export class Payload { * @param options * @returns Updated document */ - update = async (options: UpdateOptions): Promise => { + update = async (options: UpdateOptions): Promise => { const { update } = localOperations; - return update(this, options); + return update(this, options); } delete = async (options: DeleteOptions): Promise => { @@ -355,7 +356,7 @@ if (!cached) { cached = global.payload = { payload: null, promise: null }; } -export const getPayload = async (options: InitOptions): Promise> => { +export const getPayload = async (options: InitOptions): Promise> => { if (cached.payload) { return cached.payload; } diff --git a/test/fields/payload-types.ts b/test/fields/payload-types.ts index 622484aa1a..bb6dc23599 100644 --- a/test/fields/payload-types.ts +++ b/test/fields/payload-types.ts @@ -5,11 +5,31 @@ * and re-run `payload generate:types` to regenerate this file. */ -export interface Config {} -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "array-fields". - */ +export interface Config { + collections: { + 'array-fields': ArrayField; + 'block-fields': BlockField; + 'code-fields': CodeField; + 'collapsible-fields': CollapsibleField; + 'conditional-logic': ConditionalLogic; + 'date-fields': DateField; + 'radio-fields': RadioField; + 'group-fields': GroupField; + 'indexed-fields': IndexedField; + 'json-fields': JsonField; + 'number-fields': NumberField; + 'point-fields': PointField; + 'relationship-fields': RelationshipField; + 'rich-text-fields': RichTextField; + 'select-fields': SelectField; + 'tabs-fields': TabsField; + 'text-fields': TextField; + uploads: Upload; + uploads2: Uploads2; + users: User; + }; + globals: {}; +} export interface ArrayField { id: string; items: { @@ -43,10 +63,6 @@ export interface ArrayField { createdAt: string; updatedAt: string; } -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "block-fields". - */ export interface BlockField { id: string; blocks: ( @@ -187,10 +203,6 @@ export interface BlockField { createdAt: string; updatedAt: string; } -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "code-fields". - */ export interface CodeField { id: string; javascript?: string; @@ -201,10 +213,6 @@ export interface CodeField { createdAt: string; updatedAt: string; } -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "collapsible-fields". - */ export interface CollapsibleField { id: string; text: string; @@ -225,10 +233,6 @@ export interface CollapsibleField { createdAt: string; updatedAt: string; } -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "conditional-logic". - */ export interface ConditionalLogic { id: string; text: string; @@ -237,10 +241,6 @@ export interface ConditionalLogic { createdAt: string; updatedAt: string; } -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "date-fields". - */ export interface DateField { id: string; default: string; @@ -251,20 +251,12 @@ export interface DateField { createdAt: string; updatedAt: string; } -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "radio-fields". - */ export interface RadioField { id: string; radio?: 'one' | 'two' | 'three'; createdAt: string; updatedAt: string; } -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "group-fields". - */ export interface GroupField { id: string; group: { @@ -296,10 +288,6 @@ export interface GroupField { createdAt: string; updatedAt: string; } -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "indexed-fields". - */ export interface IndexedField { id: string; text: string; @@ -322,10 +310,6 @@ export interface IndexedField { createdAt: string; updatedAt: string; } -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "json-fields". - */ export interface JsonField { id: string; json?: { @@ -334,10 +318,6 @@ export interface JsonField { createdAt: string; updatedAt: string; } -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "number-fields". - */ export interface NumberField { id: string; number?: number; @@ -351,10 +331,6 @@ export interface NumberField { createdAt: string; updatedAt: string; } -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "point-fields". - */ export interface PointField { id: string; /** @@ -377,10 +353,6 @@ export interface PointField { createdAt: string; updatedAt: string; } -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "relationship-fields". - */ export interface RelationshipField { id: string; relationship: @@ -396,10 +368,6 @@ export interface RelationshipField { createdAt: string; updatedAt: string; } -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "text-fields". - */ export interface TextField { id: string; text: string; @@ -411,10 +379,6 @@ export interface TextField { createdAt: string; updatedAt: string; } -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "rich-text-fields". - */ export interface RichTextField { id: string; title: string; @@ -428,10 +392,6 @@ export interface RichTextField { createdAt: string; updatedAt: string; } -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "select-fields". - */ export interface SelectField { id: string; select?: 'one' | 'two' | 'three'; @@ -443,10 +403,6 @@ export interface SelectField { createdAt: string; updatedAt: string; } -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "tabs-fields". - */ export interface TabsField { id: string; array: { @@ -532,10 +488,6 @@ export interface TabsField { createdAt: string; updatedAt: string; } -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "uploads". - */ export interface Upload { id: string; text?: string; @@ -549,10 +501,6 @@ export interface Upload { createdAt: string; updatedAt: string; } -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "uploads2". - */ export interface Uploads2 { id: string; text?: string; @@ -566,10 +514,6 @@ export interface Uploads2 { createdAt: string; updatedAt: string; } -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "users". - */ export interface User { id: string; email?: string; From 6903d7f52f2c0c035f73d8d310d3345a18d90909 Mon Sep 17 00:00:00 2001 From: James Date: Fri, 13 Jan 2023 16:58:10 -0500 Subject: [PATCH 10/46] chore: ts compiles --- .../Cell/field-types/Relationship/index.tsx | 12 ++++++------ src/collections/config/types.ts | 2 ++ src/collections/graphql/resolvers/findByID.ts | 7 ++++--- src/collections/graphql/resolvers/update.ts | 13 ++++++++----- src/collections/initHTTP.ts | 4 ++-- src/collections/operations/findByID.ts | 4 ++-- src/collections/operations/local/findByID.ts | 3 +-- src/collections/operations/local/update.ts | 5 ++++- src/collections/operations/update.ts | 17 +++++++---------- src/fields/hooks/afterChange/index.ts | 12 ++++++------ src/fields/hooks/beforeChange/index.ts | 10 +++++----- src/fields/hooks/beforeValidate/index.ts | 10 +++++----- src/fields/hooks/beforeValidate/promise.ts | 10 +++++----- .../hooks/beforeValidate/traverseFields.ts | 10 +++++----- src/globals/initHTTP.ts | 4 ++-- src/index.ts | 3 ++- src/initHTTP.ts | 4 ++-- src/payload.ts | 3 +-- src/preferences/init.ts | 4 ++-- src/uploads/generateFileData.ts | 12 ++++++------ src/utilities/sanitizeInternalFields.ts | 4 +--- src/versions/drafts/saveCollectionDraft.ts | 8 ++++---- 22 files changed, 82 insertions(+), 79 deletions(-) diff --git a/src/admin/components/views/collections/List/Cell/field-types/Relationship/index.tsx b/src/admin/components/views/collections/List/Cell/field-types/Relationship/index.tsx index d525b3be26..24d86a1a19 100644 --- a/src/admin/components/views/collections/List/Cell/field-types/Relationship/index.tsx +++ b/src/admin/components/views/collections/List/Cell/field-types/Relationship/index.tsx @@ -52,13 +52,13 @@ const RelationshipCell = (props) => { {values.map(({ relationTo, value }, i) => { const document = documents[relationTo][value]; const relatedCollection = collections.find(({ slug }) => slug === relationTo); + const label = document?.[relatedCollection.admin.useAsTitle] ? document[relatedCollection.admin.useAsTitle] : `${t('untitled')} - ID: ${value}`; + return ( - { document === false && `${t('untitled')} - ID: ${value}`} - { document === null && t('loading')} - { document && ( - document[relatedCollection.admin.useAsTitle] ? document[relatedCollection.admin.useAsTitle] : `${t('untitled')} - ID: ${value}` - )} + {document === false && `${t('untitled')} - ID: ${value}`} + {document === null && t('loading')} + {document && label} {values.length > i + 1 && ', '} ); @@ -67,7 +67,7 @@ const RelationshipCell = (props) => { Array.isArray(cellData) && cellData.length > totalToShow && t('fields:itemsAndMore', { items: '', count: cellData.length - totalToShow }) } - { values.length === 0 && t('noLabel', { label: getTranslation(field.label, i18n) })} + {values.length === 0 && t('noLabel', { label: getTranslation(field.label, i18n) })} ); }; diff --git a/src/collections/config/types.ts b/src/collections/config/types.ts index e009faf427..2a36a4c271 100644 --- a/src/collections/config/types.ts +++ b/src/collections/config/types.ts @@ -323,10 +323,12 @@ export type AuthCollection = { export type TypeWithID = { id: string | number + [key: string]: unknown } export type TypeWithTimestamps = { id: string | number createdAt: string updatedAt: string + [key: string]: unknown } diff --git a/src/collections/graphql/resolvers/findByID.ts b/src/collections/graphql/resolvers/findByID.ts index 717bdd764a..23dbe93d38 100644 --- a/src/collections/graphql/resolvers/findByID.ts +++ b/src/collections/graphql/resolvers/findByID.ts @@ -1,8 +1,9 @@ +import { BaseConfig } from '../../../config/types'; import { PayloadRequest } from '../../../express/types'; import { Collection } from '../../config/types'; import findByID from '../../operations/findByID'; -export type Resolver = (_: unknown, args: { +export type Resolver = (_: unknown, args: { locale?: string draft: boolean id: string @@ -12,9 +13,9 @@ export type Resolver = (_: unknown, args: { req: PayloadRequest, res: Response } -) => Promise +) => Promise -export default function findByIDResolver(collection: Collection): Resolver { +export default function findByIDResolver(collection: Collection): Resolver { return async function resolver(_, args, context) { const { req } = context; if (args.locale) req.locale = args.locale; diff --git a/src/collections/graphql/resolvers/update.ts b/src/collections/graphql/resolvers/update.ts index b5ab48e4c3..579f1d2e18 100644 --- a/src/collections/graphql/resolvers/update.ts +++ b/src/collections/graphql/resolvers/update.ts @@ -3,10 +3,11 @@ import { Response } from 'express'; import { Collection } from '../../config/types'; import update from '../../operations/update'; import { PayloadRequest } from '../../../express/types'; +import { BaseConfig } from '../../../config/types'; -export type Resolver = (_: unknown, args: { +export type Resolver = (_: unknown, args: { id: string | number - data: Record, + data: Config['collections'][Slug] locale?: string draft: boolean autosave: boolean @@ -15,9 +16,11 @@ export type Resolver = (_: unknown, args: { req: PayloadRequest, res: Response } -) => Promise +) => Promise -export default function updateResolver(collection: Collection): Resolver { +export default function updateResolver( + collection: Collection, +): Resolver { async function resolver(_, args, context) { if (args.locale) context.req.locale = args.locale; if (args.fallbackLocale) context.req.fallbackLocale = args.fallbackLocale; @@ -32,7 +35,7 @@ export default function updateResolver(collection: Collection): Resolver { autosave: args.autosave, }; - const result = await update(options); + const result = await update(options); return result; } diff --git a/src/collections/initHTTP.ts b/src/collections/initHTTP.ts index 038e451258..8a3206ce11 100644 --- a/src/collections/initHTTP.ts +++ b/src/collections/initHTTP.ts @@ -5,9 +5,9 @@ import bindCollectionMiddleware from './bindCollection'; import { SanitizedCollectionConfig } from './config/types'; import mountEndpoints from '../express/mountEndpoints'; import buildEndpoints from './buildEndpoints'; -import { PayloadHTTP } from '..'; +import { Payload } from '../payload'; -export default function initCollectionsHTTP(ctx: PayloadHTTP): void { +export default function initCollectionsHTTP(ctx: Payload): void { ctx.config.collections = ctx.config.collections.map((collection: SanitizedCollectionConfig) => { const formattedCollection = collection; diff --git a/src/collections/operations/findByID.ts b/src/collections/operations/findByID.ts index 38773a4a72..c88dea47c7 100644 --- a/src/collections/operations/findByID.ts +++ b/src/collections/operations/findByID.ts @@ -1,7 +1,7 @@ /* eslint-disable no-underscore-dangle */ import memoize from 'micro-memoize'; import { PayloadRequest } from '../../express/types'; -import { Collection, TypeWithID } from '../config/types'; +import { Collection } from '../config/types'; import sanitizeInternalFields from '../../utilities/sanitizeInternalFields'; import { NotFound } from '../../errors'; import executeAccess from '../../auth/executeAccess'; @@ -23,7 +23,7 @@ export type Arguments = { } // eslint-disable-next-line @typescript-eslint/no-explicit-any -async function findByID(incomingArgs: Arguments): Promise { +async function findByID>(incomingArgs: Arguments): Promise { let args = incomingArgs; // ///////////////////////////////////// diff --git a/src/collections/operations/local/findByID.ts b/src/collections/operations/local/findByID.ts index 767b585572..cc02e191ee 100644 --- a/src/collections/operations/local/findByID.ts +++ b/src/collections/operations/local/findByID.ts @@ -21,7 +21,6 @@ export type Options = { draft?: boolean } -// eslint-disable-next-line @typescript-eslint/no-explicit-any export default async function findByIDLocal(payload: Payload, options: Options): Promise { const { collection: collectionSlug, @@ -52,7 +51,7 @@ export default async function findByIDLocal({ + return findByID({ depth, currentDepth, id, diff --git a/src/collections/operations/local/update.ts b/src/collections/operations/local/update.ts index a5140fc067..22579e571b 100644 --- a/src/collections/operations/local/update.ts +++ b/src/collections/operations/local/update.ts @@ -25,7 +25,10 @@ export type Options(payload: Payload, options: Options): Promise { +export default async function updateLocal( + payload: Payload, + options: Options, +): Promise { const { collection: collectionSlug, depth, diff --git a/src/collections/operations/update.ts b/src/collections/operations/update.ts index 3a201121b8..336dcdf032 100644 --- a/src/collections/operations/update.ts +++ b/src/collections/operations/update.ts @@ -19,7 +19,7 @@ import { afterRead } from '../../fields/hooks/afterRead'; import { generateFileData } from '../../uploads/generateFileData'; import { getLatestCollectionVersion } from '../../versions/getLatestCollectionVersion'; -export type Arguments> = { +export type Arguments = { collection: Collection req: PayloadRequest id: string | number @@ -150,7 +150,7 @@ async function update({ data, doc: originalDoc, entityConfig: collectionConfig, @@ -202,7 +202,7 @@ async function update({ data, doc: originalDoc, docWithLocales, @@ -218,7 +218,7 @@ async function update({ payload, config: collectionConfig, req, @@ -283,12 +283,9 @@ async function update(result); // ///////////////////////////////////// // afterRead - Fields @@ -320,7 +317,7 @@ async function update({ data, doc: result, previousDoc: originalDoc, diff --git a/src/fields/hooks/afterChange/index.ts b/src/fields/hooks/afterChange/index.ts index e84aa75a47..2a3ad0a78e 100644 --- a/src/fields/hooks/afterChange/index.ts +++ b/src/fields/hooks/afterChange/index.ts @@ -4,23 +4,23 @@ import { PayloadRequest } from '../../../express/types'; import { traverseFields } from './traverseFields'; import deepCopyObject from '../../../utilities/deepCopyObject'; -type Args = { - data: Record - doc: Record - previousDoc: Record +type Args = { + data: T + doc: T + previousDoc: T entityConfig: SanitizedCollectionConfig | SanitizedGlobalConfig operation: 'create' | 'update' req: PayloadRequest } -export const afterChange = async ({ +export const afterChange = async >({ data, doc: incomingDoc, previousDoc, entityConfig, operation, req, -}: Args): Promise> => { +}: Args): Promise => { const doc = deepCopyObject(incomingDoc); await traverseFields({ diff --git a/src/fields/hooks/beforeChange/index.ts b/src/fields/hooks/beforeChange/index.ts index c1d986d7b1..632f7bc26b 100644 --- a/src/fields/hooks/beforeChange/index.ts +++ b/src/fields/hooks/beforeChange/index.ts @@ -6,9 +6,9 @@ import { traverseFields } from './traverseFields'; import { ValidationError } from '../../../errors'; import deepCopyObject from '../../../utilities/deepCopyObject'; -type Args = { - data: Record - doc: Record +type Args = { + data: T + doc: T docWithLocales: Record entityConfig: SanitizedCollectionConfig | SanitizedGlobalConfig id?: string | number @@ -17,7 +17,7 @@ type Args = { skipValidation?: boolean } -export const beforeChange = async ({ +export const beforeChange = async >({ data: incomingData, doc, docWithLocales, @@ -26,7 +26,7 @@ export const beforeChange = async ({ operation, req, skipValidation, -}: Args): Promise> => { +}: Args): Promise => { const data = deepCopyObject(incomingData); const mergeLocaleActions = []; const errors: { message: string, field: string }[] = []; diff --git a/src/fields/hooks/beforeValidate/index.ts b/src/fields/hooks/beforeValidate/index.ts index 5fb02ef6e5..f118aca71d 100644 --- a/src/fields/hooks/beforeValidate/index.ts +++ b/src/fields/hooks/beforeValidate/index.ts @@ -4,9 +4,9 @@ import { PayloadRequest } from '../../../express/types'; import { traverseFields } from './traverseFields'; import deepCopyObject from '../../../utilities/deepCopyObject'; -type Args = { - data: Record - doc: Record +type Args = { + data: T + doc: T entityConfig: SanitizedCollectionConfig | SanitizedGlobalConfig id?: string | number operation: 'create' | 'update' @@ -14,7 +14,7 @@ type Args = { req: PayloadRequest } -export const beforeValidate = async ({ +export const beforeValidate = async >({ data: incomingData, doc, entityConfig, @@ -22,7 +22,7 @@ export const beforeValidate = async ({ operation, overrideAccess, req, -}: Args): Promise> => { +}: Args): Promise => { const data = deepCopyObject(incomingData); await traverseFields({ diff --git a/src/fields/hooks/beforeValidate/promise.ts b/src/fields/hooks/beforeValidate/promise.ts index e70252f289..0d5d7cf816 100644 --- a/src/fields/hooks/beforeValidate/promise.ts +++ b/src/fields/hooks/beforeValidate/promise.ts @@ -3,9 +3,9 @@ import { PayloadRequest } from '../../../express/types'; import { Field, fieldAffectsData, TabAsField, tabHasName, valueIsValueWithRelation } from '../../config/types'; import { traverseFields } from './traverseFields'; -type Args = { - data: Record - doc: Record +type Args = { + data: T + doc: T field: Field | TabAsField id?: string | number operation: 'create' | 'update' @@ -20,7 +20,7 @@ type Args = { // - Execute field hooks // - Execute field access control -export const promise = async ({ +export const promise = async ({ data, doc, field, @@ -30,7 +30,7 @@ export const promise = async ({ req, siblingData, siblingDoc, -}: Args): Promise => { +}: Args): Promise => { if (fieldAffectsData(field)) { if (field.name === 'id') { if (field.type === 'number' && typeof siblingData[field.name] === 'string') { diff --git a/src/fields/hooks/beforeValidate/traverseFields.ts b/src/fields/hooks/beforeValidate/traverseFields.ts index 7bd6bc17a1..3e2174a821 100644 --- a/src/fields/hooks/beforeValidate/traverseFields.ts +++ b/src/fields/hooks/beforeValidate/traverseFields.ts @@ -2,9 +2,9 @@ import { PayloadRequest } from '../../../express/types'; import { Field, TabAsField } from '../../config/types'; import { promise } from './promise'; -type Args = { - data: Record - doc: Record +type Args = { + data: T + doc: T fields: (Field | TabAsField)[] id?: string | number operation: 'create' | 'update' @@ -14,7 +14,7 @@ type Args = { siblingDoc: Record } -export const traverseFields = async ({ +export const traverseFields = async ({ data, doc, fields, @@ -24,7 +24,7 @@ export const traverseFields = async ({ req, siblingData, siblingDoc, -}: Args): Promise => { +}: Args): Promise => { const promises = []; fields.forEach((field) => { promises.push(promise({ diff --git a/src/globals/initHTTP.ts b/src/globals/initHTTP.ts index fb9e80c13a..27cce6ef20 100644 --- a/src/globals/initHTTP.ts +++ b/src/globals/initHTTP.ts @@ -2,9 +2,9 @@ import express from 'express'; import mountEndpoints from '../express/mountEndpoints'; import buildEndpoints from './buildEndpoints'; import { SanitizedGlobalConfig } from './config/types'; -import { PayloadHTTP } from '..'; +import { Payload } from '../payload'; -export default function initGlobals(ctx: PayloadHTTP): void { +export default function initGlobals(ctx: Payload): void { if (ctx.config.globals) { ctx.config.globals.forEach((global: SanitizedGlobalConfig) => { const router = express.Router(); diff --git a/src/index.ts b/src/index.ts index fdfd4e2e54..dffc9d6e4f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,5 @@ import { + BaseConfig, InitOptions, } from './config/types'; import { initHTTP } from './initHTTP'; @@ -9,7 +10,7 @@ export { getPayload } from './payload'; require('isomorphic-fetch'); export class PayloadHTTP extends Payload { - async init(options: InitOptions): Promise> { + async init(options: InitOptions): Promise> { const payload = await initHTTP(options); Object.assign(this, payload); return payload; diff --git a/src/initHTTP.ts b/src/initHTTP.ts index 6c0b916b13..7356a49413 100644 --- a/src/initHTTP.ts +++ b/src/initHTTP.ts @@ -1,6 +1,6 @@ /* eslint-disable no-param-reassign */ import express, { NextFunction, Response } from 'express'; -import { InitOptions } from './config/types'; +import { BaseConfig, InitOptions } from './config/types'; import authenticate from './express/middleware/authenticate'; import expressMiddleware from './express/middleware'; @@ -20,7 +20,7 @@ import { getDataLoader } from './collections/dataloader'; import mountEndpoints from './express/mountEndpoints'; import { Payload, getPayload } from './payload'; -export const initHTTP = async (options: InitOptions): Promise> => { +export const initHTTP = async (options: InitOptions): Promise> => { const payload = await getPayload(options); if (!options.local) { diff --git a/src/payload.ts b/src/payload.ts index 92fe298729..93cfbdb821 100644 --- a/src/payload.ts +++ b/src/payload.ts @@ -4,7 +4,6 @@ import { GraphQLError, GraphQLFormattedError, GraphQLSchema } from 'graphql'; import crypto from 'crypto'; import path from 'path'; import mongoose from 'mongoose'; -import { ValueOf } from 'ts-essentials'; import { TypeWithID, Collection, @@ -140,7 +139,7 @@ export class Payload { * @description Initializes Payload * @param options */ - async init(options: InitOptions): Promise> { + async init(options: InitOptions): Promise> { this.logger = Logger('payload', options.loggerOptions); this.mongoURL = options.mongoURL; diff --git a/src/preferences/init.ts b/src/preferences/init.ts index 67a8fad1cf..022390fc1d 100644 --- a/src/preferences/init.ts +++ b/src/preferences/init.ts @@ -2,9 +2,9 @@ import express from 'express'; import findOne from './requestHandlers/findOne'; import update from './requestHandlers/update'; import deleteHandler from './requestHandlers/delete'; -import { PayloadHTTP } from '..'; +import { Payload } from '../payload'; -export default function initPreferences(ctx: PayloadHTTP): void { +export default function initPreferences(ctx: Payload): void { if (!ctx.local) { const router = express.Router(); router diff --git a/src/uploads/generateFileData.ts b/src/uploads/generateFileData.ts index e76e9b6acd..ed5a03e948 100644 --- a/src/uploads/generateFileData.ts +++ b/src/uploads/generateFileData.ts @@ -14,21 +14,21 @@ import { FileData, FileToSave } from './types'; import canResizeImage from './canResizeImage'; import isImage from './isImage'; -type Args = { +type Args = { config: SanitizedConfig, collection: Collection throwOnMissingFile?: boolean req: PayloadRequest - data: Record + data: T overwriteExistingFiles?: boolean } -type Result = Promise<{ - data: Record +type Result = Promise<{ + data: T files: FileToSave[] }> -export const generateFileData = async ({ +export const generateFileData = async ({ config, collection: { config: collectionConfig, @@ -38,7 +38,7 @@ export const generateFileData = async ({ data, throwOnMissingFile, overwriteExistingFiles, -}: Args): Result => { +}: Args): Result => { let newData = data; const filesToSave: FileToSave[] = []; diff --git a/src/utilities/sanitizeInternalFields.ts b/src/utilities/sanitizeInternalFields.ts index 451337c927..ca57c1479f 100644 --- a/src/utilities/sanitizeInternalFields.ts +++ b/src/utilities/sanitizeInternalFields.ts @@ -1,8 +1,6 @@ -import { TypeWithID } from '../collections/config/types'; - const internalFields = ['__v', 'salt', 'hash']; -const sanitizeInternalFields = (incomingDoc): T => Object.entries(incomingDoc).reduce((newDoc, [key, val]): T => { +const sanitizeInternalFields = >(incomingDoc: T): T => Object.entries(incomingDoc).reduce((newDoc, [key, val]): T => { if (key === '_id') { return { ...newDoc, diff --git a/src/versions/drafts/saveCollectionDraft.ts b/src/versions/drafts/saveCollectionDraft.ts index a3f303d9b1..e7fc48bfcc 100644 --- a/src/versions/drafts/saveCollectionDraft.ts +++ b/src/versions/drafts/saveCollectionDraft.ts @@ -3,22 +3,22 @@ import { SanitizedCollectionConfig } from '../../collections/config/types'; import { enforceMaxVersions } from '../enforceMaxVersions'; import { PayloadRequest } from '../../express/types'; -type Args = { +type Args = { payload: Payload config?: SanitizedCollectionConfig req: PayloadRequest - data: any + data: T id: string | number autosave: boolean } -export const saveCollectionDraft = async ({ +export const saveCollectionDraft = async >({ payload, config, id, data, autosave, -}: Args): Promise> => { +}: Args): Promise => { const VersionsModel = payload.versions[config.slug]; const dataAsDraft = { ...data, _status: 'draft' }; From b06ca700be36cc3a945f81e3fa23ebb53d06ca23 Mon Sep 17 00:00:00 2001 From: James Date: Sun, 15 Jan 2023 09:41:54 -0500 Subject: [PATCH 11/46] fix: #1877, #1867 - mimeTypes and imageSizes no longer cause error in admin ui --- .../forms/Form/buildStateFromSchema/addFieldStatePromise.ts | 2 +- test/uploads/config.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/admin/components/forms/Form/buildStateFromSchema/addFieldStatePromise.ts b/src/admin/components/forms/Form/buildStateFromSchema/addFieldStatePromise.ts index b1572d9d26..dfc96a1c04 100644 --- a/src/admin/components/forms/Form/buildStateFromSchema/addFieldStatePromise.ts +++ b/src/admin/components/forms/Form/buildStateFromSchema/addFieldStatePromise.ts @@ -191,7 +191,7 @@ export const addFieldStatePromise = async ({ id, operation, fields: field.fields, - data: data?.[field.name], + data: data?.[field.name] || {}, fullData, parentPassesCondition: passesCondition, path: `${path}${field.name}.`, diff --git a/test/uploads/config.ts b/test/uploads/config.ts index 93cc7ce21b..c4a9f1c0b7 100644 --- a/test/uploads/config.ts +++ b/test/uploads/config.ts @@ -39,6 +39,7 @@ export default buildConfig({ upload: { staticURL: '/media', staticDir: './media', + mimeTypes: ['image/png', 'image/jpg', 'image/jpeg', 'image/svg+xml'], resizeOptions: { width: 1280, height: 720, From d8cce02e9775079179a9971e7173fd80e4fe4942 Mon Sep 17 00:00:00 2001 From: James Date: Sun, 15 Jan 2023 09:48:19 -0500 Subject: [PATCH 12/46] chore(release): v1.5.9 --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4edaa5bdca..91e29d5bcf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ +## [1.5.9](https://github.com/payloadcms/payload/compare/v1.5.8...v1.5.9) (2023-01-15) + + +### Bug Fixes + +* [#1877](https://github.com/payloadcms/payload/issues/1877), [#1867](https://github.com/payloadcms/payload/issues/1867) - mimeTypes and imageSizes no longer cause error in admin ui ([b06ca70](https://github.com/payloadcms/payload/commit/b06ca700be36cc3a945f81e3fa23ebb53d06ca23)) + ## [1.5.8](https://github.com/payloadcms/payload/compare/v1.5.7...v1.5.8) (2023-01-12) diff --git a/package.json b/package.json index 5a1e5eb442..c046be66d6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "payload", - "version": "1.5.8", + "version": "1.5.9", "description": "Node, React and MongoDB Headless CMS and Application Framework", "license": "MIT", "engines": { From 0af29ff4dbbeb48d1f6b03201bd7d811f6be243c Mon Sep 17 00:00:00 2001 From: James Date: Sun, 15 Jan 2023 12:22:16 -0500 Subject: [PATCH 13/46] chore: dynamically uses generated types via tsconfig paths --- .eslintrc.js | 1 + src/auth/operations/resetPassword.ts | 2 +- src/collections/graphql/resolvers/findByID.ts | 4 ++-- src/collections/graphql/resolvers/update.ts | 14 ++++++------ src/collections/operations/local/findByID.ts | 8 +++---- src/collections/operations/local/update.ts | 18 +++++++-------- src/collections/operations/update.ts | 20 ++++++++--------- src/config/types.ts | 13 ++--------- src/generated-types.ts | 12 ++++++++++ src/index.ts | 10 ++++----- src/initHTTP.ts | 7 +++--- src/payload.ts | 22 ++++++++++--------- test/fields/config.ts | 19 +++++++++++++--- tsconfig.json | 3 +++ 14 files changed, 88 insertions(+), 65 deletions(-) create mode 100644 src/generated-types.ts diff --git a/.eslintrc.js b/.eslintrc.js index 1ed0874712..5d825c5141 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -57,6 +57,7 @@ module.exports = { { ignore: [ 'payload-config', + 'payload/generated-types', ], }, ], diff --git a/src/auth/operations/resetPassword.ts b/src/auth/operations/resetPassword.ts index 7bbe9c645b..2faadb62b6 100644 --- a/src/auth/operations/resetPassword.ts +++ b/src/auth/operations/resetPassword.ts @@ -9,7 +9,7 @@ import { PayloadRequest } from '../../express/types'; export type Result = { token: string - user: UserDocument + user: Record } export type Arguments = { diff --git a/src/collections/graphql/resolvers/findByID.ts b/src/collections/graphql/resolvers/findByID.ts index 23dbe93d38..55d2441496 100644 --- a/src/collections/graphql/resolvers/findByID.ts +++ b/src/collections/graphql/resolvers/findByID.ts @@ -1,4 +1,4 @@ -import { BaseConfig } from '../../../config/types'; +import { Config as SchemaConfig } from 'payload/generated-types'; import { PayloadRequest } from '../../../express/types'; import { Collection } from '../../config/types'; import findByID from '../../operations/findByID'; @@ -15,7 +15,7 @@ export type Resolver = (_: unknown, args: { } ) => Promise -export default function findByIDResolver(collection: Collection): Resolver { +export default function findByIDResolver(collection: Collection): Resolver { return async function resolver(_, args, context) { const { req } = context; if (args.locale) req.locale = args.locale; diff --git a/src/collections/graphql/resolvers/update.ts b/src/collections/graphql/resolvers/update.ts index 579f1d2e18..91dabe6909 100644 --- a/src/collections/graphql/resolvers/update.ts +++ b/src/collections/graphql/resolvers/update.ts @@ -1,13 +1,13 @@ /* eslint-disable no-param-reassign */ import { Response } from 'express'; +import { Config as SchemaConfig } from 'payload/generated-types'; import { Collection } from '../../config/types'; import update from '../../operations/update'; import { PayloadRequest } from '../../../express/types'; -import { BaseConfig } from '../../../config/types'; -export type Resolver = (_: unknown, args: { +export type Resolver = (_: unknown, args: { id: string | number - data: Config['collections'][Slug] + data: SchemaConfig['collections'][TSlug] locale?: string draft: boolean autosave: boolean @@ -16,11 +16,11 @@ export type Resolver Promise +) => Promise -export default function updateResolver( +export default function updateResolver( collection: Collection, -): Resolver { +): Resolver { async function resolver(_, args, context) { if (args.locale) context.req.locale = args.locale; if (args.fallbackLocale) context.req.fallbackLocale = args.fallbackLocale; @@ -35,7 +35,7 @@ export default function updateResolver(options); + const result = await update(options); return result; } diff --git a/src/collections/operations/local/findByID.ts b/src/collections/operations/local/findByID.ts index cc02e191ee..4848dad432 100644 --- a/src/collections/operations/local/findByID.ts +++ b/src/collections/operations/local/findByID.ts @@ -1,4 +1,4 @@ -import { BaseConfig } from '../../../config/types'; +import { Config as GeneratedTypes } from 'payload/generated-types'; import { PayloadRequest } from '../../../express/types'; import { Document } from '../../../types'; import findByID from '../findByID'; @@ -6,7 +6,7 @@ import { Payload } from '../../../payload'; import { getDataLoader } from '../../dataloader'; import i18n from '../../../translations/init'; -export type Options = { +export type Options = { collection: T id: string depth?: number @@ -21,7 +21,7 @@ export type Options = { draft?: boolean } -export default async function findByIDLocal(payload: Payload, options: Options): Promise { +export default async function findByIDLocal(payload: Payload, options: Options): Promise { const { collection: collectionSlug, depth, @@ -51,7 +51,7 @@ export default async function findByIDLocal({ + return findByID({ depth, currentDepth, id, diff --git a/src/collections/operations/local/update.ts b/src/collections/operations/local/update.ts index 22579e571b..d34519da6d 100644 --- a/src/collections/operations/local/update.ts +++ b/src/collections/operations/local/update.ts @@ -1,3 +1,4 @@ +import { Config as SchemaConfig } from 'payload/generated-types'; import { Payload } from '../../../payload'; import { Document } from '../../../types'; import getFileByPath from '../../../uploads/getFileByPath'; @@ -6,12 +7,11 @@ import { PayloadRequest } from '../../../express/types'; import { getDataLoader } from '../../dataloader'; import { File } from '../../../uploads/types'; import i18nInit from '../../../translations/init'; -import { BaseConfig } from '../../../config/types'; -export type Options = { - collection: Slug +export type Options = { + collection: TSlug id: string | number - data: Config['collections'][Slug] + data: SchemaConfig['collections'][TSlug] depth?: number locale?: string fallbackLocale?: string @@ -25,10 +25,10 @@ export type Options( - payload: Payload, - options: Options, -): Promise { +export default async function updateLocal( + payload: Payload, + options: Options, +): Promise { const { collection: collectionSlug, depth, @@ -79,5 +79,5 @@ export default async function updateLocal(args); + return update(args); } diff --git a/src/collections/operations/update.ts b/src/collections/operations/update.ts index 336dcdf032..a5b6ddcdf9 100644 --- a/src/collections/operations/update.ts +++ b/src/collections/operations/update.ts @@ -1,5 +1,5 @@ import httpStatus from 'http-status'; -import { BaseConfig } from '../../config/types'; +import { Config as SchemaConfig } from 'payload/generated-types'; import { Where, Document } from '../../types'; import { Collection } from '../config/types'; import sanitizeInternalFields from '../../utilities/sanitizeInternalFields'; @@ -19,7 +19,7 @@ import { afterRead } from '../../fields/hooks/afterRead'; import { generateFileData } from '../../uploads/generateFileData'; import { getLatestCollectionVersion } from '../../versions/getLatestCollectionVersion'; -export type Arguments = { +export type Arguments = { collection: Collection req: PayloadRequest id: string | number @@ -33,9 +33,9 @@ export type Arguments = { autosave?: boolean } -async function update( - incomingArgs: Arguments, -): Promise { +async function update( + incomingArgs: Arguments, +): Promise { let args = incomingArgs; // ///////////////////////////////////// @@ -150,7 +150,7 @@ async function update({ + data = await beforeValidate({ data, doc: originalDoc, entityConfig: collectionConfig, @@ -202,7 +202,7 @@ async function update({ + let result = await beforeChange({ data, doc: originalDoc, docWithLocales, @@ -253,7 +253,7 @@ async function update({ + result = await saveCollectionDraft({ payload, config: collectionConfig, req, @@ -285,7 +285,7 @@ async function update(result); + result = sanitizeInternalFields(result); // ///////////////////////////////////// // afterRead - Fields @@ -317,7 +317,7 @@ async function update({ + result = await afterChange({ data, doc: result, previousDoc: originalDoc, diff --git a/src/config/types.ts b/src/config/types.ts index 7815f6946e..afbe5a1033 100644 --- a/src/config/types.ts +++ b/src/config/types.ts @@ -20,15 +20,6 @@ import { PayloadRequest } from '../express/types'; import { Where } from '../types'; import { User } from '../auth/types'; -export interface BaseConfig { - collections: { - [slug: string | number | symbol]: Record - } - globals: { - [slug: string | number | symbol]: Record - } -} - type Email = { fromName: string; fromAddress: string; @@ -109,7 +100,7 @@ export type InitOptions = { /** * A function that is called immediately following startup that receives the Payload instance as it's only argument. */ - onInit?: (payload: Payload) => Promise | void; + onInit?: (payload: Payload) => Promise | void; /** * Specify options for the built-in Pino logger that Payload uses for internal logging. @@ -541,7 +532,7 @@ export type Config = { /** Send anonymous telemetry data about general usage. */ telemetry?: boolean; /** A function that is called immediately following startup that receives the Payload instance as its only argument. */ - onInit?: (payload: Payload) => Promise | void; + onInit?: (payload: Payload) => Promise | void; }; export type SanitizedConfig = Omit< diff --git a/src/generated-types.ts b/src/generated-types.ts new file mode 100644 index 0000000000..f69189f7f1 --- /dev/null +++ b/src/generated-types.ts @@ -0,0 +1,12 @@ +// This is a stub for Payload's generated types. +// It will not be used. +// Instead, configure a path within your `tsconfig.json`'s `compilerOptions.paths` to point to your generated types. + +export type Config = { + collections: { + [slug: string | number | symbol]: Record + } + globals: { + [slug: string | number | symbol]: Record + } +} diff --git a/src/index.ts b/src/index.ts index dffc9d6e4f..74d240f5dc 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,17 +1,17 @@ +import { Config as GeneratedTypes } from 'payload/generated-types'; import { - BaseConfig, InitOptions, } from './config/types'; import { initHTTP } from './initHTTP'; -import { Payload } from './payload'; +import { Payload, BasePayload } from './payload'; export { getPayload } from './payload'; require('isomorphic-fetch'); -export class PayloadHTTP extends Payload { - async init(options: InitOptions): Promise> { - const payload = await initHTTP(options); +export class PayloadHTTP extends BasePayload { + async init(options: InitOptions): Promise { + const payload = await initHTTP(options); Object.assign(this, payload); return payload; } diff --git a/src/initHTTP.ts b/src/initHTTP.ts index 7356a49413..9a8ca3e2ad 100644 --- a/src/initHTTP.ts +++ b/src/initHTTP.ts @@ -1,6 +1,7 @@ /* eslint-disable no-param-reassign */ import express, { NextFunction, Response } from 'express'; -import { BaseConfig, InitOptions } from './config/types'; +import { Config as GeneratedTypes } from 'payload/generated-types'; +import { InitOptions } from './config/types'; import authenticate from './express/middleware/authenticate'; import expressMiddleware from './express/middleware'; @@ -20,8 +21,8 @@ import { getDataLoader } from './collections/dataloader'; import mountEndpoints from './express/mountEndpoints'; import { Payload, getPayload } from './payload'; -export const initHTTP = async (options: InitOptions): Promise> => { - const payload = await getPayload(options); +export const initHTTP = async (options: InitOptions): Promise => { + const payload = await getPayload(options); if (!options.local) { payload.router = express.Router(); diff --git a/src/payload.ts b/src/payload.ts index 93cfbdb821..f22d4d6937 100644 --- a/src/payload.ts +++ b/src/payload.ts @@ -4,6 +4,7 @@ import { GraphQLError, GraphQLFormattedError, GraphQLSchema } from 'graphql'; import crypto from 'crypto'; import path from 'path'; import mongoose from 'mongoose'; +import { Config as GeneratedTypes } from 'payload/generated-types'; import { TypeWithID, Collection, @@ -13,7 +14,6 @@ import { SanitizedConfig, EmailOptions, InitOptions, - BaseConfig, } from './config/types'; import { TypeWithVersion } from './versions/types'; import { PaginatedDocs } from './mongoose/types'; @@ -65,7 +65,7 @@ import findConfig from './config/find'; /** * @description Payload */ -export class Payload { +export class BasePayload { config: SanitizedConfig; collections: { @@ -139,7 +139,7 @@ export class Payload { * @description Initializes Payload * @param options */ - async init(options: InitOptions): Promise> { + async init(options: InitOptions): Promise { this.logger = Logger('payload', options.loggerOptions); this.mongoURL = options.mongoURL; @@ -272,7 +272,7 @@ export class Payload { * @returns document with specified ID */ - findByID = async (options: FindByIDOptions): Promise => { + findByID = async (options: FindByIDOptions): Promise => { const { findByID } = localOperations; return findByID(this, options); } @@ -282,9 +282,9 @@ export class Payload { * @param options * @returns Updated document */ - update = async (options: UpdateOptions): Promise => { + update = async (options: UpdateOptions): Promise => { const { update } = localOperations; - return update(this, options); + return update(this, options); } delete = async (options: DeleteOptions): Promise => { @@ -348,20 +348,22 @@ export class Payload { } } -let cached = global.payload; +export type Payload = BasePayload + +let cached = global._payload; if (!cached) { // eslint-disable-next-line no-multi-assign - cached = global.payload = { payload: null, promise: null }; + cached = global._payload = { payload: null, promise: null }; } -export const getPayload = async (options: InitOptions): Promise> => { +export const getPayload = async (options: InitOptions): Promise => { if (cached.payload) { return cached.payload; } if (!cached.promise) { - cached.promise = new Payload().init(options); + cached.promise = new BasePayload().init(options); } try { diff --git a/test/fields/config.ts b/test/fields/config.ts index 75285a0280..8fe6cb3616 100644 --- a/test/fields/config.ts +++ b/test/fields/config.ts @@ -23,6 +23,8 @@ import JSONFields, { jsonDoc } from './collections/JSON'; import RelationshipFields from './collections/Relationship'; import RadioFields, { radiosDoc } from './collections/Radio'; import Uploads2 from './collections/Upload2'; +import { Payload } from '../../src/payload'; +import { Config } from './payload-types'; export default buildConfig({ admin: { @@ -63,7 +65,7 @@ export default buildConfig({ locales: ['en', 'es'], fallback: true, }, - onInit: async (payload) => { + onInit: async (payload: Payload) => { await payload.create({ collection: 'users', data: { @@ -102,8 +104,8 @@ export default buildConfig({ ...uploadsDoc, media: createdPNGDoc.id, }, - file: jpgFile - }); + file: jpgFile, + }); const richTextDocWithRelId = JSON.parse(JSON.stringify(richTextDoc).replace('{{ARRAY_DOC_ID}}', createdArrayDoc.id)); const richTextDocWithRelationship = { ...richTextDocWithRelId }; @@ -128,5 +130,16 @@ export default buildConfig({ blocksDocWithRichText.localizedBlocks[0].richText = richTextDocWithRelationship.richText; await payload.create({ collection: 'block-fields', data: blocksDocWithRichText }); + + const arrayField = await payload.findByID({ + collection: 'array-fields', + id: 'test', + }); + + const updatedArray = await payload.update({ + collection: 'array-fields', + data: arrayField, + id: 'test', + }); }, }); diff --git a/tsconfig.json b/tsconfig.json index 9772585039..22418458ec 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,6 +15,9 @@ "strict": false, /* Enable all strict type-checking options. */ "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ "paths": { + "payload/generated-types": [ + "./src/generated-types.ts", + ], "payload/config": [ "./src/config/types.ts" ], From 773fb57c71f89d5157847ee4907c1472874f9a61 Mon Sep 17 00:00:00 2001 From: Elliot DeNolf Date: Mon, 16 Jan 2023 10:47:37 -0500 Subject: [PATCH 14/46] fix: bump pino and pino-pretty to accommodate yarn 2 --- package.json | 2 +- src/utilities/logger.ts | 12 +++-- yarn.lock | 101 ++++++++++++++++++++++++---------------- 3 files changed, 71 insertions(+), 44 deletions(-) diff --git a/package.json b/package.json index a4521c0ce0..cc21411c2d 100644 --- a/package.json +++ b/package.json @@ -144,7 +144,7 @@ "passport-local": "^1.0.0", "passport-local-mongoose": "^7.0.0", "path-browserify": "^1.0.1", - "pino": "^6.4.1", + "pino": "^8.8.0", "pino-pretty": "^9.1.1", "pluralize": "^8.0.0", "postcss": "^8.4.6", diff --git a/src/utilities/logger.ts b/src/utilities/logger.ts index 79bb970863..5b416120ff 100644 --- a/src/utilities/logger.ts +++ b/src/utilities/logger.ts @@ -3,10 +3,14 @@ import memoize from 'micro-memoize'; export type PayloadLogger = pino.Logger; -const defaultLoggerOptions = { - prettyPrint: { - ignore: 'pid,hostname', - translateTime: 'HH:MM:ss', +const defaultLoggerOptions: pino.LoggerOptions = { + transport: { + target: 'pino-pretty', + options: { + colorize: true, + ignore: 'pid,hostname', + translateTime: 'HH:MM:ss', + }, }, }; diff --git a/yarn.lock b/yarn.lock index ca47c70840..d56c3bf55a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5880,12 +5880,12 @@ fast-levenshtein@~2.0.6: resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" integrity sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw== -fast-redact@^3.0.0: +fast-redact@^3.1.1: version "3.1.2" - resolved "https://registry.yarnpkg.com/fast-redact/-/fast-redact-3.1.2.tgz#d58e69e9084ce9fa4c1a6fa98a3e1ecf5d7839aa" + resolved "https://registry.npmjs.org/fast-redact/-/fast-redact-3.1.2.tgz#d58e69e9084ce9fa4c1a6fa98a3e1ecf5d7839aa" integrity sha512-+0em+Iya9fKGfEQGcd62Yv6onjBmmhV1uh86XVfOU8VwAe6kaFdQCWI9s0/Nnugx5Vd9tdbZ7e6gE2tR9dzXdw== -fast-safe-stringify@^2.0.8, fast-safe-stringify@^2.1.1: +fast-safe-stringify@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz#c406a83b6e70d9e35ce3b30a81141df30aeba884" integrity sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA== @@ -6047,11 +6047,6 @@ flatley@^5.2.0: dependencies: is-buffer "^1.1.6" -flatstr@^1.0.12: - version "1.0.12" - resolved "https://registry.yarnpkg.com/flatstr/-/flatstr-1.0.12.tgz#c2ba6a08173edbb6c9640e3055b95e287ceb5931" - integrity sha512-4zPxDyhCyiN2wIAtSLI6gc82/EjqZc1onI4Mz/l0pWrAlsSfYH/2ZIcU+e3oA2wDwbzIWNKwa23F8rh6+DRWkw== - flatted@^2.0.0: version "2.0.2" resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.2.tgz#4575b21e2bcee7434aa9be662f4b7b5f9c2b5138" @@ -9302,7 +9297,7 @@ pify@^3.0.0: resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176" integrity sha512-C3FsVNH1udSEX48gGX1xfvwTWfsYWj5U+8/uK15BGzIGrKoUpghX8hWZwa/OFnakBiiVNmBvemTJR5mcy7iPcg== -pino-abstract-transport@^1.0.0: +pino-abstract-transport@^1.0.0, pino-abstract-transport@v1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/pino-abstract-transport/-/pino-abstract-transport-1.0.0.tgz#cc0d6955fffcadb91b7b49ef220a6cc111d48bb3" integrity sha512-c7vo5OpW4wIS42hUVcT5REsL8ZljsUfBjqV/e2sFxmFEFZiq1XLUp5EYLtuDH6PEHq9W1egWqRbnLUP5FuZmOA== @@ -9310,7 +9305,7 @@ pino-abstract-transport@^1.0.0: readable-stream "^4.0.0" split2 "^4.0.0" -pino-pretty@*, pino-pretty@^9.1.1: +pino-pretty@*: version "9.1.1" resolved "https://registry.yarnpkg.com/pino-pretty/-/pino-pretty-9.1.1.tgz#e7d64c1db98266ca428ab56567b844ba780cd0e1" integrity sha512-iJrnjgR4FWQIXZkUF48oNgoRI9BpyMhaEmihonHeCnZ6F50ZHAS4YGfGBT/ZVNsPmd+hzkIPGzjKdY08+/yAXw== @@ -9330,28 +9325,47 @@ pino-pretty@*, pino-pretty@^9.1.1: sonic-boom "^3.0.0" strip-json-comments "^3.1.1" -pino-std-serializers@*: +pino-pretty@^9.1.1: + version "9.1.1" + resolved "https://registry.npmjs.org/pino-pretty/-/pino-pretty-9.1.1.tgz#e7d64c1db98266ca428ab56567b844ba780cd0e1" + integrity sha512-iJrnjgR4FWQIXZkUF48oNgoRI9BpyMhaEmihonHeCnZ6F50ZHAS4YGfGBT/ZVNsPmd+hzkIPGzjKdY08+/yAXw== + dependencies: + colorette "^2.0.7" + dateformat "^4.6.3" + fast-copy "^3.0.0" + fast-safe-stringify "^2.1.1" + help-me "^4.0.1" + joycon "^3.1.1" + minimist "^1.2.6" + on-exit-leak-free "^2.1.0" + pino-abstract-transport "^1.0.0" + pump "^3.0.0" + readable-stream "^4.0.0" + secure-json-parse "^2.4.0" + sonic-boom "^3.0.0" + strip-json-comments "^3.1.1" + +pino-std-serializers@*, pino-std-serializers@^6.0.0: version "6.1.0" resolved "https://registry.yarnpkg.com/pino-std-serializers/-/pino-std-serializers-6.1.0.tgz#307490fd426eefc95e06067e85d8558603e8e844" integrity sha512-KO0m2f1HkrPe9S0ldjx7za9BJjeHqBku5Ch8JyxETxT8dEFGz1PwgrHaOQupVYitpzbFSYm7nnljxD8dik2c+g== -pino-std-serializers@^3.1.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/pino-std-serializers/-/pino-std-serializers-3.2.0.tgz#b56487c402d882eb96cd67c257868016b61ad671" - integrity sha512-EqX4pwDPrt3MuOAAUBMU0Tk5kR/YcCM5fNPEzgCO2zJ5HfX0vbiH9HbJglnyeQsN96Kznae6MWD47pZB5avTrg== - -pino@^6.4.1: - version "6.14.0" - resolved "https://registry.yarnpkg.com/pino/-/pino-6.14.0.tgz#b745ea87a99a6c4c9b374e4f29ca7910d4c69f78" - integrity sha512-iuhEDel3Z3hF9Jfe44DPXR8l07bhjuFY3GMHIXbjnY9XcafbyDDwl2sN2vw2GjMPf5Nkoe+OFao7ffn9SXaKDg== +pino@^8.8.0: + version "8.8.0" + resolved "https://registry.npmjs.org/pino/-/pino-8.8.0.tgz#1f0d6695a224aa06afc7ad60f2ccc4772d3b9233" + integrity sha512-cF8iGYeu2ODg2gIwgAHcPrtR63ILJz3f7gkogaHC/TXVVXxZgInmNYiIpDYEwgEkxZti2Se6P2W2DxlBIZe6eQ== dependencies: - fast-redact "^3.0.0" - fast-safe-stringify "^2.0.8" - flatstr "^1.0.12" - pino-std-serializers "^3.1.0" - process-warning "^1.0.0" + atomic-sleep "^1.0.0" + fast-redact "^3.1.1" + on-exit-leak-free "^2.1.0" + pino-abstract-transport v1.0.0 + pino-std-serializers "^6.0.0" + process-warning "^2.0.0" quick-format-unescaped "^4.0.3" - sonic-boom "^1.0.2" + real-require "^0.2.0" + safe-stable-stringify "^2.3.1" + sonic-boom "^3.1.0" + thread-stream "^2.0.0" pirates@^4.0.1, pirates@^4.0.4: version "4.0.5" @@ -9964,10 +9978,10 @@ process-nextick-args@~2.0.0: resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag== -process-warning@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/process-warning/-/process-warning-1.0.0.tgz#980a0b25dc38cd6034181be4b7726d89066b4616" - integrity sha512-du4wfLyj4yCZq1VupnVSZmRsPJsNuxoDQFdCFHLaYiEbFBD7QE0a+I4D7hOxrVnh78QE/YipFAj9lXHiXocV+Q== +process-warning@^2.0.0: + version "2.1.0" + resolved "https://registry.npmjs.org/process-warning/-/process-warning-2.1.0.tgz#1e60e3bfe8183033bbc1e702c2da74f099422d1a" + integrity sha512-9C20RLxrZU/rFnxWncDkuF6O999NdIf3E1ws4B0ZeY3sRVPzWBMsYDE2lxjxhiXxg464cQTgKUGm8/i6y2YGXg== process@^0.11.10: version "0.11.10" @@ -10478,6 +10492,11 @@ readdirp@~3.6.0: dependencies: picomatch "^2.2.1" +real-require@^0.2.0: + version "0.2.0" + resolved "https://registry.npmjs.org/real-require/-/real-require-0.2.0.tgz#209632dea1810be2ae063a6ac084fee7e33fba78" + integrity sha512-57frrGM/OCTLqLOAh0mhVA9VBMHd+9U7Zb2THMGdBUoZVOtGbJzjxsYGDJ3A9AYYCP4hn6y1TVbaOfzWtm5GFg== + rechoir@^0.6.2: version "0.6.2" resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384" @@ -10760,6 +10779,11 @@ safe-regex-test@^1.0.0: get-intrinsic "^1.1.3" is-regex "^1.1.4" +safe-stable-stringify@^2.3.1: + version "2.4.2" + resolved "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.4.2.tgz#ec7b037768098bf65310d1d64370de0dc02353aa" + integrity sha512-gMxvPJYhP0O9n2pvcfYfIuYgbledAOJFcqRThtPRmjscaipiwcwPPKLytpVzMkG2HAN87Qmo2d4PtGiri1dSLA== + "safer-buffer@>= 2.1.2 < 3", "safer-buffer@>= 2.1.2 < 3.0.0": version "2.1.2" resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" @@ -11119,14 +11143,6 @@ socks@^2.3.3, socks@^2.6.2, socks@^2.7.1: ip "^2.0.0" smart-buffer "^4.2.0" -sonic-boom@^1.0.2: - version "1.4.1" - resolved "https://registry.yarnpkg.com/sonic-boom/-/sonic-boom-1.4.1.tgz#d35d6a74076624f12e6f917ade7b9d75e918f53e" - integrity sha512-LRHh/A8tpW7ru89lrlkU4AszXt1dbwSjVWguGrmlxE7tawVmDBlI1PILMkXAxJTwqhgsEeTHzj36D5CmHgQmNg== - dependencies: - atomic-sleep "^1.0.0" - flatstr "^1.0.12" - sonic-boom@^2.1.0: version "2.8.0" resolved "https://registry.yarnpkg.com/sonic-boom/-/sonic-boom-2.8.0.tgz#c1def62a77425090e6ad7516aad8eb402e047611" @@ -11134,7 +11150,7 @@ sonic-boom@^2.1.0: dependencies: atomic-sleep "^1.0.0" -sonic-boom@^3.0.0: +sonic-boom@^3.0.0, sonic-boom@^3.1.0: version "3.2.1" resolved "https://registry.yarnpkg.com/sonic-boom/-/sonic-boom-3.2.1.tgz#972ceab831b5840a08a002fa95a672008bda1c38" integrity sha512-iITeTHxy3B9FGu8aVdiDXUVAcHMF9Ss0cCsAOo2HfCrmVGT3/DT5oYaeu0M/YKZDlKTvChEyPq0zI9Hf33EX6A== @@ -11628,6 +11644,13 @@ thenify-all@^1.0.0: dependencies: any-promise "^1.0.0" +thread-stream@^2.0.0: + version "2.3.0" + resolved "https://registry.npmjs.org/thread-stream/-/thread-stream-2.3.0.tgz#4fc07fb39eff32ae7bad803cb7dd9598349fed33" + integrity sha512-kaDqm1DET9pp3NXwR8382WHbnpXnRkN9xGN9dQt3B2+dmXiW8X1SOwmFOxAErEQ47ObhZ96J6yhZNXuyCOL7KA== + dependencies: + real-require "^0.2.0" + through2@^2.0.0, through2@^2.0.1: version "2.0.5" resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.5.tgz#01c1e39eb31d07cb7d03a96a70823260b23132cd" From cc7257efd529580b1eb7b6c01df9f7420838c345 Mon Sep 17 00:00:00 2001 From: Johan Date: Mon, 16 Jan 2023 21:11:27 +0100 Subject: [PATCH 15/46] fix: updated nl i18n typos --- src/translations/nl.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/translations/nl.json b/src/translations/nl.json index c3098cccf1..0ad4fa173d 100644 --- a/src/translations/nl.json +++ b/src/translations/nl.json @@ -93,7 +93,7 @@ "block": "blok", "blocks": "blokken", "addLabel": "Voeg {{label}} toe", - "addLink": "Voeg een link tsoe", + "addLink": "Voeg een link toe", "addNew": "Nieuw(e)", "addNewLabel": "Nieuw(e) {{label}} toevoegen", "addRelationship": "Nieuwe Relatie", @@ -112,7 +112,7 @@ "passwordsDoNotMatch": "Wachtwoorden komen niet overeen.", "relatedDocument": "Gerelateerd document", "relationTo": "Relatie tot", - "removeRelationship": "Relatie Vserwijderen", + "removeRelationship": "Relatie Verwijderen", "removeUpload": "Verwijder Upload", "saveChanges": "Bewaar aanpassingen", "searchForBlock": "Zoeken naar een blok", From 671adc7e0eab6dfc517979e3ecd6969ab5eea969 Mon Sep 17 00:00:00 2001 From: James Date: Mon, 16 Jan 2023 18:09:38 -0500 Subject: [PATCH 16/46] chore: begins simplifying versions --- .../components/elements/Autosave/index.tsx | 2 +- .../elements/VersionsCount/index.tsx | 22 +---- src/admin/components/views/Versions/index.tsx | 66 ++++---------- src/collections/operations/create.ts | 18 ++++ src/collections/operations/update.ts | 55 +++--------- src/collections/requestHandlers/create.ts | 6 +- src/versions/drafts/saveCollectionDraft.ts | 79 ---------------- src/versions/saveCollectionVersion.ts | 89 +++++++------------ test/versions/collections/Versions.ts | 56 ++++++++++++ test/versions/config.ts | 2 + 10 files changed, 146 insertions(+), 249 deletions(-) delete mode 100644 src/versions/drafts/saveCollectionDraft.ts create mode 100644 test/versions/collections/Versions.ts diff --git a/src/admin/components/elements/Autosave/index.tsx b/src/admin/components/elements/Autosave/index.tsx index e51cbb5fd4..d444277c4a 100644 --- a/src/admin/components/elements/Autosave/index.tsx +++ b/src/admin/components/elements/Autosave/index.tsx @@ -44,7 +44,7 @@ const Autosave: React.FC = ({ collection, global, id, publishedDocUpdated modifiedRef.current = modified; const createCollectionDoc = useCallback(async () => { - const res = await fetch(`${serverURL}${api}/${collection.slug}?locale=${locale}&fallback-locale=null&depth=0&draft=true`, { + const res = await fetch(`${serverURL}${api}/${collection.slug}?locale=${locale}&fallback-locale=null&depth=0&draft=true&autosave=true`, { method: 'POST', credentials: 'include', headers: { diff --git a/src/admin/components/elements/VersionsCount/index.tsx b/src/admin/components/elements/VersionsCount/index.tsx index f58731fd56..2ca490fa68 100644 --- a/src/admin/components/elements/VersionsCount/index.tsx +++ b/src/admin/components/elements/VersionsCount/index.tsx @@ -4,9 +4,6 @@ import { useConfig } from '../../utilities/Config'; import Button from '../Button'; import { Props } from './types'; import { useDocumentInfo } from '../../utilities/DocumentInfo'; -import { SanitizedCollectionConfig } from '../../../../collections/config/types'; -import { SanitizedGlobalConfig } from '../../../../globals/config/types'; -import { shouldIncrementVersionCount } from '../../../../versions/shouldIncrementVersionCount'; import './index.scss'; @@ -14,35 +11,20 @@ const baseClass = 'versions-count'; const VersionsCount: React.FC = ({ collection, global, id }) => { const { routes: { admin } } = useConfig(); - const { versions, publishedDoc, unpublishedVersions } = useDocumentInfo(); + const { versions } = useDocumentInfo(); const { t } = useTranslation('version'); - // Doc status could come from three places: - // 1. the newest unpublished version (a draft) - // 2. the published doc's status, in the event that the doc is published and there are no newer versions - // 3. if there is no published doc, it's a draft - const docStatus = unpublishedVersions?.docs?.[0]?.version?._status || publishedDoc?._status || 'draft'; - let versionsURL: string; - let entity: SanitizedCollectionConfig | SanitizedGlobalConfig; if (collection) { versionsURL = `${admin}/collections/${collection.slug}/${id}/versions`; - entity = collection; } if (global) { versionsURL = `${admin}/globals/${global.slug}/versions`; - entity = global; } - let initialVersionsCount = 0; - - if (shouldIncrementVersionCount({ entity, versions, docStatus })) { - initialVersionsCount = 1; - } - - const versionCount = (versions?.totalDocs || 0) + initialVersionsCount; + const versionCount = versions?.totalDocs || 0; return (
diff --git a/src/admin/components/views/Versions/index.tsx b/src/admin/components/views/Versions/index.tsx index eca3f3d7a3..123f793f06 100644 --- a/src/admin/components/views/Versions/index.tsx +++ b/src/admin/components/views/Versions/index.tsx @@ -1,6 +1,5 @@ import React, { useEffect, useState } from 'react'; import { useRouteMatch } from 'react-router-dom'; -import format from 'date-fns/format'; import { useTranslation } from 'react-i18next'; import { useConfig } from '../../utilities/Config'; import usePayloadAPI from '../../../hooks/usePayloadAPI'; @@ -16,10 +15,6 @@ import Table from '../../elements/Table'; import Paginator from '../../elements/Paginator'; import PerPage from '../../elements/PerPage'; import { useSearchParams } from '../../utilities/SearchParams'; -import { Banner, Pill } from '../..'; -import { SanitizedCollectionConfig } from '../../../../collections/config/types'; -import { SanitizedGlobalConfig } from '../../../../globals/config/types'; -import { shouldIncrementVersionCount } from '../../../../versions/shouldIncrementVersionCount'; import { Gutter } from '../../elements/Gutter'; import { getTranslation } from '../../../../utilities/getTranslation'; @@ -28,7 +23,7 @@ import './index.scss'; const baseClass = 'versions'; const Versions: React.FC = ({ collection, global }) => { - const { serverURL, routes: { admin, api }, admin: { dateFormat } } = useConfig(); + const { serverURL, routes: { admin, api } } = useConfig(); const { setStepNav } = useStepNav(); const { params: { id } } = useRouteMatch<{ id: string }>(); const { t, i18n } = useTranslation('version'); @@ -39,14 +34,12 @@ const Versions: React.FC = ({ collection, global }) => { let docURL: string; let entityLabel: string; let slug: string; - let entity: SanitizedCollectionConfig | SanitizedGlobalConfig; let editURL: string; if (collection) { ({ slug } = collection); docURL = `${serverURL}${api}/${slug}/${id}`; entityLabel = getTranslation(collection.labels.singular, i18n); - entity = collection; editURL = `${admin}/collections/${collection.slug}/${id}`; } @@ -54,7 +47,6 @@ const Versions: React.FC = ({ collection, global }) => { ({ slug } = global); docURL = `${serverURL}${api}/globals/${slug}`; entityLabel = getTranslation(global.label, i18n); - entity = global; editURL = `${admin}/globals/${global.slug}`; } @@ -164,10 +156,6 @@ const Versions: React.FC = ({ collection, global }) => { useIDLabel = false; } - const docStatus = doc?._status; - const docUpdatedAt = doc?.updatedAt; - const showParentDoc = versionsData?.page === 1 && shouldIncrementVersionCount({ entity, docStatus, versions: versionsData }); - return (
= ({ collection, global }) => { {isLoadingVersions && ( )} - {showParentDoc && ( - - {t('currentDocumentStatus', { docStatus })} - - - {' '} - {format(new Date(docUpdatedAt), dateFormat)} -
-    - - {t('general:edit')} - -
-
- )} {versionsData?.totalDocs > 0 && ( = ({ collection, global }) => { numberOfNeighbors={1} /> {versionsData?.totalDocs > 0 && ( - -
- {(versionsData.page * versionsData.limit) - (versionsData.limit - 1)} - - - {versionsData.totalPages > 1 && versionsData.totalPages !== versionsData.page ? (versionsData.limit * versionsData.page) : versionsData.totalDocs} - {' '} - {t('of')} - {' '} - {versionsData.totalDocs} -
- -
- )} + +
+ {(versionsData.page * versionsData.limit) - (versionsData.limit - 1)} + - + {versionsData.totalPages > 1 && versionsData.totalPages !== versionsData.page ? (versionsData.limit * versionsData.page) : versionsData.totalDocs} + {' '} + {t('of')} + {' '} + {versionsData.totalDocs} +
+ +
+ )} )} diff --git a/src/collections/operations/create.ts b/src/collections/operations/create.ts index d51509823c..35a436cce8 100644 --- a/src/collections/operations/create.ts +++ b/src/collections/operations/create.ts @@ -16,6 +16,7 @@ import { beforeValidate } from '../../fields/hooks/beforeValidate'; import { afterChange } from '../../fields/hooks/afterChange'; import { afterRead } from '../../fields/hooks/afterRead'; import { generateFileData } from '../../uploads/generateFileData'; +import { saveCollectionVersion } from '../../versions/saveCollectionVersion'; export type Arguments = { collection: Collection @@ -27,6 +28,7 @@ export type Arguments = { data: Record overwriteExistingFiles?: boolean draft?: boolean + autosave?: boolean } async function create(incomingArgs: Arguments): Promise { @@ -65,6 +67,7 @@ async function create(incomingArgs: Arguments): Promise { showHiddenFields, overwriteExistingFiles = false, draft = false, + autosave = false, } = args; let { data } = args; @@ -213,6 +216,21 @@ async function create(incomingArgs: Arguments): Promise { result = JSON.parse(result); result = sanitizeInternalFields(result); + // ///////////////////////////////////// + // Create version + // ///////////////////////////////////// + + if (collectionConfig.versions) { + await saveCollectionVersion({ + payload, + config: collectionConfig, + req, + id: result.id, + docWithLocales: result, + autosave, + }); + } + // ///////////////////////////////////// // Send verification email if applicable // ///////////////////////////////////// diff --git a/src/collections/operations/update.ts b/src/collections/operations/update.ts index 095081e3c7..954b19862e 100644 --- a/src/collections/operations/update.ts +++ b/src/collections/operations/update.ts @@ -6,11 +6,8 @@ import executeAccess from '../../auth/executeAccess'; import { NotFound, Forbidden, APIError, ValidationError } from '../../errors'; import { PayloadRequest } from '../../express/types'; import { hasWhereAccessResult } from '../../auth/types'; -import { saveCollectionDraft } from '../../versions/drafts/saveCollectionDraft'; import { saveCollectionVersion } from '../../versions/saveCollectionVersion'; import { uploadFiles } from '../../uploads/uploadFiles'; -import cleanUpFailedVersion from '../../versions/cleanUpFailedVersion'; -import { ensurePublishedCollectionVersion } from '../../versions/ensurePublishedCollectionVersion'; import { beforeChange } from '../../fields/hooks/beforeChange'; import { beforeValidate } from '../../fields/hooks/beforeValidate'; import { afterChange } from '../../fields/hooks/afterChange'; @@ -221,44 +218,11 @@ async function update(incomingArgs: Arguments): Promise { delete result.password; } - // ///////////////////////////////////// - // Create version from existing doc - // ///////////////////////////////////// - - let createdVersion; - - if (collectionConfig.versions && !shouldSaveDraft) { - createdVersion = await saveCollectionVersion({ - payload, - config: collectionConfig, - req, - docWithLocales, - id, - }); - } - // ///////////////////////////////////// // Update // ///////////////////////////////////// - if (shouldSaveDraft) { - await ensurePublishedCollectionVersion({ - payload, - config: collectionConfig, - req, - docWithLocales, - id, - }); - - result = await saveCollectionDraft({ - payload, - config: collectionConfig, - req, - data: result, - id, - autosave, - }); - } else { + if (!shouldSaveDraft) { try { result = await Model.findByIdAndUpdate( { _id: id }, @@ -266,12 +230,6 @@ async function update(incomingArgs: Arguments): Promise { { new: true }, ); } catch (error) { - cleanUpFailedVersion({ - payload, - entityConfig: collectionConfig, - version: createdVersion, - }); - // Handle uniqueness error from MongoDB throw error.code === 11000 && error.keyValue ? new ValidationError([{ message: 'Value must be unique', field: Object.keys(error.keyValue)[0] }], t) @@ -285,6 +243,17 @@ async function update(incomingArgs: Arguments): Promise { result.id = result._id; } + if (collectionConfig.versions) { + result = await saveCollectionVersion({ + payload, + config: collectionConfig, + req, + docWithLocales: result, + id, + autosave, + }); + } + result = sanitizeInternalFields(result); // ///////////////////////////////////// diff --git a/src/collections/requestHandlers/create.ts b/src/collections/requestHandlers/create.ts index 29b23aff6f..fc30fddc29 100644 --- a/src/collections/requestHandlers/create.ts +++ b/src/collections/requestHandlers/create.ts @@ -13,12 +13,16 @@ export type CreateResult = { export default async function createHandler(req: PayloadRequest, res: Response, next: NextFunction): Promise | void> { try { + const autosave = req.query.autosave === 'true'; + const draft = req.query.draft === 'true'; + const doc = await create({ req, collection: req.collection, data: req.body, depth: Number(req.query.depth), - draft: req.query.draft === 'true', + draft, + autosave, }); return res.status(httpStatus.CREATED).json({ diff --git a/src/versions/drafts/saveCollectionDraft.ts b/src/versions/drafts/saveCollectionDraft.ts deleted file mode 100644 index bab2678f20..0000000000 --- a/src/versions/drafts/saveCollectionDraft.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { Payload } from '../..'; -import { SanitizedCollectionConfig } from '../../collections/config/types'; -import { enforceMaxVersions } from '../enforceMaxVersions'; -import { PayloadRequest } from '../../express/types'; - -type Args = { - payload: Payload - config?: SanitizedCollectionConfig - req: PayloadRequest - data: any - id: string | number - autosave: boolean -} - -export const saveCollectionDraft = async ({ - payload, - config, - id, - data, - autosave, -}: Args): Promise> => { - const VersionsModel = payload.versions[config.slug]; - - const dataAsDraft = { ...data, _status: 'draft' }; - - let existingAutosaveVersion; - - if (autosave) { - existingAutosaveVersion = await VersionsModel.findOne({ - parent: id, - }, {}, { sort: { updatedAt: 'desc' } }); - } - - let result; - - try { - // If there is an existing autosave document, - // Update it - if (autosave && existingAutosaveVersion?.autosave === true) { - result = await VersionsModel.findByIdAndUpdate( - { - _id: existingAutosaveVersion._id, - }, - { - version: dataAsDraft, - }, - { new: true, lean: true }, - ); - // Otherwise, create a new one - } else { - result = await VersionsModel.create({ - parent: id, - version: dataAsDraft, - autosave: Boolean(autosave), - }); - } - } catch (err) { - payload.logger.error(`There was an error while creating a draft ${config.labels.singular} with ID ${id}.`); - payload.logger.error(err); - } - - if (config.versions.maxPerDoc) { - enforceMaxVersions({ - id, - payload, - Model: VersionsModel, - slug: config.slug, - entityType: 'collection', - max: config.versions.maxPerDoc, - }); - } - - result = result.version; - result = JSON.stringify(result); - result = JSON.parse(result); - result.id = id; - - return result; -}; diff --git a/src/versions/saveCollectionVersion.ts b/src/versions/saveCollectionVersion.ts index 5ac722896b..7b2bca8f09 100644 --- a/src/versions/saveCollectionVersion.ts +++ b/src/versions/saveCollectionVersion.ts @@ -3,7 +3,6 @@ import { SanitizedCollectionConfig } from '../collections/config/types'; import { enforceMaxVersions } from './enforceMaxVersions'; import { PayloadRequest } from '../express/types'; import sanitizeInternalFields from '../utilities/sanitizeInternalFields'; -import { afterRead } from '../fields/hooks/afterRead'; type Args = { payload: Payload @@ -11,71 +10,49 @@ type Args = { req: PayloadRequest docWithLocales: any id: string | number + autosave?: boolean } export const saveCollectionVersion = async ({ payload, config, - req, id, docWithLocales, -}: Args): Promise => { + autosave, +}: Args): Promise> => { const VersionModel = payload.versions[config.slug]; - let version = docWithLocales; + let result = { ...docWithLocales }; - if (config.versions?.drafts) { - const latestVersion = await VersionModel.findOne({ - parent: { - $eq: docWithLocales.id, - }, - updatedAt: { - $gt: docWithLocales.updatedAt, - }, - }, - {}, - { - lean: true, - leanWithId: true, - sort: { - updatedAt: 'desc', - }, - }); + if (result._id) delete result._id; - if (latestVersion) { - // If the latest version is a draft, no need to re-save it - // Example: when "promoting" a draft to published, the draft already exists. - // Instead, return null - if (latestVersion?.version?._status === 'draft') { - return null; - } + let existingAutosaveVersion; - version = latestVersion.version; - version = JSON.parse(JSON.stringify(version)); - version = sanitizeInternalFields(version); - } + if (autosave) { + existingAutosaveVersion = await VersionModel.findOne({ + parent: id, + }, {}, { sort: { updatedAt: 'desc' } }); } - version = await afterRead({ - depth: 0, - doc: version, - entityConfig: config, - req, - overrideAccess: true, - showHiddenFields: true, - flattenLocales: false, - }); - - if (version._id) delete version._id; - - let createdVersion; - try { - createdVersion = await VersionModel.create({ - parent: id, - version, - autosave: false, - }); + if (autosave && existingAutosaveVersion?.autosave === true) { + result = await VersionModel.findByIdAndUpdate( + { + _id: existingAutosaveVersion._id, + }, + { + version: result, + }, + { new: true, lean: true }, + ); + // Otherwise, create a new one + } else { + result = await VersionModel.create({ + parent: id, + version: docWithLocales, + autosave: Boolean(autosave), + }); + } } catch (err) { payload.logger.error(`There was an error while saving a version for the ${config.labels.singular} with ID ${id}.`); payload.logger.error(err); @@ -92,10 +69,10 @@ export const saveCollectionVersion = async ({ }); } - if (createdVersion) { - createdVersion = JSON.parse(JSON.stringify(createdVersion)); - createdVersion = sanitizeInternalFields(createdVersion); - } + result = result.version; + result = JSON.parse(JSON.stringify(result)); + result = sanitizeInternalFields(result); + result.id = id; - return createdVersion; + return result; }; diff --git a/test/versions/collections/Versions.ts b/test/versions/collections/Versions.ts new file mode 100644 index 0000000000..1d38c7ca29 --- /dev/null +++ b/test/versions/collections/Versions.ts @@ -0,0 +1,56 @@ +import type { CollectionConfig } from '../../../src/collections/config/types'; + +const VersionPosts: CollectionConfig = { + slug: 'version-posts', + admin: { + useAsTitle: 'title', + defaultColumns: ['title', 'description', 'createdAt'], + preview: () => 'https://payloadcms.com', + }, + versions: { + drafts: false, + maxPerDoc: 35, + retainDeleted: false, + }, + access: { + read: ({ req: { user } }) => { + if (user) { + return true; + } + + return { + or: [ + { + _status: { + equals: 'published', + }, + }, + { + _status: { + exists: false, + }, + }, + ], + }; + }, + readVersions: ({ req: { user } }) => Boolean(user), + }, + fields: [ + { + name: 'title', + label: 'Title', + type: 'text', + required: true, + unique: true, + localized: true, + }, + { + name: 'description', + label: 'Description', + type: 'textarea', + required: true, + }, + ], +}; + +export default VersionPosts; diff --git a/test/versions/config.ts b/test/versions/config.ts index 7711c9e2b5..9e0b4383d3 100644 --- a/test/versions/config.ts +++ b/test/versions/config.ts @@ -4,11 +4,13 @@ import DraftPosts from './collections/Drafts'; import AutosaveGlobal from './globals/Autosave'; import { devUser } from '../credentials'; import DraftGlobal from './globals/Draft'; +import VersionPosts from './collections/Versions'; export default buildConfig({ collections: [ AutosavePosts, DraftPosts, + VersionPosts, ], globals: [ AutosaveGlobal, From 0a4766a61e22362f361ddded826575d761675940 Mon Sep 17 00:00:00 2001 From: James Date: Mon, 16 Jan 2023 19:04:09 -0500 Subject: [PATCH 17/46] chore: passing tests --- .../components/elements/Autosave/index.tsx | 10 +-- src/collections/operations/update.ts | 1 + .../drafts/replaceWithDraftIfAvailable.ts | 1 - .../ensurePublishedCollectionVersion.ts | 80 ------------------- src/versions/saveCollectionVersion.ts | 6 +- test/versions/int.spec.ts | 14 ++-- 6 files changed, 19 insertions(+), 93 deletions(-) delete mode 100644 src/versions/ensurePublishedCollectionVersion.ts diff --git a/src/admin/components/elements/Autosave/index.tsx b/src/admin/components/elements/Autosave/index.tsx index d444277c4a..71706806e4 100644 --- a/src/admin/components/elements/Autosave/index.tsx +++ b/src/admin/components/elements/Autosave/index.tsx @@ -95,13 +95,13 @@ const Autosave: React.FC = ({ collection, global, id, publishedDocUpdated } if (url) { - const body = { - ...reduceFieldsToValues(fieldRef.current, true), - _status: 'draft', - }; - setTimeout(async () => { if (modifiedRef.current) { + const body = { + ...reduceFieldsToValues(fieldRef.current, true), + _status: 'draft', + }; + const res = await fetch(url, { method, credentials: 'include', diff --git a/src/collections/operations/update.ts b/src/collections/operations/update.ts index 954b19862e..786e7fe91e 100644 --- a/src/collections/operations/update.ts +++ b/src/collections/operations/update.ts @@ -251,6 +251,7 @@ async function update(incomingArgs: Arguments): Promise { docWithLocales: result, id, autosave, + draft: shouldSaveDraft, }); } diff --git a/src/versions/drafts/replaceWithDraftIfAvailable.ts b/src/versions/drafts/replaceWithDraftIfAvailable.ts index d8decffa7d..374edb5e19 100644 --- a/src/versions/drafts/replaceWithDraftIfAvailable.ts +++ b/src/versions/drafts/replaceWithDraftIfAvailable.ts @@ -3,7 +3,6 @@ import { docHasTimestamps, Where } from '../../types'; import { hasWhereAccessResult } from '../../auth'; import { AccessResult } from '../../config/types'; import { CollectionModel, SanitizedCollectionConfig, TypeWithID } from '../../collections/config/types'; -import flattenWhereConstraints from '../../utilities/flattenWhereConstraints'; import sanitizeInternalFields from '../../utilities/sanitizeInternalFields'; import { appendVersionToQueryKey } from './appendVersionToQueryKey'; import { SanitizedGlobalConfig } from '../../globals/config/types'; diff --git a/src/versions/ensurePublishedCollectionVersion.ts b/src/versions/ensurePublishedCollectionVersion.ts deleted file mode 100644 index d440871a6a..0000000000 --- a/src/versions/ensurePublishedCollectionVersion.ts +++ /dev/null @@ -1,80 +0,0 @@ -import { Payload } from '..'; -import { SanitizedCollectionConfig } from '../collections/config/types'; -import { enforceMaxVersions } from './enforceMaxVersions'; -import { PayloadRequest } from '../express/types'; -import { afterRead } from '../fields/hooks/afterRead'; - -type Args = { - payload: Payload - config?: SanitizedCollectionConfig - req: PayloadRequest - docWithLocales: any - id: string | number -} - -export const ensurePublishedCollectionVersion = async ({ - payload, - config, - req, - id, - docWithLocales, -}: Args): Promise => { - // If there are no newer drafts, - // And the current doc is published, - // We need to keep a version of the published document - - if (docWithLocales?._status === 'published') { - const VersionModel = payload.versions[config.slug]; - - const moreRecentDrafts = await VersionModel.find({ - parent: { - $eq: docWithLocales.id, - }, - updatedAt: { - $gt: docWithLocales.updatedAt, - }, - }, - {}, - { - lean: true, - leanWithId: true, - sort: { - updatedAt: 'desc', - }, - }); - - if (moreRecentDrafts?.length === 0) { - const version = await afterRead({ - depth: 0, - doc: docWithLocales, - entityConfig: config, - req, - overrideAccess: true, - showHiddenFields: true, - flattenLocales: false, - }); - - try { - await VersionModel.create({ - parent: id, - version, - autosave: false, - }); - } catch (err) { - payload.logger.error(`There was an error while saving a version for the ${config.slug} with ID ${id}.`); - payload.logger.error(err); - } - - if (config.versions.maxPerDoc) { - enforceMaxVersions({ - id, - payload, - Model: VersionModel, - slug: config.slug, - entityType: 'collection', - max: config.versions.maxPerDoc, - }); - } - } - } -}; diff --git a/src/versions/saveCollectionVersion.ts b/src/versions/saveCollectionVersion.ts index 7b2bca8f09..846377162d 100644 --- a/src/versions/saveCollectionVersion.ts +++ b/src/versions/saveCollectionVersion.ts @@ -11,6 +11,7 @@ type Args = { docWithLocales: any id: string | number autosave?: boolean + draft?: boolean } export const saveCollectionVersion = async ({ @@ -19,11 +20,14 @@ export const saveCollectionVersion = async ({ id, docWithLocales, autosave, + draft, }: Args): Promise> => { const VersionModel = payload.versions[config.slug]; let result = { ...docWithLocales }; + if (draft) result._status = 'draft'; + if (result._id) delete result._id; let existingAutosaveVersion; @@ -49,7 +53,7 @@ export const saveCollectionVersion = async ({ } else { result = await VersionModel.create({ parent: id, - version: docWithLocales, + version: result, autosave: Boolean(autosave), }); } diff --git a/test/versions/int.spec.ts b/test/versions/int.spec.ts index b54bad5f9f..f3a3658dff 100644 --- a/test/versions/int.spec.ts +++ b/test/versions/int.spec.ts @@ -159,7 +159,7 @@ describe('Versions', () => { locale: 'all', }); - expect(versions.docs[0].version.title.en).toStrictEqual(englishTitle); + expect(versions.docs[0].version.title.en).toStrictEqual(newEnglishTitle); expect(versions.docs[0].version.title.es).toStrictEqual(spanishTitle); }); }); @@ -184,7 +184,7 @@ describe('Versions', () => { const restore = await payload.restoreVersion({ collection, - id: versions.docs[0].id, + id: versions.docs[1].id, }); expect(restore.title).toBeDefined(); @@ -195,7 +195,7 @@ describe('Versions', () => { draft: true, }); - expect(restoredPost.title).toBe(restore.title); + expect(restoredPost.title).toBe(versions.docs[1].version.title); }); }); @@ -226,13 +226,15 @@ describe('Versions', () => { draft: true, }); + const spanishTitle = 'es title'; + // second update to existing draft await payload.update({ id: collectionLocalPostID, collection, locale: 'es', data: { - title: updatedTitle, + title: spanishTitle, }, draft: true, }); @@ -251,7 +253,7 @@ describe('Versions', () => { expect(publishedPost.title).toBe(originalTitle); expect(draftPost.title.en).toBe(updatedTitle); - expect(draftPost.title.es).toBe(updatedTitle); + expect(draftPost.title.es).toBe(spanishTitle); }); }); }); @@ -423,7 +425,7 @@ describe('Versions', () => { expect(data.id).toBeDefined(); expect(data.parent.id).toStrictEqual(collectionGraphQLPostID); - expect(data.version.title).toStrictEqual(collectionGraphQLOriginalTitle); + expect(data.version.title).toStrictEqual(updatedTitle); }); it('should allow read of versions by querying version content', async () => { From fc7709da51e5d9c382930d9d7640e6685712810b Mon Sep 17 00:00:00 2001 From: James Date: Mon, 16 Jan 2023 20:43:37 -0500 Subject: [PATCH 18/46] chore: flattens saving versions into a single file --- src/collections/operations/create.ts | 6 +- src/collections/operations/update.ts | 8 +-- src/versions/saveVersion.ts | 97 ++++++++++++++++++++++++++++ 3 files changed, 104 insertions(+), 7 deletions(-) create mode 100644 src/versions/saveVersion.ts diff --git a/src/collections/operations/create.ts b/src/collections/operations/create.ts index 35a436cce8..8fea30e3c6 100644 --- a/src/collections/operations/create.ts +++ b/src/collections/operations/create.ts @@ -16,7 +16,7 @@ import { beforeValidate } from '../../fields/hooks/beforeValidate'; import { afterChange } from '../../fields/hooks/afterChange'; import { afterRead } from '../../fields/hooks/afterRead'; import { generateFileData } from '../../uploads/generateFileData'; -import { saveCollectionVersion } from '../../versions/saveCollectionVersion'; +import { saveVersion } from '../../versions/saveVersion'; export type Arguments = { collection: Collection @@ -221,9 +221,9 @@ async function create(incomingArgs: Arguments): Promise { // ///////////////////////////////////// if (collectionConfig.versions) { - await saveCollectionVersion({ + await saveVersion({ payload, - config: collectionConfig, + collection: collectionConfig, req, id: result.id, docWithLocales: result, diff --git a/src/collections/operations/update.ts b/src/collections/operations/update.ts index 786e7fe91e..a6ad382ae4 100644 --- a/src/collections/operations/update.ts +++ b/src/collections/operations/update.ts @@ -6,7 +6,7 @@ import executeAccess from '../../auth/executeAccess'; import { NotFound, Forbidden, APIError, ValidationError } from '../../errors'; import { PayloadRequest } from '../../express/types'; import { hasWhereAccessResult } from '../../auth/types'; -import { saveCollectionVersion } from '../../versions/saveCollectionVersion'; +import { saveVersion } from '../../versions/saveVersion'; import { uploadFiles } from '../../uploads/uploadFiles'; import { beforeChange } from '../../fields/hooks/beforeChange'; import { beforeValidate } from '../../fields/hooks/beforeValidate'; @@ -241,12 +241,13 @@ async function update(incomingArgs: Arguments): Promise { // custom id type reset result.id = result._id; + result = sanitizeInternalFields(result); } if (collectionConfig.versions) { - result = await saveCollectionVersion({ + result = await saveVersion({ payload, - config: collectionConfig, + collection: collectionConfig, req, docWithLocales: result, id, @@ -255,7 +256,6 @@ async function update(incomingArgs: Arguments): Promise { }); } - result = sanitizeInternalFields(result); // ///////////////////////////////////// // afterRead - Fields diff --git a/src/versions/saveVersion.ts b/src/versions/saveVersion.ts new file mode 100644 index 0000000000..a8ca6a0dc7 --- /dev/null +++ b/src/versions/saveVersion.ts @@ -0,0 +1,97 @@ +import { FilterQuery } from 'mongoose'; +import { Payload } from '..'; +import { SanitizedCollectionConfig } from '../collections/config/types'; +import { enforceMaxVersions } from './enforceMaxVersions'; +import { PayloadRequest } from '../express/types'; +import sanitizeInternalFields from '../utilities/sanitizeInternalFields'; +import { SanitizedGlobalConfig } from '../globals/config/types'; + +type Args = { + payload: Payload + global?: SanitizedGlobalConfig + collection?: SanitizedCollectionConfig + req: PayloadRequest + docWithLocales: any + id?: string | number + autosave?: boolean + draft?: boolean +} + +export const saveVersion = async ({ + payload, + collection, + global, + id, + docWithLocales, + autosave, + draft, +}: Args): Promise> => { + let entityConfig; + if (collection) entityConfig = collection; + if (global) entityConfig = global; + + const VersionModel = payload.versions[entityConfig.slug]; + + const versionData = { ...docWithLocales }; + if (draft) versionData._status = 'draft'; + if (versionData._id) delete versionData._id; + + let existingAutosaveVersion; + + if (autosave) { + const query: FilterQuery = {}; + if (collection) query.parent = id; + existingAutosaveVersion = await VersionModel.findOne(query, {}, { sort: { updatedAt: 'desc' } }); + } + + let result; + + try { + if (autosave && existingAutosaveVersion?.autosave === true) { + result = await VersionModel.findByIdAndUpdate( + { + _id: existingAutosaveVersion._id, + }, + { + version: versionData, + }, + { new: true, lean: true }, + ); + // Otherwise, create a new one + } else { + const data: Record = { + version: versionData, + autosave: Boolean(autosave), + }; + + if (collection) data.parent = id; + + result = await VersionModel.create(data); + } + } catch (err) { + let errorMessage: string; + + if (collection) errorMessage = `There was an error while saving a version for the ${collection.labels.singular} with ID ${id}.`; + if (global) errorMessage = `There was an error while saving a version for the global ${global.label}.`; + payload.logger.error(errorMessage); + payload.logger.error(err); + } + + if (collection && collection.versions.maxPerDoc) { + enforceMaxVersions({ + id, + payload, + Model: VersionModel, + slug: entityConfig.slug, + entityType: 'collection', + max: collection.versions.maxPerDoc, + }); + } + + result = result.version; + result = JSON.parse(JSON.stringify(result)); + result = sanitizeInternalFields(result); + result.id = id; + + return result; +}; From 8cfa5509540225100237e6f569eb9eb1a7d5448e Mon Sep 17 00:00:00 2001 From: James Date: Mon, 16 Jan 2023 21:02:32 -0500 Subject: [PATCH 19/46] feat: simplifies versions logic --- src/collections/operations/update.ts | 18 ++--- src/globals/operations/update.ts | 79 ++++++++-------------- src/versions/drafts/saveGlobalDraft.ts | 70 ------------------- src/versions/saveCollectionVersion.ts | 82 ---------------------- src/versions/saveGlobalVersion.ts | 94 -------------------------- src/versions/saveVersion.ts | 38 ++++++----- 6 files changed, 57 insertions(+), 324 deletions(-) delete mode 100644 src/versions/drafts/saveGlobalDraft.ts delete mode 100644 src/versions/saveCollectionVersion.ts delete mode 100644 src/versions/saveGlobalVersion.ts diff --git a/src/collections/operations/update.ts b/src/collections/operations/update.ts index a6ad382ae4..891e49219e 100644 --- a/src/collections/operations/update.ts +++ b/src/collections/operations/update.ts @@ -235,17 +235,18 @@ async function update(incomingArgs: Arguments): Promise { ? new ValidationError([{ message: 'Value must be unique', field: Object.keys(error.keyValue)[0] }], t) : error; } - - const resultString = JSON.stringify(result); - result = JSON.parse(resultString); - - // custom id type reset - result.id = result._id; - result = sanitizeInternalFields(result); } + result = JSON.parse(JSON.stringify(result)); + result.id = result._id; + result = sanitizeInternalFields(result); + + // ///////////////////////////////////// + // Create version + // ///////////////////////////////////// + if (collectionConfig.versions) { - result = await saveVersion({ + await saveVersion({ payload, collection: collectionConfig, req, @@ -256,7 +257,6 @@ async function update(incomingArgs: Arguments): Promise { }); } - // ///////////////////////////////////// // afterRead - Fields // ///////////////////////////////////// diff --git a/src/globals/operations/update.ts b/src/globals/operations/update.ts index 7847effac7..11cdb3fc8c 100644 --- a/src/globals/operations/update.ts +++ b/src/globals/operations/update.ts @@ -1,17 +1,14 @@ import { docHasTimestamps, Where } from '../../types'; import { SanitizedGlobalConfig, TypeWithID } from '../config/types'; import executeAccess from '../../auth/executeAccess'; -import sanitizeInternalFields from '../../utilities/sanitizeInternalFields'; -import { saveGlobalVersion } from '../../versions/saveGlobalVersion'; -import { saveGlobalDraft } from '../../versions/drafts/saveGlobalDraft'; -import { ensurePublishedGlobalVersion } from '../../versions/ensurePublishedGlobalVersion'; -import cleanUpFailedVersion from '../../versions/cleanUpFailedVersion'; import { hasWhereAccessResult } from '../../auth'; import { beforeChange } from '../../fields/hooks/beforeChange'; import { beforeValidate } from '../../fields/hooks/beforeValidate'; import { afterChange } from '../../fields/hooks/afterChange'; import { afterRead } from '../../fields/hooks/afterRead'; import { PayloadRequest } from '../../express/types'; +import { saveVersion } from '../../versions/saveVersion'; +import sanitizeInternalFields from '../../utilities/sanitizeInternalFields'; type Args = { globalConfig: SanitizedGlobalConfig @@ -182,57 +179,20 @@ async function update(args: Args): Promise { skipValidation: shouldSaveDraft, }); - // ///////////////////////////////////// - // Create version from existing doc - // ///////////////////////////////////// - - let createdVersion; - - if (globalConfig.versions && !shouldSaveDraft) { - createdVersion = await saveGlobalVersion({ - payload, - config: globalConfig, - req, - docWithLocales: result, - }); - } - // ///////////////////////////////////// // Update // ///////////////////////////////////// - if (shouldSaveDraft) { - await ensurePublishedGlobalVersion({ - payload, - config: globalConfig, - req, - docWithLocales: result, - }); - - global = await saveGlobalDraft({ - payload, - config: globalConfig, - data: result, - autosave, - }); - } else { - try { - if (existingGlobal) { - global = await Model.findOneAndUpdate( - { globalType: slug }, - result, - { new: true }, - ); - } else { - result.globalType = slug; - global = await Model.create(result); - } - } catch (error) { - cleanUpFailedVersion({ - payload, - entityConfig: globalConfig, - version: createdVersion, - }); + if (!shouldSaveDraft) { + if (existingGlobal) { + global = await Model.findOneAndUpdate( + { globalType: slug }, + result, + { new: true }, + ); + } else { + result.globalType = slug; + global = await Model.create(result); } } @@ -240,6 +200,21 @@ async function update(args: Args): Promise { global = JSON.parse(global); global = sanitizeInternalFields(global); + // ///////////////////////////////////// + // Create version + // ///////////////////////////////////// + + if (globalConfig.versions) { + await saveVersion({ + payload, + global: globalConfig, + req, + docWithLocales: result, + autosave, + draft: shouldSaveDraft, + }); + } + // ///////////////////////////////////// // afterRead - Fields // ///////////////////////////////////// diff --git a/src/versions/drafts/saveGlobalDraft.ts b/src/versions/drafts/saveGlobalDraft.ts deleted file mode 100644 index de38a9aadc..0000000000 --- a/src/versions/drafts/saveGlobalDraft.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { Payload } from '../..'; -import { enforceMaxVersions } from '../enforceMaxVersions'; -import { SanitizedGlobalConfig } from '../../globals/config/types'; - -type Args = { - payload: Payload - config?: SanitizedGlobalConfig - data: any - autosave: boolean -} - -export const saveGlobalDraft = async ({ - payload, - config, - data, - autosave, -}: Args): Promise => { - const VersionsModel = payload.versions[config.slug]; - - const dataAsDraft = { ...data, _status: 'draft' }; - - let existingAutosaveVersion; - - if (autosave) { - existingAutosaveVersion = await VersionsModel.findOne(); - } - - let result; - - try { - // If there is an existing autosave document, - // Update it - if (autosave && existingAutosaveVersion?.autosave === true) { - result = await VersionsModel.findByIdAndUpdate( - { - _id: existingAutosaveVersion._id, - }, - { - version: dataAsDraft, - }, - { new: true, lean: true }, - ); - // Otherwise, create a new one - } else { - result = await VersionsModel.create({ - version: dataAsDraft, - autosave: Boolean(autosave), - }); - } - } catch (err) { - payload.logger.error(`There was an error while saving a draft for the Global ${config.slug}.`); - payload.logger.error(err); - } - - if (config.versions.max) { - enforceMaxVersions({ - payload: this, - Model: VersionsModel, - slug: config.slug, - entityType: 'global', - max: config.versions.max, - }); - } - - result = result.version; - result = JSON.stringify(result); - result = JSON.parse(result); - - return result; -}; diff --git a/src/versions/saveCollectionVersion.ts b/src/versions/saveCollectionVersion.ts deleted file mode 100644 index 846377162d..0000000000 --- a/src/versions/saveCollectionVersion.ts +++ /dev/null @@ -1,82 +0,0 @@ -import { Payload } from '..'; -import { SanitizedCollectionConfig } from '../collections/config/types'; -import { enforceMaxVersions } from './enforceMaxVersions'; -import { PayloadRequest } from '../express/types'; -import sanitizeInternalFields from '../utilities/sanitizeInternalFields'; - -type Args = { - payload: Payload - config?: SanitizedCollectionConfig - req: PayloadRequest - docWithLocales: any - id: string | number - autosave?: boolean - draft?: boolean -} - -export const saveCollectionVersion = async ({ - payload, - config, - id, - docWithLocales, - autosave, - draft, -}: Args): Promise> => { - const VersionModel = payload.versions[config.slug]; - - let result = { ...docWithLocales }; - - if (draft) result._status = 'draft'; - - if (result._id) delete result._id; - - let existingAutosaveVersion; - - if (autosave) { - existingAutosaveVersion = await VersionModel.findOne({ - parent: id, - }, {}, { sort: { updatedAt: 'desc' } }); - } - - try { - if (autosave && existingAutosaveVersion?.autosave === true) { - result = await VersionModel.findByIdAndUpdate( - { - _id: existingAutosaveVersion._id, - }, - { - version: result, - }, - { new: true, lean: true }, - ); - // Otherwise, create a new one - } else { - result = await VersionModel.create({ - parent: id, - version: result, - autosave: Boolean(autosave), - }); - } - } catch (err) { - payload.logger.error(`There was an error while saving a version for the ${config.labels.singular} with ID ${id}.`); - payload.logger.error(err); - } - - if (config.versions.maxPerDoc) { - enforceMaxVersions({ - id, - payload, - Model: VersionModel, - slug: config.slug, - entityType: 'collection', - max: config.versions.maxPerDoc, - }); - } - - result = result.version; - result = JSON.parse(JSON.stringify(result)); - result = sanitizeInternalFields(result); - result.id = id; - - return result; -}; diff --git a/src/versions/saveGlobalVersion.ts b/src/versions/saveGlobalVersion.ts deleted file mode 100644 index 176a9a2bce..0000000000 --- a/src/versions/saveGlobalVersion.ts +++ /dev/null @@ -1,94 +0,0 @@ -import { Payload } from '..'; -import { enforceMaxVersions } from './enforceMaxVersions'; -import { PayloadRequest } from '../express/types'; -import { SanitizedGlobalConfig } from '../globals/config/types'; -import sanitizeInternalFields from '../utilities/sanitizeInternalFields'; -import { afterRead } from '../fields/hooks/afterRead'; - -type Args = { - payload: Payload - config?: SanitizedGlobalConfig - req: PayloadRequest - docWithLocales: any -} - -export const saveGlobalVersion = async ({ - payload, - config, - req, - docWithLocales, -}: Args): Promise => { - const VersionModel = payload.versions[config.slug]; - - let version = docWithLocales; - - if (config.versions?.drafts) { - const latestVersion = await VersionModel.findOne({ - updatedAt: { - $gt: docWithLocales.updatedAt, - }, - }, - {}, - { - lean: true, - leanWithId: true, - sort: { - updatedAt: 'desc', - }, - }); - - if (latestVersion) { - // If the latest version is a draft, no need to re-save it - // Example: when "promoting" a draft to published, the draft already exists. - // Instead, return null - if (latestVersion?.version?._status === 'draft') { - return null; - } - - version = latestVersion.version; - version = JSON.parse(JSON.stringify(version)); - version = sanitizeInternalFields(version); - } - } - - version = await afterRead({ - depth: 0, - doc: version, - entityConfig: config, - flattenLocales: false, - overrideAccess: true, - req, - showHiddenFields: true, - }); - - if (version._id) delete version._id; - - let createdVersion; - - try { - createdVersion = await VersionModel.create({ - version, - autosave: false, - }); - } catch (err) { - payload.logger.error(`There was an error while saving a version for the Global ${config.slug}.`); - payload.logger.error(err); - } - - if (config.versions.max) { - enforceMaxVersions({ - payload: this, - Model: VersionModel, - slug: config.slug, - entityType: 'global', - max: config.versions.max, - }); - } - - if (createdVersion) { - createdVersion = JSON.parse(JSON.stringify(createdVersion)); - createdVersion = sanitizeInternalFields(createdVersion); - } - - return createdVersion; -}; diff --git a/src/versions/saveVersion.ts b/src/versions/saveVersion.ts index a8ca6a0dc7..7a706a5608 100644 --- a/src/versions/saveVersion.ts +++ b/src/versions/saveVersion.ts @@ -3,7 +3,6 @@ import { Payload } from '..'; import { SanitizedCollectionConfig } from '../collections/config/types'; import { enforceMaxVersions } from './enforceMaxVersions'; import { PayloadRequest } from '../express/types'; -import sanitizeInternalFields from '../utilities/sanitizeInternalFields'; import { SanitizedGlobalConfig } from '../globals/config/types'; type Args = { @@ -25,10 +24,19 @@ export const saveVersion = async ({ docWithLocales, autosave, draft, -}: Args): Promise> => { +}: Args): Promise => { let entityConfig; - if (collection) entityConfig = collection; - if (global) entityConfig = global; + let entityType: 'global' | 'collection'; + + if (collection) { + entityConfig = collection; + entityType = 'collection'; + } + + if (global) { + entityConfig = global; + entityType = 'global'; + } const VersionModel = payload.versions[entityConfig.slug]; @@ -44,11 +52,9 @@ export const saveVersion = async ({ existingAutosaveVersion = await VersionModel.findOne(query, {}, { sort: { updatedAt: 'desc' } }); } - let result; - try { if (autosave && existingAutosaveVersion?.autosave === true) { - result = await VersionModel.findByIdAndUpdate( + await VersionModel.findByIdAndUpdate( { _id: existingAutosaveVersion._id, }, @@ -66,7 +72,7 @@ export const saveVersion = async ({ if (collection) data.parent = id; - result = await VersionModel.create(data); + await VersionModel.create(data); } } catch (err) { let errorMessage: string; @@ -77,21 +83,19 @@ export const saveVersion = async ({ payload.logger.error(err); } + let max: number; + + if (collection && typeof collection.versions.maxPerDoc === 'number') max = collection.versions.maxPerDoc; + if (global && typeof global.versions.max === 'number') max = global.versions.max; + if (collection && collection.versions.maxPerDoc) { enforceMaxVersions({ id, payload, Model: VersionModel, slug: entityConfig.slug, - entityType: 'collection', - max: collection.versions.maxPerDoc, + entityType, + max, }); } - - result = result.version; - result = JSON.parse(JSON.stringify(result)); - result = sanitizeInternalFields(result); - result.id = id; - - return result; }; From dff840c49bdda46ccbb2029893de7ac27f7602c2 Mon Sep 17 00:00:00 2001 From: James Date: Mon, 16 Jan 2023 21:05:40 -0500 Subject: [PATCH 20/46] chore: adds version count tests --- test/versions/int.spec.ts | 55 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/test/versions/int.spec.ts b/test/versions/int.spec.ts index f3a3658dff..e45107d448 100644 --- a/test/versions/int.spec.ts +++ b/test/versions/int.spec.ts @@ -256,6 +256,61 @@ describe('Versions', () => { expect(draftPost.title.es).toBe(spanishTitle); }); }); + + describe('Draft Count', () => { + it('creates proper number of drafts', async () => { + const originalDraft = await payload.create({ + collection: 'draft-posts', + draft: true, + data: { + title: 'A', + description: 'A', + _status: 'draft', + }, + }); + + await payload.update({ + collection: 'draft-posts', + id: originalDraft.id, + draft: true, + data: { + title: 'B', + description: 'B', + _status: 'draft', + }, + }); + + await payload.update({ + collection: 'draft-posts', + id: originalDraft.id, + draft: true, + data: { + title: 'C', + description: 'C', + _status: 'draft', + }, + }); + + const mostRecentDraft = await payload.findByID({ + collection: 'draft-posts', + id: originalDraft.id, + draft: true, + }); + + expect(mostRecentDraft.title).toStrictEqual('C'); + + const versions = await payload.findVersions({ + collection: 'draft-posts', + where: { + parent: { + equals: originalDraft.id, + }, + }, + }); + + expect(versions.docs).toHaveLength(3); + }); + }); }); describe('Querying', () => { From 34582da561945cacc53d0c0664b54e63ebc8da25 Mon Sep 17 00:00:00 2001 From: James Date: Mon, 16 Jan 2023 21:40:34 -0500 Subject: [PATCH 21/46] chore: leverages versions refactor to simplify draft query logic --- package.json | 1 + src/collections/init.ts | 5 + src/collections/operations/create.ts | 1 + src/collections/operations/find.ts | 5 +- src/collections/operations/update.ts | 1 + src/globals/operations/update.ts | 1 + src/versions/drafts/mergeDrafts.ts | 229 --------------------------- src/versions/drafts/queryDrafts.ts | 86 ++++++++++ src/versions/saveVersion.ts | 13 +- yarn.lock | 5 + 10 files changed, 112 insertions(+), 235 deletions(-) delete mode 100644 src/versions/drafts/mergeDrafts.ts create mode 100644 src/versions/drafts/queryDrafts.ts diff --git a/package.json b/package.json index c046be66d6..50e204242b 100644 --- a/package.json +++ b/package.json @@ -134,6 +134,7 @@ "minimist": "^1.2.0", "mkdirp": "^1.0.4", "mongoose": "6.5.0", + "mongoose-aggregate-paginate-v2": "^1.0.6", "mongoose-paginate-v2": "^1.6.1", "nodemailer": "^6.4.2", "object-to-formdata": "^4.1.0", diff --git a/src/collections/init.ts b/src/collections/init.ts index 00626d1252..fdd83d5ef3 100644 --- a/src/collections/init.ts +++ b/src/collections/init.ts @@ -3,6 +3,7 @@ import paginate from 'mongoose-paginate-v2'; import express from 'express'; import passport from 'passport'; import passportLocalMongoose from 'passport-local-mongoose'; +import mongooseAggregatePaginate from 'mongoose-aggregate-paginate-v2'; import { buildVersionCollectionFields } from '../versions/buildCollectionFields'; import buildQueryPlugin from '../mongoose/buildQuery'; import apiKeyStrategy from '../auth/strategies/apiKey'; @@ -82,6 +83,10 @@ export default function registerCollections(ctx: Payload): void { versionSchema.plugin(paginate, { useEstimatedCount: true }) .plugin(buildQueryPlugin); + if (collection.versions?.drafts) { + versionSchema.plugin(mongooseAggregatePaginate); + } + ctx.versions[collection.slug] = mongoose.model(versionModelName, versionSchema) as CollectionModel; } diff --git a/src/collections/operations/create.ts b/src/collections/operations/create.ts index 8fea30e3c6..5818f6a95a 100644 --- a/src/collections/operations/create.ts +++ b/src/collections/operations/create.ts @@ -228,6 +228,7 @@ async function create(incomingArgs: Arguments): Promise { id: result.id, docWithLocales: result, autosave, + createdAt: result.createdAt, }); } diff --git a/src/collections/operations/find.ts b/src/collections/operations/find.ts index 46e5677bff..9f195d5539 100644 --- a/src/collections/operations/find.ts +++ b/src/collections/operations/find.ts @@ -9,7 +9,7 @@ import flattenWhereConstraints from '../../utilities/flattenWhereConstraints'; import { buildSortParam } from '../../mongoose/buildSortParam'; import { AccessResult } from '../../config/types'; import { afterRead } from '../../fields/hooks/afterRead'; -import { mergeDrafts } from '../../versions/drafts/mergeDrafts'; +import { queryDrafts } from '../../versions/drafts/queryDrafts'; export type Arguments = { collection: Collection @@ -160,13 +160,12 @@ async function find(incomingArgs: Arguments): Promis }; if (collectionConfig.versions?.drafts && draftsEnabled) { - result = await mergeDrafts({ + result = await queryDrafts({ accessResult, collection, locale, paginationOptions, payload, - query, where, }); } else { diff --git a/src/collections/operations/update.ts b/src/collections/operations/update.ts index 891e49219e..496a5f7d61 100644 --- a/src/collections/operations/update.ts +++ b/src/collections/operations/update.ts @@ -254,6 +254,7 @@ async function update(incomingArgs: Arguments): Promise { id, autosave, draft: shouldSaveDraft, + createdAt: result.createdAt as string, }); } diff --git a/src/globals/operations/update.ts b/src/globals/operations/update.ts index 11cdb3fc8c..9ba1f4e7c0 100644 --- a/src/globals/operations/update.ts +++ b/src/globals/operations/update.ts @@ -212,6 +212,7 @@ async function update(args: Args): Promise { docWithLocales: result, autosave, draft: shouldSaveDraft, + createdAt: global.createdAt, }); } diff --git a/src/versions/drafts/mergeDrafts.ts b/src/versions/drafts/mergeDrafts.ts deleted file mode 100644 index 2ec040de5d..0000000000 --- a/src/versions/drafts/mergeDrafts.ts +++ /dev/null @@ -1,229 +0,0 @@ -import { AccessResult } from '../../config/types'; -import { Where } from '../../types'; -import { Payload } from '../..'; -import { PaginatedDocs } from '../../mongoose/types'; -import { Collection, CollectionModel, TypeWithID } from '../../collections/config/types'; -import { hasWhereAccessResult } from '../../auth'; -import { appendVersionToQueryKey } from './appendVersionToQueryKey'; -import replaceWithDraftIfAvailable from './replaceWithDraftIfAvailable'; - -type AggregateVersion = { - _id: string - version: T - updatedAt: string - createdAt: string -} - -type VersionCollectionMatchMap = { - [_id: string | number]: { - updatedAt: string - createdAt: string - version: T - } -} - -type Args = { - accessResult: AccessResult - collection: Collection - locale: string - paginationOptions: any - payload: Payload - query: Record - where: Where -} - -export const mergeDrafts = async ({ - accessResult, - collection, - locale, - payload, - paginationOptions, - query, - where: incomingWhere, -}: Args): Promise> => { - // Query the main collection for any IDs that match the query - // Create object "map" for performant lookup - const mainCollectionMatchMap = await collection.Model.find(query, { updatedAt: 1 }, { limit: paginationOptions.limit, sort: paginationOptions.sort }) - .lean().then((res) => res.reduce((map, { _id, updatedAt }) => { - const newMap = map; - newMap[_id] = updatedAt; - return newMap; - }, {})); - - // Query the versions collection with a version-specific query - const VersionModel = payload.versions[collection.config.slug] as CollectionModel; - - const where = appendVersionToQueryKey(incomingWhere || {}); - - const versionQueryToBuild: { where: Where } = { - where: { - ...where, - and: [ - ...where?.and || [], - { - 'version._status': { - equals: 'draft', - }, - }, - ], - }, - }; - - if (hasWhereAccessResult(accessResult)) { - const versionAccessResult = appendVersionToQueryKey(accessResult); - versionQueryToBuild.where.and.push(versionAccessResult); - } - - const versionQuery = await VersionModel.buildQuery(versionQueryToBuild, locale); - const includedParentIDs: (string | number)[] = []; - - // Create version "map" for performant lookup - // and in the same loop, check if there are matched versions without a matched parent - // This means that the newer version's parent should appear in the main query. - // To do so, add the version's parent ID into an explicit `includedIDs` array - const versionCollectionMatchMap = await VersionModel.aggregate>([ - { - $sort: Object.entries(paginationOptions.sort).reduce((sort, [key, order]) => { - return { - ...sort, - [key]: order === 'asc' ? 1 : -1, - }; - }, {}), - }, - { - $group: { - _id: '$parent', - versionID: { $first: '$_id' }, - version: { $first: '$version' }, - updatedAt: { $first: '$updatedAt' }, - createdAt: { $first: '$createdAt' }, - }, - }, - { - $addFields: { - id: { - $toObjectId: '$_id', - }, - }, - }, - { - $lookup: { - from: collection.config.slug, - localField: 'id', - foreignField: '_id', - as: 'parent', - }, - }, - { - $match: { - parent: { - $size: 1, - }, - }, - }, - { $match: versionQuery }, - { $limit: paginationOptions.limit }, - ]).then((res) => res.reduce>((map, { _id, updatedAt, createdAt, version }) => { - const newMap = map; - newMap[_id] = { version, updatedAt, createdAt }; - - const matchedParent = mainCollectionMatchMap[_id]; - if (!matchedParent) includedParentIDs.push(_id); - return newMap; - }, {})); - - // Now we need to explicitly exclude any parent matches that have newer versions - // which did NOT appear in the versions query - const excludedParentIDs = await Promise.all(Object.entries(mainCollectionMatchMap).map(async ([parentDocID, parentDocUpdatedAt]) => { - // If there is a matched version, and it's newer, this parent should remain - if (versionCollectionMatchMap[parentDocID] && versionCollectionMatchMap[parentDocID].updatedAt > parentDocUpdatedAt) { - return null; - } - - // Otherwise, we need to check if there are newer versions present - // that did not get returned from the versions query - const versionsQuery = await VersionModel.find({ - updatedAt: { - $gt: parentDocUpdatedAt, - }, - parent: { - $eq: parentDocID, - }, - }, {}, { limit: 1 }).lean(); - - // If there are, - // this says that the newest version does not match the incoming query, - // and the parent ID should be excluded - if (versionsQuery.length > 0) { - return parentDocID; - } - - return null; - })).then((res) => res.filter((result) => Boolean(result))); - - // Run a final query against the main collection, - // passing in any ids to exclude and include - // so that they appear properly paginated - const finalQueryToBuild: { where: Where } = { - where: { - and: [], - }, - }; - - finalQueryToBuild.where.and.push({ or: [] }); - - if (hasWhereAccessResult(accessResult)) { - finalQueryToBuild.where.and.push(accessResult); - } - - if (incomingWhere) { - finalQueryToBuild.where.and[0].or.push(incomingWhere); - } - - if (includedParentIDs.length > 0) { - finalQueryToBuild.where.and[0].or.push({ - id: { - in: includedParentIDs, - }, - }); - } - - if (excludedParentIDs.length > 0) { - finalQueryToBuild.where.and.push({ - id: { - not_in: excludedParentIDs, - }, - }); - } - - const finalQuery = await collection.Model.buildQuery(finalQueryToBuild, locale); - - let result = await collection.Model.paginate(finalQuery, paginationOptions); - - result = { - ...result, - docs: await Promise.all(result.docs.map(async (doc) => { - const matchedVersion = versionCollectionMatchMap[doc.id]; - - if (matchedVersion && matchedVersion.updatedAt > doc.updatedAt) { - return { - ...doc, - ...matchedVersion.version, - createdAt: matchedVersion.createdAt, - updatedAt: matchedVersion.updatedAt, - }; - } - - return replaceWithDraftIfAvailable({ - accessResult, - payload, - entity: collection.config, - entityType: 'collection', - doc, - locale, - }); - })), - }; - - return result; -}; diff --git a/src/versions/drafts/queryDrafts.ts b/src/versions/drafts/queryDrafts.ts new file mode 100644 index 0000000000..34a9ce1398 --- /dev/null +++ b/src/versions/drafts/queryDrafts.ts @@ -0,0 +1,86 @@ +import { AccessResult } from '../../config/types'; +import { Where } from '../../types'; +import { Payload } from '../..'; +import { PaginatedDocs } from '../../mongoose/types'; +import { Collection, CollectionModel, TypeWithID } from '../../collections/config/types'; +import { hasWhereAccessResult } from '../../auth'; +import { appendVersionToQueryKey } from './appendVersionToQueryKey'; + +type AggregateVersion = { + _id: string + version: T + updatedAt: string + createdAt: string +} + +type Args = { + accessResult: AccessResult + collection: Collection + locale: string + paginationOptions: any + payload: Payload + where: Where +} + +export const queryDrafts = async ({ + accessResult, + collection, + locale, + payload, + paginationOptions, + where: incomingWhere, +}: Args): Promise> => { + const VersionModel = payload.versions[collection.config.slug] as CollectionModel; + + const where = appendVersionToQueryKey(incomingWhere || {}); + + const versionQueryToBuild: { where: Where } = { + where: { + ...where, + and: [ + ...where?.and || [], + ], + }, + }; + + if (hasWhereAccessResult(accessResult)) { + const versionAccessResult = appendVersionToQueryKey(accessResult); + versionQueryToBuild.where.and.push(versionAccessResult); + } + + const versionQuery = await VersionModel.buildQuery(versionQueryToBuild, locale); + + const aggregate = VersionModel.aggregate>([ + { + $sort: Object.entries(paginationOptions.sort).reduce((sort, [key, order]) => { + return { + ...sort, + [key]: order === 'asc' ? 1 : -1, + }; + }, {}), + }, + { + $group: { + _id: '$parent', + versionID: { $first: '$_id' }, + version: { $first: '$version' }, + updatedAt: { $first: '$updatedAt' }, + createdAt: { $first: '$createdAt' }, + }, + }, + { $match: versionQuery }, + { $limit: paginationOptions.limit }, + ]); + + const result = await VersionModel.aggregatePaginate(aggregate, paginationOptions); + + return { + ...result, + docs: result.docs.map((doc) => ({ + _id: doc._id, + ...doc.version, + updatedAt: doc.updatedAt, + createdAt: doc.createdAt, + })), + }; +}; diff --git a/src/versions/saveVersion.ts b/src/versions/saveVersion.ts index 7a706a5608..912daff087 100644 --- a/src/versions/saveVersion.ts +++ b/src/versions/saveVersion.ts @@ -14,6 +14,7 @@ type Args = { id?: string | number autosave?: boolean draft?: boolean + createdAt?: string } export const saveVersion = async ({ @@ -24,6 +25,7 @@ export const saveVersion = async ({ docWithLocales, autosave, draft, + createdAt, }: Args): Promise => { let entityConfig; let entityType: 'global' | 'collection'; @@ -54,13 +56,17 @@ export const saveVersion = async ({ try { if (autosave && existingAutosaveVersion?.autosave === true) { + const data: Record = { + version: versionData, + }; + + if (createdAt) data.updatedAt = createdAt; + await VersionModel.findByIdAndUpdate( { _id: existingAutosaveVersion._id, }, - { - version: versionData, - }, + data, { new: true, lean: true }, ); // Otherwise, create a new one @@ -70,6 +76,7 @@ export const saveVersion = async ({ autosave: Boolean(autosave), }; + if (createdAt) data.createdAt = createdAt; if (collection) data.parent = id; await VersionModel.create(data); diff --git a/yarn.lock b/yarn.lock index ca47c70840..497ea791f1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8514,6 +8514,11 @@ mongodb@^3.7.3: optionalDependencies: saslprep "^1.0.0" +mongoose-aggregate-paginate-v2@^1.0.6: + version "1.0.6" + resolved "https://registry.npmjs.org/mongoose-aggregate-paginate-v2/-/mongoose-aggregate-paginate-v2-1.0.6.tgz#fd2f2564d1bbf52f49a196f0b7b03675913dacca" + integrity sha512-UuALu+mjhQa1K9lMQvjLL3vm3iALvNw8PQNIh2gp1b+tO5hUa0NC0Wf6/8QrT9PSJVTihXaD8hQVy3J4e0jO0Q== + mongoose-paginate-v2@*, mongoose-paginate-v2@^1.6.1: version "1.7.1" resolved "https://registry.yarnpkg.com/mongoose-paginate-v2/-/mongoose-paginate-v2-1.7.1.tgz#0b390f5eb8e5dca55ffcb1fd7b4d8078636cb8f1" From d04db59880523f1b4363864922abd8fb59a8bfda Mon Sep 17 00:00:00 2001 From: Mk Date: Tue, 17 Jan 2023 17:16:30 +0400 Subject: [PATCH 22/46] chore: correct properties in example --- docs/graphql/extending.mdx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/graphql/extending.mdx b/docs/graphql/extending.mdx index e6c723e769..ae2a944ba6 100644 --- a/docs/graphql/extending.mdx +++ b/docs/graphql/extending.mdx @@ -53,13 +53,13 @@ export default buildConfig({ type: GraphQL.GraphQLFloat, }, }, - args: { - argNameHere: { - type: new GraphQL.GraphQLNonNull(GraphQLString), - } - }, - resolve: myCustomQueryResolver, - }) + }), + args: { + argNameHere: { + type: new GraphQL.GraphQLNonNull(GraphQLString), + } + }, + resolve: myCustomQueryResolver, } } } From a53682acee17f154d3e76da8cd921a3bfb214fc1 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 17 Jan 2023 09:59:32 -0500 Subject: [PATCH 23/46] chore: uses resulting version in update ops if draft=true --- src/collections/operations/update.ts | 2 +- src/globals/operations/update.ts | 2 +- src/versions/drafts/queryDrafts.ts | 6 ++++++ src/versions/saveVersion.ts | 16 +++++++++++++--- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/collections/operations/update.ts b/src/collections/operations/update.ts index 496a5f7d61..7f95a8b6db 100644 --- a/src/collections/operations/update.ts +++ b/src/collections/operations/update.ts @@ -246,7 +246,7 @@ async function update(incomingArgs: Arguments): Promise { // ///////////////////////////////////// if (collectionConfig.versions) { - await saveVersion({ + result = await saveVersion({ payload, collection: collectionConfig, req, diff --git a/src/globals/operations/update.ts b/src/globals/operations/update.ts index 9ba1f4e7c0..aed1e05d93 100644 --- a/src/globals/operations/update.ts +++ b/src/globals/operations/update.ts @@ -205,7 +205,7 @@ async function update(args: Args): Promise { // ///////////////////////////////////// if (globalConfig.versions) { - await saveVersion({ + global = await saveVersion({ payload, global: globalConfig, req, diff --git a/src/versions/drafts/queryDrafts.ts b/src/versions/drafts/queryDrafts.ts index 34a9ce1398..98ad57f083 100644 --- a/src/versions/drafts/queryDrafts.ts +++ b/src/versions/drafts/queryDrafts.ts @@ -50,6 +50,12 @@ export const queryDrafts = async ({ const versionQuery = await VersionModel.buildQuery(versionQueryToBuild, locale); + // TODO + // 1. Before group, we could potentially run $match to reduce matches + // 2. Then before group, need to sort by updatedAt so first versions are newest versions + // 3. Finally can group + // 4. Then need to sort on user-defined sort again, if it differs from default + const aggregate = VersionModel.aggregate>([ { $sort: Object.entries(paginationOptions.sort).reduce((sort, [key, order]) => { diff --git a/src/versions/saveVersion.ts b/src/versions/saveVersion.ts index 912daff087..42098bc5fe 100644 --- a/src/versions/saveVersion.ts +++ b/src/versions/saveVersion.ts @@ -4,6 +4,7 @@ import { SanitizedCollectionConfig } from '../collections/config/types'; import { enforceMaxVersions } from './enforceMaxVersions'; import { PayloadRequest } from '../express/types'; import { SanitizedGlobalConfig } from '../globals/config/types'; +import sanitizeInternalFields from '../utilities/sanitizeInternalFields'; type Args = { payload: Payload @@ -26,7 +27,7 @@ export const saveVersion = async ({ autosave, draft, createdAt, -}: Args): Promise => { +}: Args): Promise> => { let entityConfig; let entityType: 'global' | 'collection'; @@ -54,6 +55,8 @@ export const saveVersion = async ({ existingAutosaveVersion = await VersionModel.findOne(query, {}, { sort: { updatedAt: 'desc' } }); } + let result; + try { if (autosave && existingAutosaveVersion?.autosave === true) { const data: Record = { @@ -62,7 +65,7 @@ export const saveVersion = async ({ if (createdAt) data.updatedAt = createdAt; - await VersionModel.findByIdAndUpdate( + result = await VersionModel.findByIdAndUpdate( { _id: existingAutosaveVersion._id, }, @@ -79,7 +82,7 @@ export const saveVersion = async ({ if (createdAt) data.createdAt = createdAt; if (collection) data.parent = id; - await VersionModel.create(data); + result = await VersionModel.create(data); } } catch (err) { let errorMessage: string; @@ -105,4 +108,11 @@ export const saveVersion = async ({ max, }); } + + result = result.version; + result = JSON.parse(JSON.stringify(result)); + result = sanitizeInternalFields(result); + result.id = id; + + return result; }; From ed998598dfe63007b736076b5fc793ee19ca44d4 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 17 Jan 2023 10:22:17 -0500 Subject: [PATCH 24/46] chore: implements new typing into create and find operations --- src/collections/operations/create.ts | 12 +++++++----- src/collections/operations/find.ts | 6 ++++-- src/collections/operations/findByID.ts | 4 +++- src/collections/operations/local/create.ts | 14 +++++++++----- src/collections/operations/local/find.ts | 13 ++++++++----- src/payload.ts | 8 ++++---- src/versions/drafts/mergeDrafts.ts | 12 ++---------- 7 files changed, 37 insertions(+), 32 deletions(-) diff --git a/src/collections/operations/create.ts b/src/collections/operations/create.ts index d51509823c..49bad88019 100644 --- a/src/collections/operations/create.ts +++ b/src/collections/operations/create.ts @@ -1,5 +1,5 @@ import crypto from 'crypto'; - +import { Config as GeneratedTypes } from 'payload/generated-types'; import executeAccess from '../../auth/executeAccess'; import sanitizeInternalFields from '../../utilities/sanitizeInternalFields'; @@ -17,19 +17,21 @@ import { afterChange } from '../../fields/hooks/afterChange'; import { afterRead } from '../../fields/hooks/afterRead'; import { generateFileData } from '../../uploads/generateFileData'; -export type Arguments = { +export type Arguments = { collection: Collection req: PayloadRequest depth?: number disableVerificationEmail?: boolean overrideAccess?: boolean showHiddenFields?: boolean - data: Record + data: T overwriteExistingFiles?: boolean draft?: boolean } -async function create(incomingArgs: Arguments): Promise { +async function create( + incomingArgs: Arguments, +): Promise { let args = incomingArgs; // ///////////////////////////////////// @@ -159,7 +161,7 @@ async function create(incomingArgs: Arguments): Promise { // beforeChange - Fields // ///////////////////////////////////// - const resultWithLocales = await beforeChange({ + const resultWithLocales = await beforeChange>({ data, doc: {}, docWithLocales: {}, diff --git a/src/collections/operations/find.ts b/src/collections/operations/find.ts index 46e5677bff..10195753b5 100644 --- a/src/collections/operations/find.ts +++ b/src/collections/operations/find.ts @@ -2,7 +2,7 @@ import { Where } from '../../types'; import { PayloadRequest } from '../../express/types'; import executeAccess from '../../auth/executeAccess'; import sanitizeInternalFields from '../../utilities/sanitizeInternalFields'; -import { Collection, TypeWithID } from '../config/types'; +import { Collection } from '../config/types'; import { PaginatedDocs } from '../../mongoose/types'; import { hasWhereAccessResult } from '../../auth/types'; import flattenWhereConstraints from '../../utilities/flattenWhereConstraints'; @@ -28,7 +28,9 @@ export type Arguments = { } // eslint-disable-next-line @typescript-eslint/no-explicit-any -async function find(incomingArgs: Arguments): Promise> { +async function find>( + incomingArgs: Arguments, +): Promise> { let args = incomingArgs; // ///////////////////////////////////// diff --git a/src/collections/operations/findByID.ts b/src/collections/operations/findByID.ts index c88dea47c7..e01a8e940b 100644 --- a/src/collections/operations/findByID.ts +++ b/src/collections/operations/findByID.ts @@ -23,7 +23,9 @@ export type Arguments = { } // eslint-disable-next-line @typescript-eslint/no-explicit-any -async function findByID>(incomingArgs: Arguments): Promise { +async function findByID>( + incomingArgs: Arguments, +): Promise { let args = incomingArgs; // ///////////////////////////////////// diff --git a/src/collections/operations/local/create.ts b/src/collections/operations/local/create.ts index 366fc9ca0a..c91a968bf6 100644 --- a/src/collections/operations/local/create.ts +++ b/src/collections/operations/local/create.ts @@ -1,3 +1,4 @@ +import { Config as GeneratedTypes } from 'payload/generated-types'; import { UploadedFile } from 'express-fileupload'; import { Payload } from '../../../payload'; import { PayloadRequest } from '../../../express/types'; @@ -8,9 +9,9 @@ import { getDataLoader } from '../../dataloader'; import { File } from '../../../uploads/types'; import i18n from '../../../translations/init'; -export type Options = { - collection: string - data: Record +export type Options = { + collection: TSlug + data: GeneratedTypes['collections'][TSlug] depth?: number locale?: string fallbackLocale?: string @@ -25,7 +26,10 @@ export type Options = { draft?: boolean } -export default async function createLocal(payload: Payload, options: Options): Promise { +export default async function createLocal( + payload: Payload, + options: Options, +): Promise { const { collection: collectionSlug, depth, @@ -60,7 +64,7 @@ export default async function createLocal(payload: Payload, options: Op if (!req.t) req.t = req.i18n.t; if (!req.payloadDataLoader) req.payloadDataLoader = getDataLoader(req); - return create({ + return create({ depth, data, collection, diff --git a/src/collections/operations/local/find.ts b/src/collections/operations/local/find.ts index 9bf82337f1..2ced770742 100644 --- a/src/collections/operations/local/find.ts +++ b/src/collections/operations/local/find.ts @@ -1,4 +1,4 @@ -import { TypeWithID } from '../../config/types'; +import { Config as GeneratedTypes } from 'payload/generated-types'; import { PaginatedDocs } from '../../../mongoose/types'; import { Document, Where } from '../../../types'; import { Payload } from '../../../payload'; @@ -7,8 +7,8 @@ import find from '../find'; import { getDataLoader } from '../../dataloader'; import i18n from '../../../translations/init'; -export type Options = { - collection: string +export type Options = { + collection: T depth?: number currentDepth?: number page?: number @@ -27,7 +27,10 @@ export type Options = { } // eslint-disable-next-line @typescript-eslint/no-explicit-any -export default async function findLocal(payload: Payload, options: Options): Promise> { +export default async function findLocal( + payload: Payload, + options: Options, +): Promise> { const { collection: collectionSlug, depth, @@ -61,7 +64,7 @@ export default async function findLocal(payload: Pay if (typeof user !== 'undefined') req.user = user; - return find({ + return find({ depth, currentDepth, sort, diff --git a/src/payload.ts b/src/payload.ts index f22d4d6937..0d4b97946f 100644 --- a/src/payload.ts +++ b/src/payload.ts @@ -211,9 +211,9 @@ export class BasePayload { * @param options * @returns created document */ - create = async (options: CreateOptions): Promise => { + create = async (options: CreateOptions): Promise => { const { create } = localOperations; - return create(this, options); + return create(this, options); } /** @@ -221,9 +221,9 @@ export class BasePayload { * @param options * @returns documents satisfying query */ - find = async (options: FindOptions): Promise> => { + find = async (options: FindOptions): Promise> => { const { find } = localOperations; - return find(this, options); + return find(this, options); } findGlobal = async (options: FindGlobalOptions): Promise => { diff --git a/src/versions/drafts/mergeDrafts.ts b/src/versions/drafts/mergeDrafts.ts index 846e89dd70..1951514105 100644 --- a/src/versions/drafts/mergeDrafts.ts +++ b/src/versions/drafts/mergeDrafts.ts @@ -2,10 +2,9 @@ import { AccessResult } from '../../config/types'; import { Where } from '../../types'; import { Payload } from '../../payload'; import { PaginatedDocs } from '../../mongoose/types'; -import { Collection, CollectionModel, TypeWithID } from '../../collections/config/types'; +import { Collection, CollectionModel } from '../../collections/config/types'; import { hasWhereAccessResult } from '../../auth'; import { appendVersionToQueryKey } from './appendVersionToQueryKey'; -import sanitizeInternalFields from '../../utilities/sanitizeInternalFields'; import replaceWithDraftIfAvailable from './replaceWithDraftIfAvailable'; type AggregateVersion = { @@ -33,7 +32,7 @@ type Args = { where: Where } -export const mergeDrafts = async ({ +export const mergeDrafts = async >({ accessResult, collection, locale, @@ -51,8 +50,6 @@ export const mergeDrafts = async ({ return newMap; }, {})); - console.log({ mainCollectionMatchMap }); - // Query the versions collection with a version-specific query const VersionModel = payload.versions[collection.config.slug] as CollectionModel; @@ -135,9 +132,6 @@ export const mergeDrafts = async ({ return newMap; }, {})); - console.log({ versionCollectionMatchMap }); - console.log({ includedParentIDs }); - // Now we need to explicitly exclude any parent matches that have newer versions // which did NOT appear in the versions query const excludedParentIDs = await Promise.all(Object.entries(mainCollectionMatchMap).map(async ([parentDocID, parentDocUpdatedAt]) => { @@ -202,8 +196,6 @@ export const mergeDrafts = async ({ }); } - console.log({ finalQueryToBuild: JSON.stringify(finalQueryToBuild) }); - const finalQuery = await collection.Model.buildQuery(finalQueryToBuild, locale); let result = await collection.Model.paginate(finalQuery, paginationOptions); From dc0f8deb0603786ba2f88017485f8e7cee868b92 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 17 Jan 2023 10:53:50 -0500 Subject: [PATCH 25/46] chore: prefers TypeWithID over Record --- src/auth/operations/registerFirstUser.ts | 16 +++++++++------- src/collections/dataloader.ts | 2 +- src/collections/graphql/resolvers/create.ts | 11 +++++++---- src/collections/operations/create.ts | 2 +- src/collections/operations/findByID.ts | 5 ++--- src/collections/operations/local/create.ts | 2 +- src/collections/operations/local/update.ts | 10 +++++----- src/collections/operations/update.ts | 20 ++++++++++---------- src/express/types.ts | 3 +-- src/fields/hooks/afterChange/index.ts | 2 +- src/fields/hooks/beforeChange/index.ts | 2 +- src/fields/hooks/beforeValidate/index.ts | 4 ++-- src/fields/validations.ts | 2 +- src/generated-types.ts | 7 +++++-- 14 files changed, 47 insertions(+), 41 deletions(-) diff --git a/src/auth/operations/registerFirstUser.ts b/src/auth/operations/registerFirstUser.ts index 96e7b6aa6f..d085e91ff9 100644 --- a/src/auth/operations/registerFirstUser.ts +++ b/src/auth/operations/registerFirstUser.ts @@ -1,12 +1,12 @@ import { Response } from 'express'; -import { Document } from '../../types'; +import { Config as GeneratedTypes } from 'payload/generated-types'; import { Forbidden } from '../../errors'; import { PayloadRequest } from '../../express/types'; import { Collection, TypeWithID } from '../../collections/config/types'; export type Arguments = { collection: Collection - data: { + data: Omit & { email: string password: string } @@ -14,12 +14,14 @@ export type Arguments = { res: Response } -export type Result = { +export type Result = { message: string, - user: Document + user: T } -async function registerFirstUser(args: Arguments): Promise { +async function registerFirstUser( + args: Arguments, +): Promise> { const { collection: { Model, @@ -45,9 +47,9 @@ async function registerFirstUser(args: Arguments): Promise { // Register first user // ///////////////////////////////////// - const result = await payload.create({ + const result = await payload.create({ req, - collection: slug, + collection: slug as TSlug, data, overrideAccess: true, }); diff --git a/src/collections/dataloader.ts b/src/collections/dataloader.ts index b02e9bd7d4..4906b83a00 100644 --- a/src/collections/dataloader.ts +++ b/src/collections/dataloader.ts @@ -1,6 +1,6 @@ import DataLoader, { BatchLoadFn } from 'dataloader'; import { PayloadRequest } from '../express/types'; -import { TypeWithID } from '../globals/config/types'; +import { TypeWithID } from './config/types'; import { isValidID } from '../utilities/isValidID'; import { getIDType } from '../utilities/getIDType'; import { fieldAffectsData } from '../fields/config/types'; diff --git a/src/collections/graphql/resolvers/create.ts b/src/collections/graphql/resolvers/create.ts index 7f3865e0e5..6ea7a46cab 100644 --- a/src/collections/graphql/resolvers/create.ts +++ b/src/collections/graphql/resolvers/create.ts @@ -1,11 +1,12 @@ /* eslint-disable no-param-reassign */ import { Response } from 'express'; +import { Config as GeneratedTypes } from 'payload/generated-types'; import { PayloadRequest } from '../../../express/types'; import { Collection } from '../../config/types'; import create from '../../operations/create'; -export type Resolver = (_: unknown, args: { - data: Record, +export type Resolver = (_: unknown, args: { + data: Omit, locale?: string draft: boolean }, @@ -13,9 +14,11 @@ export type Resolver = (_: unknown, args: { req: PayloadRequest, res: Response } -) => Promise +) => Promise -export default function createResolver(collection: Collection): Resolver { +export default function createResolver( + collection: Collection, +): Resolver { return async function resolver(_, args, context) { if (args.locale) { context.req.locale = args.locale; diff --git a/src/collections/operations/create.ts b/src/collections/operations/create.ts index 49bad88019..f3ba92c03a 100644 --- a/src/collections/operations/create.ts +++ b/src/collections/operations/create.ts @@ -24,7 +24,7 @@ export type Arguments disableVerificationEmail?: boolean overrideAccess?: boolean showHiddenFields?: boolean - data: T + data: Omit overwriteExistingFiles?: boolean draft?: boolean } diff --git a/src/collections/operations/findByID.ts b/src/collections/operations/findByID.ts index e01a8e940b..3b4e5bc104 100644 --- a/src/collections/operations/findByID.ts +++ b/src/collections/operations/findByID.ts @@ -1,7 +1,7 @@ /* eslint-disable no-underscore-dangle */ import memoize from 'micro-memoize'; import { PayloadRequest } from '../../express/types'; -import { Collection } from '../config/types'; +import { Collection, TypeWithID } from '../config/types'; import sanitizeInternalFields from '../../utilities/sanitizeInternalFields'; import { NotFound } from '../../errors'; import executeAccess from '../../auth/executeAccess'; @@ -22,8 +22,7 @@ export type Arguments = { draft?: boolean } -// eslint-disable-next-line @typescript-eslint/no-explicit-any -async function findByID>( +async function findByID( incomingArgs: Arguments, ): Promise { let args = incomingArgs; diff --git a/src/collections/operations/local/create.ts b/src/collections/operations/local/create.ts index c91a968bf6..dd1f9499d5 100644 --- a/src/collections/operations/local/create.ts +++ b/src/collections/operations/local/create.ts @@ -11,7 +11,7 @@ import i18n from '../../../translations/init'; export type Options = { collection: TSlug - data: GeneratedTypes['collections'][TSlug] + data: Omit depth?: number locale?: string fallbackLocale?: string diff --git a/src/collections/operations/local/update.ts b/src/collections/operations/local/update.ts index d34519da6d..e5015101c9 100644 --- a/src/collections/operations/local/update.ts +++ b/src/collections/operations/local/update.ts @@ -1,4 +1,4 @@ -import { Config as SchemaConfig } from 'payload/generated-types'; +import { Config as GeneratedTypes } from 'payload/generated-types'; import { Payload } from '../../../payload'; import { Document } from '../../../types'; import getFileByPath from '../../../uploads/getFileByPath'; @@ -8,10 +8,10 @@ import { getDataLoader } from '../../dataloader'; import { File } from '../../../uploads/types'; import i18nInit from '../../../translations/init'; -export type Options = { +export type Options = { collection: TSlug id: string | number - data: SchemaConfig['collections'][TSlug] + data: Omit depth?: number locale?: string fallbackLocale?: string @@ -25,10 +25,10 @@ export type Options = { autosave?: boolean } -export default async function updateLocal( +export default async function updateLocal( payload: Payload, options: Options, -): Promise { +): Promise { const { collection: collectionSlug, depth, diff --git a/src/collections/operations/update.ts b/src/collections/operations/update.ts index a5b6ddcdf9..c45fbdb9ed 100644 --- a/src/collections/operations/update.ts +++ b/src/collections/operations/update.ts @@ -1,5 +1,5 @@ import httpStatus from 'http-status'; -import { Config as SchemaConfig } from 'payload/generated-types'; +import { Config as GeneratedTypes } from 'payload/generated-types'; import { Where, Document } from '../../types'; import { Collection } from '../config/types'; import sanitizeInternalFields from '../../utilities/sanitizeInternalFields'; @@ -23,7 +23,7 @@ export type Arguments collection: Collection req: PayloadRequest id: string | number - data: T + data: Omit depth?: number disableVerificationEmail?: boolean overrideAccess?: boolean @@ -33,9 +33,9 @@ export type Arguments autosave?: boolean } -async function update( - incomingArgs: Arguments, -): Promise { +async function update( + incomingArgs: Arguments, +): Promise { let args = incomingArgs; // ///////////////////////////////////// @@ -150,7 +150,7 @@ async function update( // beforeValidate - Fields // ///////////////////////////////////// - data = await beforeValidate({ + data = await beforeValidate({ data, doc: originalDoc, entityConfig: collectionConfig, @@ -202,7 +202,7 @@ async function update( // beforeChange - Fields // ///////////////////////////////////// - let result = await beforeChange({ + let result = await beforeChange({ data, doc: originalDoc, docWithLocales, @@ -253,7 +253,7 @@ async function update( id, }); - result = await saveCollectionDraft({ + result = await saveCollectionDraft({ payload, config: collectionConfig, req, @@ -285,7 +285,7 @@ async function update( result = JSON.parse(resultString); } - result = sanitizeInternalFields(result); + result = sanitizeInternalFields(result); // ///////////////////////////////////// // afterRead - Fields @@ -317,7 +317,7 @@ async function update( // afterChange - Fields // ///////////////////////////////////// - result = await afterChange({ + result = await afterChange({ data, doc: result, previousDoc: originalDoc, diff --git a/src/express/types.ts b/src/express/types.ts index 549b555a89..9ce8569a2e 100644 --- a/src/express/types.ts +++ b/src/express/types.ts @@ -3,10 +3,9 @@ import type { i18n as Ii18n, TFunction } from 'i18next'; import DataLoader from 'dataloader'; import { UploadedFile } from 'express-fileupload'; import { Payload } from '../payload'; -import { Collection } from '../collections/config/types'; +import { Collection, TypeWithID } from '../collections/config/types'; import { User } from '../auth/types'; import { Document } from '../types'; -import { TypeWithID } from '../globals/config/types'; /** Express request with some Payload related context added */ export declare type PayloadRequest = Request & { diff --git a/src/fields/hooks/afterChange/index.ts b/src/fields/hooks/afterChange/index.ts index 2a3ad0a78e..afbba7964a 100644 --- a/src/fields/hooks/afterChange/index.ts +++ b/src/fields/hooks/afterChange/index.ts @@ -5,7 +5,7 @@ import { traverseFields } from './traverseFields'; import deepCopyObject from '../../../utilities/deepCopyObject'; type Args = { - data: T + data: Omit doc: T previousDoc: T entityConfig: SanitizedCollectionConfig | SanitizedGlobalConfig diff --git a/src/fields/hooks/beforeChange/index.ts b/src/fields/hooks/beforeChange/index.ts index 632f7bc26b..ccb3adc6ae 100644 --- a/src/fields/hooks/beforeChange/index.ts +++ b/src/fields/hooks/beforeChange/index.ts @@ -7,7 +7,7 @@ import { ValidationError } from '../../../errors'; import deepCopyObject from '../../../utilities/deepCopyObject'; type Args = { - data: T + data: Omit doc: T docWithLocales: Record entityConfig: SanitizedCollectionConfig | SanitizedGlobalConfig diff --git a/src/fields/hooks/beforeValidate/index.ts b/src/fields/hooks/beforeValidate/index.ts index f118aca71d..17653ab705 100644 --- a/src/fields/hooks/beforeValidate/index.ts +++ b/src/fields/hooks/beforeValidate/index.ts @@ -5,8 +5,8 @@ import { traverseFields } from './traverseFields'; import deepCopyObject from '../../../utilities/deepCopyObject'; type Args = { - data: T - doc: T + data: Omit + doc?: T | Record entityConfig: SanitizedCollectionConfig | SanitizedGlobalConfig id?: string | number operation: 'create' | 'update' diff --git a/src/fields/validations.ts b/src/fields/validations.ts index c7de96192c..2d214c8ff7 100644 --- a/src/fields/validations.ts +++ b/src/fields/validations.ts @@ -212,7 +212,7 @@ const validateFilterOptions: Validate = async (value, { t, filterOptions, id, us } }); - const result = await payload.find({ + const result = await payload.find({ collection, depth: 0, where: { diff --git a/src/generated-types.ts b/src/generated-types.ts index f69189f7f1..5e685540e6 100644 --- a/src/generated-types.ts +++ b/src/generated-types.ts @@ -2,11 +2,14 @@ // It will not be used. // Instead, configure a path within your `tsconfig.json`'s `compilerOptions.paths` to point to your generated types. +import { TypeWithID } from './collections/config/types'; +import { TypeWithID as GlobalTypeWithID } from './globals/config/types'; + export type Config = { collections: { - [slug: string | number | symbol]: Record + [slug: string | number | symbol]: TypeWithID } globals: { - [slug: string | number | symbol]: Record + [slug: string | number | symbol]: GlobalTypeWithID } } From 47bb5d6c61aaf6e63eedafaa2e42c643df7b22ae Mon Sep 17 00:00:00 2001 From: Elliot DeNolf Date: Tue, 17 Jan 2023 14:50:41 -0500 Subject: [PATCH 26/46] chore: ts improvements on delete operation --- src/collections/graphql/resolvers/delete.ts | 9 ++++++--- src/collections/operations/delete.ts | 5 ++++- src/collections/operations/local/delete.ts | 13 ++++++++----- src/collections/operations/local/findByID.ts | 5 ++++- src/payload.ts | 2 +- 5 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/collections/graphql/resolvers/delete.ts b/src/collections/graphql/resolvers/delete.ts index 774b132e1f..09709ca912 100644 --- a/src/collections/graphql/resolvers/delete.ts +++ b/src/collections/graphql/resolvers/delete.ts @@ -1,10 +1,11 @@ /* eslint-disable no-param-reassign */ +import { Config as GeneratedTypes } from 'payload/generated-types'; import { Response } from 'express'; import { PayloadRequest } from '../../../express/types'; import { Collection } from '../../config/types'; import deleteOperation from '../../operations/delete'; -export type Resolver = ( +export type Resolver = ( _: unknown, args: { locale?: string @@ -14,9 +15,11 @@ export type Resolver = ( req: PayloadRequest, res: Response } -) => Promise +) => Promise -export default function getDeleteResolver(collection: Collection): Resolver { +export default function getDeleteResolver( + collection: Collection, +): Resolver { async function resolver(_, args, context) { if (args.locale) context.req.locale = args.locale; if (args.fallbackLocale) context.req.fallbackLocale = args.fallbackLocale; diff --git a/src/collections/operations/delete.ts b/src/collections/operations/delete.ts index e0454ec1dc..f364506e76 100644 --- a/src/collections/operations/delete.ts +++ b/src/collections/operations/delete.ts @@ -1,6 +1,7 @@ import fs from 'fs'; import path from 'path'; +import { Config as GeneratedTypes } from 'payload/generated-types'; import { PayloadRequest } from '../../express/types'; import sanitizeInternalFields from '../../utilities/sanitizeInternalFields'; import { NotFound, Forbidden, ErrorDeletingFile } from '../../errors'; @@ -21,7 +22,9 @@ export type Arguments = { showHiddenFields?: boolean } -async function deleteOperation(incomingArgs: Arguments): Promise { +async function deleteOperation( + incomingArgs: Arguments, +): Promise { let args = incomingArgs; // ///////////////////////////////////// diff --git a/src/collections/operations/local/delete.ts b/src/collections/operations/local/delete.ts index 562810de5b..3e3666e46d 100644 --- a/src/collections/operations/local/delete.ts +++ b/src/collections/operations/local/delete.ts @@ -1,4 +1,4 @@ -import { TypeWithID } from '../../config/types'; +import { Config as GeneratedTypes } from 'payload/generated-types'; import { Document } from '../../../types'; import { PayloadRequest } from '../../../express/types'; import { Payload } from '../../../payload'; @@ -6,8 +6,8 @@ import deleteOperation from '../delete'; import { getDataLoader } from '../../dataloader'; import i18n from '../../../translations/init'; -export type Options = { - collection: string +export type Options = { + collection: T id: string depth?: number locale?: string @@ -17,7 +17,10 @@ export type Options = { showHiddenFields?: boolean } -export default async function deleteLocal(payload: Payload, options: Options): Promise { +export default async function deleteLocal( + payload: Payload, + options: Options, +): Promise { const { collection: collectionSlug, depth, @@ -44,7 +47,7 @@ export default async function deleteLocal(payload: P if (!req.t) req.t = req.i18n.t; if (!req.payloadDataLoader) req.payloadDataLoader = getDataLoader(req); - return deleteOperation({ + return deleteOperation({ depth, id, collection, diff --git a/src/collections/operations/local/findByID.ts b/src/collections/operations/local/findByID.ts index 4848dad432..a9f859c099 100644 --- a/src/collections/operations/local/findByID.ts +++ b/src/collections/operations/local/findByID.ts @@ -21,7 +21,10 @@ export type Options = { draft?: boolean } -export default async function findByIDLocal(payload: Payload, options: Options): Promise { +export default async function findByIDLocal( + payload: Payload, + options: Options, +): Promise { const { collection: collectionSlug, depth, diff --git a/src/payload.ts b/src/payload.ts index 0d4b97946f..345466f8c1 100644 --- a/src/payload.ts +++ b/src/payload.ts @@ -287,7 +287,7 @@ export class BasePayload { return update(this, options); } - delete = async (options: DeleteOptions): Promise => { + delete = async (options: DeleteOptions): Promise => { const { localDelete } = localOperations; return localDelete(this, options); } From 3bb262fd660fe95cf09c101c702d1623552e14d8 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 17 Jan 2023 15:01:15 -0500 Subject: [PATCH 27/46] chore: passing tests --- src/collections/init.ts | 2 +- src/collections/operations/create.ts | 1 + src/collections/operations/update.ts | 2 +- src/globals/init.ts | 2 +- src/versions/buildCollectionFields.ts | 14 ++++++++++++ src/versions/buildGlobalFields.ts | 14 ++++++++++++ src/versions/drafts/queryDrafts.ts | 31 +++++++++++++-------------- src/versions/saveVersion.ts | 10 +++++++-- test/versions/int.spec.ts | 5 +++++ 9 files changed, 60 insertions(+), 21 deletions(-) diff --git a/src/collections/init.ts b/src/collections/init.ts index fdd83d5ef3..e60b95eb9b 100644 --- a/src/collections/init.ts +++ b/src/collections/init.ts @@ -75,7 +75,7 @@ export default function registerCollections(ctx: Payload): void { disableUnique: true, draftsEnabled: true, options: { - timestamps: true, + timestamps: false, }, }, ); diff --git a/src/collections/operations/create.ts b/src/collections/operations/create.ts index 5818f6a95a..532029cd37 100644 --- a/src/collections/operations/create.ts +++ b/src/collections/operations/create.ts @@ -229,6 +229,7 @@ async function create(incomingArgs: Arguments): Promise { docWithLocales: result, autosave, createdAt: result.createdAt, + onCreate: true, }); } diff --git a/src/collections/operations/update.ts b/src/collections/operations/update.ts index 7f95a8b6db..5b520bf076 100644 --- a/src/collections/operations/update.ts +++ b/src/collections/operations/update.ts @@ -254,7 +254,7 @@ async function update(incomingArgs: Arguments): Promise { id, autosave, draft: shouldSaveDraft, - createdAt: result.createdAt as string, + createdAt: originalDoc.createdAt, }); } diff --git a/src/globals/init.ts b/src/globals/init.ts index 8558aa2cbf..13d58c16a2 100644 --- a/src/globals/init.ts +++ b/src/globals/init.ts @@ -30,7 +30,7 @@ export default function initGlobals(ctx: Payload): void { disableUnique: true, draftsEnabled: true, options: { - timestamps: true, + timestamps: false, }, }, ); diff --git a/src/versions/buildCollectionFields.ts b/src/versions/buildCollectionFields.ts index ff6b552758..69395e23e1 100644 --- a/src/versions/buildCollectionFields.ts +++ b/src/versions/buildCollectionFields.ts @@ -14,6 +14,20 @@ export const buildVersionCollectionFields = (collection: SanitizedCollectionConf type: 'group', fields: collection.fields, }, + { + name: 'createdAt', + type: 'date', + admin: { + disabled: true, + }, + }, + { + name: 'updatedAt', + type: 'date', + admin: { + disabled: true, + }, + }, ]; if (collection?.versions?.drafts && collection?.versions?.drafts?.autosave) { diff --git a/src/versions/buildGlobalFields.ts b/src/versions/buildGlobalFields.ts index 23102fec93..8afb8723c4 100644 --- a/src/versions/buildGlobalFields.ts +++ b/src/versions/buildGlobalFields.ts @@ -8,6 +8,20 @@ export const buildVersionGlobalFields = (global: SanitizedGlobalConfig): Field[] type: 'group', fields: global.fields, }, + { + name: 'createdAt', + type: 'date', + admin: { + disabled: true, + }, + }, + { + name: 'updatedAt', + type: 'date', + admin: { + disabled: true, + }, + }, ]; if (global?.versions?.drafts && global?.versions?.drafts?.autosave) { diff --git a/src/versions/drafts/queryDrafts.ts b/src/versions/drafts/queryDrafts.ts index 98ad57f083..437d698ff7 100644 --- a/src/versions/drafts/queryDrafts.ts +++ b/src/versions/drafts/queryDrafts.ts @@ -50,13 +50,21 @@ export const queryDrafts = async ({ const versionQuery = await VersionModel.buildQuery(versionQueryToBuild, locale); - // TODO - // 1. Before group, we could potentially run $match to reduce matches - // 2. Then before group, need to sort by updatedAt so first versions are newest versions - // 3. Finally can group - // 4. Then need to sort on user-defined sort again, if it differs from default - const aggregate = VersionModel.aggregate>([ + // Sort so that newest are first + { $sort: { updatedAt: -1 } }, + // Group by parent ID, and take the first of each + { + $group: { + _id: '$parent', + version: { $first: '$version' }, + updatedAt: { $first: '$updatedAt' }, + createdAt: { $first: '$createdAt' }, + }, + }, + // Filter based on incoming query + { $match: versionQuery }, + // Re-sort based on incoming sort { $sort: Object.entries(paginationOptions.sort).reduce((sort, [key, order]) => { return { @@ -65,16 +73,7 @@ export const queryDrafts = async ({ }; }, {}), }, - { - $group: { - _id: '$parent', - versionID: { $first: '$_id' }, - version: { $first: '$version' }, - updatedAt: { $first: '$updatedAt' }, - createdAt: { $first: '$createdAt' }, - }, - }, - { $match: versionQuery }, + // Add pagination limit { $limit: paginationOptions.limit }, ]); diff --git a/src/versions/saveVersion.ts b/src/versions/saveVersion.ts index 42098bc5fe..9599e3c5cf 100644 --- a/src/versions/saveVersion.ts +++ b/src/versions/saveVersion.ts @@ -15,7 +15,8 @@ type Args = { id?: string | number autosave?: boolean draft?: boolean - createdAt?: string + createdAt: string + onCreate?: boolean } export const saveVersion = async ({ @@ -27,6 +28,7 @@ export const saveVersion = async ({ autosave, draft, createdAt, + onCreate = false, }: Args): Promise> => { let entityConfig; let entityType: 'global' | 'collection'; @@ -56,11 +58,14 @@ export const saveVersion = async ({ } let result; + const now = new Date().toISOString(); try { if (autosave && existingAutosaveVersion?.autosave === true) { const data: Record = { version: versionData, + createdAt, + updatedAt: now, }; if (createdAt) data.updatedAt = createdAt; @@ -77,9 +82,10 @@ export const saveVersion = async ({ const data: Record = { version: versionData, autosave: Boolean(autosave), + updatedAt: onCreate ? createdAt : now, + createdAt: createdAt || now, }; - if (createdAt) data.createdAt = createdAt; if (collection) data.parent = id; result = await VersionModel.create(data); diff --git a/test/versions/int.spec.ts b/test/versions/int.spec.ts index e45107d448..d7689797e1 100644 --- a/test/versions/int.spec.ts +++ b/test/versions/int.spec.ts @@ -157,6 +157,11 @@ describe('Versions', () => { const versions = await payload.findVersions({ collection, locale: 'all', + where: { + parent: { + equals: collectionLocalPostID, + }, + }, }); expect(versions.docs[0].version.title.en).toStrictEqual(newEnglishTitle); From 2c6844c327c4dd365e8f2020c30f5be58a2e0a26 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 17 Jan 2023 15:03:38 -0500 Subject: [PATCH 28/46] chore: removes unused code --- src/versions/cleanUpFailedVersion.ts | 21 ------ src/versions/ensurePublishedGlobalVersion.ts | 73 -------------------- src/versions/shouldIncrementVersionCount.ts | 14 ---- 3 files changed, 108 deletions(-) delete mode 100644 src/versions/cleanUpFailedVersion.ts delete mode 100644 src/versions/ensurePublishedGlobalVersion.ts delete mode 100644 src/versions/shouldIncrementVersionCount.ts diff --git a/src/versions/cleanUpFailedVersion.ts b/src/versions/cleanUpFailedVersion.ts deleted file mode 100644 index 6767c02fa9..0000000000 --- a/src/versions/cleanUpFailedVersion.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { Payload } from '..'; -import { SanitizedCollectionConfig } from '../collections/config/types'; -import { SanitizedGlobalConfig } from '../globals/config/types'; -import { TypeWithVersion } from './types'; - -type Args = { - payload: Payload, - entityConfig: SanitizedCollectionConfig | SanitizedGlobalConfig, - version: TypeWithVersion -} - -const cleanUpFailedVersion = (args: Args) => { - const { payload, entityConfig, version } = args; - - if (version) { - const VersionModel = payload.versions[entityConfig.slug]; - VersionModel.findOneAndDelete({ _id: version.id }); - } -}; - -export default cleanUpFailedVersion; diff --git a/src/versions/ensurePublishedGlobalVersion.ts b/src/versions/ensurePublishedGlobalVersion.ts deleted file mode 100644 index c4b5b85a9a..0000000000 --- a/src/versions/ensurePublishedGlobalVersion.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { Payload } from '..'; -import { enforceMaxVersions } from './enforceMaxVersions'; -import { PayloadRequest } from '../express/types'; -import { SanitizedGlobalConfig } from '../globals/config/types'; -import { afterRead } from '../fields/hooks/afterRead'; - -type Args = { - payload: Payload - config?: SanitizedGlobalConfig - req: PayloadRequest - docWithLocales: any -} - -export const ensurePublishedGlobalVersion = async ({ - payload, - config, - req, - docWithLocales, -}: Args): Promise => { - // If there are no newer drafts, - // And the current doc is published, - // We need to keep a version of the published document - - if (docWithLocales?._status === 'published') { - const VersionModel = payload.versions[config.slug]; - - const moreRecentDrafts = await VersionModel.find({ - updatedAt: { - $gt: docWithLocales.updatedAt, - }, - }, - {}, - { - lean: true, - leanWithId: true, - sort: { - updatedAt: 'desc', - }, - }); - - if (moreRecentDrafts?.length === 0) { - const version = await afterRead({ - depth: 0, - doc: docWithLocales, - entityConfig: config, - req, - overrideAccess: true, - showHiddenFields: true, - flattenLocales: false, - }); - - try { - await VersionModel.create({ - version, - autosave: false, - }); - } catch (err) { - payload.logger.error(`There was an error while saving a version for the Global ${config.label}.`); - payload.logger.error(err); - } - - if (config.versions.max) { - enforceMaxVersions({ - payload: this, - Model: VersionModel, - slug: config.slug, - entityType: 'global', - max: config.versions.max, - }); - } - } - } -}; diff --git a/src/versions/shouldIncrementVersionCount.ts b/src/versions/shouldIncrementVersionCount.ts deleted file mode 100644 index 4839c33430..0000000000 --- a/src/versions/shouldIncrementVersionCount.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { SanitizedCollectionConfig } from '../collections/config/types'; -import { SanitizedGlobalConfig } from '../globals/config/types'; -import { PaginatedDocs } from '../mongoose/types'; - -type ShouldIncrementVersionCount = (args: { - entity: SanitizedGlobalConfig | SanitizedCollectionConfig - versions: PaginatedDocs<{ version?: { _status: string} }> - docStatus: string -}) => boolean - -export const shouldIncrementVersionCount: ShouldIncrementVersionCount = ({ entity, docStatus, versions }) => { - return !(entity?.versions?.drafts && entity.versions.drafts?.autosave) - && (docStatus === 'published' || (docStatus === 'draft' && versions?.docs?.[0]?.version?._status !== 'draft')); -}; From 1f9b4e22969b58f15a03f3c08477c6fa39377d95 Mon Sep 17 00:00:00 2001 From: Elliot DeNolf Date: Tue, 17 Jan 2023 15:18:38 -0500 Subject: [PATCH 29/46] chore: ts improvements on global findOne --- src/globals/operations/findOne.ts | 4 ++-- src/globals/operations/local/findOne.ts | 13 ++++++++----- src/payload.ts | 6 ++++-- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/globals/operations/findOne.ts b/src/globals/operations/findOne.ts index e04ec672c8..1b3bec22dc 100644 --- a/src/globals/operations/findOne.ts +++ b/src/globals/operations/findOne.ts @@ -5,7 +5,7 @@ import { AccessResult } from '../../config/types'; import sanitizeInternalFields from '../../utilities/sanitizeInternalFields'; import replaceWithDraftIfAvailable from '../../versions/drafts/replaceWithDraftIfAvailable'; import { afterRead } from '../../fields/hooks/afterRead'; -import { SanitizedGlobalConfig, TypeWithID } from '../config/types'; +import { SanitizedGlobalConfig } from '../config/types'; import { PayloadRequest } from '../../express/types'; type Args = { @@ -19,7 +19,7 @@ type Args = { overrideAccess?: boolean } -async function findOne(args: Args): Promise { +async function findOne>(args: Args): Promise { const { globalConfig, locale, diff --git a/src/globals/operations/local/findOne.ts b/src/globals/operations/local/findOne.ts index a9092f65ed..532de0068f 100644 --- a/src/globals/operations/local/findOne.ts +++ b/src/globals/operations/local/findOne.ts @@ -1,13 +1,13 @@ +import { Config as GeneratedTypes } from 'payload/generated-types'; import { Payload } from '../../../payload'; import { getDataLoader } from '../../../collections/dataloader'; import { PayloadRequest } from '../../../express/types'; import { Document } from '../../../types'; -import { TypeWithID } from '../../config/types'; import findOne from '../findOne'; import i18nInit from '../../../translations/init'; -export type Options = { - slug: string +export type Options = { + slug: T depth?: number locale?: string fallbackLocale?: string @@ -17,7 +17,10 @@ export type Options = { draft?: boolean } -export default async function findOneLocal(payload: Payload, options: Options): Promise { +export default async function findOneLocal( + payload: Payload, + options: Options, +): Promise { const { slug: globalSlug, depth, @@ -45,7 +48,7 @@ export default async function findOneLocal(payload: if (!req.payloadDataLoader) req.payloadDataLoader = getDataLoader(req); return findOne({ - slug: globalSlug, + slug: globalSlug as string, depth, globalConfig, overrideAccess, diff --git a/src/payload.ts b/src/payload.ts index 345466f8c1..48431a4979 100644 --- a/src/payload.ts +++ b/src/payload.ts @@ -226,9 +226,11 @@ export class BasePayload { return find(this, options); } - findGlobal = async (options: FindGlobalOptions): Promise => { + findGlobal = async ( + options: FindGlobalOptions, + ): Promise => { const { findOne } = localGlobalOperations; - return findOne(this, options); + return findOne(this, options); } updateGlobal = async (options: UpdateGlobalOptions): Promise => { From e3c5a6c294d7481637018242f3c0d95d35bed5b3 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 17 Jan 2023 16:16:26 -0500 Subject: [PATCH 30/46] chore: further types local operations --- src/collections/graphql/resolvers/update.ts | 10 ++--- src/collections/operations/find.ts | 6 +-- src/collections/operations/local/create.ts | 2 +- src/collections/operations/local/delete.ts | 2 +- src/collections/operations/local/find.ts | 3 +- src/collections/operations/local/findByID.ts | 2 +- .../operations/local/findVersionByID.ts | 2 +- .../operations/local/findVersions.ts | 2 +- .../operations/local/restoreVersion.ts | 2 +- src/collections/operations/local/update.ts | 2 +- src/globals/graphql/resolvers/update.ts | 14 ++++--- src/globals/operations/findVersions.ts | 6 ++- src/globals/operations/local/findOne.ts | 2 +- .../operations/local/findVersionByID.ts | 2 +- src/globals/operations/local/findVersions.ts | 14 ++++--- .../operations/local/restoreVersion.ts | 2 +- src/globals/operations/local/update.ts | 17 ++++---- src/globals/operations/update.ts | 13 +++--- src/payload.ts | 40 ++++++++++++++----- src/versions/drafts/queryDrafts.ts | 2 +- 20 files changed, 88 insertions(+), 57 deletions(-) diff --git a/src/collections/graphql/resolvers/update.ts b/src/collections/graphql/resolvers/update.ts index 91dabe6909..2bf00a21a2 100644 --- a/src/collections/graphql/resolvers/update.ts +++ b/src/collections/graphql/resolvers/update.ts @@ -1,13 +1,13 @@ /* eslint-disable no-param-reassign */ import { Response } from 'express'; -import { Config as SchemaConfig } from 'payload/generated-types'; +import { Config as GeneratedTypes } from 'payload/generated-types'; import { Collection } from '../../config/types'; import update from '../../operations/update'; import { PayloadRequest } from '../../../express/types'; -export type Resolver = (_: unknown, args: { +export type Resolver = (_: unknown, args: { id: string | number - data: SchemaConfig['collections'][TSlug] + data: GeneratedTypes['collections'][TSlug] locale?: string draft: boolean autosave: boolean @@ -16,9 +16,9 @@ export type Resolver = (_: unkn req: PayloadRequest, res: Response } -) => Promise +) => Promise -export default function updateResolver( +export default function updateResolver( collection: Collection, ): Resolver { async function resolver(_, args, context) { diff --git a/src/collections/operations/find.ts b/src/collections/operations/find.ts index 2f91afaf0e..20b660f437 100644 --- a/src/collections/operations/find.ts +++ b/src/collections/operations/find.ts @@ -2,7 +2,7 @@ import { Where } from '../../types'; import { PayloadRequest } from '../../express/types'; import executeAccess from '../../auth/executeAccess'; import sanitizeInternalFields from '../../utilities/sanitizeInternalFields'; -import { Collection } from '../config/types'; +import { Collection, TypeWithID } from '../config/types'; import { PaginatedDocs } from '../../mongoose/types'; import { hasWhereAccessResult } from '../../auth/types'; import flattenWhereConstraints from '../../utilities/flattenWhereConstraints'; @@ -28,7 +28,7 @@ export type Arguments = { } // eslint-disable-next-line @typescript-eslint/no-explicit-any -async function find>( +async function find( incomingArgs: Arguments, ): Promise> { let args = incomingArgs; @@ -162,7 +162,7 @@ async function find>( }; if (collectionConfig.versions?.drafts && draftsEnabled) { - result = await queryDrafts({ + result = await queryDrafts({ accessResult, collection, locale, diff --git a/src/collections/operations/local/create.ts b/src/collections/operations/local/create.ts index cd12b9ba31..7718580976 100644 --- a/src/collections/operations/local/create.ts +++ b/src/collections/operations/local/create.ts @@ -52,7 +52,7 @@ export default async function createLocal = { req?: PayloadRequest } -// eslint-disable-next-line @typescript-eslint/no-explicit-any export default async function findLocal( payload: Payload, options: Options, @@ -55,7 +54,7 @@ export default async function findLocal const defaultLocale = payload?.config?.localization ? payload?.config?.localization?.defaultLocale : null; if (!collection) { - throw new APIError(`The collection with slug ${collectionSlug} can't be found.`); + throw new APIError(`The collection with slug ${String(collectionSlug)} can't be found.`); } req.payloadAPI = 'local'; diff --git a/src/collections/operations/local/findVersions.ts b/src/collections/operations/local/findVersions.ts index 8b0c6a3411..23f9a45650 100644 --- a/src/collections/operations/local/findVersions.ts +++ b/src/collections/operations/local/findVersions.ts @@ -41,7 +41,7 @@ export default async function findVersionsLocal = a const defaultLocale = payload?.config?.localization ? payload?.config?.localization?.defaultLocale : null; if (!collection) { - throw new APIError(`The collection with slug ${collectionSlug} can't be found.`); + throw new APIError(`The collection with slug ${String(collectionSlug)} can't be found.`); } const i18n = i18nInit(payload.config.i18n); diff --git a/src/collections/operations/local/restoreVersion.ts b/src/collections/operations/local/restoreVersion.ts index 81a0411318..35d860a9a9 100644 --- a/src/collections/operations/local/restoreVersion.ts +++ b/src/collections/operations/local/restoreVersion.ts @@ -33,7 +33,7 @@ export default async function restoreVersionLocal = const collection = payload.collections[collectionSlug]; if (!collection) { - throw new APIError(`The collection with slug ${collectionSlug} can't be found.`); + throw new APIError(`The collection with slug ${String(collectionSlug)} can't be found.`); } const i18n = i18nInit(payload.config.i18n); diff --git a/src/collections/operations/local/update.ts b/src/collections/operations/local/update.ts index 424f761b69..c30dd170a9 100644 --- a/src/collections/operations/local/update.ts +++ b/src/collections/operations/local/update.ts @@ -50,7 +50,7 @@ export default async function updateLocal = ( _: unknown, args: { locale?: string fallbackLocale?: string - data?: Record + data?: GeneratedTypes['globals'][TSlug] draft?: boolean }, context: { req: PayloadRequest, res: Response } -) => Promise +) => Promise -export default function updateResolver(globalConfig: SanitizedGlobalConfig): Resolver { +export default function updateResolver( + globalConfig: SanitizedGlobalConfig, +): Resolver { return async function resolver(_, args, context) { if (args.locale) context.req.locale = args.locale; if (args.fallbackLocale) context.req.fallbackLocale = args.fallbackLocale; @@ -34,7 +36,7 @@ export default function updateResolver(globalConfig: SanitizedGlobalConfig): Res draft: args.draft, }; - const result = await update(options); + const result = await update(options); return result; }; } diff --git a/src/globals/operations/findVersions.ts b/src/globals/operations/findVersions.ts index f2bfce95f3..e6185699ab 100644 --- a/src/globals/operations/findVersions.ts +++ b/src/globals/operations/findVersions.ts @@ -6,10 +6,10 @@ import { PaginatedDocs } from '../../mongoose/types'; import { hasWhereAccessResult } from '../../auth/types'; import flattenWhereConstraints from '../../utilities/flattenWhereConstraints'; import { buildSortParam } from '../../mongoose/buildSortParam'; -import { TypeWithVersion } from '../../versions/types'; import { SanitizedGlobalConfig } from '../config/types'; import { afterRead } from '../../fields/hooks/afterRead'; import { buildVersionGlobalFields } from '../../versions/buildGlobalFields'; +import { TypeWithVersion } from '../../versions/types'; export type Arguments = { globalConfig: SanitizedGlobalConfig @@ -23,7 +23,9 @@ export type Arguments = { showHiddenFields?: boolean } -async function findVersions = any>(args: Arguments): Promise> { +async function findVersions>( + args: Arguments, +): Promise> { const { where, page, diff --git a/src/globals/operations/local/findOne.ts b/src/globals/operations/local/findOne.ts index aed4954ffb..1f9abd953d 100644 --- a/src/globals/operations/local/findOne.ts +++ b/src/globals/operations/local/findOne.ts @@ -38,7 +38,7 @@ export default async function findOneLocal const i18n = i18nInit(payload.config.i18n); if (!globalConfig) { - throw new APIError(`The global with slug ${globalSlug} can't be found.`); + throw new APIError(`The global with slug ${String(globalSlug)} can't be found.`); } const req = { diff --git a/src/globals/operations/local/findVersions.ts b/src/globals/operations/local/findVersions.ts index af90e919a7..f5bd62a43e 100644 --- a/src/globals/operations/local/findVersions.ts +++ b/src/globals/operations/local/findVersions.ts @@ -1,15 +1,16 @@ +import { Config as GeneratedTypes } from 'payload/generated-types'; import { Document, Where } from '../../../types'; import { PaginatedDocs } from '../../../mongoose/types'; -import { TypeWithVersion } from '../../../versions/types'; import { Payload } from '../../../payload'; import { PayloadRequest } from '../../../express/types'; import findVersions from '../findVersions'; import { getDataLoader } from '../../../collections/dataloader'; import i18nInit from '../../../translations/init'; import { APIError } from '../../../errors'; +import { TypeWithVersion } from '../../../versions/types'; -export type Options = { - slug: string +export type Options = { + slug: T depth?: number page?: number limit?: number @@ -22,7 +23,10 @@ export type Options = { where?: Where } -export default async function findVersionsLocal = any>(payload: Payload, options: Options): Promise> { +export default async function findVersionsLocal( + payload: Payload, + options: Options, +): Promise>> { const { slug: globalSlug, depth, @@ -41,7 +45,7 @@ export default async function findVersionsLocal = a const i18n = i18nInit(payload.config.i18n); if (!globalConfig) { - throw new APIError(`The global with slug ${globalSlug} can't be found.`); + throw new APIError(`The global with slug ${String(globalSlug)} can't be found.`); } const req = { diff --git a/src/globals/operations/local/restoreVersion.ts b/src/globals/operations/local/restoreVersion.ts index 0b70d499de..fb7025df32 100644 --- a/src/globals/operations/local/restoreVersion.ts +++ b/src/globals/operations/local/restoreVersion.ts @@ -34,7 +34,7 @@ export default async function restoreVersionLocal = const i18n = i18nInit(payload.config.i18n); if (!globalConfig) { - throw new APIError(`The global with slug ${globalSlug} can't be found.`); + throw new APIError(`The global with slug ${String(globalSlug)} can't be found.`); } const req = { diff --git a/src/globals/operations/local/update.ts b/src/globals/operations/local/update.ts index 11bd9cf011..a4e312b785 100644 --- a/src/globals/operations/local/update.ts +++ b/src/globals/operations/local/update.ts @@ -1,25 +1,28 @@ +import { Config as GeneratedTypes } from 'payload/generated-types'; import { Payload } from '../../../payload'; import { Document } from '../../../types'; import { PayloadRequest } from '../../../express/types'; -import { TypeWithID } from '../../config/types'; import update from '../update'; import { getDataLoader } from '../../../collections/dataloader'; import i18nInit from '../../../translations/init'; import { APIError } from '../../../errors'; -export type Options = { - slug: string +export type Options = { + slug: TSlug depth?: number locale?: string fallbackLocale?: string - data: Record + data: Omit user?: Document overrideAccess?: boolean showHiddenFields?: boolean draft?: boolean } -export default async function updateLocal(payload: Payload, options: Options): Promise { +export default async function updateLocal( + payload: Payload, + options: Options, +): Promise { const { slug: globalSlug, depth, @@ -36,7 +39,7 @@ export default async function updateLocal(payload: P const i18n = i18nInit(payload.config.i18n); if (!globalConfig) { - throw new APIError(`The global with slug ${globalSlug} can't be found.`); + throw new APIError(`The global with slug ${String(globalSlug)} can't be found.`); } const req = { @@ -51,7 +54,7 @@ export default async function updateLocal(payload: P if (!req.payloadDataLoader) req.payloadDataLoader = getDataLoader(req); - return update({ + return update({ slug: globalSlug, data, depth, diff --git a/src/globals/operations/update.ts b/src/globals/operations/update.ts index aed1e05d93..70c933361a 100644 --- a/src/globals/operations/update.ts +++ b/src/globals/operations/update.ts @@ -1,5 +1,6 @@ +import { Config as GeneratedTypes } from 'payload/generated-types'; import { docHasTimestamps, Where } from '../../types'; -import { SanitizedGlobalConfig, TypeWithID } from '../config/types'; +import { SanitizedGlobalConfig } from '../config/types'; import executeAccess from '../../auth/executeAccess'; import { hasWhereAccessResult } from '../../auth'; import { beforeChange } from '../../fields/hooks/beforeChange'; @@ -10,19 +11,21 @@ import { PayloadRequest } from '../../express/types'; import { saveVersion } from '../../versions/saveVersion'; import sanitizeInternalFields from '../../utilities/sanitizeInternalFields'; -type Args = { +type Args = { globalConfig: SanitizedGlobalConfig - slug: string + slug: string | number | symbol req: PayloadRequest depth?: number overrideAccess?: boolean showHiddenFields?: boolean draft?: boolean autosave?: boolean - data: Record + data: Omit } -async function update(args: Args): Promise { +async function update( + args: Args, +): Promise { const { globalConfig, slug, diff --git a/src/payload.ts b/src/payload.ts index 48431a4979..e62fb044b5 100644 --- a/src/payload.ts +++ b/src/payload.ts @@ -19,7 +19,7 @@ import { TypeWithVersion } from './versions/types'; import { PaginatedDocs } from './mongoose/types'; import { PayloadAuthenticate } from './express/middleware/authenticate'; -import { Globals, TypeWithID as GlobalTypeWithID } from './globals/config/types'; +import { Globals } from './globals/config/types'; import { ErrorHandler } from './express/middleware/errorHandler'; import localOperations from './collections/operations/local'; import localGlobalOperations from './globals/operations/local'; @@ -211,7 +211,9 @@ export class BasePayload { * @param options * @returns created document */ - create = async (options: CreateOptions): Promise => { + create = async ( + options: CreateOptions, + ): Promise => { const { create } = localOperations; return create(this, options); } @@ -221,7 +223,9 @@ export class BasePayload { * @param options * @returns documents satisfying query */ - find = async (options: FindOptions): Promise> => { + find = async ( + options: FindOptions, + ): Promise> => { const { find } = localOperations; return find(this, options); } @@ -233,9 +237,11 @@ export class BasePayload { return findOne(this, options); } - updateGlobal = async (options: UpdateGlobalOptions): Promise => { + updateGlobal = async ( + options: UpdateGlobalOptions, + ): Promise => { const { update } = localGlobalOperations; - return update(this, options); + return update(this, options); } /** @@ -243,7 +249,9 @@ export class BasePayload { * @param options * @returns versions satisfying query */ - findGlobalVersions = async = any>(options: FindGlobalVersionsOptions): Promise> => { + findGlobalVersions = async ( + options: FindGlobalVersionsOptions, + ): Promise>> => { const { findVersions } = localGlobalOperations; return findVersions(this, options); } @@ -253,7 +261,9 @@ export class BasePayload { * @param options * @returns global version with specified ID */ - findGlobalVersionByID = async = any>(options: FindGlobalVersionByIDOptions): Promise => { + findGlobalVersionByID = async = any>( + options: FindGlobalVersionByIDOptions, + ): Promise => { const { findVersionByID } = localGlobalOperations; return findVersionByID(this, options); } @@ -263,7 +273,9 @@ export class BasePayload { * @param options * @returns version with specified ID */ - restoreGlobalVersion = async = any>(options: RestoreGlobalVersionOptions): Promise => { + restoreGlobalVersion = async = any>( + options: RestoreGlobalVersionOptions, + ): Promise => { const { restoreVersion } = localGlobalOperations; return restoreVersion(this, options); } @@ -274,7 +286,9 @@ export class BasePayload { * @returns document with specified ID */ - findByID = async (options: FindByIDOptions): Promise => { + findByID = async ( + options: FindByIDOptions, + ): Promise => { const { findByID } = localOperations; return findByID(this, options); } @@ -284,12 +298,16 @@ export class BasePayload { * @param options * @returns Updated document */ - update = async (options: UpdateOptions): Promise => { + update = async ( + options: UpdateOptions, + ): Promise => { const { update } = localOperations; return update(this, options); } - delete = async (options: DeleteOptions): Promise => { + delete = async ( + options: DeleteOptions, + ): Promise => { const { localDelete } = localOperations; return localDelete(this, options); } diff --git a/src/versions/drafts/queryDrafts.ts b/src/versions/drafts/queryDrafts.ts index 437d698ff7..8d0e8480c2 100644 --- a/src/versions/drafts/queryDrafts.ts +++ b/src/versions/drafts/queryDrafts.ts @@ -1,6 +1,6 @@ import { AccessResult } from '../../config/types'; import { Where } from '../../types'; -import { Payload } from '../..'; +import { Payload } from '../../payload'; import { PaginatedDocs } from '../../mongoose/types'; import { Collection, CollectionModel, TypeWithID } from '../../collections/config/types'; import { hasWhereAccessResult } from '../../auth'; From c0a942aa4ae9457dae0e925918c32f112dd186bc Mon Sep 17 00:00:00 2001 From: James Date: Tue, 17 Jan 2023 16:46:18 -0500 Subject: [PATCH 31/46] chore: finishes typing local API --- src/auth/operations/local/forgotPassword.ts | 12 +- src/auth/operations/local/login.ts | 17 ++- src/auth/operations/local/resetPassword.ts | 12 +- src/auth/operations/local/unlock.ts | 12 +- src/auth/operations/local/verifyEmail.ts | 12 +- src/auth/operations/login.ts | 9 +- src/collections/operations/findVersions.ts | 4 +- .../operations/local/findVersionByID.ts | 10 +- .../operations/local/findVersions.ts | 10 +- .../operations/local/restoreVersion.ts | 11 +- .../operations/local/findVersionByID.ts | 10 +- .../operations/local/restoreVersion.ts | 9 +- src/payload.ts | 142 ++++++++++-------- 13 files changed, 164 insertions(+), 106 deletions(-) diff --git a/src/auth/operations/local/forgotPassword.ts b/src/auth/operations/local/forgotPassword.ts index 9b66ab8219..40b4f75a35 100644 --- a/src/auth/operations/local/forgotPassword.ts +++ b/src/auth/operations/local/forgotPassword.ts @@ -1,3 +1,4 @@ +import { Config as GeneratedTypes } from 'payload/generated-types'; import { PayloadRequest } from '../../../express/types'; import forgotPassword, { Result } from '../forgotPassword'; import { Payload } from '../../../payload'; @@ -5,8 +6,8 @@ import { getDataLoader } from '../../../collections/dataloader'; import i18n from '../../../translations/init'; import { APIError } from '../../../errors'; -export type Options = { - collection: string +export type Options = { + collection: T data: { email: string } @@ -15,7 +16,10 @@ export type Options = { req?: PayloadRequest } -async function localForgotPassword(payload: Payload, options: Options): Promise { +async function localForgotPassword( + payload: Payload, + options: Options, +): Promise { const { collection: collectionSlug, data, @@ -27,7 +31,7 @@ async function localForgotPassword(payload: Payload, options: Options): Promise< const collection = payload.collections[collectionSlug]; if (!collection) { - throw new APIError(`The collection with slug ${collectionSlug} can't be found.`); + throw new APIError(`The collection with slug ${String(collectionSlug)} can't be found.`); } req.payloadAPI = 'local'; diff --git a/src/auth/operations/local/login.ts b/src/auth/operations/local/login.ts index 23c6e90370..93ea46f9d0 100644 --- a/src/auth/operations/local/login.ts +++ b/src/auth/operations/local/login.ts @@ -1,15 +1,15 @@ import { Response } from 'express'; +import { Config as GeneratedTypes } from 'payload/generated-types'; import login, { Result } from '../login'; import { PayloadRequest } from '../../../express/types'; -import { TypeWithID } from '../../../collections/config/types'; import { Payload } from '../../../payload'; import { getDataLoader } from '../../../collections/dataloader'; import i18n from '../../../translations/init'; import { APIError } from '../../../errors'; -export type Options = { - collection: string - data: { +export type Options = { + collection: TSlug + data: Omit & { email: string password: string } @@ -22,7 +22,10 @@ export type Options = { showHiddenFields?: boolean } -async function localLogin(payload: Payload, options: Options): Promise { +async function localLogin( + payload: Payload, + options: Options, +): Promise { const { collection: collectionSlug, req = {} as PayloadRequest, @@ -38,7 +41,7 @@ async function localLogin(payload: Payload, options: const collection = payload.collections[collectionSlug]; if (!collection) { - throw new APIError(`The collection with slug ${collectionSlug} can't be found.`); + throw new APIError(`The collection with slug ${String(collectionSlug)} can't be found.`); } req.payloadAPI = 'local'; @@ -63,7 +66,7 @@ async function localLogin(payload: Payload, options: if (locale) args.req.locale = locale; if (fallbackLocale) args.req.fallbackLocale = fallbackLocale; - return login(args); + return login(args); } export default localLogin; diff --git a/src/auth/operations/local/resetPassword.ts b/src/auth/operations/local/resetPassword.ts index 878ac42f56..1f6466ca28 100644 --- a/src/auth/operations/local/resetPassword.ts +++ b/src/auth/operations/local/resetPassword.ts @@ -1,3 +1,4 @@ +import { Config as GeneratedTypes } from 'payload/generated-types'; import { Payload } from '../../../payload'; import resetPassword, { Result } from '../resetPassword'; import { PayloadRequest } from '../../../express/types'; @@ -5,8 +6,8 @@ import { getDataLoader } from '../../../collections/dataloader'; import i18n from '../../../translations/init'; import { APIError } from '../../../errors'; -export type Options = { - collection: string +export type Options = { + collection: T data: { token: string password: string @@ -15,7 +16,10 @@ export type Options = { req?: PayloadRequest } -async function localResetPassword(payload: Payload, options: Options): Promise { +async function localResetPassword( + payload: Payload, + options: Options, +): Promise { const { collection: collectionSlug, data, @@ -26,7 +30,7 @@ async function localResetPassword(payload: Payload, options: Options): Promise = { + collection: T data: { email } @@ -14,7 +15,10 @@ export type Options = { overrideAccess: boolean } -async function localUnlock(payload: Payload, options: Options): Promise { +async function localUnlock( + payload: Payload, + options: Options, +): Promise { const { collection: collectionSlug, data, @@ -25,7 +29,7 @@ async function localUnlock(payload: Payload, options: Options): Promise const collection = payload.collections[collectionSlug]; if (!collection) { - throw new APIError(`The collection with slug ${collectionSlug} can't be found.`); + throw new APIError(`The collection with slug ${String(collectionSlug)} can't be found.`); } req.payload = payload; diff --git a/src/auth/operations/local/verifyEmail.ts b/src/auth/operations/local/verifyEmail.ts index b6f220b70d..17328df659 100644 --- a/src/auth/operations/local/verifyEmail.ts +++ b/src/auth/operations/local/verifyEmail.ts @@ -1,13 +1,17 @@ +import { Config as GeneratedTypes } from 'payload/generated-types'; import { APIError } from '../../../errors'; import { Payload } from '../../../payload'; import verifyEmail from '../verifyEmail'; -export type Options = { +export type Options = { token: string, - collection: string + collection: T } -async function localVerifyEmail(payload: Payload, options: Options): Promise { +async function localVerifyEmail( + payload: Payload, + options: Options, +): Promise { const { collection: collectionSlug, token, @@ -16,7 +20,7 @@ async function localVerifyEmail(payload: Payload, options: Options): Promise = { collection: Collection, - data: { + data: Omit & { email: string password: string } @@ -30,7 +31,9 @@ export type Arguments = { showHiddenFields?: boolean } -async function login(incomingArgs: Arguments): Promise { +async function login( + incomingArgs: Arguments, +): Promise { let args = incomingArgs; // ///////////////////////////////////// diff --git a/src/collections/operations/findVersions.ts b/src/collections/operations/findVersions.ts index 4fb5842da6..3b8dabd2e5 100644 --- a/src/collections/operations/findVersions.ts +++ b/src/collections/operations/findVersions.ts @@ -23,7 +23,9 @@ export type Arguments = { showHiddenFields?: boolean } -async function findVersions = any>(args: Arguments): Promise> { +async function findVersions>( + args: Arguments, +): Promise> { const { where, page, diff --git a/src/collections/operations/local/findVersionByID.ts b/src/collections/operations/local/findVersionByID.ts index 708dc1b0c1..f682734c65 100644 --- a/src/collections/operations/local/findVersionByID.ts +++ b/src/collections/operations/local/findVersionByID.ts @@ -1,3 +1,4 @@ +import { Config as GeneratedTypes } from 'payload/generated-types'; import { Payload } from '../../../payload'; import { Document } from '../../../types'; import { PayloadRequest } from '../../../express/types'; @@ -7,8 +8,8 @@ import { getDataLoader } from '../../dataloader'; import i18n from '../../../translations/init'; import { APIError } from '../../../errors'; -export type Options = { - collection: string +export type Options = { + collection: T id: string depth?: number locale?: string @@ -20,7 +21,10 @@ export type Options = { req?: PayloadRequest } -export default async function findVersionByIDLocal = any>(payload: Payload, options: Options): Promise { +export default async function findVersionByIDLocal( + payload: Payload, + options: Options, +): Promise> { const { collection: collectionSlug, depth, diff --git a/src/collections/operations/local/findVersions.ts b/src/collections/operations/local/findVersions.ts index 23f9a45650..54204ca873 100644 --- a/src/collections/operations/local/findVersions.ts +++ b/src/collections/operations/local/findVersions.ts @@ -1,3 +1,4 @@ +import { Config as GeneratedTypes } from 'payload/generated-types'; import { Payload } from '../../../payload'; import { Document, Where } from '../../../types'; import { PaginatedDocs } from '../../../mongoose/types'; @@ -8,8 +9,8 @@ import { getDataLoader } from '../../dataloader'; import i18nInit from '../../../translations/init'; import { APIError } from '../../../errors'; -export type Options = { - collection: string +export type Options = { + collection: T depth?: number page?: number limit?: number @@ -22,7 +23,10 @@ export type Options = { where?: Where } -export default async function findVersionsLocal = any>(payload: Payload, options: Options): Promise> { +export default async function findVersionsLocal( + payload: Payload, + options: Options, +): Promise>> { const { collection: collectionSlug, depth, diff --git a/src/collections/operations/local/restoreVersion.ts b/src/collections/operations/local/restoreVersion.ts index 35d860a9a9..c407953c13 100644 --- a/src/collections/operations/local/restoreVersion.ts +++ b/src/collections/operations/local/restoreVersion.ts @@ -1,14 +1,14 @@ +import { Config as GeneratedTypes } from 'payload/generated-types'; import { Payload } from '../../../payload'; import { PayloadRequest } from '../../../express/types'; import { Document } from '../../../types'; -import { TypeWithVersion } from '../../../versions/types'; import { getDataLoader } from '../../dataloader'; import restoreVersion from '../restoreVersion'; import i18nInit from '../../../translations/init'; import { APIError } from '../../../errors'; -export type Options = { - collection: string +export type Options = { + collection: T id: string depth?: number locale?: string @@ -18,7 +18,10 @@ export type Options = { showHiddenFields?: boolean } -export default async function restoreVersionLocal = any>(payload: Payload, options: Options): Promise { +export default async function restoreVersionLocal( + payload: Payload, + options: Options, +): Promise { const { collection: collectionSlug, depth, diff --git a/src/globals/operations/local/findVersionByID.ts b/src/globals/operations/local/findVersionByID.ts index 916dec607d..03ebfe436f 100644 --- a/src/globals/operations/local/findVersionByID.ts +++ b/src/globals/operations/local/findVersionByID.ts @@ -1,3 +1,4 @@ +import { Config as GeneratedTypes } from 'payload/generated-types'; import { Payload } from '../../../payload'; import { getDataLoader } from '../../../collections/dataloader'; import { PayloadRequest } from '../../../express/types'; @@ -7,8 +8,8 @@ import findVersionByID from '../findVersionByID'; import i18nInit from '../../../translations/init'; import { APIError } from '../../../errors'; -export type Options = { - slug: string +export type Options = { + slug: T id: string depth?: number locale?: string @@ -19,7 +20,10 @@ export type Options = { disableErrors?: boolean } -export default async function findVersionByIDLocal = any>(payload: Payload, options: Options): Promise { +export default async function findVersionByIDLocal( + payload: Payload, + options: Options, +): Promise> { const { slug: globalSlug, depth, diff --git a/src/globals/operations/local/restoreVersion.ts b/src/globals/operations/local/restoreVersion.ts index fb7025df32..be91cbbefe 100644 --- a/src/globals/operations/local/restoreVersion.ts +++ b/src/globals/operations/local/restoreVersion.ts @@ -1,13 +1,13 @@ +import { Config as GeneratedTypes } from 'payload/generated-types'; import { Payload } from '../../../payload'; import { getDataLoader } from '../../../collections/dataloader'; import { PayloadRequest } from '../../../express/types'; import { Document } from '../../../types'; -import { TypeWithVersion } from '../../../versions/types'; import restoreVersion from '../restoreVersion'; import i18nInit from '../../../translations/init'; import { APIError } from '../../../errors'; -export type Options = { +export type Options = { slug: string id: string depth?: number @@ -18,7 +18,10 @@ export type Options = { showHiddenFields?: boolean } -export default async function restoreVersionLocal = any>(payload: Payload, options: Options): Promise { +export default async function restoreVersionLocal( + payload: Payload, + options: Options, +): Promise { const { slug: globalSlug, depth, diff --git a/src/payload.ts b/src/payload.ts index e62fb044b5..93b9329721 100644 --- a/src/payload.ts +++ b/src/payload.ts @@ -230,56 +230,6 @@ export class BasePayload { return find(this, options); } - findGlobal = async ( - options: FindGlobalOptions, - ): Promise => { - const { findOne } = localGlobalOperations; - return findOne(this, options); - } - - updateGlobal = async ( - options: UpdateGlobalOptions, - ): Promise => { - const { update } = localGlobalOperations; - return update(this, options); - } - - /** - * @description Find global versions with criteria - * @param options - * @returns versions satisfying query - */ - findGlobalVersions = async ( - options: FindGlobalVersionsOptions, - ): Promise>> => { - const { findVersions } = localGlobalOperations; - return findVersions(this, options); - } - - /** - * @description Find global version by ID - * @param options - * @returns global version with specified ID - */ - findGlobalVersionByID = async = any>( - options: FindGlobalVersionByIDOptions, - ): Promise => { - const { findVersionByID } = localGlobalOperations; - return findVersionByID(this, options); - } - - /** - * @description Restore global version by ID - * @param options - * @returns version with specified ID - */ - restoreGlobalVersion = async = any>( - options: RestoreGlobalVersionOptions, - ): Promise => { - const { restoreVersion } = localGlobalOperations; - return restoreVersion(this, options); - } - /** * @description Find document by ID * @param options @@ -317,7 +267,9 @@ export class BasePayload { * @param options * @returns versions satisfying query */ - findVersions = async = any>(options: FindVersionsOptions): Promise> => { + findVersions = async ( + options: FindVersionsOptions, + ): Promise>> => { const { findVersions } = localOperations; return findVersions(this, options); } @@ -327,9 +279,11 @@ export class BasePayload { * @param options * @returns version with specified ID */ - findVersionByID = async = any>(options: FindVersionByIDOptions): Promise => { + findVersionByID = async ( + options: FindVersionByIDOptions, + ): Promise> => { const { findVersionByID } = localOperations; - return findVersionByID(this, options); + return findVersionByID(this, options); } /** @@ -337,35 +291,97 @@ export class BasePayload { * @param options * @returns version with specified ID */ - restoreVersion = async = any>(options: RestoreVersionOptions): Promise => { + restoreVersion = async ( + options: RestoreVersionOptions, + ): Promise => { const { restoreVersion } = localOperations; - return restoreVersion(this, options); + return restoreVersion(this, options); } - login = async (options: LoginOptions): Promise => { + login = async ( + options: LoginOptions, + ): Promise => { const { login } = localOperations.auth; - return login(this, options); + return login(this, options); } - forgotPassword = async (options: ForgotPasswordOptions): Promise => { + forgotPassword = async ( + options: ForgotPasswordOptions, + ): Promise => { const { forgotPassword } = localOperations.auth; - return forgotPassword(this, options); + return forgotPassword(this, options); } - resetPassword = async (options: ResetPasswordOptions): Promise => { + resetPassword = async ( + options: ResetPasswordOptions, + ): Promise => { const { resetPassword } = localOperations.auth; - return resetPassword(this, options); + return resetPassword(this, options); } - unlock = async (options: UnlockOptions): Promise => { + unlock = async ( + options: UnlockOptions, + ): Promise => { const { unlock } = localOperations.auth; return unlock(this, options); } - verifyEmail = async (options: VerifyEmailOptions): Promise => { + verifyEmail = async ( + options: VerifyEmailOptions, + ): Promise => { const { verifyEmail } = localOperations.auth; return verifyEmail(this, options); } + + findGlobal = async ( + options: FindGlobalOptions, + ): Promise => { + const { findOne } = localGlobalOperations; + return findOne(this, options); + } + + updateGlobal = async ( + options: UpdateGlobalOptions, + ): Promise => { + const { update } = localGlobalOperations; + return update(this, options); + } + + /** + * @description Find global versions with criteria + * @param options + * @returns versions satisfying query + */ + findGlobalVersions = async ( + options: FindGlobalVersionsOptions, + ): Promise>> => { + const { findVersions } = localGlobalOperations; + return findVersions(this, options); + } + + /** + * @description Find global version by ID + * @param options + * @returns global version with specified ID + */ + findGlobalVersionByID = async ( + options: FindGlobalVersionByIDOptions, + ): Promise> => { + const { findVersionByID } = localGlobalOperations; + return findVersionByID(this, options); + } + + /** + * @description Restore global version by ID + * @param options + * @returns version with specified ID + */ + restoreGlobalVersion = async ( + options: RestoreGlobalVersionOptions, + ): Promise => { + const { restoreVersion } = localGlobalOperations; + return restoreVersion(this, options); + } } export type Payload = BasePayload From 70745cea5d23e721f8568567d8decb11a60d0f1e Mon Sep 17 00:00:00 2001 From: James Date: Tue, 17 Jan 2023 16:51:50 -0500 Subject: [PATCH 32/46] chore: renames beta to canary --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0e62a3e523..ca42ce06a7 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "release:patch": "release-it patch", "release:minor": "release-it minor", "release:major": "release-it major", - "release:beta": "release-it prepatch --config .release-it.beta.json", + "release:canary": "release-it prepatch --config .release-it.canary.json", "fix": "eslint \"src/**/*.ts\" --fix", "lint": "eslint \"src/**/*.ts\"" }, From 8ae0d045e33292585f08acf4ef2cd229f8636779 Mon Sep 17 00:00:00 2001 From: Chris McGrane Date: Wed, 18 Jan 2023 10:27:26 -0500 Subject: [PATCH 33/46] Update sendEmail.ts Switched sendEmail typing to nodemailer's SendMailOptions --- src/email/sendEmail.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/email/sendEmail.ts b/src/email/sendEmail.ts index 912ecaff1e..59f4deae5c 100644 --- a/src/email/sendEmail.ts +++ b/src/email/sendEmail.ts @@ -1,7 +1,7 @@ -import { Message } from './types'; +import { SendMailOptions } from 'nodemailer'; import logger from '../utilities/logger'; -export default async function sendEmail(message: Message): Promise { +export default async function sendEmail(message: SendMailOptions): Promise { let result; try { const email = await this.email; From ed6394300fed90cc479182849c525291e93583ab Mon Sep 17 00:00:00 2001 From: James Date: Wed, 18 Jan 2023 10:28:45 -0500 Subject: [PATCH 34/46] chore: passing e2e --- package.json | 1 + src/config/types.ts | 2 +- src/payload.ts | 1 - test/fields/config.ts | 15 +-------------- test/helpers/configHelpers.ts | 14 ++++++++++++++ 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index ca42ce06a7..8d7fa946ab 100644 --- a/package.json +++ b/package.json @@ -194,6 +194,7 @@ "@playwright/test": "^1.29.2", "@release-it/conventional-changelog": "^5.1.1", "@swc/jest": "^0.2.24", + "@swc/register": "^0.1.10", "@testing-library/jest-dom": "^5.11.4", "@testing-library/react": "^13.0.1", "@trbl/eslint-config": "^1.2.4", diff --git a/src/config/types.ts b/src/config/types.ts index afbe5a1033..9b4034478b 100644 --- a/src/config/types.ts +++ b/src/config/types.ts @@ -100,7 +100,7 @@ export type InitOptions = { /** * A function that is called immediately following startup that receives the Payload instance as it's only argument. */ - onInit?: (payload: Payload) => Promise | void; + onInit?: (payload: Payload) => Promise; /** * Specify options for the built-in Pino logger that Payload uses for internal logging. diff --git a/src/payload.ts b/src/payload.ts index 93b9329721..022eb83052 100644 --- a/src/payload.ts +++ b/src/payload.ts @@ -6,7 +6,6 @@ import path from 'path'; import mongoose from 'mongoose'; import { Config as GeneratedTypes } from 'payload/generated-types'; import { - TypeWithID, Collection, CollectionModel, } from './collections/config/types'; diff --git a/test/fields/config.ts b/test/fields/config.ts index 8fe6cb3616..16737a27f7 100644 --- a/test/fields/config.ts +++ b/test/fields/config.ts @@ -23,8 +23,6 @@ import JSONFields, { jsonDoc } from './collections/JSON'; import RelationshipFields from './collections/Relationship'; import RadioFields, { radiosDoc } from './collections/Radio'; import Uploads2 from './collections/Upload2'; -import { Payload } from '../../src/payload'; -import { Config } from './payload-types'; export default buildConfig({ admin: { @@ -65,7 +63,7 @@ export default buildConfig({ locales: ['en', 'es'], fallback: true, }, - onInit: async (payload: Payload) => { + onInit: async (payload) => { await payload.create({ collection: 'users', data: { @@ -130,16 +128,5 @@ export default buildConfig({ blocksDocWithRichText.localizedBlocks[0].richText = richTextDocWithRelationship.richText; await payload.create({ collection: 'block-fields', data: blocksDocWithRichText }); - - const arrayField = await payload.findByID({ - collection: 'array-fields', - id: 'test', - }); - - const updatedArray = await payload.update({ - collection: 'array-fields', - data: arrayField, - id: 'test', - }); }, }); diff --git a/test/helpers/configHelpers.ts b/test/helpers/configHelpers.ts index bd1d30e5cc..20e386d3eb 100644 --- a/test/helpers/configHelpers.ts +++ b/test/helpers/configHelpers.ts @@ -1,4 +1,5 @@ import getPort from 'get-port'; +import swcRegister from '@swc/register'; import path from 'path'; import { v4 as uuid } from 'uuid'; import shelljs from 'shelljs'; @@ -40,6 +41,19 @@ export async function initPayloadTest(options: Options): Promise<{ serverURL: st initOptions.express = express(); } + swcRegister({ + sourceMaps: 'inline', + jsc: { + parser: { + syntax: 'typescript', + tsx: true, + }, + }, + module: { + type: 'commonjs', + }, + }); + await payload.init(initOptions); if (initOptions.express) { From 412064d77f8b634008a9f2ee3cd30dca0b3b0344 Mon Sep 17 00:00:00 2001 From: James Date: Wed, 18 Jan 2023 10:46:23 -0500 Subject: [PATCH 35/46] chore: merges version deletion --- src/versions/deleteCollectionVersions.ts | 2 +- yarn.lock | 22 +--------------------- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/src/versions/deleteCollectionVersions.ts b/src/versions/deleteCollectionVersions.ts index 27a616f2c8..3802fd6807 100644 --- a/src/versions/deleteCollectionVersions.ts +++ b/src/versions/deleteCollectionVersions.ts @@ -1,4 +1,4 @@ -import { Payload } from '..'; +import { Payload } from '../payload'; type Args = { payload: Payload diff --git a/yarn.lock b/yarn.lock index d3decbdcf0..bf7880484f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9310,27 +9310,7 @@ pino-abstract-transport@^1.0.0, pino-abstract-transport@v1.0.0: readable-stream "^4.0.0" split2 "^4.0.0" -pino-pretty@*: - version "9.1.1" - resolved "https://registry.yarnpkg.com/pino-pretty/-/pino-pretty-9.1.1.tgz#e7d64c1db98266ca428ab56567b844ba780cd0e1" - integrity sha512-iJrnjgR4FWQIXZkUF48oNgoRI9BpyMhaEmihonHeCnZ6F50ZHAS4YGfGBT/ZVNsPmd+hzkIPGzjKdY08+/yAXw== - dependencies: - colorette "^2.0.7" - dateformat "^4.6.3" - fast-copy "^3.0.0" - fast-safe-stringify "^2.1.1" - help-me "^4.0.1" - joycon "^3.1.1" - minimist "^1.2.6" - on-exit-leak-free "^2.1.0" - pino-abstract-transport "^1.0.0" - pump "^3.0.0" - readable-stream "^4.0.0" - secure-json-parse "^2.4.0" - sonic-boom "^3.0.0" - strip-json-comments "^3.1.1" - -pino-pretty@^9.1.1: +pino-pretty@*, pino-pretty@^9.1.1: version "9.1.1" resolved "https://registry.npmjs.org/pino-pretty/-/pino-pretty-9.1.1.tgz#e7d64c1db98266ca428ab56567b844ba780cd0e1" integrity sha512-iJrnjgR4FWQIXZkUF48oNgoRI9BpyMhaEmihonHeCnZ6F50ZHAS4YGfGBT/ZVNsPmd+hzkIPGzjKdY08+/yAXw== From a4105266b4019248f879290bb03d2cafce6506cb Mon Sep 17 00:00:00 2001 From: James Date: Wed, 18 Jan 2023 10:58:30 -0500 Subject: [PATCH 36/46] chore: release --- CHANGELOG.md | 16 ++++++++++++++++ package.json | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 91e29d5bcf..0a213e78bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,21 @@ +## [1.5.10-canary.0](https://github.com/payloadcms/payload/compare/v1.5.9...v1.5.10-canary.0) (2023-01-18) + + +### Bug Fixes + +* bump pino and pino-pretty to accommodate yarn 2 ([773fb57](https://github.com/payloadcms/payload/commit/773fb57c71f89d5157847ee4907c1472874f9a61)) +* updated nl i18n typos ([cc7257e](https://github.com/payloadcms/payload/commit/cc7257efd529580b1eb7b6c01df9f7420838c345)) + + +### Features + +* allows versions to be deleted alongside of main document deletion ([a5c76d4](https://github.com/payloadcms/payload/commit/a5c76d4bd544190511e34820c1145ef26d85dc53)) +* isolates local api to local-only functions, converts it to ts generic for stronger typing ([d3d367c](https://github.com/payloadcms/payload/commit/d3d367c635f72b7353ad9a6ff9ecad6a5f56dd08)) +* requires ts-node to start a project for any config that uses ts or jsx ([f1c342e](https://github.com/payloadcms/payload/commit/f1c342e05eb84254c9d84a425b4f0da1249fcef3)) +* simplifies versions logic ([8cfa550](https://github.com/payloadcms/payload/commit/8cfa5509540225100237e6f569eb9eb1a7d5448e)) + ## [1.5.9](https://github.com/payloadcms/payload/compare/v1.5.8...v1.5.9) (2023-01-15) diff --git a/package.json b/package.json index a62cdd8dac..aca4ec9949 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "payload", - "version": "1.5.9", + "version": "1.5.10-canary.0", "description": "Node, React and MongoDB Headless CMS and Application Framework", "license": "MIT", "engines": { From 63ca5126cf24508eedf25506779113a51f1429ea Mon Sep 17 00:00:00 2001 From: James Date: Wed, 18 Jan 2023 11:28:11 -0500 Subject: [PATCH 37/46] chore: changelog update --- CHANGELOG.md | 2159 ++++++++++++++++++++++++++------------------------ 1 file changed, 1132 insertions(+), 1027 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a213e78bb..a82b92cd70 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,254 +1,425 @@ - - ## [1.5.10-canary.0](https://github.com/payloadcms/payload/compare/v1.5.9...v1.5.10-canary.0) (2023-01-18) - ### Bug Fixes -* bump pino and pino-pretty to accommodate yarn 2 ([773fb57](https://github.com/payloadcms/payload/commit/773fb57c71f89d5157847ee4907c1472874f9a61)) -* updated nl i18n typos ([cc7257e](https://github.com/payloadcms/payload/commit/cc7257efd529580b1eb7b6c01df9f7420838c345)) - +- bump pino and pino-pretty to accommodate yarn 2 ([773fb57](https://github.com/payloadcms/payload/commit/773fb57c71f89d5157847ee4907c1472874f9a61)) +- updated nl i18n typos ([cc7257e](https://github.com/payloadcms/payload/commit/cc7257efd529580b1eb7b6c01df9f7420838c345)) +- fixes [#1905](https://github.com/payloadcms/payload/issues/1905) +- fixes [#1885](https://github.com/payloadcms/payload/issues/1885) +- fixes [#1869](https://github.com/payloadcms/payload/issues/1869) ### Features -* allows versions to be deleted alongside of main document deletion ([a5c76d4](https://github.com/payloadcms/payload/commit/a5c76d4bd544190511e34820c1145ef26d85dc53)) -* isolates local api to local-only functions, converts it to ts generic for stronger typing ([d3d367c](https://github.com/payloadcms/payload/commit/d3d367c635f72b7353ad9a6ff9ecad6a5f56dd08)) -* requires ts-node to start a project for any config that uses ts or jsx ([f1c342e](https://github.com/payloadcms/payload/commit/f1c342e05eb84254c9d84a425b4f0da1249fcef3)) -* simplifies versions logic ([8cfa550](https://github.com/payloadcms/payload/commit/8cfa5509540225100237e6f569eb9eb1a7d5448e)) +- Roadmap - [improved TypeScript experience](https://github.com/payloadcms/payload/discussions/1563) - begins work to SIGNIFICANTLY improve typing of Payload's Local API, removing the need for generics and inferring types automatically from your generated types +- Refactors the Local API to include only the bare minimum code necessary for running local API operations, which will allow us to deploy serverlessly +- allows versions to be deleted alongside of main document deletion ([a5c76d4](https://github.com/payloadcms/payload/commit/a5c76d4bd544190511e34820c1145ef26d85dc53)) +- requires ts-node to start a project for any config that uses ts or jsx ([f1c342e](https://github.com/payloadcms/payload/commit/f1c342e05eb84254c9d84a425b4f0da1249fcef3)) +- simplifies versions logic ([8cfa550](https://github.com/payloadcms/payload/commit/8cfa5509540225100237e6f569eb9eb1a7d5448e)) + +### 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](https://github.com/payloadcms/payload/pull/1847). + +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](https://github.com/payloadcms/payload/pull/1847). + +#### 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: + +```js +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: + +```js +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: + +```ts +const post = await payload.findByID({ + 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: + +```ts +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: + +```json +{ + "compilerOptions": { + // your compilerOptions here + "paths": { + // Tell TS where to find your generated types + // This is the default location below + "payload/generated-types": ["./src/generated-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. + +#### 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. + +Here is a way for you to determine if you need to migrate: + +1. Do you have drafts enabled on any collections? +1. If so, do you have any drafts that have **never been updated** at all? For example, a draft is created, and no further versions are ever created. The document only exists in your main collection, and there are no corresponding versions within the `_versions` collection. +1. Are you worried about losing these never-updated-drafts? + +If you think the above bullets apply to you, then you can run a simple migration script to ensure that your "never-updated-drafts" don't disappear from the Admin UI. Your data will never disappear from your database in any case, but applicable documents to the above bullets will simply not show in the List view anymore. + +To migrate, create this file within the root of your Payload project: + +**migrateVersions.js** + +```js +const payload = require("payload"); + +require("dotenv").config(); + +const { PAYLOAD_SECRET_KEY, MONGO_URL } = 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.initAsync({ + secret: PAYLOAD_SECRET_KEY, + mongoURL: MONGO_URL, + 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, + }); + + await Promise.all( + docs.map(async (doc) => { + const VersionsModel = payload.versions[slug]; + + // Find at least one version for the doc + const versions = await VersionsModel.find( + { parent: doc.id }, + null, + { limit: 1 } + ).lean(); + + // If there are no corresponding versions, + // we need to create one + if (versions.length === 0) { + await VersionsModel.create({ + parent: doc.id, + version: doc, + autosave: Boolean(versions?.drafts?.autosave), + updatedAt: doc.updatedAt, + createdAt: doc.createdAt, + }); + + console.log( + `Created version corresponding with ${collection.slug} document ID ${doc.id}` + ); + } + }) + ); + } + }) + ); + + console.log("Done!"); + process.exit(0); +}; + +ensureAtLeastOneVersion(); +``` + +Make sure your environment variables match the script's values above and then run `node migrateVersions.js` in your terminal. + +This migration script will ensure that there is at least one corresponding version for each of your draft-enabled documents. It won't modify or delete any of your existing documents at all. + +### 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. ## [1.5.9](https://github.com/payloadcms/payload/compare/v1.5.8...v1.5.9) (2023-01-15) - ### Bug Fixes -* [#1877](https://github.com/payloadcms/payload/issues/1877), [#1867](https://github.com/payloadcms/payload/issues/1867) - mimeTypes and imageSizes no longer cause error in admin ui ([b06ca70](https://github.com/payloadcms/payload/commit/b06ca700be36cc3a945f81e3fa23ebb53d06ca23)) +- [#1877](https://github.com/payloadcms/payload/issues/1877), [#1867](https://github.com/payloadcms/payload/issues/1867) - mimeTypes and imageSizes no longer cause error in admin ui ([b06ca70](https://github.com/payloadcms/payload/commit/b06ca700be36cc3a945f81e3fa23ebb53d06ca23)) ## [1.5.8](https://github.com/payloadcms/payload/compare/v1.5.7...v1.5.8) (2023-01-12) - ### Features -* throws descriptive error when collection or global slug not found ([b847d85](https://github.com/payloadcms/payload/commit/b847d85e60032b47a8eacc2c9426fdd373dff879)) +- throws descriptive error when collection or global slug not found ([b847d85](https://github.com/payloadcms/payload/commit/b847d85e60032b47a8eacc2c9426fdd373dff879)) ## [1.5.7](https://github.com/payloadcms/payload/compare/v1.5.6...v1.5.7) (2023-01-12) - ### Bug Fixes -* ensures find with draft=true does not improperly exclude draft ids ([69026c5](https://github.com/payloadcms/payload/commit/69026c577914ba029f2c45423d9f621b605a3ca0)) -* ensures querying with drafts works on both published and non-published posts ([f018fc0](https://github.com/payloadcms/payload/commit/f018fc04b02f70d0e6ea545d5eb36ea860206964)) +- ensures find with draft=true does not improperly exclude draft ids ([69026c5](https://github.com/payloadcms/payload/commit/69026c577914ba029f2c45423d9f621b605a3ca0)) +- ensures querying with drafts works on both published and non-published posts ([f018fc0](https://github.com/payloadcms/payload/commit/f018fc04b02f70d0e6ea545d5eb36ea860206964)) ## [1.5.6](https://github.com/payloadcms/payload/compare/v1.5.5...v1.5.6) (2023-01-11) - ### Bug Fixes -* ensures that find with draft=true returns ids with drafts ([3f30b2f](https://github.com/payloadcms/payload/commit/3f30b2f4894258d67e9a9a79e2213f9d5f69f856)) +- ensures that find with draft=true returns ids with drafts ([3f30b2f](https://github.com/payloadcms/payload/commit/3f30b2f4894258d67e9a9a79e2213f9d5f69f856)) ## [1.5.5](https://github.com/payloadcms/payload/compare/v1.5.4...v1.5.5) (2023-01-11) - ### Bug Fixes -* [#1808](https://github.com/payloadcms/payload/issues/1808), arrays and blocks now save localized nested field data upon reordering rows ([ee54c14](https://github.com/payloadcms/payload/commit/ee54c1481cdb8d6669864f20584fa6ef072c9097)) -* bug when clearing relationship field without hasMany: true ([#1829](https://github.com/payloadcms/payload/issues/1829)) ([ed7cfff](https://github.com/payloadcms/payload/commit/ed7cfff45c262206495580509a77adb72a646ddb)) -* ensures upload file data is available for conditions ([d40e136](https://github.com/payloadcms/payload/commit/d40e1369472f212b5f85bfc72fac01dc708aa507)) -* fix miss typo in Thai translation ([25e5ab7](https://github.com/payloadcms/payload/commit/25e5ab7ceebfb36960b6969db543a2b4ae7127d2)) -* formats date when useAsTitle ([086117d](https://github.com/payloadcms/payload/commit/086117d7039b2b68ab2789b57cac97e2735819cf)) -* prevents uploads drawer from crashing when no uploads are enabled ([84e1417](https://github.com/payloadcms/payload/commit/84e1417b711e0823753f0b9174c145e40b68e0be)) -* rte link element initial state [#1848](https://github.com/payloadcms/payload/issues/1848) ([1cde647](https://github.com/payloadcms/payload/commit/1cde647a2a86df21312229b8beec0a6b75df22c3)) -* updatesmargin for group field within a row ([1c3a257](https://github.com/payloadcms/payload/commit/1c3a257244e322c04164f6630772a40baf256da7)) -* upload field filterOptions ([9483ccb](https://github.com/payloadcms/payload/commit/9483ccb1208a91c1376ac4bd5186037f909aa45d)) -* wrong translation and punctuation spacing ([bf1242a](https://github.com/payloadcms/payload/commit/bf1242aafa3fa7e72e81af10284f4ddade28c4a0)) - +- [#1808](https://github.com/payloadcms/payload/issues/1808), arrays and blocks now save localized nested field data upon reordering rows ([ee54c14](https://github.com/payloadcms/payload/commit/ee54c1481cdb8d6669864f20584fa6ef072c9097)) +- bug when clearing relationship field without hasMany: true ([#1829](https://github.com/payloadcms/payload/issues/1829)) ([ed7cfff](https://github.com/payloadcms/payload/commit/ed7cfff45c262206495580509a77adb72a646ddb)) +- ensures upload file data is available for conditions ([d40e136](https://github.com/payloadcms/payload/commit/d40e1369472f212b5f85bfc72fac01dc708aa507)) +- fix miss typo in Thai translation ([25e5ab7](https://github.com/payloadcms/payload/commit/25e5ab7ceebfb36960b6969db543a2b4ae7127d2)) +- formats date when useAsTitle ([086117d](https://github.com/payloadcms/payload/commit/086117d7039b2b68ab2789b57cac97e2735819cf)) +- prevents uploads drawer from crashing when no uploads are enabled ([84e1417](https://github.com/payloadcms/payload/commit/84e1417b711e0823753f0b9174c145e40b68e0be)) +- rte link element initial state [#1848](https://github.com/payloadcms/payload/issues/1848) ([1cde647](https://github.com/payloadcms/payload/commit/1cde647a2a86df21312229b8beec0a6b75df22c3)) +- updatesmargin for group field within a row ([1c3a257](https://github.com/payloadcms/payload/commit/1c3a257244e322c04164f6630772a40baf256da7)) +- upload field filterOptions ([9483ccb](https://github.com/payloadcms/payload/commit/9483ccb1208a91c1376ac4bd5186037f909aa45d)) +- wrong translation and punctuation spacing ([bf1242a](https://github.com/payloadcms/payload/commit/bf1242aafa3fa7e72e81af10284f4ddade28c4a0)) ### Features -* adds translations for fallbackToDefaultLocale ([c247f31](https://github.com/payloadcms/payload/commit/c247f3130cf03d1dc12d456886b04db028161800)) -* ensures compatibility with azure cosmos and aws documentdb ([73af283](https://github.com/payloadcms/payload/commit/73af283e1c24befc2797e2bc9766a22d26e3c288)) +- adds translations for fallbackToDefaultLocale ([c247f31](https://github.com/payloadcms/payload/commit/c247f3130cf03d1dc12d456886b04db028161800)) +- ensures compatibility with azure cosmos and aws documentdb ([73af283](https://github.com/payloadcms/payload/commit/73af283e1c24befc2797e2bc9766a22d26e3c288)) ## [1.5.4](https://github.com/payloadcms/payload/compare/v1.5.3...v1.5.4) (2023-01-06) - ### Features -* allows init to accept a pre-built config ([84e00bf](https://github.com/payloadcms/payload/commit/84e00bf7b3dfc1c23367765eec60bec45b81617b)) +- allows init to accept a pre-built config ([84e00bf](https://github.com/payloadcms/payload/commit/84e00bf7b3dfc1c23367765eec60bec45b81617b)) ## [1.5.3](https://github.com/payloadcms/payload/compare/v1.5.2...v1.5.3) (2023-01-05) - ### Bug Fixes -* theme flicker on code editor ([6567454](https://github.com/payloadcms/payload/commit/6567454ae4e4808303da9b80d26633bc77e1445d)) +- theme flicker on code editor ([6567454](https://github.com/payloadcms/payload/commit/6567454ae4e4808303da9b80d26633bc77e1445d)) ## [1.5.2](https://github.com/payloadcms/payload/compare/v1.5.1...v1.5.2) (2023-01-04) - ### Bug Fixes -* ignores admin and components from swc ([7d27431](https://github.com/payloadcms/payload/commit/7d274313129c44618ebd8d1fd7a176694ee40476)) +- ignores admin and components from swc ([7d27431](https://github.com/payloadcms/payload/commit/7d274313129c44618ebd8d1fd7a176694ee40476)) ## [1.5.1](https://github.com/payloadcms/payload/compare/v1.5.0...v1.5.1) (2023-01-04) - ### Bug Fixes -* reverts components directory back to ts ([1bbf099](https://github.com/payloadcms/payload/commit/1bbf099fe052e767512e111f8f2b778c1b9c59d9)) +- reverts components directory back to ts ([1bbf099](https://github.com/payloadcms/payload/commit/1bbf099fe052e767512e111f8f2b778c1b9c59d9)) # [1.5.0](https://github.com/payloadcms/payload/compare/v1.4.2...v1.5.0) (2023-01-04) - ### Bug Fixes -* json field type ([73b8ba3](https://github.com/payloadcms/payload/commit/73b8ba3d4a86385cd0a80efcdc19e4972d16b0b7)) - +- json field type ([73b8ba3](https://github.com/payloadcms/payload/commit/73b8ba3d4a86385cd0a80efcdc19e4972d16b0b7)) ### Features -* adds initial json field ([28d9f90](https://github.com/payloadcms/payload/commit/28d9f9009cc479b0e5da5c5b4fb85eb29b055309)) -* fixes json editor errors and misc styling ([efe4f6d](https://github.com/payloadcms/payload/commit/efe4f6d861a99337cfd35592557d3e8f16ff924a)) -* swc register ([#1779](https://github.com/payloadcms/payload/issues/1779)) ([c11bcd1](https://github.com/payloadcms/payload/commit/c11bcd1416b19e48569218d9011d013ad77306ce)) -* updates code field editor ([4d6eba8](https://github.com/payloadcms/payload/commit/4d6eba8d21d19eac63df02d56d27b0a17006d042)) -* wires up i18n with monaco editor ([07b2cca](https://github.com/payloadcms/payload/commit/07b2ccad61a619478f6613fa65f4f630222639d4)) +- adds initial json field ([28d9f90](https://github.com/payloadcms/payload/commit/28d9f9009cc479b0e5da5c5b4fb85eb29b055309)) +- fixes json editor errors and misc styling ([efe4f6d](https://github.com/payloadcms/payload/commit/efe4f6d861a99337cfd35592557d3e8f16ff924a)) +- swc register ([#1779](https://github.com/payloadcms/payload/issues/1779)) ([c11bcd1](https://github.com/payloadcms/payload/commit/c11bcd1416b19e48569218d9011d013ad77306ce)) +- updates code field editor ([4d6eba8](https://github.com/payloadcms/payload/commit/4d6eba8d21d19eac63df02d56d27b0a17006d042)) +- wires up i18n with monaco editor ([07b2cca](https://github.com/payloadcms/payload/commit/07b2ccad61a619478f6613fa65f4f630222639d4)) ## [1.4.2](https://github.com/payloadcms/payload/compare/v1.4.1...v1.4.2) (2023-01-03) - ### Bug Fixes -* [#1775](https://github.com/payloadcms/payload/issues/1775) - siblingData for unnamed fields within array rows improperly formatted ([d6fcd19](https://github.com/payloadcms/payload/commit/d6fcd19bd1eaf2942c2eaa31f0de4770ca10ff06)) -* [#1786](https://github.com/payloadcms/payload/issues/1786), relationship with hasMany no longer sets empty array as default value ([ecfb363](https://github.com/payloadcms/payload/commit/ecfb36316961ef0eb9dd1ba1dc95ba98f95223f8)) -* error clearing date field ([883daf7](https://github.com/payloadcms/payload/commit/883daf7b469c03fae67c16292af6aded662c0bd0)) -* select field crash on missing value option ([ec9196e](https://github.com/payloadcms/payload/commit/ec9196e33ca01e6a15097943b4be6dee6ea5202f)) - +- [#1775](https://github.com/payloadcms/payload/issues/1775) - siblingData for unnamed fields within array rows improperly formatted ([d6fcd19](https://github.com/payloadcms/payload/commit/d6fcd19bd1eaf2942c2eaa31f0de4770ca10ff06)) +- [#1786](https://github.com/payloadcms/payload/issues/1786), relationship with hasMany no longer sets empty array as default value ([ecfb363](https://github.com/payloadcms/payload/commit/ecfb36316961ef0eb9dd1ba1dc95ba98f95223f8)) +- error clearing date field ([883daf7](https://github.com/payloadcms/payload/commit/883daf7b469c03fae67c16292af6aded662c0bd0)) +- select field crash on missing value option ([ec9196e](https://github.com/payloadcms/payload/commit/ec9196e33ca01e6a15097943b4be6dee6ea5202f)) ### Features -* add Ukrainian translation ([#1767](https://github.com/payloadcms/payload/issues/1767)) ([49fa5cb](https://github.com/payloadcms/payload/commit/49fa5cb23a0bb57348d8cd7ec0b7805d651fda2d)) -* preview now exposes most recent draft data ([54dadbe](https://github.com/payloadcms/payload/commit/54dadbeae5b195405a7cfb480fd38b2eeb684938)) +- add Ukrainian translation ([#1767](https://github.com/payloadcms/payload/issues/1767)) ([49fa5cb](https://github.com/payloadcms/payload/commit/49fa5cb23a0bb57348d8cd7ec0b7805d651fda2d)) +- preview now exposes most recent draft data ([54dadbe](https://github.com/payloadcms/payload/commit/54dadbeae5b195405a7cfb480fd38b2eeb684938)) ## [1.4.1](https://github.com/payloadcms/payload/compare/v1.4.0...v1.4.1) (2022-12-24) - ### Bug Fixes -* [#1761](https://github.com/payloadcms/payload/issues/1761), avoids rich text modifying form due to selection change ([9f4ce8d](https://github.com/payloadcms/payload/commit/9f4ce8d756742a6e1b2644ea49d0778774aae457)) +- [#1761](https://github.com/payloadcms/payload/issues/1761), avoids rich text modifying form due to selection change ([9f4ce8d](https://github.com/payloadcms/payload/commit/9f4ce8d756742a6e1b2644ea49d0778774aae457)) # [1.4.0](https://github.com/payloadcms/payload/compare/v1.3.4...v1.4.0) (2022-12-23) - ### Bug Fixes -* [#1611](https://github.com/payloadcms/payload/issues/1611), unable to query draft versions with draft=true ([44b31a9](https://github.com/payloadcms/payload/commit/44b31a9e585aad515557b749bf05253139a17bd9)) -* [#1656](https://github.com/payloadcms/payload/issues/1656) remove size data ([389ee26](https://github.com/payloadcms/payload/commit/389ee261d4ebae0b773bca375ed8a74685506aa0)) -* [#1698](https://github.com/payloadcms/payload/issues/1698) - globals and autosave not working ([915f1e2](https://github.com/payloadcms/payload/commit/915f1e2b3a0c9618d5699a0ee6f5e74c6f4038ee)) -* [#1738](https://github.com/payloadcms/payload/issues/1738) save image dimensions to svg uploads ([2de435f](https://github.com/payloadcms/payload/commit/2de435f43a2e75391a655e91a0cda251da776bcb)) -* [#1747](https://github.com/payloadcms/payload/issues/1747), rich text in arrays improperly updating initialValue when moving rows ([d417e50](https://github.com/payloadcms/payload/commit/d417e50d52fc0824fb5aaedd3e1208c3e1468bdd)) -* [#1748](https://github.com/payloadcms/payload/issues/1748), bails out of autosave if doc is published while autosaving ([95e9300](https://github.com/payloadcms/payload/commit/95e9300d109c9bfd377d5b5efbb68ddca306bbec)) -* [#1752](https://github.com/payloadcms/payload/issues/1752), removes label from row field type ([ff3ab18](https://github.com/payloadcms/payload/commit/ff3ab18d1690e50473be2d77897fb9de48361413)) -* [#551](https://github.com/payloadcms/payload/issues/551) - rich text nested list structure ([542ea8e](https://github.com/payloadcms/payload/commit/542ea8eb81a6e608c7368882da9692d656f1d36b)) -* allows cleared file to be reselected ([35abe81](https://github.com/payloadcms/payload/commit/35abe811c1534ba4f7e926edd3a2978ee67b181e)) -* get relationships in locale of i18n language setting ([#1648](https://github.com/payloadcms/payload/issues/1648)) ([60bb265](https://github.com/payloadcms/payload/commit/60bb2652f0aa63747513e771173362985123519c)) -* missing file after reselect in upload component ([6bc1758](https://github.com/payloadcms/payload/commit/6bc1758dc0cad3f52ce332e71134ee527e17fff0)) -* prevents special characters breaking relationship field search ([#1710](https://github.com/payloadcms/payload/issues/1710)) ([9af4c1d](https://github.com/payloadcms/payload/commit/9af4c1dde7f4a68dc629738dff4fc314626cabb8)) -* refreshes document drawer on save ([9567328](https://github.com/payloadcms/payload/commit/9567328d28709c5721b33e5bd61c9535568ffffd)) -* removes update and created at fields when duplicating, ensures updatedAt data is reactive ([bd4ed5b](https://github.com/payloadcms/payload/commit/bd4ed5b99b5026544c910592c3bff6040e2058bc)) -* safely clears sort [#1736](https://github.com/payloadcms/payload/issues/1736) ([341c163](https://github.com/payloadcms/payload/commit/341c163b36c330df76a6eb5146fccc80059eb9d7)) -* simplifies radio validation ([0dfed3b](https://github.com/payloadcms/payload/commit/0dfed3b30a15829f9454332a4cbd7d9ce1fddea3)) -* translated tab classnames ([238bada](https://github.com/payloadcms/payload/commit/238badabb4f38e691608219c54a541993d9f3010)) -* updates relationship label on drawer save and prevents stepnav update ([59de4f7](https://github.com/payloadcms/payload/commit/59de4f7e82dc4f08240b13d48054589b561688fa)) -* updates richtext toolbar position if inside a drawer ([468b0d2](https://github.com/payloadcms/payload/commit/468b0d2a55616993f10eac7d1709620d114ad7d6)) -* use the slug for authentication header API Key ([5b70ebd](https://github.com/payloadcms/payload/commit/5b70ebd119b557cff66e97e3554af730657b4071)) - +- [#1611](https://github.com/payloadcms/payload/issues/1611), unable to query draft versions with draft=true ([44b31a9](https://github.com/payloadcms/payload/commit/44b31a9e585aad515557b749bf05253139a17bd9)) +- [#1656](https://github.com/payloadcms/payload/issues/1656) remove size data ([389ee26](https://github.com/payloadcms/payload/commit/389ee261d4ebae0b773bca375ed8a74685506aa0)) +- [#1698](https://github.com/payloadcms/payload/issues/1698) - globals and autosave not working ([915f1e2](https://github.com/payloadcms/payload/commit/915f1e2b3a0c9618d5699a0ee6f5e74c6f4038ee)) +- [#1738](https://github.com/payloadcms/payload/issues/1738) save image dimensions to svg uploads ([2de435f](https://github.com/payloadcms/payload/commit/2de435f43a2e75391a655e91a0cda251da776bcb)) +- [#1747](https://github.com/payloadcms/payload/issues/1747), rich text in arrays improperly updating initialValue when moving rows ([d417e50](https://github.com/payloadcms/payload/commit/d417e50d52fc0824fb5aaedd3e1208c3e1468bdd)) +- [#1748](https://github.com/payloadcms/payload/issues/1748), bails out of autosave if doc is published while autosaving ([95e9300](https://github.com/payloadcms/payload/commit/95e9300d109c9bfd377d5b5efbb68ddca306bbec)) +- [#1752](https://github.com/payloadcms/payload/issues/1752), removes label from row field type ([ff3ab18](https://github.com/payloadcms/payload/commit/ff3ab18d1690e50473be2d77897fb9de48361413)) +- [#551](https://github.com/payloadcms/payload/issues/551) - rich text nested list structure ([542ea8e](https://github.com/payloadcms/payload/commit/542ea8eb81a6e608c7368882da9692d656f1d36b)) +- allows cleared file to be reselected ([35abe81](https://github.com/payloadcms/payload/commit/35abe811c1534ba4f7e926edd3a2978ee67b181e)) +- get relationships in locale of i18n language setting ([#1648](https://github.com/payloadcms/payload/issues/1648)) ([60bb265](https://github.com/payloadcms/payload/commit/60bb2652f0aa63747513e771173362985123519c)) +- missing file after reselect in upload component ([6bc1758](https://github.com/payloadcms/payload/commit/6bc1758dc0cad3f52ce332e71134ee527e17fff0)) +- prevents special characters breaking relationship field search ([#1710](https://github.com/payloadcms/payload/issues/1710)) ([9af4c1d](https://github.com/payloadcms/payload/commit/9af4c1dde7f4a68dc629738dff4fc314626cabb8)) +- refreshes document drawer on save ([9567328](https://github.com/payloadcms/payload/commit/9567328d28709c5721b33e5bd61c9535568ffffd)) +- removes update and created at fields when duplicating, ensures updatedAt data is reactive ([bd4ed5b](https://github.com/payloadcms/payload/commit/bd4ed5b99b5026544c910592c3bff6040e2058bc)) +- safely clears sort [#1736](https://github.com/payloadcms/payload/issues/1736) ([341c163](https://github.com/payloadcms/payload/commit/341c163b36c330df76a6eb5146fccc80059eb9d7)) +- simplifies radio validation ([0dfed3b](https://github.com/payloadcms/payload/commit/0dfed3b30a15829f9454332a4cbd7d9ce1fddea3)) +- translated tab classnames ([238bada](https://github.com/payloadcms/payload/commit/238badabb4f38e691608219c54a541993d9f3010)) +- updates relationship label on drawer save and prevents stepnav update ([59de4f7](https://github.com/payloadcms/payload/commit/59de4f7e82dc4f08240b13d48054589b561688fa)) +- updates richtext toolbar position if inside a drawer ([468b0d2](https://github.com/payloadcms/payload/commit/468b0d2a55616993f10eac7d1709620d114ad7d6)) +- use the slug for authentication header API Key ([5b70ebd](https://github.com/payloadcms/payload/commit/5b70ebd119b557cff66e97e3554af730657b4071)) ### Features -* add Czech translation ([#1705](https://github.com/payloadcms/payload/issues/1705)) ([0be4285](https://github.com/payloadcms/payload/commit/0be428530512c3babdfe39be259dd165bb66b5f4)) -* adds doc permissions to account view ([8d643fb](https://github.com/payloadcms/payload/commit/8d643fb29d3604b78f6cb46582720dde2a46affb)) -* **graphql:** upgrade to graphql 16 ([57f5f5e](https://github.com/payloadcms/payload/commit/57f5f5ec439b5aee1d46bff0bf31aac6148f16b2)) - +- add Czech translation ([#1705](https://github.com/payloadcms/payload/issues/1705)) ([0be4285](https://github.com/payloadcms/payload/commit/0be428530512c3babdfe39be259dd165bb66b5f4)) +- adds doc permissions to account view ([8d643fb](https://github.com/payloadcms/payload/commit/8d643fb29d3604b78f6cb46582720dde2a46affb)) +- **graphql:** upgrade to graphql 16 ([57f5f5e](https://github.com/payloadcms/payload/commit/57f5f5ec439b5aee1d46bff0bf31aac6148f16b2)) ### BREAKING CHANGES -* replaced the useAPIKey authentication header format to use the collection slug instead of the collection label. Previous: `${collection.labels.singular} API-Key ${apiKey}`, updated: `${collection.slug} API-Key ${apiKey}` +- replaced the useAPIKey authentication header format to use the collection slug instead of the collection label. Previous: `${collection.labels.singular} API-Key ${apiKey}`, updated: `${collection.slug} API-Key ${apiKey}` ## [1.3.4](https://github.com/payloadcms/payload/compare/v1.3.3...v1.3.4) (2022-12-16) - ### Bug Fixes -* async validate out of order ([e913fbe](https://github.com/payloadcms/payload/commit/e913fbe4ea4f9abf7eeb29db3b03e1afe4649d50)) -* autosave with nested localized fields ([4202fc2](https://github.com/payloadcms/payload/commit/4202fc29337763f8fd90ec4beaf0d34e39a916bc)) -* doc access should not run where query on collections without id ([016beb6](https://github.com/payloadcms/payload/commit/016beb6eec96857fe913888a1d9c4994dbd94e7e)) -* run docAccess also when checking global ([b8c0482](https://github.com/payloadcms/payload/commit/b8c0482cdae6d372f81823ee4541717131d9dac4)) +- async validate out of order ([e913fbe](https://github.com/payloadcms/payload/commit/e913fbe4ea4f9abf7eeb29db3b03e1afe4649d50)) +- autosave with nested localized fields ([4202fc2](https://github.com/payloadcms/payload/commit/4202fc29337763f8fd90ec4beaf0d34e39a916bc)) +- doc access should not run where query on collections without id ([016beb6](https://github.com/payloadcms/payload/commit/016beb6eec96857fe913888a1d9c4994dbd94e7e)) +- run docAccess also when checking global ([b8c0482](https://github.com/payloadcms/payload/commit/b8c0482cdae6d372f81823ee4541717131d9dac4)) ## [1.3.3](https://github.com/payloadcms/payload/compare/v1.3.2...v1.3.3) (2022-12-16) - ### Bug Fixes -* allow translation in group admin.description ([#1680](https://github.com/payloadcms/payload/issues/1680)) ([91e33ad](https://github.com/payloadcms/payload/commit/91e33ad1ee04750425112602fcfddcf329f934e8)) -* ensures select field avoids circular dependencies ([f715146](https://github.com/payloadcms/payload/commit/f715146aa35a6f3a8f5d7d4e066c71fb26027472)) +- allow translation in group admin.description ([#1680](https://github.com/payloadcms/payload/issues/1680)) ([91e33ad](https://github.com/payloadcms/payload/commit/91e33ad1ee04750425112602fcfddcf329f934e8)) +- ensures select field avoids circular dependencies ([f715146](https://github.com/payloadcms/payload/commit/f715146aa35a6f3a8f5d7d4e066c71fb26027472)) ## [1.3.2](https://github.com/payloadcms/payload/compare/v1.3.1...v1.3.2) (2022-12-15) - ### Bug Fixes -* safely handles rich text deselection ([420eef4](https://github.com/payloadcms/payload/commit/420eef4d91d6c5810b4e9dbda1e87e9f0e6d8dba)) +- safely handles rich text deselection ([420eef4](https://github.com/payloadcms/payload/commit/420eef4d91d6c5810b4e9dbda1e87e9f0e6d8dba)) ## [1.3.1](https://github.com/payloadcms/payload/compare/v1.3.0...v1.3.1) (2022-12-15) - ### Bug Fixes -* add i18n type to collection and globals admin.description ([#1675](https://github.com/payloadcms/payload/issues/1675)) ([049d560](https://github.com/payloadcms/payload/commit/049d560898fdf3fd9be40a4689eb1ef4170ef207)) -* adds draftsEnabled to baseSchema for tabs / arrays / groups & allows for null enum ([80da898](https://github.com/payloadcms/payload/commit/80da898de8cfe068a0ad685803d8523fd9a10dcd)) -* adds draftsEnabled to versionSchema in collections / globals ([f0db5e0](https://github.com/payloadcms/payload/commit/f0db5e0170807944cfbed8495c813b7c28b05bb3)) -* collapsible margin bottom adjustment ([#1673](https://github.com/payloadcms/payload/issues/1673)) ([64086e8](https://github.com/payloadcms/payload/commit/64086e8122e04965ca0ae8d254b99114208944bf)) -* escapes react-select events when drawer is open ([f290cda](https://github.com/payloadcms/payload/commit/f290cda333aecab104d7cd195bcc7fab2059134d)) -* label translation in about to delete dialog ([#1667](https://github.com/payloadcms/payload/issues/1667)) ([d9c45f6](https://github.com/payloadcms/payload/commit/d9c45f62b19162a34bc317e997d9912213a3012b)) -* list view date field display format ([#1661](https://github.com/payloadcms/payload/issues/1661)) ([934b443](https://github.com/payloadcms/payload/commit/934b443b5b3b0f610767786f940175b9db0b2da7)) -* removes case for select field that sets data to undefined if set to null ([b4f39d5](https://github.com/payloadcms/payload/commit/b4f39d5fd380190ee82a5bb967756d25e9c98e95)) -* Set 'Dashboard's link to config route ([#1652](https://github.com/payloadcms/payload/issues/1652)) ([940c1e8](https://github.com/payloadcms/payload/commit/940c1e84f5f091bf4b4ae0bd6628f077d9d0d6e9)) -* stringifies date in DateTime field for useAsTitle ([#1674](https://github.com/payloadcms/payload/issues/1674)) ([a1813ca](https://github.com/payloadcms/payload/commit/a1813ca4b32dfcd8ca3604f7f03b1ba316d740e2)) - +- add i18n type to collection and globals admin.description ([#1675](https://github.com/payloadcms/payload/issues/1675)) ([049d560](https://github.com/payloadcms/payload/commit/049d560898fdf3fd9be40a4689eb1ef4170ef207)) +- adds draftsEnabled to baseSchema for tabs / arrays / groups & allows for null enum ([80da898](https://github.com/payloadcms/payload/commit/80da898de8cfe068a0ad685803d8523fd9a10dcd)) +- adds draftsEnabled to versionSchema in collections / globals ([f0db5e0](https://github.com/payloadcms/payload/commit/f0db5e0170807944cfbed8495c813b7c28b05bb3)) +- collapsible margin bottom adjustment ([#1673](https://github.com/payloadcms/payload/issues/1673)) ([64086e8](https://github.com/payloadcms/payload/commit/64086e8122e04965ca0ae8d254b99114208944bf)) +- escapes react-select events when drawer is open ([f290cda](https://github.com/payloadcms/payload/commit/f290cda333aecab104d7cd195bcc7fab2059134d)) +- label translation in about to delete dialog ([#1667](https://github.com/payloadcms/payload/issues/1667)) ([d9c45f6](https://github.com/payloadcms/payload/commit/d9c45f62b19162a34bc317e997d9912213a3012b)) +- list view date field display format ([#1661](https://github.com/payloadcms/payload/issues/1661)) ([934b443](https://github.com/payloadcms/payload/commit/934b443b5b3b0f610767786f940175b9db0b2da7)) +- removes case for select field that sets data to undefined if set to null ([b4f39d5](https://github.com/payloadcms/payload/commit/b4f39d5fd380190ee82a5bb967756d25e9c98e95)) +- Set 'Dashboard's link to config route ([#1652](https://github.com/payloadcms/payload/issues/1652)) ([940c1e8](https://github.com/payloadcms/payload/commit/940c1e84f5f091bf4b4ae0bd6628f077d9d0d6e9)) +- stringifies date in DateTime field for useAsTitle ([#1674](https://github.com/payloadcms/payload/issues/1674)) ([a1813ca](https://github.com/payloadcms/payload/commit/a1813ca4b32dfcd8ca3604f7f03b1ba316d740e2)) ### Features -* inline relationships ([8d744c8](https://github.com/payloadcms/payload/commit/c6013c39043cc7bf9e8ff39551662c25e8d744c8)) -* custom button html element ([5592fb1](https://github.com/payloadcms/payload/commit/5592fb148dfa3058df577cfb7f5ed72ea25e1217)) -* further Tooltip improvements ([e101f92](https://github.com/payloadcms/payload/commit/e101f925cc71af4c3a1b5ce4ad552d9834d35bfd)) +- inline relationships ([8d744c8](https://github.com/payloadcms/payload/commit/c6013c39043cc7bf9e8ff39551662c25e8d744c8)) +- custom button html element ([5592fb1](https://github.com/payloadcms/payload/commit/5592fb148dfa3058df577cfb7f5ed72ea25e1217)) +- further Tooltip improvements ([e101f92](https://github.com/payloadcms/payload/commit/e101f925cc71af4c3a1b5ce4ad552d9834d35bfd)) # [1.3.0](https://github.com/payloadcms/payload/compare/v1.2.5...v1.3.0) (2022-12-09) - ### Bug Fixes -* [#1547](https://github.com/payloadcms/payload/issues/1547), global afterChange hook not falling back to original global if nothing returned ([a72123d](https://github.com/payloadcms/payload/commit/a72123dd471e1032d832e409560bda9cf3058095)) -* [#1632](https://github.com/payloadcms/payload/issues/1632) graphQL non-nullable relationship and upload fields ([#1633](https://github.com/payloadcms/payload/issues/1633)) ([eff3f18](https://github.com/payloadcms/payload/commit/eff3f18e7c184e5f82325e960b4cbe84b6377d82)) -* change edit key to prevent richtext editor from crashing ([#1616](https://github.com/payloadcms/payload/issues/1616)) ([471d214](https://github.com/payloadcms/payload/commit/471d21410ac9ac852a8581a019dd6759f56cd8b2)) -* filterOptions function argument relationTo is an array ([#1627](https://github.com/payloadcms/payload/issues/1627)) ([11b1c0e](https://github.com/payloadcms/payload/commit/11b1c0efc66acd32de2efcaf65bad504d2e2eb45)) -* resets slate state when initialValue changes, fixes [#1600](https://github.com/payloadcms/payload/issues/1600), [#1546](https://github.com/payloadcms/payload/issues/1546) ([9558a22](https://github.com/payloadcms/payload/commit/9558a22ce6cdf9bc13215931b43bde0a7dd4bf50)) -* sanitizes global find query params ([512bc1e](https://github.com/payloadcms/payload/commit/512bc1ebe636841f1dee6ce49c1d97db1810c4bd)) -* Select with hasMany and localized ([#1636](https://github.com/payloadcms/payload/issues/1636)) ([756edb8](https://github.com/payloadcms/payload/commit/756edb858a1ca66c32e674770ddcdceae77bf349)) -* translation key in revert published modal ([#1628](https://github.com/payloadcms/payload/issues/1628)) ([b6c597a](https://github.com/payloadcms/payload/commit/b6c597ab5c4fcd879496db5373155df48c657e28)) -* unflattens fields in filterOptions callback ([acff46b](https://github.com/payloadcms/payload/commit/acff46b4a5b57f01fa0b14c1e9fd8330b4d787db)) - - -* feat!: no longer sanitize collection slugs to kebab case (#1607) ([ba2f2d6](https://github.com/payloadcms/payload/commit/ba2f2d6e9b66568b11632bacdd92cfdc8ddae300)), closes [#1607](https://github.com/payloadcms/payload/issues/1607) +- [#1547](https://github.com/payloadcms/payload/issues/1547), global afterChange hook not falling back to original global if nothing returned ([a72123d](https://github.com/payloadcms/payload/commit/a72123dd471e1032d832e409560bda9cf3058095)) +- [#1632](https://github.com/payloadcms/payload/issues/1632) graphQL non-nullable relationship and upload fields ([#1633](https://github.com/payloadcms/payload/issues/1633)) ([eff3f18](https://github.com/payloadcms/payload/commit/eff3f18e7c184e5f82325e960b4cbe84b6377d82)) +- change edit key to prevent richtext editor from crashing ([#1616](https://github.com/payloadcms/payload/issues/1616)) ([471d214](https://github.com/payloadcms/payload/commit/471d21410ac9ac852a8581a019dd6759f56cd8b2)) +- filterOptions function argument relationTo is an array ([#1627](https://github.com/payloadcms/payload/issues/1627)) ([11b1c0e](https://github.com/payloadcms/payload/commit/11b1c0efc66acd32de2efcaf65bad504d2e2eb45)) +- resets slate state when initialValue changes, fixes [#1600](https://github.com/payloadcms/payload/issues/1600), [#1546](https://github.com/payloadcms/payload/issues/1546) ([9558a22](https://github.com/payloadcms/payload/commit/9558a22ce6cdf9bc13215931b43bde0a7dd4bf50)) +- sanitizes global find query params ([512bc1e](https://github.com/payloadcms/payload/commit/512bc1ebe636841f1dee6ce49c1d97db1810c4bd)) +- Select with hasMany and localized ([#1636](https://github.com/payloadcms/payload/issues/1636)) ([756edb8](https://github.com/payloadcms/payload/commit/756edb858a1ca66c32e674770ddcdceae77bf349)) +- translation key in revert published modal ([#1628](https://github.com/payloadcms/payload/issues/1628)) ([b6c597a](https://github.com/payloadcms/payload/commit/b6c597ab5c4fcd879496db5373155df48c657e28)) +- unflattens fields in filterOptions callback ([acff46b](https://github.com/payloadcms/payload/commit/acff46b4a5b57f01fa0b14c1e9fd8330b4d787db)) +- feat!: no longer sanitize collection slugs to kebab case (#1607) ([ba2f2d6](https://github.com/payloadcms/payload/commit/ba2f2d6e9b66568b11632bacdd92cfdc8ddae300)), closes [#1607](https://github.com/payloadcms/payload/issues/1607) ### Features -* add Norwegian bokmål (nb) translation ([#1614](https://github.com/payloadcms/payload/issues/1614)) ([759f001](https://github.com/payloadcms/payload/commit/759f00168137ff1a0fd862796a5971a9ba0264cd)) -* add Thai translation ([#1630](https://github.com/payloadcms/payload/issues/1630)) ([7777d11](https://github.com/payloadcms/payload/commit/7777d11b9ed458a6c64efc8c9572edb898f6ceed)) -* upload support pasting file ([eb69b82](https://github.com/payloadcms/payload/commit/eb69b82adfb4e94c1ef36b219310c55afc7a1d4e)) - +- add Norwegian bokmål (nb) translation ([#1614](https://github.com/payloadcms/payload/issues/1614)) ([759f001](https://github.com/payloadcms/payload/commit/759f00168137ff1a0fd862796a5971a9ba0264cd)) +- add Thai translation ([#1630](https://github.com/payloadcms/payload/issues/1630)) ([7777d11](https://github.com/payloadcms/payload/commit/7777d11b9ed458a6c64efc8c9572edb898f6ceed)) +- upload support pasting file ([eb69b82](https://github.com/payloadcms/payload/commit/eb69b82adfb4e94c1ef36b219310c55afc7a1d4e)) ### BREAKING CHANGES -* collection slugs are no longer automatically sanitized to be kebab case. This will only be an issue if your current slugs were in camel case. The upgrade path will be to change those slugs to the kebab case version that the slug was automatically being sanitized to on the backend. +- collection slugs are no longer automatically sanitized to be kebab case. This will only be an issue if your current slugs were in camel case. The upgrade path will be to change those slugs to the kebab case version that the slug was automatically being sanitized to on the backend. If you only use kebab case or single word slugs: no action needed. @@ -260,762 +431,696 @@ Any future slugs after updating will be used as-is. ## [1.2.5](https://github.com/payloadcms/payload/compare/v1.2.4...v1.2.5) (2022-12-06) - ### Bug Fixes -* exits findOptionsByValue when matchedOption is found ([881c067](https://github.com/payloadcms/payload/commit/881c067c40d7477fa2a56d9c700feab49410e1c1)) -* mismatch language condition when rendering unpublish ([3ddd0ea](https://github.com/payloadcms/payload/commit/3ddd0ea3efbd4d673a943dbf63363c548ae5562c)) -* safely coerces limit and depth to number or undefined ([dd04d78](https://github.com/payloadcms/payload/commit/dd04d7842efe9228e98271a878fd68a814042f41)) -* uses pathOrName to pass to internal Relationship field components ([8874e87](https://github.com/payloadcms/payload/commit/8874e871d4a48d5d3fccb8233464437d8ea61ad4)) - +- exits findOptionsByValue when matchedOption is found ([881c067](https://github.com/payloadcms/payload/commit/881c067c40d7477fa2a56d9c700feab49410e1c1)) +- mismatch language condition when rendering unpublish ([3ddd0ea](https://github.com/payloadcms/payload/commit/3ddd0ea3efbd4d673a943dbf63363c548ae5562c)) +- safely coerces limit and depth to number or undefined ([dd04d78](https://github.com/payloadcms/payload/commit/dd04d7842efe9228e98271a878fd68a814042f41)) +- uses pathOrName to pass to internal Relationship field components ([8874e87](https://github.com/payloadcms/payload/commit/8874e871d4a48d5d3fccb8233464437d8ea61ad4)) ### Features -* add Turkish translations ([#1596](https://github.com/payloadcms/payload/issues/1596)) ([c8a6831](https://github.com/payloadcms/payload/commit/c8a683100f1ec663a2fdfd5c1ab82300d2618995)) +- add Turkish translations ([#1596](https://github.com/payloadcms/payload/issues/1596)) ([c8a6831](https://github.com/payloadcms/payload/commit/c8a683100f1ec663a2fdfd5c1ab82300d2618995)) ## [1.2.4](https://github.com/payloadcms/payload/compare/v1.2.3...v1.2.4) (2022-12-03) - ### Bug Fixes -* missing translation richText link modal ([#1573](https://github.com/payloadcms/payload/issues/1573)) ([2dcada1](https://github.com/payloadcms/payload/commit/2dcada199c21bee97eca88aa6bc8ba1bc2b45e7c)) +- missing translation richText link modal ([#1573](https://github.com/payloadcms/payload/issues/1573)) ([2dcada1](https://github.com/payloadcms/payload/commit/2dcada199c21bee97eca88aa6bc8ba1bc2b45e7c)) ## [1.2.3](https://github.com/payloadcms/payload/compare/v1.2.2...v1.2.3) (2022-12-02) - ### Bug Fixes -* reset password regression ([#1574](https://github.com/payloadcms/payload/issues/1574)) ([396ea0b](https://github.com/payloadcms/payload/commit/396ea0bd53dc9e1ae1e348d6fe1eb3c36232b35b)) +- reset password regression ([#1574](https://github.com/payloadcms/payload/issues/1574)) ([396ea0b](https://github.com/payloadcms/payload/commit/396ea0bd53dc9e1ae1e348d6fe1eb3c36232b35b)) ## [1.2.2](https://github.com/payloadcms/payload/compare/v1.2.1...v1.2.2) (2022-12-02) - ### Bug Fixes -* adds contain operators for text/email/radio fields ([4c37af6](https://github.com/payloadcms/payload/commit/4c37af6f10dcfd77b5aec963bc5f84a178942143)) -* adjusts how limit is set, both in options and paginates limit ([a718010](https://github.com/payloadcms/payload/commit/a71801006cbc4b989d5057a5f04e8e8e0a6dbeed)) -* aligns mongoose PaginatedDocs type with actual lib type ([dce2081](https://github.com/payloadcms/payload/commit/dce208166337a8e47cc41301c9c5be0854199eaa)) -* allows for form controlled relationship fields to be populated ([e4435bb](https://github.com/payloadcms/payload/commit/e4435bb8bd13fd7122124fb6e171f4bd1cce819c)) -* allows for limit bypass on version find operations ([891f00d](https://github.com/payloadcms/payload/commit/891f00d05cd57d9387dd25be81daa3de99e315ed)) -* blockName grows in all browsers ([03c2ab5](https://github.com/payloadcms/payload/commit/03c2ab52a89817e94ec9a7b4339e807d995e04f6)) -* corrects skipValidation ([e6f1c6f](https://github.com/payloadcms/payload/commit/e6f1c6fc7bb56fe5a858b405c3bf799a46ac57f4)) -* dynamic relationship filterOptions ([99c1f41](https://github.com/payloadcms/payload/commit/99c1f41e306a11547965fd938fa5607787243003)) -* ensures enums cannot query on partial matches ([ec51929](https://github.com/payloadcms/payload/commit/ec51929b1af0b2c1138aa315d106b52f7e771779)) -* german translation optimizations ([#1485](https://github.com/payloadcms/payload/issues/1485)) ([e9d2163](https://github.com/payloadcms/payload/commit/e9d21636011ac084fa26ffbea199fc766fe19b25)) -* handle multiple locales in relationship population ([#1452](https://github.com/payloadcms/payload/issues/1452)) ([04c689c](https://github.com/payloadcms/payload/commit/04c689c5b04bc91020eb682b97721eba213836d2)) -* **i18n:** requiresAtLeast variable in de.json ([#1556](https://github.com/payloadcms/payload/issues/1556)) ([47fd0d9](https://github.com/payloadcms/payload/commit/47fd0d9ec4aa62335d505a0bfba0305355a318ca)) -* ignore validation when unpublishing, do not allow restore with invalid form state ([77ab542](https://github.com/payloadcms/payload/commit/77ab54243ab1857f4f430be4f8c4dc51e15f94ca)) -* indexSortableFields timestamp fields [#1506](https://github.com/payloadcms/payload/issues/1506) ([#1537](https://github.com/payloadcms/payload/issues/1537)) ([7aada3c](https://github.com/payloadcms/payload/commit/7aada3c746603b91bbb4fadf953f36e23fba5121)) -* infinite rerenders, accounts for hasMany false ([16d00e8](https://github.com/payloadcms/payload/commit/16d00e87c2f8b63e695e46ccbf279ad90621dc17)) -* moves relationship field useEffect into async reducer action ([54ef40a](https://github.com/payloadcms/payload/commit/54ef40a335905f7295f847c68762f7fe06bccc30)) -* moves sharp types from devDeps to deps ([b3d526b](https://github.com/payloadcms/payload/commit/b3d526b59a275a1f58a76322a588ba8a6370f26b)) -* reverts async reducer and resolves infinite effect ([a9da81f](https://github.com/payloadcms/payload/commit/a9da81f18cf9e6eba67187a3a2735b267949e0ae)) -* sanitize number query params before passing to find operation ([c8d1b9f](https://github.com/payloadcms/payload/commit/c8d1b9f88af62ad1ab927ca3d035fa4c031989f1)) -* translate select field option labels ([#1476](https://github.com/payloadcms/payload/issues/1476)) ([3a9dc9e](https://github.com/payloadcms/payload/commit/3a9dc9ef68374692c3314651bee6e1b00ae55f17)) -* update drafts includes latest version changes ([48989d0](https://github.com/payloadcms/payload/commit/48989d0f6ed086dc60dc94165a4e0ca8120f9b1a)) -* updates code field css ([3eebd66](https://github.com/payloadcms/payload/commit/3eebd6613f66f3cac38e00cfd94e80b2999cf791)) -* updates syntax colors for light theme ([dbfe7ca](https://github.com/payloadcms/payload/commit/dbfe7ca6e61e3a93baabc378f52835af9e53fd38)) -* uses baseClass in code field ([d03f0ae](https://github.com/payloadcms/payload/commit/d03f0aef8423597aceb36ddbbb1cc63033d0066d)) - +- adds contain operators for text/email/radio fields ([4c37af6](https://github.com/payloadcms/payload/commit/4c37af6f10dcfd77b5aec963bc5f84a178942143)) +- adjusts how limit is set, both in options and paginates limit ([a718010](https://github.com/payloadcms/payload/commit/a71801006cbc4b989d5057a5f04e8e8e0a6dbeed)) +- aligns mongoose PaginatedDocs type with actual lib type ([dce2081](https://github.com/payloadcms/payload/commit/dce208166337a8e47cc41301c9c5be0854199eaa)) +- allows for form controlled relationship fields to be populated ([e4435bb](https://github.com/payloadcms/payload/commit/e4435bb8bd13fd7122124fb6e171f4bd1cce819c)) +- allows for limit bypass on version find operations ([891f00d](https://github.com/payloadcms/payload/commit/891f00d05cd57d9387dd25be81daa3de99e315ed)) +- blockName grows in all browsers ([03c2ab5](https://github.com/payloadcms/payload/commit/03c2ab52a89817e94ec9a7b4339e807d995e04f6)) +- corrects skipValidation ([e6f1c6f](https://github.com/payloadcms/payload/commit/e6f1c6fc7bb56fe5a858b405c3bf799a46ac57f4)) +- dynamic relationship filterOptions ([99c1f41](https://github.com/payloadcms/payload/commit/99c1f41e306a11547965fd938fa5607787243003)) +- ensures enums cannot query on partial matches ([ec51929](https://github.com/payloadcms/payload/commit/ec51929b1af0b2c1138aa315d106b52f7e771779)) +- german translation optimizations ([#1485](https://github.com/payloadcms/payload/issues/1485)) ([e9d2163](https://github.com/payloadcms/payload/commit/e9d21636011ac084fa26ffbea199fc766fe19b25)) +- handle multiple locales in relationship population ([#1452](https://github.com/payloadcms/payload/issues/1452)) ([04c689c](https://github.com/payloadcms/payload/commit/04c689c5b04bc91020eb682b97721eba213836d2)) +- **i18n:** requiresAtLeast variable in de.json ([#1556](https://github.com/payloadcms/payload/issues/1556)) ([47fd0d9](https://github.com/payloadcms/payload/commit/47fd0d9ec4aa62335d505a0bfba0305355a318ca)) +- ignore validation when unpublishing, do not allow restore with invalid form state ([77ab542](https://github.com/payloadcms/payload/commit/77ab54243ab1857f4f430be4f8c4dc51e15f94ca)) +- indexSortableFields timestamp fields [#1506](https://github.com/payloadcms/payload/issues/1506) ([#1537](https://github.com/payloadcms/payload/issues/1537)) ([7aada3c](https://github.com/payloadcms/payload/commit/7aada3c746603b91bbb4fadf953f36e23fba5121)) +- infinite rerenders, accounts for hasMany false ([16d00e8](https://github.com/payloadcms/payload/commit/16d00e87c2f8b63e695e46ccbf279ad90621dc17)) +- moves relationship field useEffect into async reducer action ([54ef40a](https://github.com/payloadcms/payload/commit/54ef40a335905f7295f847c68762f7fe06bccc30)) +- moves sharp types from devDeps to deps ([b3d526b](https://github.com/payloadcms/payload/commit/b3d526b59a275a1f58a76322a588ba8a6370f26b)) +- reverts async reducer and resolves infinite effect ([a9da81f](https://github.com/payloadcms/payload/commit/a9da81f18cf9e6eba67187a3a2735b267949e0ae)) +- sanitize number query params before passing to find operation ([c8d1b9f](https://github.com/payloadcms/payload/commit/c8d1b9f88af62ad1ab927ca3d035fa4c031989f1)) +- translate select field option labels ([#1476](https://github.com/payloadcms/payload/issues/1476)) ([3a9dc9e](https://github.com/payloadcms/payload/commit/3a9dc9ef68374692c3314651bee6e1b00ae55f17)) +- update drafts includes latest version changes ([48989d0](https://github.com/payloadcms/payload/commit/48989d0f6ed086dc60dc94165a4e0ca8120f9b1a)) +- updates code field css ([3eebd66](https://github.com/payloadcms/payload/commit/3eebd6613f66f3cac38e00cfd94e80b2999cf791)) +- updates syntax colors for light theme ([dbfe7ca](https://github.com/payloadcms/payload/commit/dbfe7ca6e61e3a93baabc378f52835af9e53fd38)) +- uses baseClass in code field ([d03f0ae](https://github.com/payloadcms/payload/commit/d03f0aef8423597aceb36ddbbb1cc63033d0066d)) ### Features -* decouples limit from pagination, allows for no limit query ([f7ce0c6](https://github.com/payloadcms/payload/commit/f7ce0c615d76035ee48ef32047613ab1415deb44)) -* improve typescript comments ([#1467](https://github.com/payloadcms/payload/issues/1467)) ([5bd8657](https://github.com/payloadcms/payload/commit/5bd86571cada5791003bbfa84183f5b300649533)) -* log email transport error messages ([#1469](https://github.com/payloadcms/payload/issues/1469)) ([a90a1a9](https://github.com/payloadcms/payload/commit/a90a1a9e19bb54eb6d88129b5e2cb6483e22db61)) -* removes theme provider and updates background for code fields ([1a6c9a3](https://github.com/payloadcms/payload/commit/1a6c9a3e181930a6f45027fecc5313e8d7228c71)) +- decouples limit from pagination, allows for no limit query ([f7ce0c6](https://github.com/payloadcms/payload/commit/f7ce0c615d76035ee48ef32047613ab1415deb44)) +- improve typescript comments ([#1467](https://github.com/payloadcms/payload/issues/1467)) ([5bd8657](https://github.com/payloadcms/payload/commit/5bd86571cada5791003bbfa84183f5b300649533)) +- log email transport error messages ([#1469](https://github.com/payloadcms/payload/issues/1469)) ([a90a1a9](https://github.com/payloadcms/payload/commit/a90a1a9e19bb54eb6d88129b5e2cb6483e22db61)) +- removes theme provider and updates background for code fields ([1a6c9a3](https://github.com/payloadcms/payload/commit/1a6c9a3e181930a6f45027fecc5313e8d7228c71)) ## [1.2.1](https://github.com/payloadcms/payload/compare/v1.2.0...v1.2.1) (2022-11-22) - ### Bug Fixes -* adjusts styles to allow error bg to fill textarea ([2e57b76](https://github.com/payloadcms/payload/commit/2e57b76df01acf7ed1ce5fcb824ef5f96d11621d)) -* allows patching global drafts [#1415](https://github.com/payloadcms/payload/issues/1415) ([25822a9](https://github.com/payloadcms/payload/commit/25822a91b1e4f2bf4804f15947d211138d696219)) -* dynamically sets stepnav from default edit view ([40c8778](https://github.com/payloadcms/payload/commit/40c87784b0c6281c599b6d2a46a27b70b0568c30)) -* ensures drafts operations saves as draft [#1415](https://github.com/payloadcms/payload/issues/1415) ([fc16ffe](https://github.com/payloadcms/payload/commit/fc16ffefdb354ea023462d784cdac7ab6fcc26d3)) -* flattens locales before versioning published docs [#1415](https://github.com/payloadcms/payload/issues/1415) ([f700f51](https://github.com/payloadcms/payload/commit/f700f51f2bcdd657d1fab6b6d83ac00a11ed870d)) -* **i18n:** version count ([#1465](https://github.com/payloadcms/payload/issues/1465)) ([075b7e9](https://github.com/payloadcms/payload/commit/075b7e9f02498ea253cf270654dcce0f11ec1f93)) -* Increase textarea click area ([c303913](https://github.com/payloadcms/payload/commit/c303913e61881a3b0d90615dda905b20347d6f1e)) -* invalid query string user account request ([#1478](https://github.com/payloadcms/payload/issues/1478)) ([400cb9b](https://github.com/payloadcms/payload/commit/400cb9b6bcfd09c39cb6aa438daad876d12e8e13)) -* removes incorrectly import/export option type - [#1441](https://github.com/payloadcms/payload/issues/1441) ([ed01a17](https://github.com/payloadcms/payload/commit/ed01a176210a02a32874f4d0d1c5206d9a772e7e)) -* rendering of localized select value ([1d1d249](https://github.com/payloadcms/payload/commit/1d1d2493aa08db4c300c01e72ccb6c11e03f9e09)) -* sanitizes select values on the server, allowing isClearable selects to be cleared without error ([699ca14](https://github.com/payloadcms/payload/commit/699ca14434eeff3025cffd3f6e00efada80e021f)) -* translate version comparison view field labels ([#1470](https://github.com/payloadcms/payload/issues/1470)) ([8123585](https://github.com/payloadcms/payload/commit/8123585592b9a53ef746f17476b36a2661cca025)) -* versionCount was broken & other i18n improvements ([#1450](https://github.com/payloadcms/payload/issues/1450)) ([078c28b](https://github.com/payloadcms/payload/commit/078c28bd5fd08fd17a0b0b360e904f51fe8a2e98)) -* versions tests ([af6a7aa](https://github.com/payloadcms/payload/commit/af6a7aa9e850c0817ea40d755f51255ccf0938c2)) - +- adjusts styles to allow error bg to fill textarea ([2e57b76](https://github.com/payloadcms/payload/commit/2e57b76df01acf7ed1ce5fcb824ef5f96d11621d)) +- allows patching global drafts [#1415](https://github.com/payloadcms/payload/issues/1415) ([25822a9](https://github.com/payloadcms/payload/commit/25822a91b1e4f2bf4804f15947d211138d696219)) +- dynamically sets stepnav from default edit view ([40c8778](https://github.com/payloadcms/payload/commit/40c87784b0c6281c599b6d2a46a27b70b0568c30)) +- ensures drafts operations saves as draft [#1415](https://github.com/payloadcms/payload/issues/1415) ([fc16ffe](https://github.com/payloadcms/payload/commit/fc16ffefdb354ea023462d784cdac7ab6fcc26d3)) +- flattens locales before versioning published docs [#1415](https://github.com/payloadcms/payload/issues/1415) ([f700f51](https://github.com/payloadcms/payload/commit/f700f51f2bcdd657d1fab6b6d83ac00a11ed870d)) +- **i18n:** version count ([#1465](https://github.com/payloadcms/payload/issues/1465)) ([075b7e9](https://github.com/payloadcms/payload/commit/075b7e9f02498ea253cf270654dcce0f11ec1f93)) +- Increase textarea click area ([c303913](https://github.com/payloadcms/payload/commit/c303913e61881a3b0d90615dda905b20347d6f1e)) +- invalid query string user account request ([#1478](https://github.com/payloadcms/payload/issues/1478)) ([400cb9b](https://github.com/payloadcms/payload/commit/400cb9b6bcfd09c39cb6aa438daad876d12e8e13)) +- removes incorrectly import/export option type - [#1441](https://github.com/payloadcms/payload/issues/1441) ([ed01a17](https://github.com/payloadcms/payload/commit/ed01a176210a02a32874f4d0d1c5206d9a772e7e)) +- rendering of localized select value ([1d1d249](https://github.com/payloadcms/payload/commit/1d1d2493aa08db4c300c01e72ccb6c11e03f9e09)) +- sanitizes select values on the server, allowing isClearable selects to be cleared without error ([699ca14](https://github.com/payloadcms/payload/commit/699ca14434eeff3025cffd3f6e00efada80e021f)) +- translate version comparison view field labels ([#1470](https://github.com/payloadcms/payload/issues/1470)) ([8123585](https://github.com/payloadcms/payload/commit/8123585592b9a53ef746f17476b36a2661cca025)) +- versionCount was broken & other i18n improvements ([#1450](https://github.com/payloadcms/payload/issues/1450)) ([078c28b](https://github.com/payloadcms/payload/commit/078c28bd5fd08fd17a0b0b360e904f51fe8a2e98)) +- versions tests ([af6a7aa](https://github.com/payloadcms/payload/commit/af6a7aa9e850c0817ea40d755f51255ccf0938c2)) ### Features -* add i18n to option labels in version comparison ([#1477](https://github.com/payloadcms/payload/issues/1477)) ([7b6a9ed](https://github.com/payloadcms/payload/commit/7b6a9ede6e3a72e7e64358cb88946b16153d8dc6)) -* exports field types properly ([7c6d6fd](https://github.com/payloadcms/payload/commit/7c6d6fd1caeb25e1a871fa1b9cecc53be8a2a7a1)) +- add i18n to option labels in version comparison ([#1477](https://github.com/payloadcms/payload/issues/1477)) ([7b6a9ed](https://github.com/payloadcms/payload/commit/7b6a9ede6e3a72e7e64358cb88946b16153d8dc6)) +- exports field types properly ([7c6d6fd](https://github.com/payloadcms/payload/commit/7c6d6fd1caeb25e1a871fa1b9cecc53be8a2a7a1)) # [1.2.0](https://github.com/payloadcms/payload/compare/v1.1.26...v1.2.0) (2022-11-18) - ### 🐛 Bug Fixes -* build errors ([65f0e1c](https://github.com/payloadcms/payload/commit/65f0e1caace193f034139e331883d01d8eb92d2c)) -* components optional chaining ([d5e725c](https://github.com/payloadcms/payload/commit/d5e725c608588e96b974291fa86d5e89dea9060d)) -* corrects exported custom component type ([2878b4b](https://github.com/payloadcms/payload/commit/2878b4b1bec5c0c9997c1ba2a080640d4d3f8e5f)) -* corrects type for CollapsibleLabel example type, adjusts custom component filenames ([ccb4231](https://github.com/payloadcms/payload/commit/ccb42319abf0679d998e15b6b47fff3ce95d4ca1)) -* sets pointer-events to none so the entire label bar is clickable ([e458087](https://github.com/payloadcms/payload/commit/e458087a55cbbad29ca3568ca4c089aaee49693a)) - +- build errors ([65f0e1c](https://github.com/payloadcms/payload/commit/65f0e1caace193f034139e331883d01d8eb92d2c)) +- components optional chaining ([d5e725c](https://github.com/payloadcms/payload/commit/d5e725c608588e96b974291fa86d5e89dea9060d)) +- corrects exported custom component type ([2878b4b](https://github.com/payloadcms/payload/commit/2878b4b1bec5c0c9997c1ba2a080640d4d3f8e5f)) +- corrects type for CollapsibleLabel example type, adjusts custom component filenames ([ccb4231](https://github.com/payloadcms/payload/commit/ccb42319abf0679d998e15b6b47fff3ce95d4ca1)) +- sets pointer-events to none so the entire label bar is clickable ([e458087](https://github.com/payloadcms/payload/commit/e458087a55cbbad29ca3568ca4c089aaee49693a)) ### ✨ Features -* add i18n to admin panel ([#1326](https://github.com/payloadcms/payload/issues/1326)) ([bab34d8](https://github.com/payloadcms/payload/commit/bab34d82f5fddad32ceafd116ad97e87cab4c862)) -* adds docs example ([2bf0fff](https://github.com/payloadcms/payload/commit/2bf0fffa0dd83f395aa3318b3baba1e22dd58b51)) -* adds playwright tests for array fields ([57a8c35](https://github.com/payloadcms/payload/commit/57a8c352e44750d1785b65074c15812dc8226585)) -* converts rowHeader to collapsibleLabel, extends data passed to functions/components ([13ec1e0](https://github.com/payloadcms/payload/commit/13ec1e0398d2a9ce1aeddc5692008173acfde45e)) -* customizable header-labels ([d45de99](https://github.com/payloadcms/payload/commit/d45de99956273c59e6d1a3a11c7cce36f3d123f6)) -* simplifies collapsible label API, adds e2e tests ([d9df98f](https://github.com/payloadcms/payload/commit/d9df98ff22041908fc2ce0972c844116edd409be)) -* specifies component names for arrays/collapsibles, simplifies threaded data ([b74ea21](https://github.com/payloadcms/payload/commit/b74ea218ca47ce9db9d20586dbbce73e4ce0f917)) - +- add i18n to admin panel ([#1326](https://github.com/payloadcms/payload/issues/1326)) ([bab34d8](https://github.com/payloadcms/payload/commit/bab34d82f5fddad32ceafd116ad97e87cab4c862)) +- adds docs example ([2bf0fff](https://github.com/payloadcms/payload/commit/2bf0fffa0dd83f395aa3318b3baba1e22dd58b51)) +- adds playwright tests for array fields ([57a8c35](https://github.com/payloadcms/payload/commit/57a8c352e44750d1785b65074c15812dc8226585)) +- converts rowHeader to collapsibleLabel, extends data passed to functions/components ([13ec1e0](https://github.com/payloadcms/payload/commit/13ec1e0398d2a9ce1aeddc5692008173acfde45e)) +- customizable header-labels ([d45de99](https://github.com/payloadcms/payload/commit/d45de99956273c59e6d1a3a11c7cce36f3d123f6)) +- simplifies collapsible label API, adds e2e tests ([d9df98f](https://github.com/payloadcms/payload/commit/d9df98ff22041908fc2ce0972c844116edd409be)) +- specifies component names for arrays/collapsibles, simplifies threaded data ([b74ea21](https://github.com/payloadcms/payload/commit/b74ea218ca47ce9db9d20586dbbce73e4ce0f917)) ### 🚨 BREAKING CHANGES -* You ***might*** need to update your config. This change affects `collections`, `globals` and `block fields` with custom labeling. - * **Collections:** are affected if you have a custom `labels.singular` defined that differs from your collection slug. +- You **_might_** need to update your config. This change affects `collections`, `globals` and `block fields` with custom labeling. + + - **Collections:** are affected if you have a custom `labels.singular` defined that differs from your collection slug. + ```typescript // ExampleCollection.ts // Before const ExampleCollection: CollectionConfig = { - slug: 'case-studies', + slug: "case-studies", labels: { // Before Payload used `labels.singular` to generate types/graphQL schema - singular: 'Project', - plural: 'Projects', + singular: "Project", + plural: "Projects", }, - } + }; // After const ExampleCollection: CollectionConfig = { // Now Payload uses `slug` to generate types/graphQL schema - slug: 'case-studies', + slug: "case-studies", labels: { - singular: 'Project', - plural: 'Projects', + singular: "Project", + plural: "Projects", }, // To override the usage of slug in graphQL schema generation graphQL: { - singularName: 'Project', - pluralName: 'Projects', + singularName: "Project", + pluralName: "Projects", }, // To override the usage of slug in type file generation typescript: { - interface: 'Project', - } - } + interface: "Project", + }, + }; ``` - * **Globals:** are affected if you have a `label` defined that differs from your global slug. + + - **Globals:** are affected if you have a `label` defined that differs from your global slug. + ```typescript // ExampleGlobal.ts // Before const ExampleGlobal: GlobalConfig = { - slug: 'footer', + slug: "footer", // Before Payload used `label` to generate types/graphQL schema - label: 'Page Footer', - } + label: "Page Footer", + }; // After const ExampleGlobal: GlobalConfig = { // Now Payload uses `slug` to generate types/graphQL schema - slug: 'footer', - label: 'Page Footer', + slug: "footer", + label: "Page Footer", // To override the usage of slug in graphQL schema generation graphQL: { - name: 'PageFooter', + name: "PageFooter", }, // To override the usage of slug in type file generation typescript: { - interface: 'PageFooter', + interface: "PageFooter", }, - } + }; ``` - * **Block Fields:** are affected if you have a `label` defined that differs from your block slug. - ```typescript + + - **Block Fields:** are affected if you have a `label` defined that differs from your block slug. + + ````typescript // ExampleBlock.ts - // Before - const ExampleBlock: Block = { - slug: 'content', - // Before Payload used `label` to generate graphQL schema - label: 'Content Block', - } + // Before + const ExampleBlock: Block = { + slug: 'content', + // Before Payload used `label` to generate graphQL schema + label: 'Content Block', + } + + // After + const ExampleBlock: Block = { + // Now Payload uses `slug` to generate graphQL schema + slug: 'content', + label: 'Content Block', + // To override the usage of slug in graphQL schema generation + graphQL: { + singularName: 'ContentBlock', + }, + } + ``` + + **Breaking changes recap**: + ```` + +* On Collections - // After - const ExampleBlock: Block = { - // Now Payload uses `slug` to generate graphQL schema - slug: 'content', - label: 'Content Block', - // To override the usage of slug in graphQL schema generation - graphQL: { - singularName: 'ContentBlock', - }, - } - ``` -**Breaking changes recap**: -- On Collections - Use `graphQL.singularName`, `graphQL.pluralName` for GraphQL schema names. - Use `typescript.interface` for typescript generation name. -- On Globals +* On Globals + - Use `graphQL.name` for GraphQL Schema name. - Use `typescript.interface` for typescript generation name. -- On Blocks (within Block fields) +* On Blocks (within Block fields) - Use `graphQL.singularName` for graphQL schema names. ## [1.1.26](https://github.com/payloadcms/payload/compare/v1.1.25...v1.1.26) (2022-11-15) - ### Bug Fixes -* [#1414](https://github.com/payloadcms/payload/issues/1414) ([50bcf00](https://github.com/payloadcms/payload/commit/50bcf001ea613c65cfe0545e7257d5b13ca688f3)) +- [#1414](https://github.com/payloadcms/payload/issues/1414) ([50bcf00](https://github.com/payloadcms/payload/commit/50bcf001ea613c65cfe0545e7257d5b13ca688f3)) ## [1.1.25](https://github.com/payloadcms/payload/compare/v1.1.24...v1.1.25) (2022-11-15) - ### Bug Fixes -* add slug to DocumentInfo context ([#1389](https://github.com/payloadcms/payload/issues/1389)) ([4d8cc97](https://github.com/payloadcms/payload/commit/4d8cc97475c73e5131699ef03dca275a17535a25)) -* adds unique key to upload cards to prevent old images being shown while navigating to new page ([5e8a8b2](https://github.com/payloadcms/payload/commit/5e8a8b2df9af435f0df8a8a07dddf7dcc24cf9ac)) -* ensures admin components is defaulted ([d103f6c](https://github.com/payloadcms/payload/commit/d103f6c94f91b5359aea722c2d7781bf144f6a26)) -* global afterRead and afterChange execution ([#1405](https://github.com/payloadcms/payload/issues/1405)) ([cdaa8cc](https://github.com/payloadcms/payload/commit/cdaa8cc29f58308a387375ec41eafd0d38b13bcb)) - +- add slug to DocumentInfo context ([#1389](https://github.com/payloadcms/payload/issues/1389)) ([4d8cc97](https://github.com/payloadcms/payload/commit/4d8cc97475c73e5131699ef03dca275a17535a25)) +- adds unique key to upload cards to prevent old images being shown while navigating to new page ([5e8a8b2](https://github.com/payloadcms/payload/commit/5e8a8b2df9af435f0df8a8a07dddf7dcc24cf9ac)) +- ensures admin components is defaulted ([d103f6c](https://github.com/payloadcms/payload/commit/d103f6c94f91b5359aea722c2d7781bf144f6a26)) +- global afterRead and afterChange execution ([#1405](https://github.com/payloadcms/payload/issues/1405)) ([cdaa8cc](https://github.com/payloadcms/payload/commit/cdaa8cc29f58308a387375ec41eafd0d38b13bcb)) ### Features -* admin UI logout extensibility ([#1274](https://github.com/payloadcms/payload/issues/1274)) ([a345ef0](https://github.com/payloadcms/payload/commit/a345ef0d3179000a2930f8b09886e06fd0801d21)) -* let textarea grow based on value ([#1398](https://github.com/payloadcms/payload/issues/1398)) ([0f27b10](https://github.com/payloadcms/payload/commit/0f27b103b44935480b8ffe17427fc5ed05b92446)) -* saves tab index to user preferences ([5eb8e4a](https://github.com/payloadcms/payload/commit/5eb8e4a28f34a1c51790d4eabfb21606b7fb41c6)) +- admin UI logout extensibility ([#1274](https://github.com/payloadcms/payload/issues/1274)) ([a345ef0](https://github.com/payloadcms/payload/commit/a345ef0d3179000a2930f8b09886e06fd0801d21)) +- let textarea grow based on value ([#1398](https://github.com/payloadcms/payload/issues/1398)) ([0f27b10](https://github.com/payloadcms/payload/commit/0f27b103b44935480b8ffe17427fc5ed05b92446)) +- saves tab index to user preferences ([5eb8e4a](https://github.com/payloadcms/payload/commit/5eb8e4a28f34a1c51790d4eabfb21606b7fb41c6)) ## [1.1.24](https://github.com/payloadcms/payload/compare/v1.1.23...v1.1.24) (2022-11-14) - ### Bug Fixes -* cursor jumping while typing in inputs ([216b9f8](https://github.com/payloadcms/payload/commit/216b9f88d988c692d6acdf920ee4dbb9903020ae)), closes [#1393](https://github.com/payloadcms/payload/issues/1393) +- cursor jumping while typing in inputs ([216b9f8](https://github.com/payloadcms/payload/commit/216b9f88d988c692d6acdf920ee4dbb9903020ae)), closes [#1393](https://github.com/payloadcms/payload/issues/1393) ## [1.1.23](https://github.com/payloadcms/payload/compare/v1.1.22...v1.1.23) (2022-11-12) - ### Bug Fixes -* [#1361](https://github.com/payloadcms/payload/issues/1361), ensures collection auth depth works while retrieving static assets ([2f68404](https://github.com/payloadcms/payload/commit/2f684040fc9ca717d48b0d95cbd3468c35973993)) - +- [#1361](https://github.com/payloadcms/payload/issues/1361), ensures collection auth depth works while retrieving static assets ([2f68404](https://github.com/payloadcms/payload/commit/2f684040fc9ca717d48b0d95cbd3468c35973993)) ### Features -* optimizes field performance by storing internal values in useField hook ([66210b8](https://github.com/payloadcms/payload/commit/66210b856b97139f9959fac47154bca44f0a4de0)) +- optimizes field performance by storing internal values in useField hook ([66210b8](https://github.com/payloadcms/payload/commit/66210b856b97139f9959fac47154bca44f0a4de0)) ## [1.1.22](https://github.com/payloadcms/payload/compare/v1.1.21...v1.1.22) (2022-11-12) - ### Bug Fixes -* [#1353](https://github.com/payloadcms/payload/issues/1353), ensures errors returned from server make their way to UI ([3f28a69](https://github.com/payloadcms/payload/commit/3f28a69959be9c98869f81bcd379b8c7cd505a12)) -* [#1357](https://github.com/payloadcms/payload/issues/1357), nested arrays and blocks sometimes not allowing save ([86855d6](https://github.com/payloadcms/payload/commit/86855d68f65dfadbf51050bdaf6a28c3220add6f)) -* [#1358](https://github.com/payloadcms/payload/issues/1358), allows listSearchableFields to work when indicated fields are nested ([eb0023e](https://github.com/payloadcms/payload/commit/eb0023e9617894873fe75748de187d85279498c8)) -* [#1360](https://github.com/payloadcms/payload/issues/1360), relationship field onMenuScrollToBottom not working in some browsers ([7136db4](https://github.com/payloadcms/payload/commit/7136db4c718b70833fa75f5c8e9ae596298b3aa9)) -* [#1367](https://github.com/payloadcms/payload/issues/1367), allows custom global components within schema validation ([1d76e97](https://github.com/payloadcms/payload/commit/1d76e973bb8e6e33e40b469bd410042ae4b90e2e)) -* 1309, duplicative logout in admin UI ([35f91b0](https://github.com/payloadcms/payload/commit/35f91b038b66d74468dad250dbe7cbf1ea88b444)) -* fixed GraphQL Access query resolver to return the correct data ([#1339](https://github.com/payloadcms/payload/issues/1339)) ([cfef68f](https://github.com/payloadcms/payload/commit/cfef68f36477e34b9943d9334c65fa46ee3eb339)) +- [#1353](https://github.com/payloadcms/payload/issues/1353), ensures errors returned from server make their way to UI ([3f28a69](https://github.com/payloadcms/payload/commit/3f28a69959be9c98869f81bcd379b8c7cd505a12)) +- [#1357](https://github.com/payloadcms/payload/issues/1357), nested arrays and blocks sometimes not allowing save ([86855d6](https://github.com/payloadcms/payload/commit/86855d68f65dfadbf51050bdaf6a28c3220add6f)) +- [#1358](https://github.com/payloadcms/payload/issues/1358), allows listSearchableFields to work when indicated fields are nested ([eb0023e](https://github.com/payloadcms/payload/commit/eb0023e9617894873fe75748de187d85279498c8)) +- [#1360](https://github.com/payloadcms/payload/issues/1360), relationship field onMenuScrollToBottom not working in some browsers ([7136db4](https://github.com/payloadcms/payload/commit/7136db4c718b70833fa75f5c8e9ae596298b3aa9)) +- [#1367](https://github.com/payloadcms/payload/issues/1367), allows custom global components within schema validation ([1d76e97](https://github.com/payloadcms/payload/commit/1d76e973bb8e6e33e40b469bd410042ae4b90e2e)) +- 1309, duplicative logout in admin UI ([35f91b0](https://github.com/payloadcms/payload/commit/35f91b038b66d74468dad250dbe7cbf1ea88b444)) +- fixed GraphQL Access query resolver to return the correct data ([#1339](https://github.com/payloadcms/payload/issues/1339)) ([cfef68f](https://github.com/payloadcms/payload/commit/cfef68f36477e34b9943d9334c65fa46ee3eb339)) ## [1.1.21](https://github.com/payloadcms/payload/compare/v1.1.20...v1.1.21) (2022-11-05) ## [1.1.20](https://github.com/payloadcms/payload/compare/v1.1.19...v1.1.20) (2022-11-05) - ### Features -* optimizes blocks and arrays by removing some additional rerenders ([483adf0](https://github.com/payloadcms/payload/commit/483adf08c4131d0401e47ec45d72200b9dc60de2)) +- optimizes blocks and arrays by removing some additional rerenders ([483adf0](https://github.com/payloadcms/payload/commit/483adf08c4131d0401e47ec45d72200b9dc60de2)) ## [1.1.19](https://github.com/payloadcms/payload/compare/v1.1.18...v1.1.19) (2022-10-31) - ### Bug Fixes -* [#1307](https://github.com/payloadcms/payload/issues/1307), [#1321](https://github.com/payloadcms/payload/issues/1321) - bug with disableFormData and blocks field ([2a09f15](https://github.com/payloadcms/payload/commit/2a09f15a158ff30e89c5454f81aa140448f15d30)) -* [#1311](https://github.com/payloadcms/payload/issues/1311), select existing upload modal always updates state ([e2ec2f7](https://github.com/payloadcms/payload/commit/e2ec2f7b97ed308c4ff7deefbc58cf0df6ff0602)) -* [#1318](https://github.com/payloadcms/payload/issues/1318), improves popup positioning and logic ([c651835](https://github.com/payloadcms/payload/commit/c6518350617d14818dfc537b5b0a147274c1119b)) -* custom pino logger options ([#1299](https://github.com/payloadcms/payload/issues/1299)) ([2500026](https://github.com/payloadcms/payload/commit/25000261bd6ecb0f05ae79de9a0693078a0e3e0d)) +- [#1307](https://github.com/payloadcms/payload/issues/1307), [#1321](https://github.com/payloadcms/payload/issues/1321) - bug with disableFormData and blocks field ([2a09f15](https://github.com/payloadcms/payload/commit/2a09f15a158ff30e89c5454f81aa140448f15d30)) +- [#1311](https://github.com/payloadcms/payload/issues/1311), select existing upload modal always updates state ([e2ec2f7](https://github.com/payloadcms/payload/commit/e2ec2f7b97ed308c4ff7deefbc58cf0df6ff0602)) +- [#1318](https://github.com/payloadcms/payload/issues/1318), improves popup positioning and logic ([c651835](https://github.com/payloadcms/payload/commit/c6518350617d14818dfc537b5b0a147274c1119b)) +- custom pino logger options ([#1299](https://github.com/payloadcms/payload/issues/1299)) ([2500026](https://github.com/payloadcms/payload/commit/25000261bd6ecb0f05ae79de9a0693078a0e3e0d)) ## [1.1.18](https://github.com/payloadcms/payload/compare/v1.1.17...v1.1.18) (2022-10-25) ## [1.1.17](https://github.com/payloadcms/payload/compare/v1.1.16...v1.1.17) (2022-10-25) - ### Bug Fixes -* [#1286](https://github.com/payloadcms/payload/issues/1286), uses defaultDepth in graphql rich text depth ([66bf8c3](https://github.com/payloadcms/payload/commit/66bf8c3cbd080ee5a28b7af521d427d3aae59ba2)) -* [#1290](https://github.com/payloadcms/payload/issues/1290), renders more than one rich text leaf where applicable ([a9f2f0e](https://github.com/payloadcms/payload/commit/a9f2f0ec03383ef4c3ef3ba98274b0abaaf962ed)) -* [#1291](https://github.com/payloadcms/payload/issues/1291), add inline relationship drafts ([3967c12](https://github.com/payloadcms/payload/commit/3967c1233fda00b48e9df15276502a6b14b737ff)) -* enforces depth: 0 in graphql resolvers ([3301f59](https://github.com/payloadcms/payload/commit/3301f598223d517ac310909bb74e455891c27693)) -* ensures field updates when disableFormData changes ([c929725](https://github.com/payloadcms/payload/commit/c929725dd565de08871dad655442ee9ac4f29dd5)) -* group + group styles within collapsible ([17dbbc7](https://github.com/payloadcms/payload/commit/17dbbc77757a7cd6e517bac443859561fee86e32)) - +- [#1286](https://github.com/payloadcms/payload/issues/1286), uses defaultDepth in graphql rich text depth ([66bf8c3](https://github.com/payloadcms/payload/commit/66bf8c3cbd080ee5a28b7af521d427d3aae59ba2)) +- [#1290](https://github.com/payloadcms/payload/issues/1290), renders more than one rich text leaf where applicable ([a9f2f0e](https://github.com/payloadcms/payload/commit/a9f2f0ec03383ef4c3ef3ba98274b0abaaf962ed)) +- [#1291](https://github.com/payloadcms/payload/issues/1291), add inline relationship drafts ([3967c12](https://github.com/payloadcms/payload/commit/3967c1233fda00b48e9df15276502a6b14b737ff)) +- enforces depth: 0 in graphql resolvers ([3301f59](https://github.com/payloadcms/payload/commit/3301f598223d517ac310909bb74e455891c27693)) +- ensures field updates when disableFormData changes ([c929725](https://github.com/payloadcms/payload/commit/c929725dd565de08871dad655442ee9ac4f29dd5)) +- group + group styles within collapsible ([17dbbc7](https://github.com/payloadcms/payload/commit/17dbbc77757a7cd6e517bac443859561fee86e32)) ### Features -* added beforeLogin hook ([#1289](https://github.com/payloadcms/payload/issues/1289)) ([09d7939](https://github.com/payloadcms/payload/commit/09d793926dbb642bbcb6ab975735d069df355a8a)) -* adds default max length for text-based fields ([6a1b25a](https://github.com/payloadcms/payload/commit/6a1b25ab302cbdf7f312012b29b78288815810af)) -* specify node 14+ and yarn classic LTS ([#1240](https://github.com/payloadcms/payload/issues/1240)) ([9181477](https://github.com/payloadcms/payload/commit/91814777b0bf3830c4a468b76783ff6f42ad824a)) +- added beforeLogin hook ([#1289](https://github.com/payloadcms/payload/issues/1289)) ([09d7939](https://github.com/payloadcms/payload/commit/09d793926dbb642bbcb6ab975735d069df355a8a)) +- adds default max length for text-based fields ([6a1b25a](https://github.com/payloadcms/payload/commit/6a1b25ab302cbdf7f312012b29b78288815810af)) +- specify node 14+ and yarn classic LTS ([#1240](https://github.com/payloadcms/payload/issues/1240)) ([9181477](https://github.com/payloadcms/payload/commit/91814777b0bf3830c4a468b76783ff6f42ad824a)) ## [1.1.16](https://github.com/payloadcms/payload/compare/v1.1.15...v1.1.16) (2022-10-21) - ### Bug Fixes -* indexSortableFields not respected ([785b992](https://github.com/payloadcms/payload/commit/785b992c3ea31f7818f1c87c816b8b8de644851d)) -* obscure bug where upload collection has upload field relating to itself ([36ef378](https://github.com/payloadcms/payload/commit/36ef3789fbe00cafe8b3587d6c370e28efd5a187)) +- indexSortableFields not respected ([785b992](https://github.com/payloadcms/payload/commit/785b992c3ea31f7818f1c87c816b8b8de644851d)) +- obscure bug where upload collection has upload field relating to itself ([36ef378](https://github.com/payloadcms/payload/commit/36ef3789fbe00cafe8b3587d6c370e28efd5a187)) ## [1.1.15](https://github.com/payloadcms/payload/compare/v1.1.14...v1.1.15) (2022-10-14) - ### Bug Fixes -* ensures svg mime type is always image/svg+xml ([0b0d971](https://github.com/payloadcms/payload/commit/0b0d9714917b1a56fb899a053e2e35c878a00992)) +- ensures svg mime type is always image/svg+xml ([0b0d971](https://github.com/payloadcms/payload/commit/0b0d9714917b1a56fb899a053e2e35c878a00992)) ## [1.1.14](https://github.com/payloadcms/payload/compare/v1.1.13...v1.1.14) (2022-10-14) ## [1.1.11](https://github.com/payloadcms/payload/compare/v1.1.10...v1.1.11) (2022-10-12) - ### Bug Fixes -* ensures arrays and blocks mount as disableFormData: true, fixes [#1242](https://github.com/payloadcms/payload/issues/1242) ([5ca5aba](https://github.com/payloadcms/payload/commit/5ca5abab422ad1cdb1b449a8298f439c57dda464)) - +- ensures arrays and blocks mount as disableFormData: true, fixes [#1242](https://github.com/payloadcms/payload/issues/1242) ([5ca5aba](https://github.com/payloadcms/payload/commit/5ca5abab422ad1cdb1b449a8298f439c57dda464)) ### Features -* builds beforeDuplicate admin hook, closes [#1243](https://github.com/payloadcms/payload/issues/1243) ([6f6f2f8](https://github.com/payloadcms/payload/commit/6f6f2f8e7b83821ae2f2d30d08460439746cc0c6)) +- builds beforeDuplicate admin hook, closes [#1243](https://github.com/payloadcms/payload/issues/1243) ([6f6f2f8](https://github.com/payloadcms/payload/commit/6f6f2f8e7b83821ae2f2d30d08460439746cc0c6)) ## [1.1.10](https://github.com/payloadcms/payload/compare/v1.1.9...v1.1.10) (2022-10-11) ## [1.1.9](https://github.com/payloadcms/payload/compare/v1.1.8...v1.1.9) (2022-10-11) - ### Features -* improves access control typing ([5322ada](https://github.com/payloadcms/payload/commit/5322ada9e690544c4864abba202a14ec1f2f5e9d)) +- improves access control typing ([5322ada](https://github.com/payloadcms/payload/commit/5322ada9e690544c4864abba202a14ec1f2f5e9d)) ## [1.1.8](https://github.com/payloadcms/payload/compare/v1.1.7...v1.1.8) (2022-10-11) - ### Features -* adds ability to create related docs while editing another ([1e048fe](https://github.com/payloadcms/payload/commit/1e048fe03787577fe4d584cec9c2d7c78bc90a17)) -* implements use-context-selector for form field access ([5c1a3fa](https://github.com/payloadcms/payload/commit/5c1a3fabeef48b78f173af084f9117515e1297ba)) +- adds ability to create related docs while editing another ([1e048fe](https://github.com/payloadcms/payload/commit/1e048fe03787577fe4d584cec9c2d7c78bc90a17)) +- implements use-context-selector for form field access ([5c1a3fa](https://github.com/payloadcms/payload/commit/5c1a3fabeef48b78f173af084f9117515e1297ba)) ## [1.1.7](https://github.com/payloadcms/payload/compare/v1.1.6...v1.1.7) (2022-10-06) ## [1.1.6](https://github.com/payloadcms/payload/compare/v1.1.5...v1.1.6) (2022-10-06) - ### Bug Fixes -* [#1184](https://github.com/payloadcms/payload/issues/1184) ([c2ec54a](https://github.com/payloadcms/payload/commit/c2ec54a7cbd8cd94bcd4a68d885e35986fec7f18)) -* [#1189](https://github.com/payloadcms/payload/issues/1189) ([3641dfd](https://github.com/payloadcms/payload/commit/3641dfd38a147b24e0e3ef93a125b12ad7763f66)) -* [#1204](https://github.com/payloadcms/payload/issues/1204) ([b4becd1](https://github.com/payloadcms/payload/commit/b4becd1493d55aae887008ab573ab710c400103a)) -* [#940](https://github.com/payloadcms/payload/issues/940) ([7926083](https://github.com/payloadcms/payload/commit/7926083732fbaec78d87f67742cdbd8bd00cd48a)) -* ajusts how disabled states are being set on anchors and buttons ([00ef170](https://github.com/payloadcms/payload/commit/00ef1700ae41e68ff0831a587bf3f09fe6c2c966)) -* remove min-width from fileupload ([73848b6](https://github.com/payloadcms/payload/commit/73848b603790b3c3d8ad8c9dac81b33c0b65fc7e)) -* resize textarea only vertically ([6e1dfff](https://github.com/payloadcms/payload/commit/6e1dfff1b8195a1f81e6ea6ccf3b36dd5359c039)) -* richText e2e test, specific selectors ([09a8144](https://github.com/payloadcms/payload/commit/09a8144f3cc63f7ec15fd75f51b8ac8d0cf3f1b5)) -* styles readOnly RichTextEditor, removes interactivity within when readOnly ([9181304](https://github.com/payloadcms/payload/commit/918130486e1e38a3d57fb993f466207209c5c0bb)) -* **style:** system dark scrollbars ([a30d9dc](https://github.com/payloadcms/payload/commit/a30d9dc1d70340cc6c5ac5b3415a6f57bec117ae)) -* threads readOnly to ReactSelect ([b454811](https://github.com/payloadcms/payload/commit/b454811698c7ea0cee944ed50030c13163cf72c9)) -* upload xls renaming ext ([7fd8124](https://github.com/payloadcms/payload/commit/7fd8124df68d208813de46172c5cd3f479b9b8be)) - +- [#1184](https://github.com/payloadcms/payload/issues/1184) ([c2ec54a](https://github.com/payloadcms/payload/commit/c2ec54a7cbd8cd94bcd4a68d885e35986fec7f18)) +- [#1189](https://github.com/payloadcms/payload/issues/1189) ([3641dfd](https://github.com/payloadcms/payload/commit/3641dfd38a147b24e0e3ef93a125b12ad7763f66)) +- [#1204](https://github.com/payloadcms/payload/issues/1204) ([b4becd1](https://github.com/payloadcms/payload/commit/b4becd1493d55aae887008ab573ab710c400103a)) +- [#940](https://github.com/payloadcms/payload/issues/940) ([7926083](https://github.com/payloadcms/payload/commit/7926083732fbaec78d87f67742cdbd8bd00cd48a)) +- ajusts how disabled states are being set on anchors and buttons ([00ef170](https://github.com/payloadcms/payload/commit/00ef1700ae41e68ff0831a587bf3f09fe6c2c966)) +- remove min-width from fileupload ([73848b6](https://github.com/payloadcms/payload/commit/73848b603790b3c3d8ad8c9dac81b33c0b65fc7e)) +- resize textarea only vertically ([6e1dfff](https://github.com/payloadcms/payload/commit/6e1dfff1b8195a1f81e6ea6ccf3b36dd5359c039)) +- richText e2e test, specific selectors ([09a8144](https://github.com/payloadcms/payload/commit/09a8144f3cc63f7ec15fd75f51b8ac8d0cf3f1b5)) +- styles readOnly RichTextEditor, removes interactivity within when readOnly ([9181304](https://github.com/payloadcms/payload/commit/918130486e1e38a3d57fb993f466207209c5c0bb)) +- **style:** system dark scrollbars ([a30d9dc](https://github.com/payloadcms/payload/commit/a30d9dc1d70340cc6c5ac5b3415a6f57bec117ae)) +- threads readOnly to ReactSelect ([b454811](https://github.com/payloadcms/payload/commit/b454811698c7ea0cee944ed50030c13163cf72c9)) +- upload xls renaming ext ([7fd8124](https://github.com/payloadcms/payload/commit/7fd8124df68d208813de46172c5cd3f479b9b8be)) ### Features -* async admin access control ([1cfce87](https://github.com/payloadcms/payload/commit/1cfce8754947487e6c598ed5bc881526295acabf)) -* sort select and relationship fields by default ([813c46c](https://github.com/payloadcms/payload/commit/813c46c86d86f8b0a3ba7280d31f24e844c916b6)) +- async admin access control ([1cfce87](https://github.com/payloadcms/payload/commit/1cfce8754947487e6c598ed5bc881526295acabf)) +- sort select and relationship fields by default ([813c46c](https://github.com/payloadcms/payload/commit/813c46c86d86f8b0a3ba7280d31f24e844c916b6)) ## [1.1.5](https://github.com/payloadcms/payload/compare/v1.1.4...v1.1.5) (2022-09-29) - ### Bug Fixes -* bug in useThrottledEffect ([3ce8ee4](https://github.com/payloadcms/payload/commit/3ce8ee4661bfa3825c5b8c41232d5da57f7591ed)) +- bug in useThrottledEffect ([3ce8ee4](https://github.com/payloadcms/payload/commit/3ce8ee4661bfa3825c5b8c41232d5da57f7591ed)) ## [1.1.4](https://github.com/payloadcms/payload/compare/v1.1.3...v1.1.4) (2022-09-24) - ### Bug Fixes -* field level access for nested fields ([22ea98c](https://github.com/payloadcms/payload/commit/22ea98ca33770a0ec6652f814726454abb6da24e)) -* refine type generation for relationships ([ef83bdb](https://github.com/payloadcms/payload/commit/ef83bdb709ebde008b90930a6875b24f042a41b0)) - +- field level access for nested fields ([22ea98c](https://github.com/payloadcms/payload/commit/22ea98ca33770a0ec6652f814726454abb6da24e)) +- refine type generation for relationships ([ef83bdb](https://github.com/payloadcms/payload/commit/ef83bdb709ebde008b90930a6875b24f042a41b0)) ### Features -* supports root endpoints ([52cd3b4](https://github.com/payloadcms/payload/commit/52cd3b4a7ed9bc85e93d753a3aaf190489ca98cd)) +- supports root endpoints ([52cd3b4](https://github.com/payloadcms/payload/commit/52cd3b4a7ed9bc85e93d753a3aaf190489ca98cd)) ## [1.1.3](https://github.com/payloadcms/payload/compare/v1.1.2...v1.1.3) (2022-09-16) - ### Bug Fixes -* adjust prevPage and nextPage graphql typing ([#1140](https://github.com/payloadcms/payload/issues/1140)) ([b3bb421](https://github.com/payloadcms/payload/commit/b3bb421c6ca4176974488b3270384386a151560c)) -* duplicate with relationships ([eabb981](https://github.com/payloadcms/payload/commit/eabb981243e005facb5fff6d9222903d4704ca55)) +- adjust prevPage and nextPage graphql typing ([#1140](https://github.com/payloadcms/payload/issues/1140)) ([b3bb421](https://github.com/payloadcms/payload/commit/b3bb421c6ca4176974488b3270384386a151560c)) +- duplicate with relationships ([eabb981](https://github.com/payloadcms/payload/commit/eabb981243e005facb5fff6d9222903d4704ca55)) ## [1.1.2](https://github.com/payloadcms/payload/compare/v1.1.1...v1.1.2) (2022-09-14) - ### Bug Fixes -* resize images without local storage ([1496679](https://github.com/payloadcms/payload/commit/14966796ae0d0bcff8cb56b62e3a21c2de2176da)) -* resize images without local storage ([7b756f3](https://github.com/payloadcms/payload/commit/7b756f3421f02d1ff55374a72396e15e9f3e23d7)) +- resize images without local storage ([1496679](https://github.com/payloadcms/payload/commit/14966796ae0d0bcff8cb56b62e3a21c2de2176da)) +- resize images without local storage ([7b756f3](https://github.com/payloadcms/payload/commit/7b756f3421f02d1ff55374a72396e15e9f3e23d7)) ## [1.1.1](https://github.com/payloadcms/payload/compare/v1.1.0...v1.1.1) (2022-09-13) - ### Bug Fixes -* conditions on collapsible fields ([9c4f2b6](https://github.com/payloadcms/payload/commit/9c4f2b68b07bbdd2ac9a6dee280f50379638fc50)) -* dashboard links to globals ([dcc8dad](https://github.com/payloadcms/payload/commit/dcc8dad53b006f86e93150f9439eafc8d9e01d79)) +- conditions on collapsible fields ([9c4f2b6](https://github.com/payloadcms/payload/commit/9c4f2b68b07bbdd2ac9a6dee280f50379638fc50)) +- dashboard links to globals ([dcc8dad](https://github.com/payloadcms/payload/commit/dcc8dad53b006f86e93150f9439eafc8d9e01d79)) # [1.1.0](https://github.com/payloadcms/payload/compare/v1.0.36...v1.1.0) (2022-09-13) - ### Bug Fixes -* [#1106](https://github.com/payloadcms/payload/issues/1106) ([9a461b8](https://github.com/payloadcms/payload/commit/9a461b853689fdbc8229c8e103c5e237e451425f)) -* word boundaries, no regex lookbehind support for Safari ([#1114](https://github.com/payloadcms/payload/issues/1114)) ([391c9d8](https://github.com/payloadcms/payload/commit/391c9d8682175ea37f1f7b2bb9d1361dc4ac8140)) - +- [#1106](https://github.com/payloadcms/payload/issues/1106) ([9a461b8](https://github.com/payloadcms/payload/commit/9a461b853689fdbc8229c8e103c5e237e451425f)) +- word boundaries, no regex lookbehind support for Safari ([#1114](https://github.com/payloadcms/payload/issues/1114)) ([391c9d8](https://github.com/payloadcms/payload/commit/391c9d8682175ea37f1f7b2bb9d1361dc4ac8140)) ### Features -* [#1001](https://github.com/payloadcms/payload/issues/1001) - builds a way to allow list view to search multiple fields ([a108372](https://github.com/payloadcms/payload/commit/a1083727ef54ec15ea2c3b4dfd114567639dfef1)) -* collection groups ([dffeaf6](https://github.com/payloadcms/payload/commit/dffeaf6a69746b944bf36bd172da3cc19fa025a0)) -* globals groups ([59af872](https://github.com/payloadcms/payload/commit/59af8725b4625f8e08aaab730fce177e870279ca)) -* hide nav labels with no un-grouped collections ([c40e232](https://github.com/payloadcms/payload/commit/c40e232ac67e7bc1ced3775060beb835efff46b9)) -* implement gravatar ([#1107](https://github.com/payloadcms/payload/issues/1107)) ([ca434b8](https://github.com/payloadcms/payload/commit/ca434b8a929af081bb3b92b51f35058a23ce5e37)) -* support localized tab fields ([a83921a](https://github.com/payloadcms/payload/commit/a83921a2fe927d59562272cb111c68a840b1914f)) -* tabs support localization at the tab level ([6a6a691](https://github.com/payloadcms/payload/commit/6a6a69190fe13bebf3e0b089265d71be2a691488)) -* WIP tab compatible with traverseFields ([2ae33b6](https://github.com/payloadcms/payload/commit/2ae33b603abaec4ff80261a465781f508b4a1e06)) +- [#1001](https://github.com/payloadcms/payload/issues/1001) - builds a way to allow list view to search multiple fields ([a108372](https://github.com/payloadcms/payload/commit/a1083727ef54ec15ea2c3b4dfd114567639dfef1)) +- collection groups ([dffeaf6](https://github.com/payloadcms/payload/commit/dffeaf6a69746b944bf36bd172da3cc19fa025a0)) +- globals groups ([59af872](https://github.com/payloadcms/payload/commit/59af8725b4625f8e08aaab730fce177e870279ca)) +- hide nav labels with no un-grouped collections ([c40e232](https://github.com/payloadcms/payload/commit/c40e232ac67e7bc1ced3775060beb835efff46b9)) +- implement gravatar ([#1107](https://github.com/payloadcms/payload/issues/1107)) ([ca434b8](https://github.com/payloadcms/payload/commit/ca434b8a929af081bb3b92b51f35058a23ce5e37)) +- support localized tab fields ([a83921a](https://github.com/payloadcms/payload/commit/a83921a2fe927d59562272cb111c68a840b1914f)) +- tabs support localization at the tab level ([6a6a691](https://github.com/payloadcms/payload/commit/6a6a69190fe13bebf3e0b089265d71be2a691488)) +- WIP tab compatible with traverseFields ([2ae33b6](https://github.com/payloadcms/payload/commit/2ae33b603abaec4ff80261a465781f508b4a1e06)) ## [1.0.36](https://github.com/payloadcms/payload/compare/v1.0.35...v1.0.36) (2022-09-10) - ### Bug Fixes -* bug with account view ([ada1871](https://github.com/payloadcms/payload/commit/ada1871993bae92bc7a30f48029b437d63eb3871)) +- bug with account view ([ada1871](https://github.com/payloadcms/payload/commit/ada1871993bae92bc7a30f48029b437d63eb3871)) ## [1.0.35](https://github.com/payloadcms/payload/compare/v1.0.34...v1.0.35) (2022-09-10) - ### Bug Fixes -* [#1059](https://github.com/payloadcms/payload/issues/1059) ([13dc39d](https://github.com/payloadcms/payload/commit/13dc39dc6da4cb7c450477f539b09a3cb54ed5af)) -* add height/width if imageSizes not specified ([8bd2a0e](https://github.com/payloadcms/payload/commit/8bd2a0e6c9a9cd05c7b162ade47f3bb111236ba3)) -* incorrect auth strategy type ([c8b37f4](https://github.com/payloadcms/payload/commit/c8b37f40cbdc766a45dbe21573b1848bfc091901)) -* rich text link with no selection ([5a19f69](https://github.com/payloadcms/payload/commit/5a19f6915a17dbb072b89f63f32705d5f0fc75ce)) - +- [#1059](https://github.com/payloadcms/payload/issues/1059) ([13dc39d](https://github.com/payloadcms/payload/commit/13dc39dc6da4cb7c450477f539b09a3cb54ed5af)) +- add height/width if imageSizes not specified ([8bd2a0e](https://github.com/payloadcms/payload/commit/8bd2a0e6c9a9cd05c7b162ade47f3bb111236ba3)) +- incorrect auth strategy type ([c8b37f4](https://github.com/payloadcms/payload/commit/c8b37f40cbdc766a45dbe21573b1848bfc091901)) +- rich text link with no selection ([5a19f69](https://github.com/payloadcms/payload/commit/5a19f6915a17dbb072b89f63f32705d5f0fc75ce)) ### Features -* allows rich text links to link to other docs ([a99d9c9](https://github.com/payloadcms/payload/commit/a99d9c98c3f92d6fbeb65c384ca4d43b82184bfd)) -* improves rich text link ux ([91000d7](https://github.com/payloadcms/payload/commit/91000d7fdaa9628650c737fc3f7f6a900b7447d4)) +- allows rich text links to link to other docs ([a99d9c9](https://github.com/payloadcms/payload/commit/a99d9c98c3f92d6fbeb65c384ca4d43b82184bfd)) +- improves rich text link ux ([91000d7](https://github.com/payloadcms/payload/commit/91000d7fdaa9628650c737fc3f7f6a900b7447d4)) ## [1.0.34](https://github.com/payloadcms/payload/compare/v1.0.33...v1.0.34) (2022-09-07) - ### Bug Fixes -* pins faceless ui modal ([b38b642](https://github.com/payloadcms/payload/commit/b38b6427b8b813487922db0bb7d3762cc41d3447)) +- pins faceless ui modal ([b38b642](https://github.com/payloadcms/payload/commit/b38b6427b8b813487922db0bb7d3762cc41d3447)) ## [1.0.33](https://github.com/payloadcms/payload/compare/v1.0.30...v1.0.33) (2022-09-07) - ### Bug Fixes -* [#1062](https://github.com/payloadcms/payload/issues/1062) ([05d1b14](https://github.com/payloadcms/payload/commit/05d1b141b22f66cb9007f20f2ae9d8e31db4f32f)) -* [#948](https://github.com/payloadcms/payload/issues/948) ([8df9ee7](https://github.com/payloadcms/payload/commit/8df9ee7b2dfcb2f77f049d02788a5c60c45f8c12)) -* [#981](https://github.com/payloadcms/payload/issues/981) ([d588843](https://github.com/payloadcms/payload/commit/d58884312132e109ae3f6619be2e0d7bab3f3111)) -* accented label char sanitization for GraphQL ([#1080](https://github.com/payloadcms/payload/issues/1080)) ([888734d](https://github.com/payloadcms/payload/commit/888734dcdf775f416395f8830561c47235bb9019)) -* children of conditional fields required in graphql schema ([#1055](https://github.com/payloadcms/payload/issues/1055)) ([29e82ec](https://github.com/payloadcms/payload/commit/29e82ec845f69bf5a09b682739e88529ebc53c16)) -* ensures adding new media to upload works when existing doc does not exist ([5ae666b](https://github.com/payloadcms/payload/commit/5ae666b0e08b128bdf2d576428e8638c2b8c2ed8)) -* implement the same word boundary search as the like query ([#1038](https://github.com/payloadcms/payload/issues/1038)) ([c3a0bd8](https://github.com/payloadcms/payload/commit/c3a0bd86254dfc3f49e46d4e41bdf717424ea342)) -* reorder plugin wrapping ([#1051](https://github.com/payloadcms/payload/issues/1051)) ([cd8edba](https://github.com/payloadcms/payload/commit/cd8edbaa1faa5a94166396918089a01058a4e75e)) -* require min 1 option in field schema validation ([#1082](https://github.com/payloadcms/payload/issues/1082)) ([d56882c](https://github.com/payloadcms/payload/commit/d56882cc20764b793049f20a91864c943e711375)) -* update removing a relationship with null ([#1056](https://github.com/payloadcms/payload/issues/1056)) ([44b0073](https://github.com/payloadcms/payload/commit/44b0073834830a9d645a11bcafab3869b4eb1899)) -* update removing an upload with null ([#1076](https://github.com/payloadcms/payload/issues/1076)) ([2ee4c7a](https://github.com/payloadcms/payload/commit/2ee4c7ad727b9311578d3049660de81c27dace55)) - +- [#1062](https://github.com/payloadcms/payload/issues/1062) ([05d1b14](https://github.com/payloadcms/payload/commit/05d1b141b22f66cb9007f20f2ae9d8e31db4f32f)) +- [#948](https://github.com/payloadcms/payload/issues/948) ([8df9ee7](https://github.com/payloadcms/payload/commit/8df9ee7b2dfcb2f77f049d02788a5c60c45f8c12)) +- [#981](https://github.com/payloadcms/payload/issues/981) ([d588843](https://github.com/payloadcms/payload/commit/d58884312132e109ae3f6619be2e0d7bab3f3111)) +- accented label char sanitization for GraphQL ([#1080](https://github.com/payloadcms/payload/issues/1080)) ([888734d](https://github.com/payloadcms/payload/commit/888734dcdf775f416395f8830561c47235bb9019)) +- children of conditional fields required in graphql schema ([#1055](https://github.com/payloadcms/payload/issues/1055)) ([29e82ec](https://github.com/payloadcms/payload/commit/29e82ec845f69bf5a09b682739e88529ebc53c16)) +- ensures adding new media to upload works when existing doc does not exist ([5ae666b](https://github.com/payloadcms/payload/commit/5ae666b0e08b128bdf2d576428e8638c2b8c2ed8)) +- implement the same word boundary search as the like query ([#1038](https://github.com/payloadcms/payload/issues/1038)) ([c3a0bd8](https://github.com/payloadcms/payload/commit/c3a0bd86254dfc3f49e46d4e41bdf717424ea342)) +- reorder plugin wrapping ([#1051](https://github.com/payloadcms/payload/issues/1051)) ([cd8edba](https://github.com/payloadcms/payload/commit/cd8edbaa1faa5a94166396918089a01058a4e75e)) +- require min 1 option in field schema validation ([#1082](https://github.com/payloadcms/payload/issues/1082)) ([d56882c](https://github.com/payloadcms/payload/commit/d56882cc20764b793049f20a91864c943e711375)) +- update removing a relationship with null ([#1056](https://github.com/payloadcms/payload/issues/1056)) ([44b0073](https://github.com/payloadcms/payload/commit/44b0073834830a9d645a11bcafab3869b4eb1899)) +- update removing an upload with null ([#1076](https://github.com/payloadcms/payload/issues/1076)) ([2ee4c7a](https://github.com/payloadcms/payload/commit/2ee4c7ad727b9311578d3049660de81c27dace55)) ### Features -* cyrillic like query support ([#1078](https://github.com/payloadcms/payload/issues/1078)) ([b7e5828](https://github.com/payloadcms/payload/commit/b7e5828adc7bc6602da7992b073b005b30aa896f)) -* duplicate copies all locales ([51c7770](https://github.com/payloadcms/payload/commit/51c7770b10c34a3e40520ca8d64beedc67693c5c)) -* update operator type with contains ([#1045](https://github.com/payloadcms/payload/issues/1045)) ([482cbe7](https://github.com/payloadcms/payload/commit/482cbe71c7b1d39b665fb0b29a7a0b69f454180a)) +- cyrillic like query support ([#1078](https://github.com/payloadcms/payload/issues/1078)) ([b7e5828](https://github.com/payloadcms/payload/commit/b7e5828adc7bc6602da7992b073b005b30aa896f)) +- duplicate copies all locales ([51c7770](https://github.com/payloadcms/payload/commit/51c7770b10c34a3e40520ca8d64beedc67693c5c)) +- update operator type with contains ([#1045](https://github.com/payloadcms/payload/issues/1045)) ([482cbe7](https://github.com/payloadcms/payload/commit/482cbe71c7b1d39b665fb0b29a7a0b69f454180a)) ## [1.0.30](https://github.com/payloadcms/payload/compare/v1.0.29...v1.0.30) (2022-08-30) - ### Bug Fixes -* upload field validation not required ([#1025](https://github.com/payloadcms/payload/issues/1025)) ([689fa00](https://github.com/payloadcms/payload/commit/689fa008fb0b28fb92be4ca785a77f4c35ae16b2)) +- upload field validation not required ([#1025](https://github.com/payloadcms/payload/issues/1025)) ([689fa00](https://github.com/payloadcms/payload/commit/689fa008fb0b28fb92be4ca785a77f4c35ae16b2)) ## [1.0.29](https://github.com/payloadcms/payload/compare/v1.0.28...v1.0.29) (2022-08-29) - ### Bug Fixes -* [#953](https://github.com/payloadcms/payload/issues/953) ([a73c391](https://github.com/payloadcms/payload/commit/a73c391c2cecc3acf8dc3115b56c018f85d9bebf)) +- [#953](https://github.com/payloadcms/payload/issues/953) ([a73c391](https://github.com/payloadcms/payload/commit/a73c391c2cecc3acf8dc3115b56c018f85d9bebf)) ## [1.0.28](https://github.com/payloadcms/payload/compare/v1.0.27...v1.0.28) (2022-08-29) - ### Bug Fixes -* incorrect field paths when nesting unnamed fields ([#1011](https://github.com/payloadcms/payload/issues/1011)) ([50b0303](https://github.com/payloadcms/payload/commit/50b0303ab39f0d0500c5e4116df95f02d1d7fff3)), closes [#976](https://github.com/payloadcms/payload/issues/976) -* relationship cell loading ([#1021](https://github.com/payloadcms/payload/issues/1021)) ([6a3cfce](https://github.com/payloadcms/payload/commit/6a3cfced9a6e0ef75b398ec663f908c725b10d1a)) -* remove lazy loading of array and blocks ([4900fa7](https://github.com/payloadcms/payload/commit/4900fa799ffbeb70e689622b269dc04a67978552)) -* require properties in blocks and arrays fields ([#1020](https://github.com/payloadcms/payload/issues/1020)) ([6bc6e7b](https://github.com/payloadcms/payload/commit/6bc6e7bb616bd9f28f2464d3e55e7a1d19a8e7f8)) -* unpublish item will not crash the UI anymore ([#1016](https://github.com/payloadcms/payload/issues/1016)) ([0586d7a](https://github.com/payloadcms/payload/commit/0586d7aa7d0938df25492487aa073c2aa366e1e4)) - +- incorrect field paths when nesting unnamed fields ([#1011](https://github.com/payloadcms/payload/issues/1011)) ([50b0303](https://github.com/payloadcms/payload/commit/50b0303ab39f0d0500c5e4116df95f02d1d7fff3)), closes [#976](https://github.com/payloadcms/payload/issues/976) +- relationship cell loading ([#1021](https://github.com/payloadcms/payload/issues/1021)) ([6a3cfce](https://github.com/payloadcms/payload/commit/6a3cfced9a6e0ef75b398ec663f908c725b10d1a)) +- remove lazy loading of array and blocks ([4900fa7](https://github.com/payloadcms/payload/commit/4900fa799ffbeb70e689622b269dc04a67978552)) +- require properties in blocks and arrays fields ([#1020](https://github.com/payloadcms/payload/issues/1020)) ([6bc6e7b](https://github.com/payloadcms/payload/commit/6bc6e7bb616bd9f28f2464d3e55e7a1d19a8e7f8)) +- unpublish item will not crash the UI anymore ([#1016](https://github.com/payloadcms/payload/issues/1016)) ([0586d7a](https://github.com/payloadcms/payload/commit/0586d7aa7d0938df25492487aa073c2aa366e1e4)) ### Features -* export more fields config types and validation type ([#989](https://github.com/payloadcms/payload/issues/989)) ([25f5d68](https://github.com/payloadcms/payload/commit/25f5d68b74b081c060ddf6f0405c9211f5da6b54)) -* types custom components to allow any props ([#1013](https://github.com/payloadcms/payload/issues/1013)) ([3736755](https://github.com/payloadcms/payload/commit/3736755a12cf5bbaaa916a5c0363026318a60823)) -* validate relationship and upload ids ([#1004](https://github.com/payloadcms/payload/issues/1004)) ([d727fc8](https://github.com/payloadcms/payload/commit/d727fc8e2467e3f438ea6b1d2031e0657bffd183)) +- export more fields config types and validation type ([#989](https://github.com/payloadcms/payload/issues/989)) ([25f5d68](https://github.com/payloadcms/payload/commit/25f5d68b74b081c060ddf6f0405c9211f5da6b54)) +- types custom components to allow any props ([#1013](https://github.com/payloadcms/payload/issues/1013)) ([3736755](https://github.com/payloadcms/payload/commit/3736755a12cf5bbaaa916a5c0363026318a60823)) +- validate relationship and upload ids ([#1004](https://github.com/payloadcms/payload/issues/1004)) ([d727fc8](https://github.com/payloadcms/payload/commit/d727fc8e2467e3f438ea6b1d2031e0657bffd183)) ## [1.0.27](https://github.com/payloadcms/payload/compare/v1.0.26...v1.0.27) (2022-08-18) - ### Bug Fixes -* react-sortable-hoc dependency instead of dev dependency ([4ef6801](https://github.com/payloadcms/payload/commit/4ef6801230cb0309a9d20dd092f8a3372f75f9ca)) +- react-sortable-hoc dependency instead of dev dependency ([4ef6801](https://github.com/payloadcms/payload/commit/4ef6801230cb0309a9d20dd092f8a3372f75f9ca)) ## [1.0.26](https://github.com/payloadcms/payload/compare/v1.0.25...v1.0.26) (2022-08-18) - ### Bug Fixes -* missing fields in rows on custom id collections ([#954](https://github.com/payloadcms/payload/issues/954)) ([39586d3](https://github.com/payloadcms/payload/commit/39586d3cdb01131b29f1f8f7346086d2bc9903c1)) - +- missing fields in rows on custom id collections ([#954](https://github.com/payloadcms/payload/issues/954)) ([39586d3](https://github.com/payloadcms/payload/commit/39586d3cdb01131b29f1f8f7346086d2bc9903c1)) ### Features -* adds more prismjs syntax highlighting options for code blocks ([#961](https://github.com/payloadcms/payload/issues/961)) ([f45d5a0](https://github.com/payloadcms/payload/commit/f45d5a0421117180f85f8e3cd86f835c13ac6d16)) -* enable reordering of hasMany relationship and select fields ([#952](https://github.com/payloadcms/payload/issues/952)) ([38a1a38](https://github.com/payloadcms/payload/commit/38a1a38c0c52403083458619b2f9b58044c5c0ea)) +- adds more prismjs syntax highlighting options for code blocks ([#961](https://github.com/payloadcms/payload/issues/961)) ([f45d5a0](https://github.com/payloadcms/payload/commit/f45d5a0421117180f85f8e3cd86f835c13ac6d16)) +- enable reordering of hasMany relationship and select fields ([#952](https://github.com/payloadcms/payload/issues/952)) ([38a1a38](https://github.com/payloadcms/payload/commit/38a1a38c0c52403083458619b2f9b58044c5c0ea)) ## [1.0.25](https://github.com/payloadcms/payload/compare/v1.0.24...v1.0.25) (2022-08-17) - ### Bug Fixes -* [#568](https://github.com/payloadcms/payload/issues/568) ([a3edbf4](https://github.com/payloadcms/payload/commit/a3edbf4fef5efd8293cb4d6139b2513441cb741e)) - +- [#568](https://github.com/payloadcms/payload/issues/568) ([a3edbf4](https://github.com/payloadcms/payload/commit/a3edbf4fef5efd8293cb4d6139b2513441cb741e)) ### Features -* add new pickerAppearance option 'monthOnly' ([566c6ba](https://github.com/payloadcms/payload/commit/566c6ba3a9beb13ea9437844313ec6701effce27)) -* custom api endpoints ([11d8fc7](https://github.com/payloadcms/payload/commit/11d8fc71e8bdb62c6755789903702b0ee257b448)) +- add new pickerAppearance option 'monthOnly' ([566c6ba](https://github.com/payloadcms/payload/commit/566c6ba3a9beb13ea9437844313ec6701effce27)) +- custom api endpoints ([11d8fc7](https://github.com/payloadcms/payload/commit/11d8fc71e8bdb62c6755789903702b0ee257b448)) ## [1.0.24](https://github.com/payloadcms/payload/compare/v1.0.23...v1.0.24) (2022-08-16) - ### Bug Fixes -* [#939](https://github.com/payloadcms/payload/issues/939) ([b1a1575](https://github.com/payloadcms/payload/commit/b1a1575122f602ff6ba77973ab2a67893d352487)) -* create indexes in nested fields ([f615abc](https://github.com/payloadcms/payload/commit/f615abc9b1d9000aff114010ef7f618ec70b6491)) -* format graphql localization input type ([#932](https://github.com/payloadcms/payload/issues/932)) ([1c7445d](https://github.com/payloadcms/payload/commit/1c7445dc7fd883f6d5dcba532e9e048b1cff08f5)) - +- [#939](https://github.com/payloadcms/payload/issues/939) ([b1a1575](https://github.com/payloadcms/payload/commit/b1a1575122f602ff6ba77973ab2a67893d352487)) +- create indexes in nested fields ([f615abc](https://github.com/payloadcms/payload/commit/f615abc9b1d9000aff114010ef7f618ec70b6491)) +- format graphql localization input type ([#932](https://github.com/payloadcms/payload/issues/932)) ([1c7445d](https://github.com/payloadcms/payload/commit/1c7445dc7fd883f6d5dcba532e9e048b1cff08f5)) ### Features -* ensures you can query on blocks via specifying locale or not specifying locale ([078e8dc](https://github.com/payloadcms/payload/commit/078e8dcc51197133788294bac6fa380b192defbc)) +- ensures you can query on blocks via specifying locale or not specifying locale ([078e8dc](https://github.com/payloadcms/payload/commit/078e8dcc51197133788294bac6fa380b192defbc)) ## [1.0.23](https://github.com/payloadcms/payload/compare/v1.0.22...v1.0.23) (2022-08-15) - ### Bug Fixes -* [#930](https://github.com/payloadcms/payload/issues/930) ([cbb1c84](https://github.com/payloadcms/payload/commit/cbb1c84be76146301ce41c4bdace647df83a4aac)) -* dev:generate-types on all test configs ([#919](https://github.com/payloadcms/payload/issues/919)) ([145e1db](https://github.com/payloadcms/payload/commit/145e1db05db0e71149ba74e95764970dfdfd8b6b)) +- [#930](https://github.com/payloadcms/payload/issues/930) ([cbb1c84](https://github.com/payloadcms/payload/commit/cbb1c84be76146301ce41c4bdace647df83a4aac)) +- dev:generate-types on all test configs ([#919](https://github.com/payloadcms/payload/issues/919)) ([145e1db](https://github.com/payloadcms/payload/commit/145e1db05db0e71149ba74e95764970dfdfd8b6b)) ## [1.0.22](https://github.com/payloadcms/payload/compare/v1.0.21...v1.0.22) (2022-08-12) - ### Bug Fixes -* [#905](https://github.com/payloadcms/payload/issues/905) ([b8421dd](https://github.com/payloadcms/payload/commit/b8421ddc0c9357de7a61bdc565fe2f9c4cf62681)) -* ensures you can query on mixed schema type within blocks ([fba0847](https://github.com/payloadcms/payload/commit/fba0847f0fbc4c144ec85bb7a1ed3f2a953f5e05)) +- [#905](https://github.com/payloadcms/payload/issues/905) ([b8421dd](https://github.com/payloadcms/payload/commit/b8421ddc0c9357de7a61bdc565fe2f9c4cf62681)) +- ensures you can query on mixed schema type within blocks ([fba0847](https://github.com/payloadcms/payload/commit/fba0847f0fbc4c144ec85bb7a1ed3f2a953f5e05)) ## [1.0.21](https://github.com/payloadcms/payload/compare/v1.0.20...v1.0.21) (2022-08-11) - ### Bug Fixes -* ensures you can query on nested block fields ([ca852e8](https://github.com/payloadcms/payload/commit/ca852e8cb2d78982abeae0b5db4117f0261d8fed)) -* saving multiple versions ([#918](https://github.com/payloadcms/payload/issues/918)) ([d0da3d7](https://github.com/payloadcms/payload/commit/d0da3d7962bbddfbdc1c553816409823bf6e1335)) +- ensures you can query on nested block fields ([ca852e8](https://github.com/payloadcms/payload/commit/ca852e8cb2d78982abeae0b5db4117f0261d8fed)) +- saving multiple versions ([#918](https://github.com/payloadcms/payload/issues/918)) ([d0da3d7](https://github.com/payloadcms/payload/commit/d0da3d7962bbddfbdc1c553816409823bf6e1335)) ## [1.0.20](https://github.com/payloadcms/payload/compare/v1.0.19...v1.0.20) (2022-08-11) - ### Bug Fixes -* E11000 duplicate key error has no keyValue ([#916](https://github.com/payloadcms/payload/issues/916)) ([50972b9](https://github.com/payloadcms/payload/commit/50972b98a1d30c86d8b429ee5ba1c7dacac59f2c)) -* number validation works with 0 min and max ([#906](https://github.com/payloadcms/payload/issues/906)) ([874c001](https://github.com/payloadcms/payload/commit/874c001d3b9712bce342c206e66f794a7e4938ba)) - +- E11000 duplicate key error has no keyValue ([#916](https://github.com/payloadcms/payload/issues/916)) ([50972b9](https://github.com/payloadcms/payload/commit/50972b98a1d30c86d8b429ee5ba1c7dacac59f2c)) +- number validation works with 0 min and max ([#906](https://github.com/payloadcms/payload/issues/906)) ([874c001](https://github.com/payloadcms/payload/commit/874c001d3b9712bce342c206e66f794a7e4938ba)) ### Features -* field name validation ([#903](https://github.com/payloadcms/payload/issues/903)) ([2f4f075](https://github.com/payloadcms/payload/commit/2f4f075441768475f1202587abf578d5e4ae9f2a)) +- field name validation ([#903](https://github.com/payloadcms/payload/issues/903)) ([2f4f075](https://github.com/payloadcms/payload/commit/2f4f075441768475f1202587abf578d5e4ae9f2a)) ## [1.0.19](https://github.com/payloadcms/payload/compare/v1.0.18...v1.0.19) (2022-08-07) - ### Features -* exposes static upload handlers ([a8d2e09](https://github.com/payloadcms/payload/commit/a8d2e099523cc7b99f94ae0cad574b41679c6e25)) +- exposes static upload handlers ([a8d2e09](https://github.com/payloadcms/payload/commit/a8d2e099523cc7b99f94ae0cad574b41679c6e25)) ## [1.0.18](https://github.com/payloadcms/payload/compare/v1.0.17...v1.0.18) (2022-08-06) ## [1.0.17](https://github.com/payloadcms/payload/compare/v1.0.16...v1.0.17) (2022-08-06) - ### Bug Fixes -* [#898](https://github.com/payloadcms/payload/issues/898) ([209b02b](https://github.com/payloadcms/payload/commit/209b02b0699b17d060dab3cc09cdd06ad813c053)) +- [#898](https://github.com/payloadcms/payload/issues/898) ([209b02b](https://github.com/payloadcms/payload/commit/209b02b0699b17d060dab3cc09cdd06ad813c053)) ## [1.0.16](https://github.com/payloadcms/payload/compare/v1.0.15...v1.0.16) (2022-08-05) - ### Bug Fixes -* [#896](https://github.com/payloadcms/payload/issues/896) ([c32dfea](https://github.com/payloadcms/payload/commit/c32dfea35607991f7260c74121074d105f1b200c)) +- [#896](https://github.com/payloadcms/payload/issues/896) ([c32dfea](https://github.com/payloadcms/payload/commit/c32dfea35607991f7260c74121074d105f1b200c)) ## [1.0.15](https://github.com/payloadcms/payload/compare/v1.0.14...v1.0.15) (2022-08-04) ## [1.0.14](https://github.com/payloadcms/payload/compare/v1.0.13...v1.0.14) (2022-08-04) - ### Bug Fixes -* [#884](https://github.com/payloadcms/payload/issues/884) ([e9b3f3f](https://github.com/payloadcms/payload/commit/e9b3f3f060d134f3ed4b410adddb9d2593f6ee95)) -* allows querying incomplete drafts in graphql ([8d968b7](https://github.com/payloadcms/payload/commit/8d968b7690c147685d569c334c108d8830ee7581)) - +- [#884](https://github.com/payloadcms/payload/issues/884) ([e9b3f3f](https://github.com/payloadcms/payload/commit/e9b3f3f060d134f3ed4b410adddb9d2593f6ee95)) +- allows querying incomplete drafts in graphql ([8d968b7](https://github.com/payloadcms/payload/commit/8d968b7690c147685d569c334c108d8830ee7581)) ### Features -* allows querying on rich text content ([3343adb](https://github.com/payloadcms/payload/commit/3343adb95257daae0be49daf6c768788292ef267)) +- allows querying on rich text content ([3343adb](https://github.com/payloadcms/payload/commit/3343adb95257daae0be49daf6c768788292ef267)) ## [1.0.13](https://github.com/payloadcms/payload/compare/v1.0.12...v1.0.13) (2022-08-03) - ### Bug Fixes -* [#878](https://github.com/payloadcms/payload/issues/878) ([b8504ff](https://github.com/payloadcms/payload/commit/b8504ffb25310095097f35107e2b33dc648580cc)) -* [#880](https://github.com/payloadcms/payload/issues/880) ([9c0c606](https://github.com/payloadcms/payload/commit/9c0c606b20e963a12d23b428c54c63d6a73be472)) - +- [#878](https://github.com/payloadcms/payload/issues/878) ([b8504ff](https://github.com/payloadcms/payload/commit/b8504ffb25310095097f35107e2b33dc648580cc)) +- [#880](https://github.com/payloadcms/payload/issues/880) ([9c0c606](https://github.com/payloadcms/payload/commit/9c0c606b20e963a12d23b428c54c63d6a73be472)) ### Features -* improves adjacent group styling ([0294c02](https://github.com/payloadcms/payload/commit/0294c02aedaa11a72240ab1dc7d6ccd2318de51f)) +- improves adjacent group styling ([0294c02](https://github.com/payloadcms/payload/commit/0294c02aedaa11a72240ab1dc7d6ccd2318de51f)) ## [1.0.12](https://github.com/payloadcms/payload/compare/v1.0.11...v1.0.12) (2022-08-02) - ### Bug Fixes -* ensures tabs can overflow on mobile when there are many ([663cae4](https://github.com/payloadcms/payload/commit/663cae4788f2726f3fa2430228706be63b7e642b)) -* unique index creation ([#867](https://github.com/payloadcms/payload/issues/867)) ([c175476](https://github.com/payloadcms/payload/commit/c175476e74b31ea1fbc4a250fa8d23953d13e541)) +- ensures tabs can overflow on mobile when there are many ([663cae4](https://github.com/payloadcms/payload/commit/663cae4788f2726f3fa2430228706be63b7e642b)) +- unique index creation ([#867](https://github.com/payloadcms/payload/issues/867)) ([c175476](https://github.com/payloadcms/payload/commit/c175476e74b31ea1fbc4a250fa8d23953d13e541)) ## [1.0.11](https://github.com/payloadcms/payload/compare/v1.0.10...v1.0.11) (2022-07-28) - ### Bug Fixes -* ensures when initial values changes, field value is updated ([858b1af](https://github.com/payloadcms/payload/commit/858b1afa546db68416d625a7ab970c9693d0595e)) +- ensures when initial values changes, field value is updated ([858b1af](https://github.com/payloadcms/payload/commit/858b1afa546db68416d625a7ab970c9693d0595e)) ## [1.0.10](https://github.com/payloadcms/payload/compare/v1.0.9...v1.0.10) (2022-07-27) - ### Bug Fixes -* [#806](https://github.com/payloadcms/payload/issues/806), allow partial word matches using 'like' operator ([c96985b](https://github.com/payloadcms/payload/commit/c96985be0c14fcff768e036de96ebef3caa24d1c)) -* [#836](https://github.com/payloadcms/payload/issues/836) ([84611af](https://github.com/payloadcms/payload/commit/84611aff2c9e0b1a1e721a72e9d3fc0740f10aff)) -* accesses payload config correctly in gql refresh resolver ([d5e88cc](https://github.com/payloadcms/payload/commit/d5e88cc1a93ee8f93ee2eb75ab1690281f266f6a)) -* email not always loading while viewing auth collections ([36e9acc](https://github.com/payloadcms/payload/commit/36e9acc637c4a706f0d3d07fbfb88e9afdccc2da)) -* ensures collapsible preferences are retained through doc save ([61f0e8e](https://github.com/payloadcms/payload/commit/61f0e8ea9fd574fc40186f63c0016da150610d70)) -* id now properly required in graphql findByID operation ([5dc7caf](https://github.com/payloadcms/payload/commit/5dc7caf35689d3f5cd71b9b2759edcb9b7eaadc5)) -* set overflow payload modal container to auto ([cfb5540](https://github.com/payloadcms/payload/commit/cfb5540e64ccc016a4ef408a71b9aaf3d219b0fc)) -* trim trailing whitespaces of email in login ([8feed39](https://github.com/payloadcms/payload/commit/8feed39fb92f2e194ae628b090cbb84d802586b6)) - +- [#806](https://github.com/payloadcms/payload/issues/806), allow partial word matches using 'like' operator ([c96985b](https://github.com/payloadcms/payload/commit/c96985be0c14fcff768e036de96ebef3caa24d1c)) +- [#836](https://github.com/payloadcms/payload/issues/836) ([84611af](https://github.com/payloadcms/payload/commit/84611aff2c9e0b1a1e721a72e9d3fc0740f10aff)) +- accesses payload config correctly in gql refresh resolver ([d5e88cc](https://github.com/payloadcms/payload/commit/d5e88cc1a93ee8f93ee2eb75ab1690281f266f6a)) +- email not always loading while viewing auth collections ([36e9acc](https://github.com/payloadcms/payload/commit/36e9acc637c4a706f0d3d07fbfb88e9afdccc2da)) +- ensures collapsible preferences are retained through doc save ([61f0e8e](https://github.com/payloadcms/payload/commit/61f0e8ea9fd574fc40186f63c0016da150610d70)) +- id now properly required in graphql findByID operation ([5dc7caf](https://github.com/payloadcms/payload/commit/5dc7caf35689d3f5cd71b9b2759edcb9b7eaadc5)) +- set overflow payload modal container to auto ([cfb5540](https://github.com/payloadcms/payload/commit/cfb5540e64ccc016a4ef408a71b9aaf3d219b0fc)) +- trim trailing whitespaces of email in login ([8feed39](https://github.com/payloadcms/payload/commit/8feed39fb92f2e194ae628b090cbb84d802586b6)) ### Features -* greatly enhances performance by using dataloader pattern to batch populations ([c5bcd1e](https://github.com/payloadcms/payload/commit/c5bcd1e3412087249a2a3d98830a1b69e33736a0)) -* significantly improves complex GraphQL query performance ([5d57bfa](https://github.com/payloadcms/payload/commit/5d57bfa4382470d2a171dcac3743523c930e3a3f)) +- greatly enhances performance by using dataloader pattern to batch populations ([c5bcd1e](https://github.com/payloadcms/payload/commit/c5bcd1e3412087249a2a3d98830a1b69e33736a0)) +- significantly improves complex GraphQL query performance ([5d57bfa](https://github.com/payloadcms/payload/commit/5d57bfa4382470d2a171dcac3743523c930e3a3f)) ## [1.0.9](https://github.com/payloadcms/payload/compare/v1.0.8...v1.0.9) (2022-07-21) - ### Bug Fixes -* avoid assuming Email will be present on JWT token. Using ID instead as email might not be in if using disableLocalStrategy ([#789](https://github.com/payloadcms/payload/issues/789)) ([3b4d5af](https://github.com/payloadcms/payload/commit/3b4d5afd41f898c06c5d0f2b96ce0478c27d0976)) -* enable index creation from schema ([#791](https://github.com/payloadcms/payload/issues/791)) ([2a1f387](https://github.com/payloadcms/payload/commit/2a1f387bcc071730692b5eadadf01a91d7a1f5d4)) -* graphql gen logging output ([#795](https://github.com/payloadcms/payload/issues/795)) ([8a81d0b](https://github.com/payloadcms/payload/commit/8a81d0b2746b727784280704aab26b0aed3a757d)) -* sharpens radio input edges by replacing box-shadow trick with border property ([#768](https://github.com/payloadcms/payload/issues/768)) ([e2c366f](https://github.com/payloadcms/payload/commit/e2c366f5363aa88b29a1b90688f75a1da0c2cca8)) - +- avoid assuming Email will be present on JWT token. Using ID instead as email might not be in if using disableLocalStrategy ([#789](https://github.com/payloadcms/payload/issues/789)) ([3b4d5af](https://github.com/payloadcms/payload/commit/3b4d5afd41f898c06c5d0f2b96ce0478c27d0976)) +- enable index creation from schema ([#791](https://github.com/payloadcms/payload/issues/791)) ([2a1f387](https://github.com/payloadcms/payload/commit/2a1f387bcc071730692b5eadadf01a91d7a1f5d4)) +- graphql gen logging output ([#795](https://github.com/payloadcms/payload/issues/795)) ([8a81d0b](https://github.com/payloadcms/payload/commit/8a81d0b2746b727784280704aab26b0aed3a757d)) +- sharpens radio input edges by replacing box-shadow trick with border property ([#768](https://github.com/payloadcms/payload/issues/768)) ([e2c366f](https://github.com/payloadcms/payload/commit/e2c366f5363aa88b29a1b90688f75a1da0c2cca8)) ### Features -* pass payload and names to custom auth strategies ([#781](https://github.com/payloadcms/payload/issues/781)) ([3a3026c](https://github.com/payloadcms/payload/commit/3a3026cd637c1274fdf6e4c4cba4f30a202e1ff7)) -* use provided auth strategy name or strategy.name ([#797](https://github.com/payloadcms/payload/issues/797)) ([f22f56e](https://github.com/payloadcms/payload/commit/f22f56e73c979ee3e1b165b327b1bcf6e1de6eda)) +- pass payload and names to custom auth strategies ([#781](https://github.com/payloadcms/payload/issues/781)) ([3a3026c](https://github.com/payloadcms/payload/commit/3a3026cd637c1274fdf6e4c4cba4f30a202e1ff7)) +- use provided auth strategy name or strategy.name ([#797](https://github.com/payloadcms/payload/issues/797)) ([f22f56e](https://github.com/payloadcms/payload/commit/f22f56e73c979ee3e1b165b327b1bcf6e1de6eda)) ## [1.0.8](https://github.com/payloadcms/payload/compare/v1.0.7...v1.0.8) (2022-07-20) - ### Bug Fixes -* await field hooks recursively ([893772e](https://github.com/payloadcms/payload/commit/893772ebd8b3d565f9c62d83ca0fa131b9d59970)) -* potential solution for [#756](https://github.com/payloadcms/payload/issues/756) ([b987cb8](https://github.com/payloadcms/payload/commit/b987cb8dc4774fbcc11b71661f2c4d25208f7de2)) - +- await field hooks recursively ([893772e](https://github.com/payloadcms/payload/commit/893772ebd8b3d565f9c62d83ca0fa131b9d59970)) +- potential solution for [#756](https://github.com/payloadcms/payload/issues/756) ([b987cb8](https://github.com/payloadcms/payload/commit/b987cb8dc4774fbcc11b71661f2c4d25208f7de2)) ### Features -* export PayloadRequest ([66c820c](https://github.com/payloadcms/payload/commit/66c820c863e7aeaa9050c0a0964256d6878af9d9)) -* improves generated types by removing unnecessary optional properties ([#784](https://github.com/payloadcms/payload/issues/784)) ([6f748f1](https://github.com/payloadcms/payload/commit/6f748f1adb78a70c9e5dba6cedcf1e2cdd55498a)) +- export PayloadRequest ([66c820c](https://github.com/payloadcms/payload/commit/66c820c863e7aeaa9050c0a0964256d6878af9d9)) +- improves generated types by removing unnecessary optional properties ([#784](https://github.com/payloadcms/payload/issues/784)) ([6f748f1](https://github.com/payloadcms/payload/commit/6f748f1adb78a70c9e5dba6cedcf1e2cdd55498a)) ## [1.0.7](https://github.com/payloadcms/payload/compare/v1.0.6...v1.0.7) (2022-07-19) ## [1.0.6](https://github.com/payloadcms/payload/compare/v1.0.5...v1.0.6) (2022-07-19) - ### Features -* improves initAsync pattern ([428edb0](https://github.com/payloadcms/payload/commit/428edb05c4d8805bb2c4fb98f51e57eed2926374)) +- improves initAsync pattern ([428edb0](https://github.com/payloadcms/payload/commit/428edb05c4d8805bb2c4fb98f51e57eed2926374)) ## [1.0.5](https://github.com/payloadcms/payload/compare/v1.0.4...v1.0.5) (2022-07-19) - ### Features -* adds initAsync ([b4ffa22](https://github.com/payloadcms/payload/commit/b4ffa228858e584b3a177b0b096077a5c660b892)) +- adds initAsync ([b4ffa22](https://github.com/payloadcms/payload/commit/b4ffa228858e584b3a177b0b096077a5c660b892)) ## [1.0.4](https://github.com/payloadcms/payload/compare/v0.20.1...v1.0.4) (2022-07-19) ### Features -* Updated UI: Dark Mode -* Updated UI: Collapsibles ([60bfb1c](https://github.com/payloadcms/payload/commit/60bfb1c3b801c89de055d11cee50a1b51e864b7b)) -* Updated UI: Tabs field ([68e7c41](https://github.com/payloadcms/payload/commit/68e7c41fdc07df04dcc3caaf486d2d596354039d)) -* Updated UI: Styling Revamp and responsive improvements -* More maintainable colors via CSS vars -* Improved test coverage through granular Payload configs -* Introduction of E2E tests through Playwright -* allow clear select value ([#735](https://github.com/payloadcms/payload/issues/735)) ([3132d35](https://github.com/payloadcms/payload/commit/3132d35e27f3c1037aeb3d1801e13df2e992e98b)) +- Updated UI: Dark Mode +- Updated UI: Collapsibles ([60bfb1c](https://github.com/payloadcms/payload/commit/60bfb1c3b801c89de055d11cee50a1b51e864b7b)) +- Updated UI: Tabs field ([68e7c41](https://github.com/payloadcms/payload/commit/68e7c41fdc07df04dcc3caaf486d2d596354039d)) +- Updated UI: Styling Revamp and responsive improvements +- More maintainable colors via CSS vars +- Improved test coverage through granular Payload configs +- Introduction of E2E tests through Playwright +- allow clear select value ([#735](https://github.com/payloadcms/payload/issues/735)) ([3132d35](https://github.com/payloadcms/payload/commit/3132d35e27f3c1037aeb3d1801e13df2e992e98b)) ### BREAKING CHANGES @@ -1027,47 +1132,47 @@ Due to this change, the `admin.scss` functionality has become obsolete, and over ### Bug Fixes -* ensures only plain objects are merged within incoming configs ([2c66ad8](https://github.com/payloadcms/payload/commit/2c66ad86898c28da32b1714821c2ea8fe8e17868)) +- ensures only plain objects are merged within incoming configs ([2c66ad8](https://github.com/payloadcms/payload/commit/2c66ad86898c28da32b1714821c2ea8fe8e17868)) ### Features -* :tada: [Extensible Authentication Strategies](https://github.com/payloadcms/payload/discussions/290)! -* add afterMe afterLogout and afterRefresh ([4055908](https://github.com/payloadcms/payload/commit/4055908bc885ec1b2d69817a9937e4591d099fa1)) -* add preMiddleware and postMiddleware, deprecate middleware ([e806437](https://github.com/payloadcms/payload/commit/e8064371b01b4e66d3b1af980e71364714bf3d5b)) -* better types useAuth and custom provider components ([38b52bf](https://github.com/payloadcms/payload/commit/38b52bf67b0d1545bb8ee627f3b6140e27887099)) +- :tada: [Extensible Authentication Strategies](https://github.com/payloadcms/payload/discussions/290)! +- add afterMe afterLogout and afterRefresh ([4055908](https://github.com/payloadcms/payload/commit/4055908bc885ec1b2d69817a9937e4591d099fa1)) +- add preMiddleware and postMiddleware, deprecate middleware ([e806437](https://github.com/payloadcms/payload/commit/e8064371b01b4e66d3b1af980e71364714bf3d5b)) +- better types useAuth and custom provider components ([38b52bf](https://github.com/payloadcms/payload/commit/38b52bf67b0d1545bb8ee627f3b6140e27887099)) ## [0.19.1](https://github.com/payloadcms/payload/compare/v0.19.0...v0.19.1) (2022-07-09) ### Bug Fixes -* ensures duplicative relationship options are not present ([#732](https://github.com/payloadcms/payload/issues/732)) ([ce1c99b](https://github.com/payloadcms/payload/commit/ce1c99b01c0b615401d618bd1894450114cc1f4c)) +- ensures duplicative relationship options are not present ([#732](https://github.com/payloadcms/payload/issues/732)) ([ce1c99b](https://github.com/payloadcms/payload/commit/ce1c99b01c0b615401d618bd1894450114cc1f4c)) # [0.19.0](https://github.com/payloadcms/payload/compare/v0.18.5...v0.19.0) (2022-07-08) ### BREAKING CHANGES -* relationship fields with access control preventing read of relation will return id instead of null ([#644](https://github.com/payloadcms/payload/pull/644)) +- relationship fields with access control preventing read of relation will return id instead of null ([#644](https://github.com/payloadcms/payload/pull/644)) ### Bug Fixes -* allow passing of autoIndex mongoose connectionOptions ([#722](https://github.com/payloadcms/payload/issues/722)) ([567d8c1](https://github.com/payloadcms/payload/commit/567d8c19bff05c4d5edfcff1f04ff5e7804412ce)) -* copyfiles cross platform ([#712](https://github.com/payloadcms/payload/issues/712)) ([67331eb](https://github.com/payloadcms/payload/commit/67331eb975c57897236466bef109a9559ff0d1a0)) -* ensures auth/me relations in gql can be queried ([01bc1fe](https://github.com/payloadcms/payload/commit/01bc1fef1e498038457b9454fc0969c2a1fe4601)) -* ensures old data from arrays is not persisted ([d9ef803](https://github.com/payloadcms/payload/commit/d9ef803d203c03a161dedff7076381ed944cf8d6)) -* relationship field disabled from access control in related collections ([#644](https://github.com/payloadcms/payload/issues/644)) ([91e33d1](https://github.com/payloadcms/payload/commit/91e33d1c1cf97d3f8512caea72dc1012969b84bb)) +- allow passing of autoIndex mongoose connectionOptions ([#722](https://github.com/payloadcms/payload/issues/722)) ([567d8c1](https://github.com/payloadcms/payload/commit/567d8c19bff05c4d5edfcff1f04ff5e7804412ce)) +- copyfiles cross platform ([#712](https://github.com/payloadcms/payload/issues/712)) ([67331eb](https://github.com/payloadcms/payload/commit/67331eb975c57897236466bef109a9559ff0d1a0)) +- ensures auth/me relations in gql can be queried ([01bc1fe](https://github.com/payloadcms/payload/commit/01bc1fef1e498038457b9454fc0969c2a1fe4601)) +- ensures old data from arrays is not persisted ([d9ef803](https://github.com/payloadcms/payload/commit/d9ef803d203c03a161dedff7076381ed944cf8d6)) +- relationship field disabled from access control in related collections ([#644](https://github.com/payloadcms/payload/issues/644)) ([91e33d1](https://github.com/payloadcms/payload/commit/91e33d1c1cf97d3f8512caea72dc1012969b84bb)) ### Features -* allow clearing DatePicker value ([#641](https://github.com/payloadcms/payload/issues/641)) ([9fd171b](https://github.com/payloadcms/payload/commit/9fd171b26db5e3aaa6ade706f02c9697e1d785f3)) -* File argument in create/update operation ([#708](https://github.com/payloadcms/payload/issues/708)) ([f3b7dcf](https://github.com/payloadcms/payload/commit/f3b7dcff57961e0c6a5b1536de23b7fe6fa035cf)) -* graphql schema output ([#730](https://github.com/payloadcms/payload/issues/730)) ([ad43cbc](https://github.com/payloadcms/payload/commit/ad43cbc808572f15157e4e52d211253c63012d7f)) +- allow clearing DatePicker value ([#641](https://github.com/payloadcms/payload/issues/641)) ([9fd171b](https://github.com/payloadcms/payload/commit/9fd171b26db5e3aaa6ade706f02c9697e1d785f3)) +- File argument in create/update operation ([#708](https://github.com/payloadcms/payload/issues/708)) ([f3b7dcf](https://github.com/payloadcms/payload/commit/f3b7dcff57961e0c6a5b1536de23b7fe6fa035cf)) +- graphql schema output ([#730](https://github.com/payloadcms/payload/issues/730)) ([ad43cbc](https://github.com/payloadcms/payload/commit/ad43cbc808572f15157e4e52d211253c63012d7f)) ## [0.18.5](https://github.com/payloadcms/payload/compare/v0.18.4...v0.18.5) (2022-06-29) ### Bug Fixes -* empty cell data renders in list ([#699](https://github.com/payloadcms/payload/issues/699)) ([b6b0ffb](https://github.com/payloadcms/payload/commit/b6b0ffb674ca6d1568981ab110013e66c678270f)) -* icon appears above select field's option list ([#685](https://github.com/payloadcms/payload/issues/685)) ([c78d774](https://github.com/payloadcms/payload/commit/c78d77446a6a8fd1e85f8c094f751dfc1f8b0530)) +- empty cell data renders in list ([#699](https://github.com/payloadcms/payload/issues/699)) ([b6b0ffb](https://github.com/payloadcms/payload/commit/b6b0ffb674ca6d1568981ab110013e66c678270f)) +- icon appears above select field's option list ([#685](https://github.com/payloadcms/payload/issues/685)) ([c78d774](https://github.com/payloadcms/payload/commit/c78d77446a6a8fd1e85f8c094f751dfc1f8b0530)) ## [0.18.4](https://github.com/payloadcms/payload/compare/v0.18.3...v0.18.4) (2022-06-24) @@ -1075,100 +1180,100 @@ Due to this change, the `admin.scss` functionality has become obsolete, and over ### Bug Fixes -* [#670](https://github.com/payloadcms/payload/issues/670), max tokenExpiration ([918062d](https://github.com/payloadcms/payload/commit/918062de2fba371068efc62a989a93ee07fd4c17)) +- [#670](https://github.com/payloadcms/payload/issues/670), max tokenExpiration ([918062d](https://github.com/payloadcms/payload/commit/918062de2fba371068efc62a989a93ee07fd4c17)) ## [0.18.2](https://github.com/payloadcms/payload/compare/v0.18.1...v0.18.2) (2022-06-24) ### Features -* telemetry ([1c37ec3](https://github.com/payloadcms/payload/commit/1c37ec39027c73e57ff53db58eca94d485d1fa14)) +- telemetry ([1c37ec3](https://github.com/payloadcms/payload/commit/1c37ec39027c73e57ff53db58eca94d485d1fa14)) ## [0.18.1](https://github.com/payloadcms/payload/compare/v0.18.0...v0.18.1) (2022-06-21) ### Bug Fixes -* [#671](https://github.com/payloadcms/payload/issues/671), password reset broken ([3d5ed93](https://github.com/payloadcms/payload/commit/3d5ed93fcea8a44d70aa6d46184fa7a50372cf88)) +- [#671](https://github.com/payloadcms/payload/issues/671), password reset broken ([3d5ed93](https://github.com/payloadcms/payload/commit/3d5ed93fcea8a44d70aa6d46184fa7a50372cf88)) # [0.18.0](https://github.com/payloadcms/payload/compare/v0.17.3...v0.18.0) (2022-06-14) ### Bug Fixes -* custom fields values resetting in ui ([#626](https://github.com/payloadcms/payload/issues/626)) ([f2bf239](https://github.com/payloadcms/payload/commit/f2bf2399fa34c49b3b68be55257908b0f8733962)) -* me auth route breaks with query params ([#648](https://github.com/payloadcms/payload/issues/648)) ([a1fe17d](https://github.com/payloadcms/payload/commit/a1fe17d05da57a6fc3ab933d064289fdcd7bf280)) +- custom fields values resetting in ui ([#626](https://github.com/payloadcms/payload/issues/626)) ([f2bf239](https://github.com/payloadcms/payload/commit/f2bf2399fa34c49b3b68be55257908b0f8733962)) +- me auth route breaks with query params ([#648](https://github.com/payloadcms/payload/issues/648)) ([a1fe17d](https://github.com/payloadcms/payload/commit/a1fe17d05da57a6fc3ab933d064289fdcd7bf280)) ### Features -* adds timestamps to generated collection types if enabled ([#604](https://github.com/payloadcms/payload/issues/604)) ([af6479b](https://github.com/payloadcms/payload/commit/af6479bf34128ee1c64f534778d6151fdc15f4f6)) -* enable webpack filesystem cache in dev ([#621](https://github.com/payloadcms/payload/issues/621)) ([44c1232](https://github.com/payloadcms/payload/commit/44c12325b4e47eed26c70047c4e594650bcf2648)) +- adds timestamps to generated collection types if enabled ([#604](https://github.com/payloadcms/payload/issues/604)) ([af6479b](https://github.com/payloadcms/payload/commit/af6479bf34128ee1c64f534778d6151fdc15f4f6)) +- enable webpack filesystem cache in dev ([#621](https://github.com/payloadcms/payload/issues/621)) ([44c1232](https://github.com/payloadcms/payload/commit/44c12325b4e47eed26c70047c4e594650bcf2648)) ## [0.17.3](https://github.com/payloadcms/payload/compare/v0.17.2...v0.17.3) (2022-06-08) ### Bug Fixes -* duplicate objects in array fields in validate data and siblingData ([#599](https://github.com/payloadcms/payload/issues/599)) ([20bbda9](https://github.com/payloadcms/payload/commit/20bbda95c67efb985f08b0380c6f21c13068a8b5)) -* ensures unflattening locales only happens if config specifies locales ([c18cc23](https://github.com/payloadcms/payload/commit/c18cc23c71bf8147a0cebed8415642c81f38eb0f)) +- duplicate objects in array fields in validate data and siblingData ([#599](https://github.com/payloadcms/payload/issues/599)) ([20bbda9](https://github.com/payloadcms/payload/commit/20bbda95c67efb985f08b0380c6f21c13068a8b5)) +- ensures unflattening locales only happens if config specifies locales ([c18cc23](https://github.com/payloadcms/payload/commit/c18cc23c71bf8147a0cebed8415642c81f38eb0f)) ## [0.17.2](https://github.com/payloadcms/payload/compare/v0.17.1...v0.17.2) (2022-05-24) ### Bug Fixes -* [#576](https://github.com/payloadcms/payload/issues/576), graphql where on hasMany relationship not working ([#582](https://github.com/payloadcms/payload/issues/582)) ([20d251f](https://github.com/payloadcms/payload/commit/20d251fd5dabd06f8d58ffcd5acec4dbd64ee515)) -* adds optional chaining to safely read drafts setting on versions ([#577](https://github.com/payloadcms/payload/issues/577)) ([982b3f0](https://github.com/payloadcms/payload/commit/982b3f0582d9f64bd560e96b0df3cc505cc86a2a)) -* passes required prop for select field ([#579](https://github.com/payloadcms/payload/issues/579)) ([734e905](https://github.com/payloadcms/payload/commit/734e905c186ebf96ff659008cb240f5adaa2b5b5)) +- [#576](https://github.com/payloadcms/payload/issues/576), graphql where on hasMany relationship not working ([#582](https://github.com/payloadcms/payload/issues/582)) ([20d251f](https://github.com/payloadcms/payload/commit/20d251fd5dabd06f8d58ffcd5acec4dbd64ee515)) +- adds optional chaining to safely read drafts setting on versions ([#577](https://github.com/payloadcms/payload/issues/577)) ([982b3f0](https://github.com/payloadcms/payload/commit/982b3f0582d9f64bd560e96b0df3cc505cc86a2a)) +- passes required prop for select field ([#579](https://github.com/payloadcms/payload/issues/579)) ([734e905](https://github.com/payloadcms/payload/commit/734e905c186ebf96ff659008cb240f5adaa2b5b5)) ## [0.17.1](https://github.com/payloadcms/payload/compare/v0.17.0...v0.17.1) (2022-05-17) ### Bug Fixes -* only localizes schema if both field and top-level config are enabled ([e1a5547](https://github.com/payloadcms/payload/commit/e1a5547fea065f5590930cbeb6d07bf59d62d21d)) +- only localizes schema if both field and top-level config are enabled ([e1a5547](https://github.com/payloadcms/payload/commit/e1a5547fea065f5590930cbeb6d07bf59d62d21d)) # [0.17.0](https://github.com/payloadcms/payload/compare/v0.16.4...v0.17.0) (2022-05-16) ### Bug Fixes -* apply field condition to custom components ([#560](https://github.com/payloadcms/payload/issues/560)) ([1dfe2b8](https://github.com/payloadcms/payload/commit/1dfe2b892947411ff5295f5818befe28c4972915)) -* prevent changing order of readOnly arrays ([#563](https://github.com/payloadcms/payload/issues/563)) ([16b7edb](https://github.com/payloadcms/payload/commit/16b7edbc9782dcfb3bef77f1ff312e041d66922c)) +- apply field condition to custom components ([#560](https://github.com/payloadcms/payload/issues/560)) ([1dfe2b8](https://github.com/payloadcms/payload/commit/1dfe2b892947411ff5295f5818befe28c4972915)) +- prevent changing order of readOnly arrays ([#563](https://github.com/payloadcms/payload/issues/563)) ([16b7edb](https://github.com/payloadcms/payload/commit/16b7edbc9782dcfb3bef77f1ff312e041d66922c)) ## [0.16.4](https://github.com/payloadcms/payload/compare/v0.16.3...v0.16.4) (2022-05-06) ### Bug Fixes -* fields in groups causing console error in browser ([#553](https://github.com/payloadcms/payload/issues/553)) ([78edac6](https://github.com/payloadcms/payload/commit/78edac684e54d335b15303d8348c8abcb2bba716)) -* save resized image file when equal to upload size ([#555](https://github.com/payloadcms/payload/issues/555)) ([46f4bc2](https://github.com/payloadcms/payload/commit/46f4bc2a077ce668e9b30c187092b9b0c6d83f86)) +- fields in groups causing console error in browser ([#553](https://github.com/payloadcms/payload/issues/553)) ([78edac6](https://github.com/payloadcms/payload/commit/78edac684e54d335b15303d8348c8abcb2bba716)) +- save resized image file when equal to upload size ([#555](https://github.com/payloadcms/payload/issues/555)) ([46f4bc2](https://github.com/payloadcms/payload/commit/46f4bc2a077ce668e9b30c187092b9b0c6d83f86)) ## [0.16.3](https://github.com/payloadcms/payload/compare/v0.16.2...v0.16.3) (2022-05-04) ### Bug Fixes -* rare bug while merging locale data ([47c37e0](https://github.com/payloadcms/payload/commit/47c37e015300be4f9d5d4387f26a0adb39b8379c)) +- rare bug while merging locale data ([47c37e0](https://github.com/payloadcms/payload/commit/47c37e015300be4f9d5d4387f26a0adb39b8379c)) ## [0.16.2](https://github.com/payloadcms/payload/compare/v0.16.1...v0.16.2) (2022-05-02) ### Bug Fixes -* checkbox defaultValues and more typing of sanitize ([#550](https://github.com/payloadcms/payload/issues/550)) ([1e4a68f](https://github.com/payloadcms/payload/commit/1e4a68f76eeaab58ced0cc500223a1b86d66668e)) +- checkbox defaultValues and more typing of sanitize ([#550](https://github.com/payloadcms/payload/issues/550)) ([1e4a68f](https://github.com/payloadcms/payload/commit/1e4a68f76eeaab58ced0cc500223a1b86d66668e)) ### Features -* exposes findMany argument to afterRead hooks to discern between find and findByID ([b3832e2](https://github.com/payloadcms/payload/commit/b3832e21c91fa5d52067cfc24a0b4f8aa6e178ec)) -* optimizes field operations ([18489fa](https://github.com/payloadcms/payload/commit/18489facebe5d7b0abc87dcc30fae28510b6bb19)) +- exposes findMany argument to afterRead hooks to discern between find and findByID ([b3832e2](https://github.com/payloadcms/payload/commit/b3832e21c91fa5d52067cfc24a0b4f8aa6e178ec)) +- optimizes field operations ([18489fa](https://github.com/payloadcms/payload/commit/18489facebe5d7b0abc87dcc30fae28510b6bb19)) ## [0.16.1](https://github.com/payloadcms/payload/compare/v0.16.0...v0.16.1) (2022-04-29) ### Features -* exposes payload within server-side validation args ([e46b942](https://github.com/payloadcms/payload/commit/e46b94225957bba7758a0a2c22776c44a2d2d633)) +- exposes payload within server-side validation args ([e46b942](https://github.com/payloadcms/payload/commit/e46b94225957bba7758a0a2c22776c44a2d2d633)) # [0.16.0](https://github.com/payloadcms/payload/compare/v0.15.13...v0.16.0) (2022-04-29) ### Bug Fixes -* file upload safely handles missing mimeTypes ([#540](https://github.com/payloadcms/payload/issues/540)) ([bf48fdf](https://github.com/payloadcms/payload/commit/bf48fdf18961a2e57bcc5aae73de4c569e97e42b)) +- file upload safely handles missing mimeTypes ([#540](https://github.com/payloadcms/payload/issues/540)) ([bf48fdf](https://github.com/payloadcms/payload/commit/bf48fdf18961a2e57bcc5aae73de4c569e97e42b)) ### Features -* allow subfield readOnly to override parent readOnly ([#546](https://github.com/payloadcms/payload/issues/546)) ([834f4c2](https://github.com/payloadcms/payload/commit/834f4c270020bf32852c00a3abbb908853689006)) -* allows defaultValue to accept async function to calculate defaultValue ([#547](https://github.com/payloadcms/payload/issues/547)) ([e297eb9](https://github.com/payloadcms/payload/commit/e297eb90907d933524d220255d5f8dc4276358c5)) +- allow subfield readOnly to override parent readOnly ([#546](https://github.com/payloadcms/payload/issues/546)) ([834f4c2](https://github.com/payloadcms/payload/commit/834f4c270020bf32852c00a3abbb908853689006)) +- allows defaultValue to accept async function to calculate defaultValue ([#547](https://github.com/payloadcms/payload/issues/547)) ([e297eb9](https://github.com/payloadcms/payload/commit/e297eb90907d933524d220255d5f8dc4276358c5)) ## [0.15.13](https://github.com/payloadcms/payload/compare/v0.15.12...v0.15.13) (2022-04-26) @@ -1176,88 +1281,88 @@ Due to this change, the `admin.scss` functionality has become obsolete, and over ### Bug Fixes -* ensures adding array / block rows modifies form state ([8bdbd0d](https://github.com/payloadcms/payload/commit/8bdbd0dd418cd665441703fa4fd87becafd26170)) +- ensures adding array / block rows modifies form state ([8bdbd0d](https://github.com/payloadcms/payload/commit/8bdbd0dd418cd665441703fa4fd87becafd26170)) ## [0.15.11](https://github.com/payloadcms/payload/compare/v0.15.10...v0.15.11) (2022-04-24) ### Bug Fixes -* improperly typed access control ([b99ec06](https://github.com/payloadcms/payload/commit/b99ec060cacf7a05c20ba0a05dd6ef6ab60df304)) +- improperly typed access control ([b99ec06](https://github.com/payloadcms/payload/commit/b99ec060cacf7a05c20ba0a05dd6ef6ab60df304)) ## [0.15.10](https://github.com/payloadcms/payload/compare/v0.15.9...v0.15.10) (2022-04-24) ### Bug Fixes -* block form-data bug ([3b70560](https://github.com/payloadcms/payload/commit/3b70560e2566de5294eb15945120ffd6f1f5f1c4)) +- block form-data bug ([3b70560](https://github.com/payloadcms/payload/commit/3b70560e2566de5294eb15945120ffd6f1f5f1c4)) ## [0.15.9](https://github.com/payloadcms/payload/compare/v0.15.8...v0.15.9) (2022-04-20) ### Bug Fixes -* intermittent blocks UI issue ([3c1dfb8](https://github.com/payloadcms/payload/commit/3c1dfb88df8651b26cb1dbc102a34cd0aad722bc)) +- intermittent blocks UI issue ([3c1dfb8](https://github.com/payloadcms/payload/commit/3c1dfb88df8651b26cb1dbc102a34cd0aad722bc)) ## [0.15.8](https://github.com/payloadcms/payload/compare/v0.15.7...v0.15.8) (2022-04-20) ### Bug Fixes -* ensure relationTo is valid in upload fields ([#533](https://github.com/payloadcms/payload/issues/533)) ([9e324be](https://github.com/payloadcms/payload/commit/9e324be0577447965ee2f87c3a3943cd4f0c0a1c)) -* richtext editor input height ([#529](https://github.com/payloadcms/payload/issues/529)) ([3dcd8a2](https://github.com/payloadcms/payload/commit/3dcd8a24cb8cbb77aae82a1f841429e7149e3182)) +- ensure relationTo is valid in upload fields ([#533](https://github.com/payloadcms/payload/issues/533)) ([9e324be](https://github.com/payloadcms/payload/commit/9e324be0577447965ee2f87c3a3943cd4f0c0a1c)) +- richtext editor input height ([#529](https://github.com/payloadcms/payload/issues/529)) ([3dcd8a2](https://github.com/payloadcms/payload/commit/3dcd8a24cb8cbb77aae82a1f841429e7149e3182)) ## [0.15.7](https://github.com/payloadcms/payload/compare/v0.15.6...v0.15.7) (2022-04-12) ### Bug Fixes -* checkbox validation error positioning ([9af89b6](https://github.com/payloadcms/payload/commit/9af89b6c03bc4e82a0c3e353f0d53ec14a847ee2)) +- checkbox validation error positioning ([9af89b6](https://github.com/payloadcms/payload/commit/9af89b6c03bc4e82a0c3e353f0d53ec14a847ee2)) ### Features -* sanitize defaultValue to false when field is required ([6f84c0a](https://github.com/payloadcms/payload/commit/6f84c0a86943e9d99edde21b1d448e7ece3dd83c)) +- sanitize defaultValue to false when field is required ([6f84c0a](https://github.com/payloadcms/payload/commit/6f84c0a86943e9d99edde21b1d448e7ece3dd83c)) ## [0.15.6](https://github.com/payloadcms/payload/compare/v0.15.5...v0.15.6) (2022-04-06) ### Bug Fixes -* new up separate logger for generateTypes script ([cf54b33](https://github.com/payloadcms/payload/commit/cf54b336d17a79d775dd673c0eda361b356d159c)) +- new up separate logger for generateTypes script ([cf54b33](https://github.com/payloadcms/payload/commit/cf54b336d17a79d775dd673c0eda361b356d159c)) ## [0.15.5](https://github.com/payloadcms/payload/compare/v0.15.4...v0.15.5) (2022-04-06) ### Bug Fixes -* relationship component showing no results ([#508](https://github.com/payloadcms/payload/issues/508)) ([e1c6d9d](https://github.com/payloadcms/payload/commit/e1c6d9dd7d390c671edb0430d04aa0f194bf43e3)) +- relationship component showing no results ([#508](https://github.com/payloadcms/payload/issues/508)) ([e1c6d9d](https://github.com/payloadcms/payload/commit/e1c6d9dd7d390c671edb0430d04aa0f194bf43e3)) ## [0.15.4](https://github.com/payloadcms/payload/compare/v0.15.3...v0.15.4) (2022-04-05) ### Bug Fixes -* [#495](https://github.com/payloadcms/payload/issues/495), avoids appending version to id queries ([ab432a4](https://github.com/payloadcms/payload/commit/ab432a43dc568da0b7e65e275aed335d729600fa)) -* default point validation allows not required and some edge cases ([29405bb](https://github.com/payloadcms/payload/commit/29405bbc0e3a5c3c1f3dadb2386a68e1fe159c42)) +- [#495](https://github.com/payloadcms/payload/issues/495), avoids appending version to id queries ([ab432a4](https://github.com/payloadcms/payload/commit/ab432a43dc568da0b7e65e275aed335d729600fa)) +- default point validation allows not required and some edge cases ([29405bb](https://github.com/payloadcms/payload/commit/29405bbc0e3a5c3c1f3dadb2386a68e1fe159c42)) ### Features -* allows like to search by many words, adds contain to match exact strings ([ec91757](https://github.com/payloadcms/payload/commit/ec91757257ed062c7743fca3d07d1b6af21cacb4)) -* extended validation function arguments ([#494](https://github.com/payloadcms/payload/issues/494)) ([1b4b570](https://github.com/payloadcms/payload/commit/1b4b5707bfa731bedc5d9ca49ac9f425932b999c)), closes [#495](https://github.com/payloadcms/payload/issues/495) -* filter relationship options using filterOptions ([485991b](https://github.com/payloadcms/payload/commit/485991bd48c3512acca8dd94b3ab6c160bf1f153)) -* **logging:** allow pino logger options to be passed into init ([6620a4f](https://github.com/payloadcms/payload/commit/6620a4f682f0a3169218dd83e1de315f95726287)) -* support className config for row, block and array fields ([#504](https://github.com/payloadcms/payload/issues/504)) ([0461c21](https://github.com/payloadcms/payload/commit/0461c2109bea76742f94ae6f830c655ec67d1428)) +- allows like to search by many words, adds contain to match exact strings ([ec91757](https://github.com/payloadcms/payload/commit/ec91757257ed062c7743fca3d07d1b6af21cacb4)) +- extended validation function arguments ([#494](https://github.com/payloadcms/payload/issues/494)) ([1b4b570](https://github.com/payloadcms/payload/commit/1b4b5707bfa731bedc5d9ca49ac9f425932b999c)), closes [#495](https://github.com/payloadcms/payload/issues/495) +- filter relationship options using filterOptions ([485991b](https://github.com/payloadcms/payload/commit/485991bd48c3512acca8dd94b3ab6c160bf1f153)) +- **logging:** allow pino logger options to be passed into init ([6620a4f](https://github.com/payloadcms/payload/commit/6620a4f682f0a3169218dd83e1de315f95726287)) +- support className config for row, block and array fields ([#504](https://github.com/payloadcms/payload/issues/504)) ([0461c21](https://github.com/payloadcms/payload/commit/0461c2109bea76742f94ae6f830c655ec67d1428)) ## [0.15.3](https://github.com/payloadcms/payload/compare/v0.15.2...v0.15.3) (2022-04-04) ### Bug Fixes -* [#499](https://github.com/payloadcms/payload/issues/499), graphql row / ui field bug ([f4a2dff](https://github.com/payloadcms/payload/commit/f4a2dff892e6e8a6aa201c2a66b4db4fa2cd98b8)) +- [#499](https://github.com/payloadcms/payload/issues/499), graphql row / ui field bug ([f4a2dff](https://github.com/payloadcms/payload/commit/f4a2dff892e6e8a6aa201c2a66b4db4fa2cd98b8)) ## [0.15.2](https://github.com/payloadcms/payload/compare/v0.15.1...v0.15.2) (2022-04-04) ### Bug Fixes -* [#495](https://github.com/payloadcms/payload/issues/495), avoids appending version to id queries ([a703e05](https://github.com/payloadcms/payload/commit/a703e0582df3f4706ee051cf1752c79ff4b551ef)) +- [#495](https://github.com/payloadcms/payload/issues/495), avoids appending version to id queries ([a703e05](https://github.com/payloadcms/payload/commit/a703e0582df3f4706ee051cf1752c79ff4b551ef)) ## [0.15.1](https://github.com/payloadcms/payload/compare/v0.15.0...v0.15.1) (2022-03-28) ### Features -* builds a way to inject custom React providers into admin UI ([5a7e8a9](https://github.com/payloadcms/payload/commit/5a7e8a980be4e93f2503d8d007019948199a4867)) -* export Plugin type from config types ([#491](https://github.com/payloadcms/payload/issues/491)) ([45f7011](https://github.com/payloadcms/payload/commit/45f70114e6664942228b46373843879c06ab8211)) +- builds a way to inject custom React providers into admin UI ([5a7e8a9](https://github.com/payloadcms/payload/commit/5a7e8a980be4e93f2503d8d007019948199a4867)) +- export Plugin type from config types ([#491](https://github.com/payloadcms/payload/issues/491)) ([45f7011](https://github.com/payloadcms/payload/commit/45f70114e6664942228b46373843879c06ab8211)) # [0.15.0](https://github.com/payloadcms/payload/compare/v0.14.0...v0.15.0) (2022-03-16) @@ -1295,413 +1400,413 @@ The new shape of GraphQL errors is as follows: ### Bug Fixes -* [#422](https://github.com/payloadcms/payload/issues/422), prevents loading duplicative relationship options ([414679d](https://github.com/payloadcms/payload/commit/414679d86aac7ed94970a6eee14ff77b65f5c1d1)) -* [#423](https://github.com/payloadcms/payload/issues/423), [#391](https://github.com/payloadcms/payload/issues/391) - prevents loading edit views until data initializes ([2884654](https://github.com/payloadcms/payload/commit/28846547afc7e7bb8accc5dbe9f3b98593f332fa)) -* [#424](https://github.com/payloadcms/payload/issues/424), unable to clear localized property vals ([1a05fe4](https://github.com/payloadcms/payload/commit/1a05fe448c0755438dedc20c95d4a6a587912e2f)) -* [#431](https://github.com/payloadcms/payload/issues/431) - relationship field not properly fetching option results ([6fab8bf](https://github.com/payloadcms/payload/commit/6fab8bfbef43d5da67cadc7dd61fd14b9b36bdc1)) -* [#454](https://github.com/payloadcms/payload/issues/454), withCondition type usability ([56c16d5](https://github.com/payloadcms/payload/commit/56c16d5c16311b445662f715cc07e67d651e53a6)) -* [#459](https://github.com/payloadcms/payload/issues/459) - in Relationship field to multiple collections, when the value is null, options are not populated ([#460](https://github.com/payloadcms/payload/issues/460)) ([a9b83c8](https://github.com/payloadcms/payload/commit/a9b83c87980df0a62823950e5ef31ad0de218f1a)) -* [#461](https://github.com/payloadcms/payload/issues/461) ([08924a1](https://github.com/payloadcms/payload/commit/08924a1934ef257992381dfdded0cd9c7333e40c)) -* [#464](https://github.com/payloadcms/payload/issues/464), graphql upload access control ([fd0629e](https://github.com/payloadcms/payload/commit/fd0629e93202dfaa399c753c59481b1cbd139bf6)) -* adds key to RichText based on initialValue ([f710b8c](https://github.com/payloadcms/payload/commit/f710b8c4f3247156f64fb2b528a960bf808ef7ac)) -* adjusts lte and gte types to match docs and codebase ([#480](https://github.com/payloadcms/payload/issues/480)) ([8fc4f7f](https://github.com/payloadcms/payload/commit/8fc4f7f8068cb8fcef13b1cfd6de7b4f74b5415f)) -* allow jwt to work without csrf in config ([4048734](https://github.com/payloadcms/payload/commit/40487347e3f8bd03da440a73bec0ee491abbef85)) -* awaits beforeDelete hooks ([609b871](https://github.com/payloadcms/payload/commit/609b871fa274e8b6d9eaf301e52ab42179aad9b7)) -* config empty and sparse csrf is now allowed ([7e7b058](https://github.com/payloadcms/payload/commit/7e7b0589ef6c06941af3e7e3a24c7071d8b77a1a)) -* ensures empty hasMany relationships save as empty arrays ([08b3e8f](https://github.com/payloadcms/payload/commit/08b3e8f18f0aa620d537f3258b2e080600e0f43e)) -* ensures nested lists always render properly ([20e5dfb](https://github.com/payloadcms/payload/commit/20e5dfbb4ab8dab320d60772f5195c5faffe38d3)) -* ensures overrideAccess is false if undefined while populating ([97f3178](https://github.com/payloadcms/payload/commit/97f31780051828a9d506eba3520a1390acb99a96)) -* ensures rte upload is populated when only upload is enabled ([39438b8](https://github.com/payloadcms/payload/commit/39438b8460f853f64d84436eed49dde74cd207d2)) -* import path for createRichTextRelationshipPromise ([586cd4d](https://github.com/payloadcms/payload/commit/586cd4d6af5485116ebb299a5af3d24f5baeaa2e)) -* improperly typed local create method ([48aa27c](https://github.com/payloadcms/payload/commit/48aa27ce701e44561edf442ee6c248b007ecafcb)) -* mobile styling to not found page ([d3f88a1](https://github.com/payloadcms/payload/commit/d3f88a1bd9aeb1551d64b9ed975da5e69e5821bd)) -* new slate version types ([c5de01b](https://github.com/payloadcms/payload/commit/c5de01bfc48ca6793c1526499fe934d9ad8f0cc9)) -* optimizes relationship input search querying ([7e69fcb](https://github.com/payloadcms/payload/commit/7e69fcbc7d89012a7caff6e0e9013a9ad8a62a14)) -* prevents None from appearing in hasMany relationship select options ([cbf43fa](https://github.com/payloadcms/payload/commit/cbf43fa0d8ba50b7a9ef952f1693de6923068ffd)) -* rare crash with link rte element ([f5535f6](https://github.com/payloadcms/payload/commit/f5535f613ac4d876d040be74b45e105e0f4775a8)) -* rte upload field population ([8327b5a](https://github.com/payloadcms/payload/commit/8327b5aae505a189a5b9617c3485d646b5f8b517)) -* type error in useField ([ef4e6d3](https://github.com/payloadcms/payload/commit/ef4e6d32a90215c07aa2c1e7217cf53558bfae97)) +- [#422](https://github.com/payloadcms/payload/issues/422), prevents loading duplicative relationship options ([414679d](https://github.com/payloadcms/payload/commit/414679d86aac7ed94970a6eee14ff77b65f5c1d1)) +- [#423](https://github.com/payloadcms/payload/issues/423), [#391](https://github.com/payloadcms/payload/issues/391) - prevents loading edit views until data initializes ([2884654](https://github.com/payloadcms/payload/commit/28846547afc7e7bb8accc5dbe9f3b98593f332fa)) +- [#424](https://github.com/payloadcms/payload/issues/424), unable to clear localized property vals ([1a05fe4](https://github.com/payloadcms/payload/commit/1a05fe448c0755438dedc20c95d4a6a587912e2f)) +- [#431](https://github.com/payloadcms/payload/issues/431) - relationship field not properly fetching option results ([6fab8bf](https://github.com/payloadcms/payload/commit/6fab8bfbef43d5da67cadc7dd61fd14b9b36bdc1)) +- [#454](https://github.com/payloadcms/payload/issues/454), withCondition type usability ([56c16d5](https://github.com/payloadcms/payload/commit/56c16d5c16311b445662f715cc07e67d651e53a6)) +- [#459](https://github.com/payloadcms/payload/issues/459) - in Relationship field to multiple collections, when the value is null, options are not populated ([#460](https://github.com/payloadcms/payload/issues/460)) ([a9b83c8](https://github.com/payloadcms/payload/commit/a9b83c87980df0a62823950e5ef31ad0de218f1a)) +- [#461](https://github.com/payloadcms/payload/issues/461) ([08924a1](https://github.com/payloadcms/payload/commit/08924a1934ef257992381dfdded0cd9c7333e40c)) +- [#464](https://github.com/payloadcms/payload/issues/464), graphql upload access control ([fd0629e](https://github.com/payloadcms/payload/commit/fd0629e93202dfaa399c753c59481b1cbd139bf6)) +- adds key to RichText based on initialValue ([f710b8c](https://github.com/payloadcms/payload/commit/f710b8c4f3247156f64fb2b528a960bf808ef7ac)) +- adjusts lte and gte types to match docs and codebase ([#480](https://github.com/payloadcms/payload/issues/480)) ([8fc4f7f](https://github.com/payloadcms/payload/commit/8fc4f7f8068cb8fcef13b1cfd6de7b4f74b5415f)) +- allow jwt to work without csrf in config ([4048734](https://github.com/payloadcms/payload/commit/40487347e3f8bd03da440a73bec0ee491abbef85)) +- awaits beforeDelete hooks ([609b871](https://github.com/payloadcms/payload/commit/609b871fa274e8b6d9eaf301e52ab42179aad9b7)) +- config empty and sparse csrf is now allowed ([7e7b058](https://github.com/payloadcms/payload/commit/7e7b0589ef6c06941af3e7e3a24c7071d8b77a1a)) +- ensures empty hasMany relationships save as empty arrays ([08b3e8f](https://github.com/payloadcms/payload/commit/08b3e8f18f0aa620d537f3258b2e080600e0f43e)) +- ensures nested lists always render properly ([20e5dfb](https://github.com/payloadcms/payload/commit/20e5dfbb4ab8dab320d60772f5195c5faffe38d3)) +- ensures overrideAccess is false if undefined while populating ([97f3178](https://github.com/payloadcms/payload/commit/97f31780051828a9d506eba3520a1390acb99a96)) +- ensures rte upload is populated when only upload is enabled ([39438b8](https://github.com/payloadcms/payload/commit/39438b8460f853f64d84436eed49dde74cd207d2)) +- import path for createRichTextRelationshipPromise ([586cd4d](https://github.com/payloadcms/payload/commit/586cd4d6af5485116ebb299a5af3d24f5baeaa2e)) +- improperly typed local create method ([48aa27c](https://github.com/payloadcms/payload/commit/48aa27ce701e44561edf442ee6c248b007ecafcb)) +- mobile styling to not found page ([d3f88a1](https://github.com/payloadcms/payload/commit/d3f88a1bd9aeb1551d64b9ed975da5e69e5821bd)) +- new slate version types ([c5de01b](https://github.com/payloadcms/payload/commit/c5de01bfc48ca6793c1526499fe934d9ad8f0cc9)) +- optimizes relationship input search querying ([7e69fcb](https://github.com/payloadcms/payload/commit/7e69fcbc7d89012a7caff6e0e9013a9ad8a62a14)) +- prevents None from appearing in hasMany relationship select options ([cbf43fa](https://github.com/payloadcms/payload/commit/cbf43fa0d8ba50b7a9ef952f1693de6923068ffd)) +- rare crash with link rte element ([f5535f6](https://github.com/payloadcms/payload/commit/f5535f613ac4d876d040be74b45e105e0f4775a8)) +- rte upload field population ([8327b5a](https://github.com/payloadcms/payload/commit/8327b5aae505a189a5b9617c3485d646b5f8b517)) +- type error in useField ([ef4e6d3](https://github.com/payloadcms/payload/commit/ef4e6d32a90215c07aa2c1e7217cf53558bfae97)) ### Features -* :tada: versions, drafts, & autosave! -* [#458](https://github.com/payloadcms/payload/issues/458), provides field hooks with sibling data ([8e23a24](https://github.com/payloadcms/payload/commit/8e23a24f34ef7425bb4d43e96e869b255740c739)) -* add before and after login components ([#427](https://github.com/payloadcms/payload/issues/427)) ([5591eea](https://github.com/payloadcms/payload/commit/5591eeafca1aa6e8abcc2d8276f7478e00b75ef2)) -* add logMockCredentials email option ([ff33453](https://github.com/payloadcms/payload/commit/ff3345373630ca6913165284123a62269b3fa2c6)) -* add pagination argument to optimize graphql relationships and use in local api ([#482](https://github.com/payloadcms/payload/issues/482)) ([647db51](https://github.com/payloadcms/payload/commit/647db5122e7b7be7f032d50ccf332780d8203369)) -* adds a way to customize express.static options ([dbb3c50](https://github.com/payloadcms/payload/commit/dbb3c502227597ef4d04c9e5c8db6d2f51a8aac4)) -* adds admin.upload.collections[collection-name].fields to the RTE to save specific data on upload elements ([3adf44a](https://github.com/payloadcms/payload/commit/3adf44a24162e5adbcebdb0ca7d0d460d23c57eb)) -* adds indentation controls to rich text ([7df50f9](https://github.com/payloadcms/payload/commit/7df50f9bf9d4867e65bdd8cebdf43e0ab1737a63)) -* adds originalDoc to field access control ([c979513](https://github.com/payloadcms/payload/commit/c9795133b376d8159457a0a38784d0b53a549061)) -* adds path to GraphQL errors ([#457](https://github.com/payloadcms/payload/issues/457)) ([ad98b29](https://github.com/payloadcms/payload/commit/ad98b293983016db3c730112c9d2387de7bacb34)) -* adds recursion to richText field to populate relationship and upload nested fields ([42af22c](https://github.com/payloadcms/payload/commit/42af22c2a10de44555bfedf902e7b4a4c9b25d6b)) -* allow empty string radio and select option values ([#479](https://github.com/payloadcms/payload/issues/479)) ([f14e187](https://github.com/payloadcms/payload/commit/f14e187545b759ac4623189d5e31f25382728cc0)) -* allows access control to prevent reading of drafts ([c38470c](https://github.com/payloadcms/payload/commit/c38470c7b2119cec6ff9a3efc89f087a5999bb66)) -* allows global access control to return query constraints ([c0150ae](https://github.com/payloadcms/payload/commit/c0150ae8465777a2be1b6bc496a5be30cf478f42)) -* allows select input to receive new options ([#435](https://github.com/payloadcms/payload/issues/435)) ([500fb1c](https://github.com/payloadcms/payload/commit/500fb1c5c41a55d35c41173d50a976388fd0bd1b)) -* builds a way for multipart/form-data reqs to retain non-string values ([4efc2cf](https://github.com/payloadcms/payload/commit/4efc2cf71c8ec4c452fea0febfd1156b37868739)) -* enhances rich text upload with custom field API ([0e4eb90](https://github.com/payloadcms/payload/commit/0e4eb906f2881dca518fea6b41e460bc57da9801)) -* ensures field hooks run on all locales when locale=all ([c3f743a](https://github.com/payloadcms/payload/commit/c3f743af03bbde856dcd87114383f0b484c0b20f)) -* exposes data arg within create and update access control ([73f418b](https://github.com/payloadcms/payload/commit/73f418bb5cadf73f683fe04ee94e4d24c8cfe96f)) -* exposes FieldWithPath type for reuse ([df3a836](https://github.com/payloadcms/payload/commit/df3a83634fcb64724ef239600e3af4fc295fee4f)) -* exposes useLocale for reuse ([bef0206](https://github.com/payloadcms/payload/commit/bef02062e769d1b0279c51af748f06d41c924c8a)) -* improves adding rich text voids to RTE ([966c3c6](https://github.com/payloadcms/payload/commit/966c3c647198569ba06013481a3b6fa9042b058d)) -* improves relationship field performance ([13318ff](https://github.com/payloadcms/payload/commit/13318ff3608a6be3dc7b86cc4e97155b26ef9df6)) -* improves rich text link ([2e9a4c7](https://github.com/payloadcms/payload/commit/2e9a4c7d717e3a08b2982b8c49eb358baf23da17)) -* indexes filenames ([07c8ac0](https://github.com/payloadcms/payload/commit/07c8ac08e21689cc6a3a2a546e58cf544fb61dec)) +- :tada: versions, drafts, & autosave! +- [#458](https://github.com/payloadcms/payload/issues/458), provides field hooks with sibling data ([8e23a24](https://github.com/payloadcms/payload/commit/8e23a24f34ef7425bb4d43e96e869b255740c739)) +- add before and after login components ([#427](https://github.com/payloadcms/payload/issues/427)) ([5591eea](https://github.com/payloadcms/payload/commit/5591eeafca1aa6e8abcc2d8276f7478e00b75ef2)) +- add logMockCredentials email option ([ff33453](https://github.com/payloadcms/payload/commit/ff3345373630ca6913165284123a62269b3fa2c6)) +- add pagination argument to optimize graphql relationships and use in local api ([#482](https://github.com/payloadcms/payload/issues/482)) ([647db51](https://github.com/payloadcms/payload/commit/647db5122e7b7be7f032d50ccf332780d8203369)) +- adds a way to customize express.static options ([dbb3c50](https://github.com/payloadcms/payload/commit/dbb3c502227597ef4d04c9e5c8db6d2f51a8aac4)) +- adds admin.upload.collections[collection-name].fields to the RTE to save specific data on upload elements ([3adf44a](https://github.com/payloadcms/payload/commit/3adf44a24162e5adbcebdb0ca7d0d460d23c57eb)) +- adds indentation controls to rich text ([7df50f9](https://github.com/payloadcms/payload/commit/7df50f9bf9d4867e65bdd8cebdf43e0ab1737a63)) +- adds originalDoc to field access control ([c979513](https://github.com/payloadcms/payload/commit/c9795133b376d8159457a0a38784d0b53a549061)) +- adds path to GraphQL errors ([#457](https://github.com/payloadcms/payload/issues/457)) ([ad98b29](https://github.com/payloadcms/payload/commit/ad98b293983016db3c730112c9d2387de7bacb34)) +- adds recursion to richText field to populate relationship and upload nested fields ([42af22c](https://github.com/payloadcms/payload/commit/42af22c2a10de44555bfedf902e7b4a4c9b25d6b)) +- allow empty string radio and select option values ([#479](https://github.com/payloadcms/payload/issues/479)) ([f14e187](https://github.com/payloadcms/payload/commit/f14e187545b759ac4623189d5e31f25382728cc0)) +- allows access control to prevent reading of drafts ([c38470c](https://github.com/payloadcms/payload/commit/c38470c7b2119cec6ff9a3efc89f087a5999bb66)) +- allows global access control to return query constraints ([c0150ae](https://github.com/payloadcms/payload/commit/c0150ae8465777a2be1b6bc496a5be30cf478f42)) +- allows select input to receive new options ([#435](https://github.com/payloadcms/payload/issues/435)) ([500fb1c](https://github.com/payloadcms/payload/commit/500fb1c5c41a55d35c41173d50a976388fd0bd1b)) +- builds a way for multipart/form-data reqs to retain non-string values ([4efc2cf](https://github.com/payloadcms/payload/commit/4efc2cf71c8ec4c452fea0febfd1156b37868739)) +- enhances rich text upload with custom field API ([0e4eb90](https://github.com/payloadcms/payload/commit/0e4eb906f2881dca518fea6b41e460bc57da9801)) +- ensures field hooks run on all locales when locale=all ([c3f743a](https://github.com/payloadcms/payload/commit/c3f743af03bbde856dcd87114383f0b484c0b20f)) +- exposes data arg within create and update access control ([73f418b](https://github.com/payloadcms/payload/commit/73f418bb5cadf73f683fe04ee94e4d24c8cfe96f)) +- exposes FieldWithPath type for reuse ([df3a836](https://github.com/payloadcms/payload/commit/df3a83634fcb64724ef239600e3af4fc295fee4f)) +- exposes useLocale for reuse ([bef0206](https://github.com/payloadcms/payload/commit/bef02062e769d1b0279c51af748f06d41c924c8a)) +- improves adding rich text voids to RTE ([966c3c6](https://github.com/payloadcms/payload/commit/966c3c647198569ba06013481a3b6fa9042b058d)) +- improves relationship field performance ([13318ff](https://github.com/payloadcms/payload/commit/13318ff3608a6be3dc7b86cc4e97155b26ef9df6)) +- improves rich text link ([2e9a4c7](https://github.com/payloadcms/payload/commit/2e9a4c7d717e3a08b2982b8c49eb358baf23da17)) +- indexes filenames ([07c8ac0](https://github.com/payloadcms/payload/commit/07c8ac08e21689cc6a3a2a546e58cf544fb61dec)) a79570c)) -* rich text indentation ([2deed8b](https://github.com/payloadcms/payload/commit/2deed8b1464931c4bc76a288923b307cf04b6a4a)) -* serverURL is no longer required ([#437](https://github.com/payloadcms/payload/issues/437)) ([dca90c4](https://github.com/payloadcms/payload/commit/dca90c4aa92dd0cc2084ba16249254c9259622c3)) -* updates dependencies ([3ca3f53](https://github.com/payloadcms/payload/commit/3ca3f533d07b644fa8a3d077932860e9f12318c2)) +- rich text indentation ([2deed8b](https://github.com/payloadcms/payload/commit/2deed8b1464931c4bc76a288923b307cf04b6a4a)) +- serverURL is no longer required ([#437](https://github.com/payloadcms/payload/issues/437)) ([dca90c4](https://github.com/payloadcms/payload/commit/dca90c4aa92dd0cc2084ba16249254c9259622c3)) +- updates dependencies ([3ca3f53](https://github.com/payloadcms/payload/commit/3ca3f533d07b644fa8a3d077932860e9f12318c2)) ## [0.14.31-beta.0](https://github.com/payloadcms/payload/compare/v0.14.0...v0.14.31-beta.0) (2022-03-10) ### Bug Fixes -* improves rich text link ([2e9a4c7](https://github.com/payloadcms/payload/commit/2e9a4c7d717e3a08b2982b8c49eb358baf23da17)) -* improves adding rich text voids to RTE ([966c3c6](https://github.com/payloadcms/payload/commit/966c3c647198569ba06013481a3b6fa9042b058d)) -* rare crash with link rte element ([f5535f6](https://github.com/payloadcms/payload/commit/f5535f613ac4d876d040be74b45e105e0f4775a8)) -* ensures empty hasMany relationships save as empty arrays ([08b3e8f](https://github.com/payloadcms/payload/commit/08b3e8f18f0aa620d537f3258b2e080600e0f43e)) -* [#422](https://github.com/payloadcms/payload/issues/422), prevents loading duplicative relationship options ([414679d](https://github.com/payloadcms/payload/commit/414679d86aac7ed94970a6eee14ff77b65f5c1d1)) -* [#423](https://github.com/payloadcms/payload/issues/423), [#391](https://github.com/payloadcms/payload/issues/391) - prevents loading edit views until data initializes ([2884654](https://github.com/payloadcms/payload/commit/28846547afc7e7bb8accc5dbe9f3b98593f332fa)) -* [#424](https://github.com/payloadcms/payload/issues/424), unable to clear localized property vals ([1a05fe4](https://github.com/payloadcms/payload/commit/1a05fe448c0755438dedc20c95d4a6a587912e2f)) -* [#431](https://github.com/payloadcms/payload/issues/431) - relationship field not properly fetching option results ([6fab8bf](https://github.com/payloadcms/payload/commit/6fab8bfbef43d5da67cadc7dd61fd14b9b36bdc1)) -* adds key to RichText based on initialValue ([f710b8c](https://github.com/payloadcms/payload/commit/f710b8c4f3247156f64fb2b528a960bf808ef7ac)) -* awaits beforeDelete hooks ([609b871](https://github.com/payloadcms/payload/commit/609b871fa274e8b6d9eaf301e52ab42179aad9b7)) -* ensures multipart/form-data using \_payload flattens field data before sending ([ae44727](https://github.com/payloadcms/payload/commit/ae44727fb9734fc3801f7249fa9e78668311c09e)) -* ensures nested lists always render properly ([20e5dfb](https://github.com/payloadcms/payload/commit/20e5dfbb4ab8dab320d60772f5195c5faffe38d3)) -* ensures rte upload is populated when only upload is enabled ([39438b8](https://github.com/payloadcms/payload/commit/39438b8460f853f64d84436eed49dde74cd207d2)) -* import path for createRichTextRelationshipPromise ([586cd4d](https://github.com/payloadcms/payload/commit/586cd4d6af5485116ebb299a5af3d24f5baeaa2e)) -* improperly typed local create method ([48aa27c](https://github.com/payloadcms/payload/commit/48aa27ce701e44561edf442ee6c248b007ecafcb)) -* mobile styling to not found page ([d3f88a1](https://github.com/payloadcms/payload/commit/d3f88a1bd9aeb1551d64b9ed975da5e69e5821bd)) -* new slate version types ([c5de01b](https://github.com/payloadcms/payload/commit/c5de01bfc48ca6793c1526499fe934d9ad8f0cc9)) -* rte upload field population ([8327b5a](https://github.com/payloadcms/payload/commit/8327b5aae505a189a5b9617c3485d646b5f8b517)) -* type error in useField ([ef4e6d3](https://github.com/payloadcms/payload/commit/ef4e6d32a90215c07aa2c1e7217cf53558bfae97)) -* [#464](https://github.com/payloadcms/payload/issues/464), graphql upload access control ([fd0629e](https://github.com/payloadcms/payload/commit/fd0629e93202dfaa399c753c59481b1cbd139bf6)) -* ensures overrideAccess is false if undefined while populating ([97f3178](https://github.com/payloadcms/payload/commit/97f31780051828a9d506eba3520a1390acb99a96)) +- improves rich text link ([2e9a4c7](https://github.com/payloadcms/payload/commit/2e9a4c7d717e3a08b2982b8c49eb358baf23da17)) +- improves adding rich text voids to RTE ([966c3c6](https://github.com/payloadcms/payload/commit/966c3c647198569ba06013481a3b6fa9042b058d)) +- rare crash with link rte element ([f5535f6](https://github.com/payloadcms/payload/commit/f5535f613ac4d876d040be74b45e105e0f4775a8)) +- ensures empty hasMany relationships save as empty arrays ([08b3e8f](https://github.com/payloadcms/payload/commit/08b3e8f18f0aa620d537f3258b2e080600e0f43e)) +- [#422](https://github.com/payloadcms/payload/issues/422), prevents loading duplicative relationship options ([414679d](https://github.com/payloadcms/payload/commit/414679d86aac7ed94970a6eee14ff77b65f5c1d1)) +- [#423](https://github.com/payloadcms/payload/issues/423), [#391](https://github.com/payloadcms/payload/issues/391) - prevents loading edit views until data initializes ([2884654](https://github.com/payloadcms/payload/commit/28846547afc7e7bb8accc5dbe9f3b98593f332fa)) +- [#424](https://github.com/payloadcms/payload/issues/424), unable to clear localized property vals ([1a05fe4](https://github.com/payloadcms/payload/commit/1a05fe448c0755438dedc20c95d4a6a587912e2f)) +- [#431](https://github.com/payloadcms/payload/issues/431) - relationship field not properly fetching option results ([6fab8bf](https://github.com/payloadcms/payload/commit/6fab8bfbef43d5da67cadc7dd61fd14b9b36bdc1)) +- adds key to RichText based on initialValue ([f710b8c](https://github.com/payloadcms/payload/commit/f710b8c4f3247156f64fb2b528a960bf808ef7ac)) +- awaits beforeDelete hooks ([609b871](https://github.com/payloadcms/payload/commit/609b871fa274e8b6d9eaf301e52ab42179aad9b7)) +- ensures multipart/form-data using \_payload flattens field data before sending ([ae44727](https://github.com/payloadcms/payload/commit/ae44727fb9734fc3801f7249fa9e78668311c09e)) +- ensures nested lists always render properly ([20e5dfb](https://github.com/payloadcms/payload/commit/20e5dfbb4ab8dab320d60772f5195c5faffe38d3)) +- ensures rte upload is populated when only upload is enabled ([39438b8](https://github.com/payloadcms/payload/commit/39438b8460f853f64d84436eed49dde74cd207d2)) +- import path for createRichTextRelationshipPromise ([586cd4d](https://github.com/payloadcms/payload/commit/586cd4d6af5485116ebb299a5af3d24f5baeaa2e)) +- improperly typed local create method ([48aa27c](https://github.com/payloadcms/payload/commit/48aa27ce701e44561edf442ee6c248b007ecafcb)) +- mobile styling to not found page ([d3f88a1](https://github.com/payloadcms/payload/commit/d3f88a1bd9aeb1551d64b9ed975da5e69e5821bd)) +- new slate version types ([c5de01b](https://github.com/payloadcms/payload/commit/c5de01bfc48ca6793c1526499fe934d9ad8f0cc9)) +- rte upload field population ([8327b5a](https://github.com/payloadcms/payload/commit/8327b5aae505a189a5b9617c3485d646b5f8b517)) +- type error in useField ([ef4e6d3](https://github.com/payloadcms/payload/commit/ef4e6d32a90215c07aa2c1e7217cf53558bfae97)) +- [#464](https://github.com/payloadcms/payload/issues/464), graphql upload access control ([fd0629e](https://github.com/payloadcms/payload/commit/fd0629e93202dfaa399c753c59481b1cbd139bf6)) +- ensures overrideAccess is false if undefined while populating ([97f3178](https://github.com/payloadcms/payload/commit/97f31780051828a9d506eba3520a1390acb99a96)) ### Features -* :tada: versions, drafts, & autosave! -* adds originalDoc to field access control ([c979513](https://github.com/payloadcms/payload/commit/c9795133b376d8159457a0a38784d0b53a549061)) -* [#458](https://github.com/payloadcms/payload/issues/458), provides field hooks with sibling data ([8e23a24](https://github.com/payloadcms/payload/commit/8e23a24f34ef7425bb4d43e96e869b255740c739)) -* add before and after login components ([#427](https://github.com/payloadcms/payload/issues/427)) ([5591eea](https://github.com/payloadcms/payload/commit/5591eeafca1aa6e8abcc2d8276f7478e00b75ef2)) -* add logMockCredentials email option ([ff33453](https://github.com/payloadcms/payload/commit/ff3345373630ca6913165284123a62269b3fa2c6)) -* adds a way to customize express.static options ([dbb3c50](https://github.com/payloadcms/payload/commit/dbb3c502227597ef4d04c9e5c8db6d2f51a8aac4)) -* adds admin.upload.collections[collection-name].fields to the RTE to save specific data on upload elements ([3adf44a](https://github.com/payloadcms/payload/commit/3adf44a24162e5adbcebdb0ca7d0d460d23c57eb)) -* adds indentation controls to rich text ([7df50f9](https://github.com/payloadcms/payload/commit/7df50f9bf9d4867e65bdd8cebdf43e0ab1737a63)) -* adds recursion to richText field to populate relationship and upload nested fields ([42af22c](https://github.com/payloadcms/payload/commit/42af22c2a10de44555bfedf902e7b4a4c9b25d6b)) -* allows access control to prevent reading of drafts ([c38470c](https://github.com/payloadcms/payload/commit/c38470c7b2119cec6ff9a3efc89f087a5999bb66)) -* allows global access control to return query constraints ([c0150ae](https://github.com/payloadcms/payload/commit/c0150ae8465777a2be1b6bc496a5be30cf478f42)) -* allows select input to receive new options ([#435](https://github.com/payloadcms/payload/issues/435)) ([500fb1c](https://github.com/payloadcms/payload/commit/500fb1c5c41a55d35c41173d50a976388fd0bd1b)) -* builds a way for multipart/form-data reqs to retain non-string values ([4efc2cf](https://github.com/payloadcms/payload/commit/4efc2cf71c8ec4c452fea0febfd1156b37868739)) -* enhances rich text upload with custom field API ([0e4eb90](https://github.com/payloadcms/payload/commit/0e4eb906f2881dca518fea6b41e460bc57da9801)) -* ensures field hooks run on all locales when locale=all ([c3f743a](https://github.com/payloadcms/payload/commit/c3f743af03bbde856dcd87114383f0b484c0b20f)) -* exposes FieldWithPath type for reuse ([df3a836](https://github.com/payloadcms/payload/commit/df3a83634fcb64724ef239600e3af4fc295fee4f)) -* exposes useLocale for reuse ([bef0206](https://github.com/payloadcms/payload/commit/bef02062e769d1b0279c51af748f06d41c924c8a)) -* improves relationship field performance ([13318ff](https://github.com/payloadcms/payload/commit/13318ff3608a6be3dc7b86cc4e97155b26ef9df6)) -* indexes filenames ([07c8ac0](https://github.com/payloadcms/payload/commit/07c8ac08e21689cc6a3a2a546e58cf544fb61dec)) -* serverURL is no longer required ([#437](https://github.com/payloadcms/payload/issues/437)) ([dca90c4](https://github.com/payloadcms/payload/commit/dca90c4aa92dd0cc2084ba16249254c9259622c3)) -* updates dependencies ([3ca3f53](https://github.com/payloadcms/payload/commit/3ca3f533d07b644fa8a3d077932860e9f12318c2)) -* uses DocumentInfo to fetch and maintain doc versions ([8f30c3b](https://github.com/payloadcms/payload/commit/8f30c3bfefaa1530ac086aba22d4b8e6bac8f97d)) -* exposes data arg within create and update access control ([73f418b](https://github.com/payloadcms/payload/commit/73f418bb5cadf73f683fe04ee94e4d24c8cfe96f)) +- :tada: versions, drafts, & autosave! +- adds originalDoc to field access control ([c979513](https://github.com/payloadcms/payload/commit/c9795133b376d8159457a0a38784d0b53a549061)) +- [#458](https://github.com/payloadcms/payload/issues/458), provides field hooks with sibling data ([8e23a24](https://github.com/payloadcms/payload/commit/8e23a24f34ef7425bb4d43e96e869b255740c739)) +- add before and after login components ([#427](https://github.com/payloadcms/payload/issues/427)) ([5591eea](https://github.com/payloadcms/payload/commit/5591eeafca1aa6e8abcc2d8276f7478e00b75ef2)) +- add logMockCredentials email option ([ff33453](https://github.com/payloadcms/payload/commit/ff3345373630ca6913165284123a62269b3fa2c6)) +- adds a way to customize express.static options ([dbb3c50](https://github.com/payloadcms/payload/commit/dbb3c502227597ef4d04c9e5c8db6d2f51a8aac4)) +- adds admin.upload.collections[collection-name].fields to the RTE to save specific data on upload elements ([3adf44a](https://github.com/payloadcms/payload/commit/3adf44a24162e5adbcebdb0ca7d0d460d23c57eb)) +- adds indentation controls to rich text ([7df50f9](https://github.com/payloadcms/payload/commit/7df50f9bf9d4867e65bdd8cebdf43e0ab1737a63)) +- adds recursion to richText field to populate relationship and upload nested fields ([42af22c](https://github.com/payloadcms/payload/commit/42af22c2a10de44555bfedf902e7b4a4c9b25d6b)) +- allows access control to prevent reading of drafts ([c38470c](https://github.com/payloadcms/payload/commit/c38470c7b2119cec6ff9a3efc89f087a5999bb66)) +- allows global access control to return query constraints ([c0150ae](https://github.com/payloadcms/payload/commit/c0150ae8465777a2be1b6bc496a5be30cf478f42)) +- allows select input to receive new options ([#435](https://github.com/payloadcms/payload/issues/435)) ([500fb1c](https://github.com/payloadcms/payload/commit/500fb1c5c41a55d35c41173d50a976388fd0bd1b)) +- builds a way for multipart/form-data reqs to retain non-string values ([4efc2cf](https://github.com/payloadcms/payload/commit/4efc2cf71c8ec4c452fea0febfd1156b37868739)) +- enhances rich text upload with custom field API ([0e4eb90](https://github.com/payloadcms/payload/commit/0e4eb906f2881dca518fea6b41e460bc57da9801)) +- ensures field hooks run on all locales when locale=all ([c3f743a](https://github.com/payloadcms/payload/commit/c3f743af03bbde856dcd87114383f0b484c0b20f)) +- exposes FieldWithPath type for reuse ([df3a836](https://github.com/payloadcms/payload/commit/df3a83634fcb64724ef239600e3af4fc295fee4f)) +- exposes useLocale for reuse ([bef0206](https://github.com/payloadcms/payload/commit/bef02062e769d1b0279c51af748f06d41c924c8a)) +- improves relationship field performance ([13318ff](https://github.com/payloadcms/payload/commit/13318ff3608a6be3dc7b86cc4e97155b26ef9df6)) +- indexes filenames ([07c8ac0](https://github.com/payloadcms/payload/commit/07c8ac08e21689cc6a3a2a546e58cf544fb61dec)) +- serverURL is no longer required ([#437](https://github.com/payloadcms/payload/issues/437)) ([dca90c4](https://github.com/payloadcms/payload/commit/dca90c4aa92dd0cc2084ba16249254c9259622c3)) +- updates dependencies ([3ca3f53](https://github.com/payloadcms/payload/commit/3ca3f533d07b644fa8a3d077932860e9f12318c2)) +- uses DocumentInfo to fetch and maintain doc versions ([8f30c3b](https://github.com/payloadcms/payload/commit/8f30c3bfefaa1530ac086aba22d4b8e6bac8f97d)) +- exposes data arg within create and update access control ([73f418b](https://github.com/payloadcms/payload/commit/73f418bb5cadf73f683fe04ee94e4d24c8cfe96f)) # [0.14.0](https://github.com/payloadcms/payload/compare/v0.13.6...v0.14.0) (2022-01-03) ### Bug Fixes -* [#370](https://github.com/payloadcms/payload/issues/370), only performs password functions when auth enabled ([9738873](https://github.com/payloadcms/payload/commit/97388738def687f3b26eaf8de6b067f4d3758418)) -* [#390](https://github.com/payloadcms/payload/issues/390), safari rich text link bug ([a16b99b](https://github.com/payloadcms/payload/commit/a16b99b0c87d55f768ed74ab35708a291fc7bbb0)) -* [#393](https://github.com/payloadcms/payload/issues/393), ensures preview button gets up to date data ([2f47e39](https://github.com/payloadcms/payload/commit/2f47e39a9f765bd8ce437d4b7500a5b314a192a5)) -* [#408](https://github.com/payloadcms/payload/issues/408) ([5c3cfa4](https://github.com/payloadcms/payload/commit/5c3cfa4c93767a5ead9e816bf11a000ebdac9761)) -* [#408](https://github.com/payloadcms/payload/issues/408) ([e2c5d93](https://github.com/payloadcms/payload/commit/e2c5d93751cb1902d6dce2147953b97c2dc17939)) -* 407 ([a09570c](https://github.com/payloadcms/payload/commit/a09570c78dc923f3553f36d726e5cfac925290a0)) -* allows null in ImageSize width and height types ([ba79fd4](https://github.com/payloadcms/payload/commit/ba79fd42dbf20ba712a0632da9193fcc516c0257)) -* cross-browser upload drag and drop ([4119eec](https://github.com/payloadcms/payload/commit/4119eec796794d6a026f34f8b097b379eb9895a0)) -* ensures getDataByPath works ([140a3aa](https://github.com/payloadcms/payload/commit/140a3aa9eafa29b2a43bdfd8883c79c6ee4a93e4)) -* ensures local findByID retains user ([05288ee](https://github.com/payloadcms/payload/commit/05288ee08c077019e4432bf385aeacc23a0643f3)) -* ensures row count is set properly in block fields ([9e091af](https://github.com/payloadcms/payload/commit/9e091af67e944e6a15d1d1174a18cde6deda40d7)) -* ensures searching relationships works with many pages of results ([961787d](https://github.com/payloadcms/payload/commit/961787d681882e5ab48bb676490555c93f5d4a2e)) -* globals model typing ([da7c0c9](https://github.com/payloadcms/payload/commit/da7c0c984c1fb57038d620fc59bcd27972919ade)) +- [#370](https://github.com/payloadcms/payload/issues/370), only performs password functions when auth enabled ([9738873](https://github.com/payloadcms/payload/commit/97388738def687f3b26eaf8de6b067f4d3758418)) +- [#390](https://github.com/payloadcms/payload/issues/390), safari rich text link bug ([a16b99b](https://github.com/payloadcms/payload/commit/a16b99b0c87d55f768ed74ab35708a291fc7bbb0)) +- [#393](https://github.com/payloadcms/payload/issues/393), ensures preview button gets up to date data ([2f47e39](https://github.com/payloadcms/payload/commit/2f47e39a9f765bd8ce437d4b7500a5b314a192a5)) +- [#408](https://github.com/payloadcms/payload/issues/408) ([5c3cfa4](https://github.com/payloadcms/payload/commit/5c3cfa4c93767a5ead9e816bf11a000ebdac9761)) +- [#408](https://github.com/payloadcms/payload/issues/408) ([e2c5d93](https://github.com/payloadcms/payload/commit/e2c5d93751cb1902d6dce2147953b97c2dc17939)) +- 407 ([a09570c](https://github.com/payloadcms/payload/commit/a09570c78dc923f3553f36d726e5cfac925290a0)) +- allows null in ImageSize width and height types ([ba79fd4](https://github.com/payloadcms/payload/commit/ba79fd42dbf20ba712a0632da9193fcc516c0257)) +- cross-browser upload drag and drop ([4119eec](https://github.com/payloadcms/payload/commit/4119eec796794d6a026f34f8b097b379eb9895a0)) +- ensures getDataByPath works ([140a3aa](https://github.com/payloadcms/payload/commit/140a3aa9eafa29b2a43bdfd8883c79c6ee4a93e4)) +- ensures local findByID retains user ([05288ee](https://github.com/payloadcms/payload/commit/05288ee08c077019e4432bf385aeacc23a0643f3)) +- ensures row count is set properly in block fields ([9e091af](https://github.com/payloadcms/payload/commit/9e091af67e944e6a15d1d1174a18cde6deda40d7)) +- ensures searching relationships works with many pages of results ([961787d](https://github.com/payloadcms/payload/commit/961787d681882e5ab48bb676490555c93f5d4a2e)) +- globals model typing ([da7c0c9](https://github.com/payloadcms/payload/commit/da7c0c984c1fb57038d620fc59bcd27972919ade)) ### Features -* builds custom routes API, Before/After Dashboard and Nav custom components ([e337c62](https://github.com/payloadcms/payload/commit/e337c62ba179821c994404a2b693871b2401861b)) -* exports custom text and select inputs ([52edb5b](https://github.com/payloadcms/payload/commit/52edb5b77f45e267c43a284c5591044ac4d726e7)) -* exposes default Dashboard and Nav components for re-import ([ffe8e17](https://github.com/payloadcms/payload/commit/ffe8e17ac06c2fc89c3c51cab545df9756d3910b)) +- builds custom routes API, Before/After Dashboard and Nav custom components ([e337c62](https://github.com/payloadcms/payload/commit/e337c62ba179821c994404a2b693871b2401861b)) +- exports custom text and select inputs ([52edb5b](https://github.com/payloadcms/payload/commit/52edb5b77f45e267c43a284c5591044ac4d726e7)) +- exposes default Dashboard and Nav components for re-import ([ffe8e17](https://github.com/payloadcms/payload/commit/ffe8e17ac06c2fc89c3c51cab545df9756d3910b)) ## [0.13.21-beta.0](https://github.com/payloadcms/payload/compare/v0.13.6...v0.13.21-beta.0) (2021-12-29) ### Bug Fixes -* [#370](https://github.com/payloadcms/payload/issues/370), only performs password functions when auth enabled ([9738873](https://github.com/payloadcms/payload/commit/97388738def687f3b26eaf8de6b067f4d3758418)) -* [#390](https://github.com/payloadcms/payload/issues/390), safari rich text link bug ([a16b99b](https://github.com/payloadcms/payload/commit/a16b99b0c87d55f768ed74ab35708a291fc7bbb0)) -* [#393](https://github.com/payloadcms/payload/issues/393), ensures preview button gets up to date data ([2f47e39](https://github.com/payloadcms/payload/commit/2f47e39a9f765bd8ce437d4b7500a5b314a192a5)) -* [#408](https://github.com/payloadcms/payload/issues/408) ([5c3cfa4](https://github.com/payloadcms/payload/commit/5c3cfa4c93767a5ead9e816bf11a000ebdac9761)) -* [#408](https://github.com/payloadcms/payload/issues/408) ([e2c5d93](https://github.com/payloadcms/payload/commit/e2c5d93751cb1902d6dce2147953b97c2dc17939)) -* 407 ([a09570c](https://github.com/payloadcms/payload/commit/a09570c78dc923f3553f36d726e5cfac925290a0)) -* allows null in ImageSize width and height types ([ba79fd4](https://github.com/payloadcms/payload/commit/ba79fd42dbf20ba712a0632da9193fcc516c0257)) -* cross-browser upload drag and drop ([4119eec](https://github.com/payloadcms/payload/commit/4119eec796794d6a026f34f8b097b379eb9895a0)) -* ensures getDataByPath works ([140a3aa](https://github.com/payloadcms/payload/commit/140a3aa9eafa29b2a43bdfd8883c79c6ee4a93e4)) -* ensures local findByID retains user ([05288ee](https://github.com/payloadcms/payload/commit/05288ee08c077019e4432bf385aeacc23a0643f3)) -* ensures row count is set properly in block fields ([9e091af](https://github.com/payloadcms/payload/commit/9e091af67e944e6a15d1d1174a18cde6deda40d7)) -* ensures searching relationships works with many pages of results ([961787d](https://github.com/payloadcms/payload/commit/961787d681882e5ab48bb676490555c93f5d4a2e)) -* globals model typing ([da7c0c9](https://github.com/payloadcms/payload/commit/da7c0c984c1fb57038d620fc59bcd27972919ade)) +- [#370](https://github.com/payloadcms/payload/issues/370), only performs password functions when auth enabled ([9738873](https://github.com/payloadcms/payload/commit/97388738def687f3b26eaf8de6b067f4d3758418)) +- [#390](https://github.com/payloadcms/payload/issues/390), safari rich text link bug ([a16b99b](https://github.com/payloadcms/payload/commit/a16b99b0c87d55f768ed74ab35708a291fc7bbb0)) +- [#393](https://github.com/payloadcms/payload/issues/393), ensures preview button gets up to date data ([2f47e39](https://github.com/payloadcms/payload/commit/2f47e39a9f765bd8ce437d4b7500a5b314a192a5)) +- [#408](https://github.com/payloadcms/payload/issues/408) ([5c3cfa4](https://github.com/payloadcms/payload/commit/5c3cfa4c93767a5ead9e816bf11a000ebdac9761)) +- [#408](https://github.com/payloadcms/payload/issues/408) ([e2c5d93](https://github.com/payloadcms/payload/commit/e2c5d93751cb1902d6dce2147953b97c2dc17939)) +- 407 ([a09570c](https://github.com/payloadcms/payload/commit/a09570c78dc923f3553f36d726e5cfac925290a0)) +- allows null in ImageSize width and height types ([ba79fd4](https://github.com/payloadcms/payload/commit/ba79fd42dbf20ba712a0632da9193fcc516c0257)) +- cross-browser upload drag and drop ([4119eec](https://github.com/payloadcms/payload/commit/4119eec796794d6a026f34f8b097b379eb9895a0)) +- ensures getDataByPath works ([140a3aa](https://github.com/payloadcms/payload/commit/140a3aa9eafa29b2a43bdfd8883c79c6ee4a93e4)) +- ensures local findByID retains user ([05288ee](https://github.com/payloadcms/payload/commit/05288ee08c077019e4432bf385aeacc23a0643f3)) +- ensures row count is set properly in block fields ([9e091af](https://github.com/payloadcms/payload/commit/9e091af67e944e6a15d1d1174a18cde6deda40d7)) +- ensures searching relationships works with many pages of results ([961787d](https://github.com/payloadcms/payload/commit/961787d681882e5ab48bb676490555c93f5d4a2e)) +- globals model typing ([da7c0c9](https://github.com/payloadcms/payload/commit/da7c0c984c1fb57038d620fc59bcd27972919ade)) ### Features -* builds custom routes API, Before/After Dashboard and Nav custom components ([e337c62](https://github.com/payloadcms/payload/commit/e337c62ba179821c994404a2b693871b2401861b)) -* exports custom text and select inputs ([52edb5b](https://github.com/payloadcms/payload/commit/52edb5b77f45e267c43a284c5591044ac4d726e7)) -* exposes default Dashboard and Nav components for re-import ([ffe8e17](https://github.com/payloadcms/payload/commit/ffe8e17ac06c2fc89c3c51cab545df9756d3910b)) +- builds custom routes API, Before/After Dashboard and Nav custom components ([e337c62](https://github.com/payloadcms/payload/commit/e337c62ba179821c994404a2b693871b2401861b)) +- exports custom text and select inputs ([52edb5b](https://github.com/payloadcms/payload/commit/52edb5b77f45e267c43a284c5591044ac4d726e7)) +- exposes default Dashboard and Nav components for re-import ([ffe8e17](https://github.com/payloadcms/payload/commit/ffe8e17ac06c2fc89c3c51cab545df9756d3910b)) ## [0.13.6](https://github.com/payloadcms/payload/compare/v0.13.5...v0.13.6) (2021-11-30) ### Bug Fixes -* requires path in select, text, textarea, and upload components ([925a33e](https://github.com/payloadcms/payload/commit/925a33e5602336f6128188aaf73001dbd23bd411)) +- requires path in select, text, textarea, and upload components ([925a33e](https://github.com/payloadcms/payload/commit/925a33e5602336f6128188aaf73001dbd23bd411)) ## [0.13.5](https://github.com/payloadcms/payload/compare/v0.13.4...v0.13.5) (2021-11-30) ### Bug Fixes -* select component rendered value ([ecabf13](https://github.com/payloadcms/payload/commit/ecabf130fd1b4b87c45196d4bdf675e76b20c9e3)) +- select component rendered value ([ecabf13](https://github.com/payloadcms/payload/commit/ecabf130fd1b4b87c45196d4bdf675e76b20c9e3)) ## [0.13.4](https://github.com/payloadcms/payload/compare/v0.13.3...v0.13.4) (2021-11-30) ### Bug Fixes -* passes hasMany through select component ([c77bf3a](https://github.com/payloadcms/payload/commit/c77bf3aa42d76b7a0649b28fee3fe5d4bd06dcf6)) -* prevents uncontrolled text field component ([f0fd859](https://github.com/payloadcms/payload/commit/f0fd859347804fdf0d79bbe566412abaeec6ff6a)) -* select component types ([7e2b259](https://github.com/payloadcms/payload/commit/7e2b2598167dc59b8982f635cb95eacf247abb43)) -* threads props through textarea component ([0b13eda](https://github.com/payloadcms/payload/commit/0b13eda1e55299f7d6dfac2854acc04cff459396)) +- passes hasMany through select component ([c77bf3a](https://github.com/payloadcms/payload/commit/c77bf3aa42d76b7a0649b28fee3fe5d4bd06dcf6)) +- prevents uncontrolled text field component ([f0fd859](https://github.com/payloadcms/payload/commit/f0fd859347804fdf0d79bbe566412abaeec6ff6a)) +- select component types ([7e2b259](https://github.com/payloadcms/payload/commit/7e2b2598167dc59b8982f635cb95eacf247abb43)) +- threads props through textarea component ([0b13eda](https://github.com/payloadcms/payload/commit/0b13eda1e55299f7d6dfac2854acc04cff459396)) ### Features -* abstracts input from text component ([615e369](https://github.com/payloadcms/payload/commit/615e3695f2e62ce5d8a43ccb84192aca57770af8)) -* abstracts select component ([fa67137](https://github.com/payloadcms/payload/commit/fa671378c7282cda1ed6f46340a53622e3bc96dc)) -* abstracts textarea component and improves event typing ([86480b7](https://github.com/payloadcms/payload/commit/86480b7482b2b9413272ab0f9d0a82cd5e2920b8)) -* abstracts upload component ([f234f68](https://github.com/payloadcms/payload/commit/f234f68019f122bd46cb2af2e8f62cf07cd53c1b)) +- abstracts input from text component ([615e369](https://github.com/payloadcms/payload/commit/615e3695f2e62ce5d8a43ccb84192aca57770af8)) +- abstracts select component ([fa67137](https://github.com/payloadcms/payload/commit/fa671378c7282cda1ed6f46340a53622e3bc96dc)) +- abstracts textarea component and improves event typing ([86480b7](https://github.com/payloadcms/payload/commit/86480b7482b2b9413272ab0f9d0a82cd5e2920b8)) +- abstracts upload component ([f234f68](https://github.com/payloadcms/payload/commit/f234f68019f122bd46cb2af2e8f62cf07cd53c1b)) ## [0.13.3](https://github.com/payloadcms/payload/compare/v0.13.2...v0.13.3) (2021-11-29) ### Bug Fixes -* upgrade sharp for prebuilt M1 binaries ([34f416a](https://github.com/payloadcms/payload/commit/34f416aace112013359351e17c4371c30303156f)) +- upgrade sharp for prebuilt M1 binaries ([34f416a](https://github.com/payloadcms/payload/commit/34f416aace112013359351e17c4371c30303156f)) ## [0.13.2](https://github.com/payloadcms/payload/compare/v0.13.1...v0.13.2) (2021-11-29) ### Bug Fixes -* [#373](https://github.com/payloadcms/payload/issues/373) ([727fbec](https://github.com/payloadcms/payload/commit/727fbeceb4b93936ca08d0ca48ac0d2beb1ce96e)) +- [#373](https://github.com/payloadcms/payload/issues/373) ([727fbec](https://github.com/payloadcms/payload/commit/727fbeceb4b93936ca08d0ca48ac0d2beb1ce96e)) ## [0.13.1](https://github.com/payloadcms/payload/compare/v0.13.0...v0.13.1) (2021-11-29) ### Bug Fixes -* ensures sorting by \_id instead of improper id ([ded891e](https://github.com/payloadcms/payload/commit/ded891e390a93f71963762c0200c97a0beec5cad)) +- ensures sorting by \_id instead of improper id ([ded891e](https://github.com/payloadcms/payload/commit/ded891e390a93f71963762c0200c97a0beec5cad)) ### Features -* only adds list search query param if value is present ([d6d76d4](https://github.com/payloadcms/payload/commit/d6d76d4088a23ed43122333873ada6846c808d37)) +- only adds list search query param if value is present ([d6d76d4](https://github.com/payloadcms/payload/commit/d6d76d4088a23ed43122333873ada6846c808d37)) # [0.13.0](https://github.com/payloadcms/payload/compare/v0.12.3...v0.13.0) (2021-11-26) ### Bug Fixes -* [#351](https://github.com/payloadcms/payload/issues/351) ([94c2b8d](https://github.com/payloadcms/payload/commit/94c2b8d80b046c067057d4ad089ed6a2edd656cf)) -* [#358](https://github.com/payloadcms/payload/issues/358) - reuploading with existing filenames ([a0fb48c](https://github.com/payloadcms/payload/commit/a0fb48c9a37beceafc6f0638604e9946d0814635)) -* allows sync or async preview urls ([da6e1df](https://github.com/payloadcms/payload/commit/da6e1df293ce46bc4d0c84645db61feea2881aa7)) -* bug with relationship cell when no doc is available ([40b33d9](https://github.com/payloadcms/payload/commit/40b33d9f5e99285cb0de148dbe059259817fcad8)) +- [#351](https://github.com/payloadcms/payload/issues/351) ([94c2b8d](https://github.com/payloadcms/payload/commit/94c2b8d80b046c067057d4ad089ed6a2edd656cf)) +- [#358](https://github.com/payloadcms/payload/issues/358) - reuploading with existing filenames ([a0fb48c](https://github.com/payloadcms/payload/commit/a0fb48c9a37beceafc6f0638604e9946d0814635)) +- allows sync or async preview urls ([da6e1df](https://github.com/payloadcms/payload/commit/da6e1df293ce46bc4d0c84645db61feea2881aa7)) +- bug with relationship cell when no doc is available ([40b33d9](https://github.com/payloadcms/payload/commit/40b33d9f5e99285cb0de148dbe059259817fcad8)) 3839ef75151f)) -* ensures richtext links retain proper formatting ([abf61d0](https://github.com/payloadcms/payload/commit/abf61d0734c09fd0fc5c5b827cb0631e11701f71)) -* ensures that querying by relationship subpaths works ([37b21b0](https://github.com/payloadcms/payload/commit/37b21b07628e892e85c2cf979d9e2c8af0d291f7)) -* ensures uploads can be fetched with CORS ([96421b3](https://github.com/payloadcms/payload/commit/96421b3d59a87f8a3d781005c02344fe5d3a607f)) -* typing for collection description ([bb18e82](https://github.com/payloadcms/payload/commit/bb18e8250c5742d9615e5780c1cd02d33ecca3d0)) -* updates field description type to include react nodes ([291c193](https://github.com/payloadcms/payload/commit/291c193ad4a9ec8ce9310cc63c714eba10eca102)) +- ensures richtext links retain proper formatting ([abf61d0](https://github.com/payloadcms/payload/commit/abf61d0734c09fd0fc5c5b827cb0631e11701f71)) +- ensures that querying by relationship subpaths works ([37b21b0](https://github.com/payloadcms/payload/commit/37b21b07628e892e85c2cf979d9e2c8af0d291f7)) +- ensures uploads can be fetched with CORS ([96421b3](https://github.com/payloadcms/payload/commit/96421b3d59a87f8a3d781005c02344fe5d3a607f)) +- typing for collection description ([bb18e82](https://github.com/payloadcms/payload/commit/bb18e8250c5742d9615e5780c1cd02d33ecca3d0)) +- updates field description type to include react nodes ([291c193](https://github.com/payloadcms/payload/commit/291c193ad4a9ec8ce9310cc63c714eba10eca102)) ### Features -* :tada: :tada: builds a way to automatically generate types for collections and globals!. -* :tada: dramatically improves Payload types like local API methods and hooks to function as `generic`s -* adds relationship filter field ([463c4e6](https://github.com/payloadcms/payload/commit/463c4e60de8e647fca6268b826d826f9c6e45412)) -* applies upload access control to all auto-generated image sizes ([051b7d4](https://github.com/payloadcms/payload/commit/051b7d45befc331af3f73a669b2bb6467505902f)) -* azure cosmos compatibility ([6fd5ac2](https://github.com/payloadcms/payload/commit/6fd5ac2c082a5a5e6f510d781b2a2e12b7b62cb9)) -* ensures update hooks have access to full original docs even in spite of access control ([b2c5b7e](https://github.com/payloadcms/payload/commit/b2c5b7e5752e829c7a53c054decceb43ec33065e)) -* improves querying logic ([4c85747](https://github.com/payloadcms/payload/commit/4c8574784995b1cb1f939648f4d2158286089b3d)) -* indexes filenames ([5d43262](https://github.com/payloadcms/payload/commit/5d43262f42e0529a44572f398aa1ec5fd7858286)) -* renames useFieldType to useField ([0245747](https://github.com/payloadcms/payload/commit/0245747020c7c039b15d055f54a4548a364d047e)) -* supports custom onChange handling in text, select, and upload fields ([4affdc3](https://github.com/payloadcms/payload/commit/4affdc3a9397d70f5baacdd12753c8fc8c7d8368)) +- :tada: :tada: builds a way to automatically generate types for collections and globals!. +- :tada: dramatically improves Payload types like local API methods and hooks to function as `generic`s +- adds relationship filter field ([463c4e6](https://github.com/payloadcms/payload/commit/463c4e60de8e647fca6268b826d826f9c6e45412)) +- applies upload access control to all auto-generated image sizes ([051b7d4](https://github.com/payloadcms/payload/commit/051b7d45befc331af3f73a669b2bb6467505902f)) +- azure cosmos compatibility ([6fd5ac2](https://github.com/payloadcms/payload/commit/6fd5ac2c082a5a5e6f510d781b2a2e12b7b62cb9)) +- ensures update hooks have access to full original docs even in spite of access control ([b2c5b7e](https://github.com/payloadcms/payload/commit/b2c5b7e5752e829c7a53c054decceb43ec33065e)) +- improves querying logic ([4c85747](https://github.com/payloadcms/payload/commit/4c8574784995b1cb1f939648f4d2158286089b3d)) +- indexes filenames ([5d43262](https://github.com/payloadcms/payload/commit/5d43262f42e0529a44572f398aa1ec5fd7858286)) +- renames useFieldType to useField ([0245747](https://github.com/payloadcms/payload/commit/0245747020c7c039b15d055f54a4548a364d047e)) +- supports custom onChange handling in text, select, and upload fields ([4affdc3](https://github.com/payloadcms/payload/commit/4affdc3a9397d70f5baacdd12753c8fc8c7d8368)) ## [0.12.3](https://github.com/payloadcms/payload/compare/v0.12.2...v0.12.3) (2021-10-23) ### Bug Fixes -* [#348](https://github.com/payloadcms/payload/issues/348), relationship options appearing twice in admin ui ([b4c15ed](https://github.com/payloadcms/payload/commit/b4c15ed3f3649ea6d157987571874fb8486ab3cb)) -* ensures tooltips in email fields are positioned properly ([a0b38f6](https://github.com/payloadcms/payload/commit/a0b38f68322cd7a39ca6ae08e6ffb7f57aa62171)) +- [#348](https://github.com/payloadcms/payload/issues/348), relationship options appearing twice in admin ui ([b4c15ed](https://github.com/payloadcms/payload/commit/b4c15ed3f3649ea6d157987571874fb8486ab3cb)) +- ensures tooltips in email fields are positioned properly ([a0b38f6](https://github.com/payloadcms/payload/commit/a0b38f68322cd7a39ca6ae08e6ffb7f57aa62171)) ## [0.12.2](https://github.com/payloadcms/payload/compare/v0.12.1...v0.12.2) (2021-10-21) ### Bug Fixes -* improves paste html formatting ([d443ea5](https://github.com/payloadcms/payload/commit/d443ea582cc60be367dd3edbdcb062af0786b8ee)) +- improves paste html formatting ([d443ea5](https://github.com/payloadcms/payload/commit/d443ea582cc60be367dd3edbdcb062af0786b8ee)) ## [0.12.1](https://github.com/payloadcms/payload/compare/v0.12.0...v0.12.1) (2021-10-21) ### Bug Fixes -* rich text copy and paste now saves formatting properly ([9d7feb9](https://github.com/payloadcms/payload/commit/9d7feb9796e4b76e01f4ac2d0cb117bb091aa3d5)) +- rich text copy and paste now saves formatting properly ([9d7feb9](https://github.com/payloadcms/payload/commit/9d7feb9796e4b76e01f4ac2d0cb117bb091aa3d5)) # [0.12.0](https://github.com/payloadcms/payload/compare/v0.11.0...v0.12.0) (2021-10-21) ### Bug Fixes -* bug where field hooks and access control couuld potentially compete ([c35009f](https://github.com/payloadcms/payload/commit/c35009f14c9403e63727d4d77af51a449a5f7b4b)) +- bug where field hooks and access control couuld potentially compete ([c35009f](https://github.com/payloadcms/payload/commit/c35009f14c9403e63727d4d77af51a449a5f7b4b)) ### Features -* builds UI field ([edb723a](https://github.com/payloadcms/payload/commit/edb723a4fb8b4c353a9073cc7ec5f5cfd026cbe0)) -* exposes withCondition for re-use ([c02e8f1](https://github.com/payloadcms/payload/commit/c02e8f14c74a2ab9a53b0d8fd81f1083bede594e)) +- builds UI field ([edb723a](https://github.com/payloadcms/payload/commit/edb723a4fb8b4c353a9073cc7ec5f5cfd026cbe0)) +- exposes withCondition for re-use ([c02e8f1](https://github.com/payloadcms/payload/commit/c02e8f14c74a2ab9a53b0d8fd81f1083bede594e)) ## [0.11.2-beta.0](https://github.com/payloadcms/payload/compare/v0.11.0...v0.11.2-beta.0) (2021-10-21) ### Features -* exposes withCondition for re-use ([c02e8f1](https://github.com/payloadcms/payload/commit/c02e8f14c74a2ab9a53b0d8fd81f1083bede594e)) +- exposes withCondition for re-use ([c02e8f1](https://github.com/payloadcms/payload/commit/c02e8f14c74a2ab9a53b0d8fd81f1083bede594e)) ## [0.11.1-beta.0](https://github.com/payloadcms/payload/compare/v0.11.0...v0.11.1-beta.0) (2021-10-20) ### Features -* builds UI field ([edb723a](https://github.com/payloadcms/payload/commit/edb723a4fb8b4c353a9073cc7ec5f5cfd026cbe0)) +- builds UI field ([edb723a](https://github.com/payloadcms/payload/commit/edb723a4fb8b4c353a9073cc7ec5f5cfd026cbe0)) # [0.11.0](https://github.com/payloadcms/payload/compare/v0.10.11...v0.11.0) (2021-10-20) ### Bug Fixes -* [#338](https://github.com/payloadcms/payload/issues/338), array / block fields with only nested array block fields break admin UI ([86e88d9](https://github.com/payloadcms/payload/commit/86e88d998fbc36d7ea2456dfbc685edadff107d3)) -* [#341](https://github.com/payloadcms/payload/issues/341) - searching on multiple relationship collections ([3b99ded](https://github.com/payloadcms/payload/commit/3b99deda450fbbe4a9d05c28c9c485c466872097)) -* [#343](https://github.com/payloadcms/payload/issues/343) - upload rte element crashes admin when no upload collection present ([914cca6](https://github.com/payloadcms/payload/commit/914cca6b926923bd238605856a7b7125c13244e1)) -* make name required on field types ([#337](https://github.com/payloadcms/payload/issues/337)) ([b257e01](https://github.com/payloadcms/payload/commit/b257e01c8dea5d22172ce4f71e4124aecc39bba8)) -* more strict field typing ([84f6a9d](https://github.com/payloadcms/payload/commit/84f6a9d659fd443545f3ba7adf9f6adab98452ca)) -* per page now properly modifies search query ([fcd9c28](https://github.com/payloadcms/payload/commit/fcd9c2887175396bdedc051f3f30f1080d8c5953)) -* properly types row field ([7d49302](https://github.com/payloadcms/payload/commit/7d49302ffa8207498e6e70255b3be84b3ac890c1)) -* removes node 15 from CI ([a2df67e](https://github.com/payloadcms/payload/commit/a2df67eccd9ab6f8c9d4982bdade9b47186c2c82)) -* use proper error code on webpack build failure ([2eb8154](https://github.com/payloadcms/payload/commit/2eb81546c3b4bf1804d25ccd5307af4855c4f750)) +- [#338](https://github.com/payloadcms/payload/issues/338), array / block fields with only nested array block fields break admin UI ([86e88d9](https://github.com/payloadcms/payload/commit/86e88d998fbc36d7ea2456dfbc685edadff107d3)) +- [#341](https://github.com/payloadcms/payload/issues/341) - searching on multiple relationship collections ([3b99ded](https://github.com/payloadcms/payload/commit/3b99deda450fbbe4a9d05c28c9c485c466872097)) +- [#343](https://github.com/payloadcms/payload/issues/343) - upload rte element crashes admin when no upload collection present ([914cca6](https://github.com/payloadcms/payload/commit/914cca6b926923bd238605856a7b7125c13244e1)) +- make name required on field types ([#337](https://github.com/payloadcms/payload/issues/337)) ([b257e01](https://github.com/payloadcms/payload/commit/b257e01c8dea5d22172ce4f71e4124aecc39bba8)) +- more strict field typing ([84f6a9d](https://github.com/payloadcms/payload/commit/84f6a9d659fd443545f3ba7adf9f6adab98452ca)) +- per page now properly modifies search query ([fcd9c28](https://github.com/payloadcms/payload/commit/fcd9c2887175396bdedc051f3f30f1080d8c5953)) +- properly types row field ([7d49302](https://github.com/payloadcms/payload/commit/7d49302ffa8207498e6e70255b3be84b3ac890c1)) +- removes node 15 from CI ([a2df67e](https://github.com/payloadcms/payload/commit/a2df67eccd9ab6f8c9d4982bdade9b47186c2c82)) +- use proper error code on webpack build failure ([2eb8154](https://github.com/payloadcms/payload/commit/2eb81546c3b4bf1804d25ccd5307af4855c4f750)) ### Features -* adds dynamic url field to upload-enabled collections ([cc4d1fd](https://github.com/payloadcms/payload/commit/cc4d1fd045ed54c6a35c7104182e6fbeadb6dac4)) -* adds safety checks while querying on id with bad values ([900f05e](https://github.com/payloadcms/payload/commit/900f05eefdc63978809a88a2e1474be08afff6c6)) -* **admin:** initial per page component ([3715e01](https://github.com/payloadcms/payload/commit/3715e011c97c8e30174c35c502fa7db12bc84e2c)) -* allows richText enter key break out functionality to be extended in custom elements ([ca91f47](https://github.com/payloadcms/payload/commit/ca91f47d325de5211f24000c7d90b10a8fdfc544)) -* improves richtext link ([423ca01](https://github.com/payloadcms/payload/commit/423ca01ab1d5d07e2f5369d82928d6c7dad052b0)) -* **per-page:** add pagination to admin config ([c132f2f](https://github.com/payloadcms/payload/commit/c132f2ff10b3efdb3854ec2d5a895120ccf22002)) -* **per-page:** set and load from preferences ([d88ce2d](https://github.com/payloadcms/payload/commit/d88ce2d342b20c1601b1b58470c226a9826758b3)) -* saves active list filters in URL, implements per-page control ([a6fc1fd](https://github.com/payloadcms/payload/commit/a6fc1fdc5838c3d17c5a8b6cbe9a46b86c89af71)) +- adds dynamic url field to upload-enabled collections ([cc4d1fd](https://github.com/payloadcms/payload/commit/cc4d1fd045ed54c6a35c7104182e6fbeadb6dac4)) +- adds safety checks while querying on id with bad values ([900f05e](https://github.com/payloadcms/payload/commit/900f05eefdc63978809a88a2e1474be08afff6c6)) +- **admin:** initial per page component ([3715e01](https://github.com/payloadcms/payload/commit/3715e011c97c8e30174c35c502fa7db12bc84e2c)) +- allows richText enter key break out functionality to be extended in custom elements ([ca91f47](https://github.com/payloadcms/payload/commit/ca91f47d325de5211f24000c7d90b10a8fdfc544)) +- improves richtext link ([423ca01](https://github.com/payloadcms/payload/commit/423ca01ab1d5d07e2f5369d82928d6c7dad052b0)) +- **per-page:** add pagination to admin config ([c132f2f](https://github.com/payloadcms/payload/commit/c132f2ff10b3efdb3854ec2d5a895120ccf22002)) +- **per-page:** set and load from preferences ([d88ce2d](https://github.com/payloadcms/payload/commit/d88ce2d342b20c1601b1b58470c226a9826758b3)) +- saves active list filters in URL, implements per-page control ([a6fc1fd](https://github.com/payloadcms/payload/commit/a6fc1fdc5838c3d17c5a8b6cbe9a46b86c89af71)) ## [0.10.11](https://github.com/payloadcms/payload/compare/v0.10.10...v0.10.11) (2021-10-08) ### Bug Fixes -* bug with local API and not passing array / block data ([fd4fbe8](https://github.com/payloadcms/payload/commit/fd4fbe8c8b492445ab29d26d9648cff4e98d5708)) +- bug with local API and not passing array / block data ([fd4fbe8](https://github.com/payloadcms/payload/commit/fd4fbe8c8b492445ab29d26d9648cff4e98d5708)) ## [0.10.10](https://github.com/payloadcms/payload/compare/v0.10.9...v0.10.10) (2021-10-07) ### Bug Fixes -* deepObjectCopy returns Date object instead of empty object ([2711729](https://github.com/payloadcms/payload/commit/27117292f3a4e207d9705e79f82fb78f70985915)) +- deepObjectCopy returns Date object instead of empty object ([2711729](https://github.com/payloadcms/payload/commit/27117292f3a4e207d9705e79f82fb78f70985915)) ## [0.10.9](https://github.com/payloadcms/payload/compare/v0.10.8...v0.10.9) (2021-10-05) ### Bug Fixes -* ensures field read access within login operation has id ([e3229c5](https://github.com/payloadcms/payload/commit/e3229c55f352a2f68bbea967f816badfd265dd02)) +- ensures field read access within login operation has id ([e3229c5](https://github.com/payloadcms/payload/commit/e3229c55f352a2f68bbea967f816badfd265dd02)) ## [0.10.8](https://github.com/payloadcms/payload/compare/v0.10.7...v0.10.8) (2021-10-04) ### Bug Fixes -* ensures update field access control receives id ([ffab6c4](https://github.com/payloadcms/payload/commit/ffab6c46c1c267f46d1d4eb3fd8060a4e5fada4b)) +- ensures update field access control receives id ([ffab6c4](https://github.com/payloadcms/payload/commit/ffab6c46c1c267f46d1d4eb3fd8060a4e5fada4b)) ## [0.10.7](https://github.com/payloadcms/payload/compare/v0.10.6...v0.10.7) (2021-10-04) ### Bug Fixes -* ensures non populated relationships still retain IDs ([a201109](https://github.com/payloadcms/payload/commit/a20110974d781e972831fa8a52a0839a613121f6)) -* ensures relationship field access control receives id ([470d434](https://github.com/payloadcms/payload/commit/470d4345f9ccc7630dc55b40172937509475d534)) +- ensures non populated relationships still retain IDs ([a201109](https://github.com/payloadcms/payload/commit/a20110974d781e972831fa8a52a0839a613121f6)) +- ensures relationship field access control receives id ([470d434](https://github.com/payloadcms/payload/commit/470d4345f9ccc7630dc55b40172937509475d534)) ### Features -* add indexSortableField option to create indexes for sortable fields on all collections ([ad09782](https://github.com/payloadcms/payload/commit/ad097820bfe32b0a4ef428a37a78e5a569258ec6)) +- add indexSortableField option to create indexes for sortable fields on all collections ([ad09782](https://github.com/payloadcms/payload/commit/ad097820bfe32b0a4ef428a37a78e5a569258ec6)) ## [0.10.6](https://github.com/payloadcms/payload/compare/v0.10.5...v0.10.6) (2021-09-30) ### Bug Fixes -* allow debug in payload config ([65bf13d](https://github.com/payloadcms/payload/commit/65bf13d7c137eafdbbeadc1d36d26b7b8389088f)) -* relationship + new slate incompatibility ([f422053](https://github.com/payloadcms/payload/commit/f42205307e33916fc3b139f6ee97eb66d5d0816a)) +- allow debug in payload config ([65bf13d](https://github.com/payloadcms/payload/commit/65bf13d7c137eafdbbeadc1d36d26b7b8389088f)) +- relationship + new slate incompatibility ([f422053](https://github.com/payloadcms/payload/commit/f42205307e33916fc3b139f6ee97eb66d5d0816a)) ## [0.10.5](https://github.com/payloadcms/payload/compare/v0.10.4...v0.10.5) (2021-09-28) ### Bug Fixes -* ensures that fields within non-required groups are correctly not required ([1597055](https://github.com/payloadcms/payload/commit/15970550f7b00ce0527027c362a9550ff8ad5d2a)) -* index creation on localized field parent ([23e8197](https://github.com/payloadcms/payload/commit/23e81971eb94fd5b991aedb02aab84931937ae37)) -* pagination estimatedCount limited to near query ([73bd698](https://github.com/payloadcms/payload/commit/73bd69870c4ff8ae92053e77ef95cfae18c142b5)) +- ensures that fields within non-required groups are correctly not required ([1597055](https://github.com/payloadcms/payload/commit/15970550f7b00ce0527027c362a9550ff8ad5d2a)) +- index creation on localized field parent ([23e8197](https://github.com/payloadcms/payload/commit/23e81971eb94fd5b991aedb02aab84931937ae37)) +- pagination estimatedCount limited to near query ([73bd698](https://github.com/payloadcms/payload/commit/73bd69870c4ff8ae92053e77ef95cfae18c142b5)) ### Features -* adds rich text editor upload element ([aa76950](https://github.com/payloadcms/payload/commit/aa769500c934f4dee51a24c0cfc0297c12b5ae47)) -* updates slate, finishes rte upload ([08db431](https://github.com/payloadcms/payload/commit/08db431c0c4626a0d10f4e1c7bca29fa075eedc6)) +- adds rich text editor upload element ([aa76950](https://github.com/payloadcms/payload/commit/aa769500c934f4dee51a24c0cfc0297c12b5ae47)) +- updates slate, finishes rte upload ([08db431](https://github.com/payloadcms/payload/commit/08db431c0c4626a0d10f4e1c7bca29fa075eedc6)) ## [0.10.4](https://github.com/payloadcms/payload/compare/v0.10.0...v0.10.4) (2021-09-22) ### Bug Fixes -* allows image resizing if either width or height is larger ([8661115](https://github.com/payloadcms/payload/commit/866111528377808009fa71595691e6a08ec77dc5)) -* array objects now properly save IDs ([2b8f925](https://github.com/payloadcms/payload/commit/2b8f925e81c58f6aa010bf13a318236f211ea091)) -* date field error message position ([03c0435](https://github.com/payloadcms/payload/commit/03c0435e3b3ecdfa0713e3e5026b80f8985ca290)) -* properly types optional req in local findByID ([02e7fe3](https://github.com/payloadcms/payload/commit/02e7fe3f1f3763f32f100cf2e5a8596aa16f3bd9)) +- allows image resizing if either width or height is larger ([8661115](https://github.com/payloadcms/payload/commit/866111528377808009fa71595691e6a08ec77dc5)) +- array objects now properly save IDs ([2b8f925](https://github.com/payloadcms/payload/commit/2b8f925e81c58f6aa010bf13a318236f211ea091)) +- date field error message position ([03c0435](https://github.com/payloadcms/payload/commit/03c0435e3b3ecdfa0713e3e5026b80f8985ca290)) +- properly types optional req in local findByID ([02e7fe3](https://github.com/payloadcms/payload/commit/02e7fe3f1f3763f32f100cf2e5a8596aa16f3bd9)) ### Features -* defaults empty group fields to empty object ([8a890fd](https://github.com/payloadcms/payload/commit/8a890fdc15b646c24963a1ef7584237b1d3c5783)) -* allows local update api to replace existing files with newly uploaded ones ([dbbff4c](https://github.com/payloadcms/payload/commit/dbbff4cfa41aa20077e47c8c7b87d4d00683c571)) -* exposes Pill component for re-use ([7e8df10](https://github.com/payloadcms/payload/commit/7e8df100bbf86798de292466afd4c00c455ecb35)) -* performance improvement while saving large docs ([901ad49](https://github.com/payloadcms/payload/commit/901ad498b47bcb8ae995ade18f2fc08cd33f0645)) +- defaults empty group fields to empty object ([8a890fd](https://github.com/payloadcms/payload/commit/8a890fdc15b646c24963a1ef7584237b1d3c5783)) +- allows local update api to replace existing files with newly uploaded ones ([dbbff4c](https://github.com/payloadcms/payload/commit/dbbff4cfa41aa20077e47c8c7b87d4d00683c571)) +- exposes Pill component for re-use ([7e8df10](https://github.com/payloadcms/payload/commit/7e8df100bbf86798de292466afd4c00c455ecb35)) +- performance improvement while saving large docs ([901ad49](https://github.com/payloadcms/payload/commit/901ad498b47bcb8ae995ade18f2fc08cd33f0645)) # [0.10.0](https://github.com/payloadcms/payload/compare/v0.9.5...v0.10.0) (2021-09-09) ### Bug Fixes -* admin UI collection id is required ([dc96b90](https://github.com/payloadcms/payload/commit/dc96b90cba01756374dde5b91f7702e0a0c661aa)) -* allow save of collection with an undefined point ([f80646c](https://github.com/payloadcms/payload/commit/f80646c5987db4c228b00beda9549259021c2a40)) -* config validation correctly prevents empty strings for option values ([41e7feb](https://github.com/payloadcms/payload/commit/41e7febf6a21d2fff39a335c033d9e9582294147)) -* ensures hooks run before access ([96629f1](https://github.com/payloadcms/payload/commit/96629f1f0100efdb9c5ad57c1a46add3c15ea65d)) -* ensures proper order while transforming incoming and outgoing data ([c187da0](https://github.com/payloadcms/payload/commit/c187da00b1f18c66d9252a5a3e2029455d75b371)) -* improve id type semantic and restrict possible types to text and number ([29529b2](https://github.com/payloadcms/payload/commit/29529b2c56d4af7c6abce113da2f7ce84f1dcc02)) -* remove media directory to improve test run consistency ([d42d8f7](https://github.com/payloadcms/payload/commit/d42d8f76efcda7a24f2f50d60caf47b1027d81f6)) -* sanitize custom id number types ([c7558d8](https://github.com/payloadcms/payload/commit/c7558d8652780e24479b39e5f2a08a49ffff3358)) -* sort id columns ([114dc1b](https://github.com/payloadcms/payload/commit/114dc1b3fb9a1895e09671aca7a57fd5c7d84911)) +- admin UI collection id is required ([dc96b90](https://github.com/payloadcms/payload/commit/dc96b90cba01756374dde5b91f7702e0a0c661aa)) +- allow save of collection with an undefined point ([f80646c](https://github.com/payloadcms/payload/commit/f80646c5987db4c228b00beda9549259021c2a40)) +- config validation correctly prevents empty strings for option values ([41e7feb](https://github.com/payloadcms/payload/commit/41e7febf6a21d2fff39a335c033d9e9582294147)) +- ensures hooks run before access ([96629f1](https://github.com/payloadcms/payload/commit/96629f1f0100efdb9c5ad57c1a46add3c15ea65d)) +- ensures proper order while transforming incoming and outgoing data ([c187da0](https://github.com/payloadcms/payload/commit/c187da00b1f18c66d9252a5a3e2029455d75b371)) +- improve id type semantic and restrict possible types to text and number ([29529b2](https://github.com/payloadcms/payload/commit/29529b2c56d4af7c6abce113da2f7ce84f1dcc02)) +- remove media directory to improve test run consistency ([d42d8f7](https://github.com/payloadcms/payload/commit/d42d8f76efcda7a24f2f50d60caf47b1027d81f6)) +- sanitize custom id number types ([c7558d8](https://github.com/payloadcms/payload/commit/c7558d8652780e24479b39e5f2a08a49ffff3358)) +- sort id columns ([114dc1b](https://github.com/payloadcms/payload/commit/114dc1b3fb9a1895e09671aca7a57fd5c7d84911)) ### Features -* add config validation for collections with custom id ([fe1dc0b](https://github.com/payloadcms/payload/commit/fe1dc0b191e73f350b77a90887d8172bf76d46fd)) -* add config validation for collections with custom id ([d0aaf4a](https://github.com/payloadcms/payload/commit/d0aaf4a4128ad585013c392bb608f586985b71ad)) -* add point field type ([7504155](https://github.com/payloadcms/payload/commit/7504155e17a2881b7a60f49e610c062665b46d21)) -* allows user to pass req through local findByID ([8675481](https://github.com/payloadcms/payload/commit/8675481343ef45fefc2eaaea939eda8ed0a2577f)) -* frontend polish to point field ([64ad6a3](https://github.com/payloadcms/payload/commit/64ad6a30a56969127dfb592a7e0c8807e9f3d8f7)) -* graphql support for custom id types ([bc2a6e1](https://github.com/payloadcms/payload/commit/bc2a6e15753c62d2041e9afded3f1ca040dbffa3)) -* point field localization and graphql ([30f1750](https://github.com/payloadcms/payload/commit/30f17509ea9927d923ffd42c703adefc902b66ea)) -* replace the collection idType option with an explicit id field ([4b70a12](https://github.com/payloadcms/payload/commit/4b70a1225f834ecd0aab50c6e92ad50572389962)) -* support custom ids ([3cc921a](https://github.com/payloadcms/payload/commit/3cc921acc92e1b4a372468b644b7e676400d9c26)) +- add config validation for collections with custom id ([fe1dc0b](https://github.com/payloadcms/payload/commit/fe1dc0b191e73f350b77a90887d8172bf76d46fd)) +- add config validation for collections with custom id ([d0aaf4a](https://github.com/payloadcms/payload/commit/d0aaf4a4128ad585013c392bb608f586985b71ad)) +- add point field type ([7504155](https://github.com/payloadcms/payload/commit/7504155e17a2881b7a60f49e610c062665b46d21)) +- allows user to pass req through local findByID ([8675481](https://github.com/payloadcms/payload/commit/8675481343ef45fefc2eaaea939eda8ed0a2577f)) +- frontend polish to point field ([64ad6a3](https://github.com/payloadcms/payload/commit/64ad6a30a56969127dfb592a7e0c8807e9f3d8f7)) +- graphql support for custom id types ([bc2a6e1](https://github.com/payloadcms/payload/commit/bc2a6e15753c62d2041e9afded3f1ca040dbffa3)) +- point field localization and graphql ([30f1750](https://github.com/payloadcms/payload/commit/30f17509ea9927d923ffd42c703adefc902b66ea)) +- replace the collection idType option with an explicit id field ([4b70a12](https://github.com/payloadcms/payload/commit/4b70a1225f834ecd0aab50c6e92ad50572389962)) +- support custom ids ([3cc921a](https://github.com/payloadcms/payload/commit/3cc921acc92e1b4a372468b644b7e676400d9c26)) ## [0.9.5](https://github.com/payloadcms/payload/compare/v0.9.4...v0.9.5) (2021-08-23) ### Bug Fixes -* obscure conditional logic bug ([b0dc125](https://github.com/payloadcms/payload/commit/b0dc12560423af5083d36cfd16f464f08ab66d9d)) -* windows compatible absolute paths for staticDir ([b21316b](https://github.com/payloadcms/payload/commit/b21316b6cc392c793614024648c5301c7e03c326)) +- obscure conditional logic bug ([b0dc125](https://github.com/payloadcms/payload/commit/b0dc12560423af5083d36cfd16f464f08ab66d9d)) +- windows compatible absolute paths for staticDir ([b21316b](https://github.com/payloadcms/payload/commit/b21316b6cc392c793614024648c5301c7e03c326)) ## [0.9.4](https://github.com/payloadcms/payload/compare/v0.9.3...v0.9.4) (2021-08-06) @@ -1709,57 +1814,57 @@ The new shape of GraphQL errors is as follows: ### Bug Fixes -* args no longer optional in collection and global hooks ([a5ea0ff](https://github.com/payloadcms/payload/commit/a5ea0ff61945f3da106f0d9dbb6a90fb1d884061)) +- args no longer optional in collection and global hooks ([a5ea0ff](https://github.com/payloadcms/payload/commit/a5ea0ff61945f3da106f0d9dbb6a90fb1d884061)) ## [0.9.2](https://github.com/payloadcms/payload/compare/v0.9.1...v0.9.2) (2021-08-06) ### Bug Fixes -* row admin type ([deef520](https://github.com/payloadcms/payload/commit/deef5202c15301b685fe5efc8a6ff59b012ea1d4)) +- row admin type ([deef520](https://github.com/payloadcms/payload/commit/deef5202c15301b685fe5efc8a6ff59b012ea1d4)) ### Features -* allow completely disabling local file storage ([9661c6d](https://github.com/payloadcms/payload/commit/9661c6d40acc41d21eebc42b0cc1871f28d35a73)) -* allows upload resizing to maintain aspect ratio ([dea54a4](https://github.com/payloadcms/payload/commit/dea54a4cccead86e6ffc9f20457f295e1c08405b)) -* exposes auto-sized uploads on payload req ([9c8935f](https://github.com/payloadcms/payload/commit/9c8935fd51439627cccf3f6625236375f5909445)) -* reduces group heading from h2 to h3 ([907f8fd](https://github.com/payloadcms/payload/commit/907f8fd94d7e6cfa7eac0040c134cc714f29800d)) +- allow completely disabling local file storage ([9661c6d](https://github.com/payloadcms/payload/commit/9661c6d40acc41d21eebc42b0cc1871f28d35a73)) +- allows upload resizing to maintain aspect ratio ([dea54a4](https://github.com/payloadcms/payload/commit/dea54a4cccead86e6ffc9f20457f295e1c08405b)) +- exposes auto-sized uploads on payload req ([9c8935f](https://github.com/payloadcms/payload/commit/9c8935fd51439627cccf3f6625236375f5909445)) +- reduces group heading from h2 to h3 ([907f8fd](https://github.com/payloadcms/payload/commit/907f8fd94d7e6cfa7eac0040c134cc714f29800d)) ## [0.9.1](https://github.com/payloadcms/payload/compare/v0.9.0...v0.9.1) (2021-08-03) ### Bug Fixes -* groups with failing conditions being incorrectly required on backend ([4cc0ea1](https://github.com/payloadcms/payload/commit/4cc0ea1d81cd7579cb330091eb111a27262ff031)) -* relationship field access control in admin UI ([65db8d9](https://github.com/payloadcms/payload/commit/65db8d9fc2c8b556cc284966b9b69f5d6512aca5)) +- groups with failing conditions being incorrectly required on backend ([4cc0ea1](https://github.com/payloadcms/payload/commit/4cc0ea1d81cd7579cb330091eb111a27262ff031)) +- relationship field access control in admin UI ([65db8d9](https://github.com/payloadcms/payload/commit/65db8d9fc2c8b556cc284966b9b69f5d6512aca5)) ### Features -* exposes collection after read hook type ([01a191a](https://github.com/payloadcms/payload/commit/01a191a13967d98ebf57891efd21b2607804e4e3)) +- exposes collection after read hook type ([01a191a](https://github.com/payloadcms/payload/commit/01a191a13967d98ebf57891efd21b2607804e4e3)) # [0.9.0](https://github.com/payloadcms/payload/compare/v0.8.2...v0.9.0) (2021-08-02) ### BREAKING CHANGES -* Due to greater plugin possibilities and performance enhancements, plugins themselves no longer accept a completely sanitized config. Instead, they accept a _validated_ config as-provided, but sanitization is now only performed after all plugins have been initialized. By config santitization, we refer to merging in default values and ensuring that the config has its full, required shape. What this now means for plugins is that within plugin code, deeply nested properties like `config.graphQL.mutations` will need to be accessed safely (optional chaining is great for this), because a user's config may not have defined `config.graphQL`. So, the only real breaking change here is are that plugins now need to safely access properties from an incoming config. +- Due to greater plugin possibilities and performance enhancements, plugins themselves no longer accept a completely sanitized config. Instead, they accept a _validated_ config as-provided, but sanitization is now only performed after all plugins have been initialized. By config santitization, we refer to merging in default values and ensuring that the config has its full, required shape. What this now means for plugins is that within plugin code, deeply nested properties like `config.graphQL.mutations` will need to be accessed safely (optional chaining is great for this), because a user's config may not have defined `config.graphQL`. So, the only real breaking change here is are that plugins now need to safely access properties from an incoming config. ### Features -* removes sanitization of configs before plugins are instantiated ([8af3947](https://github.com/payloadcms/payload/commit/8af39472e19a26453647d1c1ab0bbce15db2c642)) +- removes sanitization of configs before plugins are instantiated ([8af3947](https://github.com/payloadcms/payload/commit/8af39472e19a26453647d1c1ab0bbce15db2c642)) ## [0.8.2](https://github.com/payloadcms/payload/compare/v0.8.1...v0.8.2) (2021-08-02) ### Bug Fixes -* more advanced conditional logic edge cases ([33983de](https://github.com/payloadcms/payload/commit/33983deb3761813506348f8ff804a2117d1324ef)) +- more advanced conditional logic edge cases ([33983de](https://github.com/payloadcms/payload/commit/33983deb3761813506348f8ff804a2117d1324ef)) ### Features -* export error types ([12cba62](https://github.com/payloadcms/payload/commit/12cba62930b8d35b22e3a7a99cf06df29bd4964a)) +- export error types ([12cba62](https://github.com/payloadcms/payload/commit/12cba62930b8d35b22e3a7a99cf06df29bd4964a)) ## [0.8.1](https://github.com/payloadcms/payload/compare/v0.8.0...v0.8.1) (2021-07-29) ### BREAKING CHANGES -* If you have any plugins that are written in TypeScript, we have changed plugin types to make them more flexible. Whereas before you needed to take in a fully sanitized config, and return a fully sanitized config, we now have simplified that requirement so that you can write configs in your own plugins just as an end user of Payload can write their own configs. +- If you have any plugins that are written in TypeScript, we have changed plugin types to make them more flexible. Whereas before you needed to take in a fully sanitized config, and return a fully sanitized config, we now have simplified that requirement so that you can write configs in your own plugins just as an end user of Payload can write their own configs. Now, configs will be sanitized **_before_** plugins are executed **_as well as_** after plugins are executed. @@ -1789,80 +1894,80 @@ const plugin = (config: Config): Config => { ### Features -* improves plugin writability ([a002b71](https://github.com/payloadcms/payload/commit/a002b7105f5c312e846c80032a350046db10236c)) +- improves plugin writability ([a002b71](https://github.com/payloadcms/payload/commit/a002b7105f5c312e846c80032a350046db10236c)) # [0.8.0](https://github.com/payloadcms/payload/compare/v0.7.10...v0.8.0) (2021-07-28) ### BREAKING CHANGES -* There have been a few very minor, yet breaking TypeScript changes in this release. If you are accessing Payload config types from directly within the `dist` folder, like any of the following: +- There have been a few very minor, yet breaking TypeScript changes in this release. If you are accessing Payload config types from directly within the `dist` folder, like any of the following: -* `import { PayloadCollectionConfig, CollectionConfig } from 'payload/dist/collections/config/types';` -* `import { PayloadGlobalConfig, GlobalConfig } from 'payload/dist/globals/config/types';` -* `import { Config, PayloadConfig } from 'payload/config';` +- `import { PayloadCollectionConfig, CollectionConfig } from 'payload/dist/collections/config/types';` +- `import { PayloadGlobalConfig, GlobalConfig } from 'payload/dist/globals/config/types';` +- `import { Config, PayloadConfig } from 'payload/config';` You may need to modify your code to work with this release. The TL;DR of the change is that we have improved our naming conventions of internally used types, which will become more important over time. Now, we have landed on a naming convention as follows: -* Incoming configs, typed correctly for optional / required config properties, are named `Config`, `CollectionConfig`, and `GlobalConfig`. -* Fully defaulted, sanitized, and validated configs are now named `SanitizedConfig`, `SanitizedCollectionConfig`, and `SanitizedGlobalConfig`. +- Incoming configs, typed correctly for optional / required config properties, are named `Config`, `CollectionConfig`, and `GlobalConfig`. +- Fully defaulted, sanitized, and validated configs are now named `SanitizedConfig`, `SanitizedCollectionConfig`, and `SanitizedGlobalConfig`. They can be imported safely outside of the `dist` folder now as well. For more information on how to properly import which types you need, see the following Docs pages which have now been updated with examples on how to properly access the new types: -* [Base Payload config docs](https://payloadcms.com/docs/configuration/overview) -* [Collection config docs](https://payloadcms.com/docs/configuration/collections) -* [Global config docs](https://payloadcms.com/docs/configuration/globals) +- [Base Payload config docs](https://payloadcms.com/docs/configuration/overview) +- [Collection config docs](https://payloadcms.com/docs/configuration/collections) +- [Global config docs](https://payloadcms.com/docs/configuration/globals) ### Bug Fixes -* ensures text component is always controlled ([c649362](https://github.com/payloadcms/payload/commit/c649362b95f1ddaeb47cb121b814ca30712dea86)) +- ensures text component is always controlled ([c649362](https://github.com/payloadcms/payload/commit/c649362b95f1ddaeb47cb121b814ca30712dea86)) ### Features -* revises naming conventions of config types ([5a7e5b9](https://github.com/payloadcms/payload/commit/5a7e5b921d7803ec2da8cc3dc8162c1dd6828ca0)) +- revises naming conventions of config types ([5a7e5b9](https://github.com/payloadcms/payload/commit/5a7e5b921d7803ec2da8cc3dc8162c1dd6828ca0)) ## [0.7.10](https://github.com/payloadcms/payload/compare/v0.7.9...v0.7.10) (2021-07-27) ### Bug Fixes -* jest debug testing ([a2fa30f](https://github.com/payloadcms/payload/commit/a2fa30fad2cd9b8ab6ac4f3905706b97d5663954)) -* skipValidation logic ([fedeaea](https://github.com/payloadcms/payload/commit/fedeaeafc9607f7c21e40c2df44923056e5d460c)) +- jest debug testing ([a2fa30f](https://github.com/payloadcms/payload/commit/a2fa30fad2cd9b8ab6ac4f3905706b97d5663954)) +- skipValidation logic ([fedeaea](https://github.com/payloadcms/payload/commit/fedeaeafc9607f7c21e40c2df44923056e5d460c)) ### Features -* improves conditional logic performance and edge cases ([d43390f](https://github.com/payloadcms/payload/commit/d43390f2a4c5ebeb7b9b0f07e003816005efc761)) +- improves conditional logic performance and edge cases ([d43390f](https://github.com/payloadcms/payload/commit/d43390f2a4c5ebeb7b9b0f07e003816005efc761)) ## [0.7.9](https://github.com/payloadcms/payload/compare/v0.7.8...v0.7.9) (2021-07-27) ### Bug Fixes -* missing richtext gutter ([4d1249d](https://github.com/payloadcms/payload/commit/4d1249dd03f441ee872e66437118c3e8703aaefc)) +- missing richtext gutter ([4d1249d](https://github.com/payloadcms/payload/commit/4d1249dd03f441ee872e66437118c3e8703aaefc)) ### Features -* add admin description to collections and globals ([4544711](https://github.com/payloadcms/payload/commit/4544711f0e4ea0e78570b93717a4bf213946d9b3)) -* add collection slug to schema validation errors ([ebfb72c](https://github.com/payloadcms/payload/commit/ebfb72c8fa0723ec75922c6fa4739b48ee82b29f)) -* add component support to collection and global description ([fe0098c](https://github.com/payloadcms/payload/commit/fe0098ccd9b3477b47985222659a0e3fc2e7bb3b)) -* add component support to field description ([e0933f6](https://github.com/payloadcms/payload/commit/e0933f612a70af0a18c88ef96e7af0878e20cf01)) -* add customizable admin field descriptions ([dac60a0](https://github.com/payloadcms/payload/commit/dac60a024b0eb7197d5a501daea342827ee7c751)) -* add descriptions to every allowed field type, globals and collections ([29a1108](https://github.com/payloadcms/payload/commit/29a1108518c7942f8ae06a990393a6e0ad4b6b16)) -* add global slug and field names to schema validation errors ([bb63b4a](https://github.com/payloadcms/payload/commit/bb63b4aad153d125f68bf1fe1e9a3e4a5358ded9)) -* improves group styling when there is no label ([ea358a6](https://github.com/payloadcms/payload/commit/ea358a66e8b8d2e54dd162eae0cf7066128cfabf)) +- add admin description to collections and globals ([4544711](https://github.com/payloadcms/payload/commit/4544711f0e4ea0e78570b93717a4bf213946d9b3)) +- add collection slug to schema validation errors ([ebfb72c](https://github.com/payloadcms/payload/commit/ebfb72c8fa0723ec75922c6fa4739b48ee82b29f)) +- add component support to collection and global description ([fe0098c](https://github.com/payloadcms/payload/commit/fe0098ccd9b3477b47985222659a0e3fc2e7bb3b)) +- add component support to field description ([e0933f6](https://github.com/payloadcms/payload/commit/e0933f612a70af0a18c88ef96e7af0878e20cf01)) +- add customizable admin field descriptions ([dac60a0](https://github.com/payloadcms/payload/commit/dac60a024b0eb7197d5a501daea342827ee7c751)) +- add descriptions to every allowed field type, globals and collections ([29a1108](https://github.com/payloadcms/payload/commit/29a1108518c7942f8ae06a990393a6e0ad4b6b16)) +- add global slug and field names to schema validation errors ([bb63b4a](https://github.com/payloadcms/payload/commit/bb63b4aad153d125f68bf1fe1e9a3e4a5358ded9)) +- improves group styling when there is no label ([ea358a6](https://github.com/payloadcms/payload/commit/ea358a66e8b8d2e54dd162eae0cf7066128cfabf)) ## [0.7.8](https://github.com/payloadcms/payload/compare/v0.7.7...v0.7.8) (2021-07-23) ### Features -* fixes group label schema validation ([cbac888](https://github.com/payloadcms/payload/commit/cbac8887ddb7a4446f5502c577d4600905b13380)) +- fixes group label schema validation ([cbac888](https://github.com/payloadcms/payload/commit/cbac8887ddb7a4446f5502c577d4600905b13380)) ## [0.7.7](https://github.com/payloadcms/payload/compare/v0.7.6...v0.7.7) (2021-07-23) ### Bug Fixes -* accurately documents the props for the datepicker field ([dcd8052](https://github.com/payloadcms/payload/commit/dcd8052498dd2900f228eaffcf6142b63e8e5a9b)) +- accurately documents the props for the datepicker field ([dcd8052](https://github.com/payloadcms/payload/commit/dcd8052498dd2900f228eaffcf6142b63e8e5a9b)) ### Features -* only attempts to find config when payload is initialized ([266ccb3](https://github.com/payloadcms/payload/commit/266ccb374449b0a131a574d9b12275b6bb7e5c60)) +- only attempts to find config when payload is initialized ([266ccb3](https://github.com/payloadcms/payload/commit/266ccb374449b0a131a574d9b12275b6bb7e5c60)) ## [0.7.6](https://github.com/payloadcms/payload/compare/v0.7.5...v0.7.6) (2021-07-07) @@ -1870,58 +1975,58 @@ They can be imported safely outside of the `dist` folder now as well. For more i ### Bug Fixes -* crash on bullet list de-selection ([5388513](https://github.com/payloadcms/payload/commit/538851325d1558425918098e35e108595189774b)) -* updates demo richtext elements with proper SCSS ([0075912](https://github.com/payloadcms/payload/commit/007591272f77e5dcc5e5a4a8f71459402f6605d4)) +- crash on bullet list de-selection ([5388513](https://github.com/payloadcms/payload/commit/538851325d1558425918098e35e108595189774b)) +- updates demo richtext elements with proper SCSS ([0075912](https://github.com/payloadcms/payload/commit/007591272f77e5dcc5e5a4a8f71459402f6605d4)) ### Features -* adds plugins infrastructure ([6b25531](https://github.com/payloadcms/payload/commit/6b255315e0c475d700383f2738839966449fc563)) -* enables backspace to deactivate richtext list elements ([91141ad](https://github.com/payloadcms/payload/commit/91141ad62f0f6ef3528e62eef23711e937d302ce)) +- adds plugins infrastructure ([6b25531](https://github.com/payloadcms/payload/commit/6b255315e0c475d700383f2738839966449fc563)) +- enables backspace to deactivate richtext list elements ([91141ad](https://github.com/payloadcms/payload/commit/91141ad62f0f6ef3528e62eef23711e937d302ce)) ## [0.7.4](https://github.com/payloadcms/payload/compare/v0.7.3...v0.7.4) (2021-07-01) ### Bug Fixes -* adds proper scss stylesheets to payload/scss ([84e31ae](https://github.com/payloadcms/payload/commit/84e31aed141efe5aa1b0c24a61bf35eb3d671242)) +- adds proper scss stylesheets to payload/scss ([84e31ae](https://github.com/payloadcms/payload/commit/84e31aed141efe5aa1b0c24a61bf35eb3d671242)) ## [0.7.3](https://github.com/payloadcms/payload/compare/v0.7.2...v0.7.3) (2021-07-01) ### Bug Fixes -* changes scss imports to allow vars imports to payload projects ([ea80fd6](https://github.com/payloadcms/payload/commit/ea80fd68b14139cb01259a47ea597d33526d0c76)) +- changes scss imports to allow vars imports to payload projects ([ea80fd6](https://github.com/payloadcms/payload/commit/ea80fd68b14139cb01259a47ea597d33526d0c76)) ### Features -* export all field prop types for custom components ([5bea9ae](https://github.com/payloadcms/payload/commit/5bea9ae1263f1d93e8b011ae97bb067a8c9bb4e1)) +- export all field prop types for custom components ([5bea9ae](https://github.com/payloadcms/payload/commit/5bea9ae1263f1d93e8b011ae97bb067a8c9bb4e1)) ## [0.7.2](https://github.com/payloadcms/payload/compare/v0.7.1...v0.7.2) (2021-06-22) ### Bug Fixes -* parses incoming numbers through query string for use in where clauses ([4933b34](https://github.com/payloadcms/payload/commit/4933b34f6b5dfa960c2a830a8c74769d6712130a)) -* respect maxDepth 0 ([95c1650](https://github.com/payloadcms/payload/commit/95c165018edf8e80c4dc828d3d77b6fa6d799de9)) -* safely stringifies ObjectIDs while populating relationships ([d6bc6f9](https://github.com/payloadcms/payload/commit/d6bc6f9f0e8391818783cdf7edf282506e2c9fed)) +- parses incoming numbers through query string for use in where clauses ([4933b34](https://github.com/payloadcms/payload/commit/4933b34f6b5dfa960c2a830a8c74769d6712130a)) +- respect maxDepth 0 ([95c1650](https://github.com/payloadcms/payload/commit/95c165018edf8e80c4dc828d3d77b6fa6d799de9)) +- safely stringifies ObjectIDs while populating relationships ([d6bc6f9](https://github.com/payloadcms/payload/commit/d6bc6f9f0e8391818783cdf7edf282506e2c9fed)) ### Features -* adds maxDepth to relationships and upload fields ([880dabd](https://github.com/payloadcms/payload/commit/880dabdcad10dcd9f057da71a601190fbeecf92d)) +- adds maxDepth to relationships and upload fields ([880dabd](https://github.com/payloadcms/payload/commit/880dabdcad10dcd9f057da71a601190fbeecf92d)) ## [0.7.1](https://github.com/payloadcms/payload/compare/v0.7.0...v0.7.1) (2021-06-21) ### Bug Fixes -* babel config file error ([3af2554](https://github.com/payloadcms/payload/commit/3af2554eacab45317745ad72c8848b4dd1ddc16a)) +- babel config file error ([3af2554](https://github.com/payloadcms/payload/commit/3af2554eacab45317745ad72c8848b4dd1ddc16a)) # [0.7.0](https://github.com/payloadcms/payload/compare/v0.6.10...v0.7.0) (2021-06-21) ### Bug Fixes -* handle all scenarios in select cell ([dd40ab0](https://github.com/payloadcms/payload/commit/dd40ab07fa359802578ed948136018dfc9a538c5)) +- handle all scenarios in select cell ([dd40ab0](https://github.com/payloadcms/payload/commit/dd40ab07fa359802578ed948136018dfc9a538c5)) ### Features -* exposes babel config via payload/babel ([#203](https://github.com/payloadcms/payload/issues/203)) ([67c1e28](https://github.com/payloadcms/payload/commit/67c1e280eb891a736703e242518bbeac8b8c2878)) -* user preferences ([#195](https://github.com/payloadcms/payload/issues/195)) ([fb60bc7](https://github.com/payloadcms/payload/commit/fb60bc79a11d69c5dab6b4921d62614a7b914fef)) +- exposes babel config via payload/babel ([#203](https://github.com/payloadcms/payload/issues/203)) ([67c1e28](https://github.com/payloadcms/payload/commit/67c1e280eb891a736703e242518bbeac8b8c2878)) +- user preferences ([#195](https://github.com/payloadcms/payload/issues/195)) ([fb60bc7](https://github.com/payloadcms/payload/commit/fb60bc79a11d69c5dab6b4921d62614a7b914fef)) ## [0.6.10](https://github.com/payloadcms/payload/compare/v0.6.9...v0.6.10) (2021-05-23) @@ -1929,84 +2034,84 @@ They can be imported safely outside of the `dist` folder now as well. For more i ### Bug Fixes -* misc responsive improvements -* date clipping in sidebar ([#165](https://github.com/payloadcms/payload/issues/165)) -* misc polish to popup component -* admin \_verified field not displaying proper field value -* properly typed express-fileupload config options ([#180](https://github.com/payloadcms/payload/issues/180)) +- misc responsive improvements +- date clipping in sidebar ([#165](https://github.com/payloadcms/payload/issues/165)) +- misc polish to popup component +- admin \_verified field not displaying proper field value +- properly typed express-fileupload config options ([#180](https://github.com/payloadcms/payload/issues/180)) ## [0.6.8](https://github.com/payloadcms/payload/compare/v0.6.7...v0.6.8) (2021-05-12) ### Features -* add mimeTypes validation for uploads ([a5fcdf0](https://github.com/payloadcms/payload/commit/a5fcdf03bae681c5b2e0de6b681d20efe8ebdd7f)) -* disables user scalable in mobile ([#177](https://github.com/payloadcms/payload/issues/177)) ([46c1a36](https://github.com/payloadcms/payload/commit/46c1a36fdb9363201b65ecdec44088cb41532bd6)) -* exposes locale within preview function ([2d67448](https://github.com/payloadcms/payload/commit/2d67448d8ad1a7d4238820d0ccd93da961fc051c)) -* restrict upload mime types in file picker ([1c6f32f](https://github.com/payloadcms/payload/commit/1c6f32f2881410a1534b61711af05fd35e7977c2)) +- add mimeTypes validation for uploads ([a5fcdf0](https://github.com/payloadcms/payload/commit/a5fcdf03bae681c5b2e0de6b681d20efe8ebdd7f)) +- disables user scalable in mobile ([#177](https://github.com/payloadcms/payload/issues/177)) ([46c1a36](https://github.com/payloadcms/payload/commit/46c1a36fdb9363201b65ecdec44088cb41532bd6)) +- exposes locale within preview function ([2d67448](https://github.com/payloadcms/payload/commit/2d67448d8ad1a7d4238820d0ccd93da961fc051c)) +- restrict upload mime types in file picker ([1c6f32f](https://github.com/payloadcms/payload/commit/1c6f32f2881410a1534b61711af05fd35e7977c2)) ## [0.6.7](https://github.com/payloadcms/payload/compare/v0.6.6...v0.6.7) (2021-05-07) ### Features -* add ability to hide gutter for RichText fields ([e791c5b](https://github.com/payloadcms/payload/commit/e791c5b7b325e58d273041ff426d19bafc4fc102)) -* allows group field gutter to be disabled ([9aebeaf](https://github.com/payloadcms/payload/commit/9aebeaf579b9c8add64734dce92e4d92c0a1a24c)) -* exposes component types ([99466fa](https://github.com/payloadcms/payload/commit/99466fa41e24779705f517d29d57e6174508ebcc)) -* shrink image thumbnails on larger screens ([e565fa6](https://github.com/payloadcms/payload/commit/e565fa6f1ce13d76b8111e543d4c799a5d7f450e)) -* support global date format ([670ccf2](https://github.com/payloadcms/payload/commit/670ccf2f589c306d13f3060b8acf4f4d33fcdd23)) +- add ability to hide gutter for RichText fields ([e791c5b](https://github.com/payloadcms/payload/commit/e791c5b7b325e58d273041ff426d19bafc4fc102)) +- allows group field gutter to be disabled ([9aebeaf](https://github.com/payloadcms/payload/commit/9aebeaf579b9c8add64734dce92e4d92c0a1a24c)) +- exposes component types ([99466fa](https://github.com/payloadcms/payload/commit/99466fa41e24779705f517d29d57e6174508ebcc)) +- shrink image thumbnails on larger screens ([e565fa6](https://github.com/payloadcms/payload/commit/e565fa6f1ce13d76b8111e543d4c799a5d7f450e)) +- support global date format ([670ccf2](https://github.com/payloadcms/payload/commit/670ccf2f589c306d13f3060b8acf4f4d33fcdd23)) ## [0.6.6](https://github.com/payloadcms/payload/compare/v0.6.5...v0.6.6) (2021-04-27) ### Bug Fixes -* graphql returns compatible error format ([6f188b1](https://github.com/payloadcms/payload/commit/6f188b1fa6e631a992439f055e8e76c341ca6dfa)) -* handle rich text saving as empty string ([382089b](https://github.com/payloadcms/payload/commit/382089b484b278e6ff491a2447ad06c41b96d5e3)) -* removes incoming.data.length check, since data is typed as a keyed array when it is an instance of APIError ([2643e1a](https://github.com/payloadcms/payload/commit/2643e1a1006f86b24001f65cf39da245fa4daaad)) -* support image resizing on M1 chip ([8cfc039](https://github.com/payloadcms/payload/commit/8cfc039cd0ffd497728f185b6ab45695302d3b95)) -* update operation can save password changes ([a85bf9e](https://github.com/payloadcms/payload/commit/a85bf9e836f9463d94f13857254f5d4df6f68c72)) +- graphql returns compatible error format ([6f188b1](https://github.com/payloadcms/payload/commit/6f188b1fa6e631a992439f055e8e76c341ca6dfa)) +- handle rich text saving as empty string ([382089b](https://github.com/payloadcms/payload/commit/382089b484b278e6ff491a2447ad06c41b96d5e3)) +- removes incoming.data.length check, since data is typed as a keyed array when it is an instance of APIError ([2643e1a](https://github.com/payloadcms/payload/commit/2643e1a1006f86b24001f65cf39da245fa4daaad)) +- support image resizing on M1 chip ([8cfc039](https://github.com/payloadcms/payload/commit/8cfc039cd0ffd497728f185b6ab45695302d3b95)) +- update operation can save password changes ([a85bf9e](https://github.com/payloadcms/payload/commit/a85bf9e836f9463d94f13857254f5d4df6f68c72)) ## [0.6.5](https://github.com/payloadcms/payload/compare/v0.6.4...v0.6.5) (2021-04-22) ### Features -* builds plugin infrastructure ([#149](https://github.com/payloadcms/payload/issues/149)) ([f17c6e4](https://github.com/payloadcms/payload/commit/f17c6e4010de07578af21398f667fa55bc8343bc)) +- builds plugin infrastructure ([#149](https://github.com/payloadcms/payload/issues/149)) ([f17c6e4](https://github.com/payloadcms/payload/commit/f17c6e4010de07578af21398f667fa55bc8343bc)) ## [0.6.4](https://github.com/payloadcms/payload/compare/v0.6.3...v0.6.4) (2021-04-21) ### Bug Fixes -* allows \_verificationToken to come back via showHiddenFields ([74430ea](https://github.com/payloadcms/payload/commit/74430ea1519c1ba0ad655daf4e8f5d8dae855358)) +- allows \_verificationToken to come back via showHiddenFields ([74430ea](https://github.com/payloadcms/payload/commit/74430ea1519c1ba0ad655daf4e8f5d8dae855358)) ## [0.6.3](https://github.com/payloadcms/payload/compare/v0.6.2...v0.6.3) (2021-04-21) ### Bug Fixes -* make admin field properties in joi schema match TS types ([519c021](https://github.com/payloadcms/payload/commit/519c021525be114f43ad321233a9b8211d309ed0)) -* properly label arrays/blocks with plural and singular ([fa49811](https://github.com/payloadcms/payload/commit/fa49811377103db9241f43537e508da62eb19076)) -* safely parses incoming stringified richtext json ([9c95c75](https://github.com/payloadcms/payload/commit/9c95c750305633e99e7d80b5ba407b5b3146d691)) +- make admin field properties in joi schema match TS types ([519c021](https://github.com/payloadcms/payload/commit/519c021525be114f43ad321233a9b8211d309ed0)) +- properly label arrays/blocks with plural and singular ([fa49811](https://github.com/payloadcms/payload/commit/fa49811377103db9241f43537e508da62eb19076)) +- safely parses incoming stringified richtext json ([9c95c75](https://github.com/payloadcms/payload/commit/9c95c750305633e99e7d80b5ba407b5b3146d691)) ## [0.6.2](https://github.com/payloadcms/payload/compare/v0.6.1...v0.6.2) (2021-04-19) ### Features -* modifies relationship field to react to changing relationTo ([ddf25fb](https://github.com/payloadcms/payload/commit/ddf25fbb6559d93dd5b9105bd4a0a952fc72154b)) +- modifies relationship field to react to changing relationTo ([ddf25fb](https://github.com/payloadcms/payload/commit/ddf25fbb6559d93dd5b9105bd4a0a952fc72154b)) ## [0.6.1](https://github.com/payloadcms/payload/compare/v0.6.0...v0.6.1) (2021-04-19) ### Bug Fixes -* cleans up duplicative columns ([5f2073a](https://github.com/payloadcms/payload/commit/5f2073ae685f22d099bc8f0d3e406e73ee59cd1d)) -* graphql localized relationship bugs ([280f809](https://github.com/payloadcms/payload/commit/280f8094217de759ba6424dfd2294a6bfcb1d57a)) -* moves enableRichTextRelationship to proper spot ([16ca22b](https://github.com/payloadcms/payload/commit/16ca22b4cc0d8e5d106fa8c8c6e2dde0ff972839)) +- cleans up duplicative columns ([5f2073a](https://github.com/payloadcms/payload/commit/5f2073ae685f22d099bc8f0d3e406e73ee59cd1d)) +- graphql localized relationship bugs ([280f809](https://github.com/payloadcms/payload/commit/280f8094217de759ba6424dfd2294a6bfcb1d57a)) +- moves enableRichTextRelationship to proper spot ([16ca22b](https://github.com/payloadcms/payload/commit/16ca22b4cc0d8e5d106fa8c8c6e2dde0ff972839)) ### Features -* sets enableRichTextRelationship to true by default ([9970470](https://github.com/payloadcms/payload/commit/99704707dda25f8617d26552942915aa6e9d7a57)) +- sets enableRichTextRelationship to true by default ([9970470](https://github.com/payloadcms/payload/commit/99704707dda25f8617d26552942915aa6e9d7a57)) # [0.6.0](https://github.com/payloadcms/payload/compare/v0.5.10...v0.6.0) (2021-04-19) ### BREAKING CHANGES -* By default, all Collection and Global access control functions are now set to require a user to be logged in to interact through GraphQL or REST APIs. This default access control is set to ensure that your API data is secure out of the box. From there, you can opt to publicly expose API actions as you need. +- By default, all Collection and Global access control functions are now set to require a user to be logged in to interact through GraphQL or REST APIs. This default access control is set to ensure that your API data is secure out of the box. From there, you can opt to publicly expose API actions as you need. #### Migration Instructions to `0.6.x` @@ -2040,24 +2145,24 @@ If none of your collections or globals should be publicly exposed, you don't nee ### Bug Fixes -* clears richtext element on enter, refocuses on toolbar button click ([4b19795](https://github.com/payloadcms/payload/commit/4b1979540d2ec33ce8396f572baba5e64962c0da)) -* ensures api keys are properly populated in admin ([4359a70](https://github.com/payloadcms/payload/commit/4359a70a8b0bca380cc513dfcb83b2fbe28cbef4)) -* ensures first relationship options are loaded only once ([75a5b04](https://github.com/payloadcms/payload/commit/75a5b047056b4e4e7a415a6903a1131cc61b0318)) -* searching on relationship fields properly fetches results ([b86c3da](https://github.com/payloadcms/payload/commit/b86c3daa9952ccc9db324fecd53bb75f69cecfd4)) -* upload useAsTitle set to filename by default ([7db23f8](https://github.com/payloadcms/payload/commit/7db23f8ebbf115ca45fa55718b0d1be18ca54cd3)) +- clears richtext element on enter, refocuses on toolbar button click ([4b19795](https://github.com/payloadcms/payload/commit/4b1979540d2ec33ce8396f572baba5e64962c0da)) +- ensures api keys are properly populated in admin ([4359a70](https://github.com/payloadcms/payload/commit/4359a70a8b0bca380cc513dfcb83b2fbe28cbef4)) +- ensures first relationship options are loaded only once ([75a5b04](https://github.com/payloadcms/payload/commit/75a5b047056b4e4e7a415a6903a1131cc61b0318)) +- searching on relationship fields properly fetches results ([b86c3da](https://github.com/payloadcms/payload/commit/b86c3daa9952ccc9db324fecd53bb75f69cecfd4)) +- upload useAsTitle set to filename by default ([7db23f8](https://github.com/payloadcms/payload/commit/7db23f8ebbf115ca45fa55718b0d1be18ca54cd3)) ### Features -* autolabel fields when label is omitted ([#42](https://github.com/payloadcms/payload/issues/42)) ([b383eb6](https://github.com/payloadcms/payload/commit/b383eb65c6b524fd7cfddb7ac60a3f263e1b891e)) -* dynamically populates richtext relationships ([3530424](https://github.com/payloadcms/payload/commit/353042467f12458994d734cf54423eb95eea9003)) -* improve unique field value error handling ([21b2bd4](https://github.com/payloadcms/payload/commit/21b2bd4b6708823880fb87035495ab4c2c55da90)) -* improves margins in rich text elements ([20d7a01](https://github.com/payloadcms/payload/commit/20d7a01919634faa366add792f98a36e68f213e9)) +- autolabel fields when label is omitted ([#42](https://github.com/payloadcms/payload/issues/42)) ([b383eb6](https://github.com/payloadcms/payload/commit/b383eb65c6b524fd7cfddb7ac60a3f263e1b891e)) +- dynamically populates richtext relationships ([3530424](https://github.com/payloadcms/payload/commit/353042467f12458994d734cf54423eb95eea9003)) +- improve unique field value error handling ([21b2bd4](https://github.com/payloadcms/payload/commit/21b2bd4b6708823880fb87035495ab4c2c55da90)) +- improves margins in rich text elements ([20d7a01](https://github.com/payloadcms/payload/commit/20d7a01919634faa366add792f98a36e68f213e9)) ## [0.5.10](https://github.com/payloadcms/payload/compare/v0.5.9...v0.5.10) (2021-04-14) ### Bug Fixes -* feeds collectionSlug through me auth for graphql resolver ([9ee2f9c](https://github.com/payloadcms/payload/commit/9ee2f9c0dc25ea32ee0f0864e30afb389903b3cd)) +- feeds collectionSlug through me auth for graphql resolver ([9ee2f9c](https://github.com/payloadcms/payload/commit/9ee2f9c0dc25ea32ee0f0864e30afb389903b3cd)) ## [0.5.9](https://github.com/payloadcms/payload/compare/v0.5.8...v0.5.9) (2021-04-14) @@ -2065,70 +2170,70 @@ If none of your collections or globals should be publicly exposed, you don't nee ### Bug Fixes -* revises graphql import syntax ([20f1e6c](https://github.com/payloadcms/payload/commit/20f1e6cb044254af7a0db72cc9dab95d32db0333)) +- revises graphql import syntax ([20f1e6c](https://github.com/payloadcms/payload/commit/20f1e6cb044254af7a0db72cc9dab95d32db0333)) ## [0.5.7](https://github.com/payloadcms/payload/compare/v0.5.5...v0.5.7) (2021-04-13) ### Bug Fixes -* clears verificationToken when \_verified is true ([e58b152](https://github.com/payloadcms/payload/commit/e58b152d40394ec59b7a779feb3b9f02a6f4a0b6)) -* custom query / mutation types ([a78fc97](https://github.com/payloadcms/payload/commit/a78fc974b80b153028e4796b15d2b6b17fe023bb)) -* ensures email is still prefilled in auth configs ([31c41c2](https://github.com/payloadcms/payload/commit/31c41c22eca96721ce2982bcf5860dfd9e5c7beb)) -* ensures failed conditions send path to form ([dff72fb](https://github.com/payloadcms/payload/commit/dff72fbf2f49d372423da8bc2840aad6d9c1ea1b)) -* handle add/remove labels for all usage of Array field type ([ddf5df2](https://github.com/payloadcms/payload/commit/ddf5df290c5b36af0dc37a79c476001387f73275)) -* make upload cell mimetype inline ([414bc01](https://github.com/payloadcms/payload/commit/414bc01b055ed6075613f4241f185cb0c25f046d)) -* pagination calculation for current range ([000dee8](https://github.com/payloadcms/payload/commit/000dee85bd5858fe3d45e08c62943a6a1c6e349c)) -* updates config schema for graphQL mutations and queries ([afc9454](https://github.com/payloadcms/payload/commit/afc9454465d7445c45f560eade0b17d831b04e2c)) +- clears verificationToken when \_verified is true ([e58b152](https://github.com/payloadcms/payload/commit/e58b152d40394ec59b7a779feb3b9f02a6f4a0b6)) +- custom query / mutation types ([a78fc97](https://github.com/payloadcms/payload/commit/a78fc974b80b153028e4796b15d2b6b17fe023bb)) +- ensures email is still prefilled in auth configs ([31c41c2](https://github.com/payloadcms/payload/commit/31c41c22eca96721ce2982bcf5860dfd9e5c7beb)) +- ensures failed conditions send path to form ([dff72fb](https://github.com/payloadcms/payload/commit/dff72fbf2f49d372423da8bc2840aad6d9c1ea1b)) +- handle add/remove labels for all usage of Array field type ([ddf5df2](https://github.com/payloadcms/payload/commit/ddf5df290c5b36af0dc37a79c476001387f73275)) +- make upload cell mimetype inline ([414bc01](https://github.com/payloadcms/payload/commit/414bc01b055ed6075613f4241f185cb0c25f046d)) +- pagination calculation for current range ([000dee8](https://github.com/payloadcms/payload/commit/000dee85bd5858fe3d45e08c62943a6a1c6e349c)) +- updates config schema for graphQL mutations and queries ([afc9454](https://github.com/payloadcms/payload/commit/afc9454465d7445c45f560eade0b17d831b04e2c)) ### Features -* auto verifies first user registration ([8f720c0](https://github.com/payloadcms/payload/commit/8f720c000df26d34f7f8652f170525c7d54184a5)) -* optimize save within Edit ([91d37fb](https://github.com/payloadcms/payload/commit/91d37fb41d820fe2cdcdbb28f999df2de751316e)) -* prevents DraggableSections from re-mounting on doc save ([0094837](https://github.com/payloadcms/payload/commit/00948376358a4bfecc3a6cb8cf0a6ad9a0b5a227)) -* remembers conditional field values after removing / readding ([988d0a4](https://github.com/payloadcms/payload/commit/988d0a4b08e1228bb358bb133bcb05dbce7f55ab)) -* remove mimetype from upload cell type ([776b9c9](https://github.com/payloadcms/payload/commit/776b9c9c30b6d9d795c509a558fd1eee666b2652)) +- auto verifies first user registration ([8f720c0](https://github.com/payloadcms/payload/commit/8f720c000df26d34f7f8652f170525c7d54184a5)) +- optimize save within Edit ([91d37fb](https://github.com/payloadcms/payload/commit/91d37fb41d820fe2cdcdbb28f999df2de751316e)) +- prevents DraggableSections from re-mounting on doc save ([0094837](https://github.com/payloadcms/payload/commit/00948376358a4bfecc3a6cb8cf0a6ad9a0b5a227)) +- remembers conditional field values after removing / readding ([988d0a4](https://github.com/payloadcms/payload/commit/988d0a4b08e1228bb358bb133bcb05dbce7f55ab)) +- remove mimetype from upload cell type ([776b9c9](https://github.com/payloadcms/payload/commit/776b9c9c30b6d9d795c509a558fd1eee666b2652)) ## [0.5.5](https://github.com/payloadcms/payload/compare/v0.5.4...v0.5.5) (2021-04-02) ### Features -* allows soft breaks in rich text ([ecd277d](https://github.com/payloadcms/payload/commit/ecd277da7dff24dc49f6061e7d50e4b21bc285c9)) +- allows soft breaks in rich text ([ecd277d](https://github.com/payloadcms/payload/commit/ecd277da7dff24dc49f6061e7d50e4b21bc285c9)) ## [0.5.4](https://github.com/payloadcms/payload/compare/v0.5.2...v0.5.4) (2021-04-02) ### Bug Fixes -* ensures arrays and blocks reset row count on initialState change ([9a7c0e3](https://github.com/payloadcms/payload/commit/9a7c0e3dbdf4e6decb03ae085a41fb239fd5b7a8)) -* unique indices ([23c45f1](https://github.com/payloadcms/payload/commit/23c45f137ac97c99ed38969bed64928f2ce2795e)) +- ensures arrays and blocks reset row count on initialState change ([9a7c0e3](https://github.com/payloadcms/payload/commit/9a7c0e3dbdf4e6decb03ae085a41fb239fd5b7a8)) +- unique indices ([23c45f1](https://github.com/payloadcms/payload/commit/23c45f137ac97c99ed38969bed64928f2ce2795e)) ## [0.5.2](https://github.com/payloadcms/payload/compare/v0.5.1...v0.5.2) (2021-03-31) ### Bug Fixes -* modal issues with richtext relationship ([8ea4407](https://github.com/payloadcms/payload/commit/8ea4407f04fd4b63df6afffbe15301f7d5746016)) +- modal issues with richtext relationship ([8ea4407](https://github.com/payloadcms/payload/commit/8ea4407f04fd4b63df6afffbe15301f7d5746016)) ## [0.5.1](https://github.com/payloadcms/payload/compare/v0.5.0...v0.5.1) (2021-03-29) ### Bug Fixes -* base auth / upload fields no longer cause validation issues ([23e1fc3](https://github.com/payloadcms/payload/commit/23e1fc3f73673d4694763908bb819c77bf600702)) +- base auth / upload fields no longer cause validation issues ([23e1fc3](https://github.com/payloadcms/payload/commit/23e1fc3f73673d4694763908bb819c77bf600702)) # [0.5.0](https://github.com/payloadcms/payload/compare/v0.4.7...v0.5.0) (2021-03-29) ### BREAKING CHANGES -* changes global find and update payload api from global to slug as the key to find/update with ([c71ba2b](https://github.com/payloadcms/payload/commit/c71ba2b079d109d4028d74f76603905d9382d364)) +- changes global find and update payload api from global to slug as the key to find/update with ([c71ba2b](https://github.com/payloadcms/payload/commit/c71ba2b079d109d4028d74f76603905d9382d364)) ### Bug Fixes -* allows absolute urls within adminThumbnail ([51b46d4](https://github.com/payloadcms/payload/commit/51b46d44b0c88387d8b23859129f163b581bf1cc)) -* handles empty indices within array field data ([d47e2c5](https://github.com/payloadcms/payload/commit/d47e2c57868667f2ff9ca87aa9ad862687bd985e)) -* moving nested arrays now properly persists row count ([5f9a5c8](https://github.com/payloadcms/payload/commit/5f9a5c859eca8854592b2a7a32bef50db4584709)) -* validation consistency within admin ([50b9937](https://github.com/payloadcms/payload/commit/50b99370d2b849e858fd64e6018ebf0e94103998)) +- allows absolute urls within adminThumbnail ([51b46d4](https://github.com/payloadcms/payload/commit/51b46d44b0c88387d8b23859129f163b581bf1cc)) +- handles empty indices within array field data ([d47e2c5](https://github.com/payloadcms/payload/commit/d47e2c57868667f2ff9ca87aa9ad862687bd985e)) +- moving nested arrays now properly persists row count ([5f9a5c8](https://github.com/payloadcms/payload/commit/5f9a5c859eca8854592b2a7a32bef50db4584709)) +- validation consistency within admin ([50b9937](https://github.com/payloadcms/payload/commit/50b99370d2b849e858fd64e6018ebf0e94103998)) ### Features -* saves cursor position when relationship element is added to richText ([d24b3f7](https://github.com/payloadcms/payload/commit/d24b3f72ce222e4551c12e202238f171f9cc4b97)) +- saves cursor position when relationship element is added to richText ([d24b3f7](https://github.com/payloadcms/payload/commit/d24b3f72ce222e4551c12e202238f171f9cc4b97)) ## [0.4.7](https://github.com/payloadcms/payload/compare/v0.4.6...v0.4.7) (2021-03-15) @@ -2136,127 +2241,127 @@ If none of your collections or globals should be publicly exposed, you don't nee ### Features -* allows admin thumbnail to be set programmatically ([b6a9fe4](https://github.com/payloadcms/payload/commit/b6a9fe4bcfc85815a60a3fe8d3cb38b7ae673424)) -* exports collection field hook types from payload/types ([36aae5c](https://github.com/payloadcms/payload/commit/36aae5c37f8ea8c5dde16a898a28b9301efa6a5b)) -* only runs adminThumbnail func if image type ([5e1ddb5](https://github.com/payloadcms/payload/commit/5e1ddb552ee9fc8972c9537eee62cddc93a24f42)) -* provides field access control with document data ([339f750](https://github.com/payloadcms/payload/commit/339f7503a41802421bb38c8cf5da0f0f1573bdd6)) -* reorders uploads to provide beforeChange hooks with upload data ([3c42e6e](https://github.com/payloadcms/payload/commit/3c42e6e6af849a8acc45e93017b0eafea74ecdba)) +- allows admin thumbnail to be set programmatically ([b6a9fe4](https://github.com/payloadcms/payload/commit/b6a9fe4bcfc85815a60a3fe8d3cb38b7ae673424)) +- exports collection field hook types from payload/types ([36aae5c](https://github.com/payloadcms/payload/commit/36aae5c37f8ea8c5dde16a898a28b9301efa6a5b)) +- only runs adminThumbnail func if image type ([5e1ddb5](https://github.com/payloadcms/payload/commit/5e1ddb552ee9fc8972c9537eee62cddc93a24f42)) +- provides field access control with document data ([339f750](https://github.com/payloadcms/payload/commit/339f7503a41802421bb38c8cf5da0f0f1573bdd6)) +- reorders uploads to provide beforeChange hooks with upload data ([3c42e6e](https://github.com/payloadcms/payload/commit/3c42e6e6af849a8acc45e93017b0eafea74ecdba)) ## [0.4.5](https://github.com/payloadcms/payload/compare/v0.4.4...v0.4.5) (2021-03-04) ### Bug Fixes -* config validation allow admin dashboard ([2d1d1b4](https://github.com/payloadcms/payload/commit/2d1d1b4f32bcc6ee1ce709208ae28369611e5bdd)) +- config validation allow admin dashboard ([2d1d1b4](https://github.com/payloadcms/payload/commit/2d1d1b4f32bcc6ee1ce709208ae28369611e5bdd)) ## [0.4.4](https://github.com/payloadcms/payload/compare/v0.4.3...v0.4.4) (2021-03-04) ### Bug Fixes -* email verification template missing token ([93ed664](https://github.com/payloadcms/payload/commit/93ed6649201511edfaea14c199022f05623c404c)) +- email verification template missing token ([93ed664](https://github.com/payloadcms/payload/commit/93ed6649201511edfaea14c199022f05623c404c)) ## [0.4.1](https://github.com/payloadcms/payload/compare/v0.4.0...v0.4.3) (2021-03-04) ### Documentation -* fixed broken links throughout docs ([3afefbe](https://github.com/payloadcms/payload/commit/3afefbe5922ee7aff496a96c61ff9a5270d6a7cb)) +- fixed broken links throughout docs ([3afefbe](https://github.com/payloadcms/payload/commit/3afefbe5922ee7aff496a96c61ff9a5270d6a7cb)) ## [0.4.0](https://github.com/payloadcms/payload/compare/v0.3.0...v0.4.0) (2021-02-28) ### Breaking Changes -* reverts preview function to only requiring the return of a preview URL ([ca14e66](https://github.com/payloadcms/payload/commit/ca14e66a580fea94ef71416edf6c8caffcf446b0)) +- reverts preview function to only requiring the return of a preview URL ([ca14e66](https://github.com/payloadcms/payload/commit/ca14e66a580fea94ef71416edf6c8caffcf446b0)) ### Features -* implements new billing model, including new Personal license which is free forever ([c97ddeb](https://github.com/payloadcms/payload/commit/c97ddeb2d96f949604d46212166c4784330cc72d)) -* simplifies logic in update operations ([e268e25](https://github.com/payloadcms/payload/commit/e268e25719dd4ebd1a6818dca86d12dc057386ca)) -* removes the requirement of returning a value from field hooks ([4de5605](https://github.com/payloadcms/payload/commit/4de56059319a6d13b6f0ec20ac4d344f265446bf)) +- implements new billing model, including new Personal license which is free forever ([c97ddeb](https://github.com/payloadcms/payload/commit/c97ddeb2d96f949604d46212166c4784330cc72d)) +- simplifies logic in update operations ([e268e25](https://github.com/payloadcms/payload/commit/e268e25719dd4ebd1a6818dca86d12dc057386ca)) +- removes the requirement of returning a value from field hooks ([4de5605](https://github.com/payloadcms/payload/commit/4de56059319a6d13b6f0ec20ac4d344f265446bf)) ### Bug Fixes -* properly exposes scss variables for re-use ([c1b2301](https://github.com/payloadcms/payload/commit/c1b230165033ed3cf382a6e42b590815489525f9)) -* explicitly sets modal z-index and css breakpoints ([c1b2301](https://github.com/payloadcms/payload/commit/c1b230165033ed3cf382a6e42b590815489525f9)) -* removes `overwrite` from update operation to ensure hidden fields don't get lost on document update ([a8e2cc1](https://github.com/payloadcms/payload/commit/a8e2cc11af177641409ff7726ed8c4f1a154dee4)) +- properly exposes scss variables for re-use ([c1b2301](https://github.com/payloadcms/payload/commit/c1b230165033ed3cf382a6e42b590815489525f9)) +- explicitly sets modal z-index and css breakpoints ([c1b2301](https://github.com/payloadcms/payload/commit/c1b230165033ed3cf382a6e42b590815489525f9)) +- removes `overwrite` from update operation to ensure hidden fields don't get lost on document update ([a8e2cc1](https://github.com/payloadcms/payload/commit/a8e2cc11af177641409ff7726ed8c4f1a154dee4)) ## [0.3.0](https://github.com/payloadcms/payload/compare/v0.2.13...v0.3.0) (2021-02-23) ### Bug Fixes -* properly exposes scss variables for re-use ([c1b2301](https://github.com/payloadcms/payload/commit/c1b230165033ed3cf382a6e42b590815489525f9)) -* explicitly sets modal z-index and css breakpoints ([c1b2301](https://github.com/payloadcms/payload/commit/c1b230165033ed3cf382a6e42b590815489525f9)) -* removes `overwrite` from update operation to ensure hidden fields don't get lost on document update ([a8e2cc1](https://github.com/payloadcms/payload/commit/a8e2cc11af177641409ff7726ed8c4f1a154dee4)) +- properly exposes scss variables for re-use ([c1b2301](https://github.com/payloadcms/payload/commit/c1b230165033ed3cf382a6e42b590815489525f9)) +- explicitly sets modal z-index and css breakpoints ([c1b2301](https://github.com/payloadcms/payload/commit/c1b230165033ed3cf382a6e42b590815489525f9)) +- removes `overwrite` from update operation to ensure hidden fields don't get lost on document update ([a8e2cc1](https://github.com/payloadcms/payload/commit/a8e2cc11af177641409ff7726ed8c4f1a154dee4)) ## [0.2.13](https://github.com/payloadcms/payload/compare/v0.2.12...v0.2.13) (2021-02-20) ### Breaking Changes -* Preview function now no longer takes form field state as an arg and instead takes a copy of the document itself +- Preview function now no longer takes form field state as an arg and instead takes a copy of the document itself ### Features -* supports newTab in Button, updates generatePreviewURL api to forward through PreviewButton ([6b6297f](https://github.com/payloadcms/payload/commit/6b6297fb2d22b813f45729429b7efbe9a6ab97da)) -* detaches localization from mongoose entirely ([162ec74](https://github.com/payloadcms/payload/commit/162ec74445c51a79cd50f75ffb56de8e4bcf9ace)) +- supports newTab in Button, updates generatePreviewURL api to forward through PreviewButton ([6b6297f](https://github.com/payloadcms/payload/commit/6b6297fb2d22b813f45729429b7efbe9a6ab97da)) +- detaches localization from mongoose entirely ([162ec74](https://github.com/payloadcms/payload/commit/162ec74445c51a79cd50f75ffb56de8e4bcf9ace)) ### Bug Fixes -* infinite loop caused within block component ([9e42d11](https://github.com/payloadcms/payload/commit/9e42d119e471b0efe0d6f69e99d0e31ba5e9237f)) -* sets sparse true if field localized and unique ([2bc5c59](https://github.com/payloadcms/payload/commit/2bc5c59fec842cd5c5adf201084cdba9b0cab310)) -* returns entire doc to generatePreviewURL callback of PreviewButton ([9b9d0f2](https://github.com/payloadcms/payload/commit/9b9d0f24b54d46c24734f30ed9640d25e6c19097)) -* log mongoose connect error message ([e36c7d2](https://github.com/payloadcms/payload/commit/e36c7d269c4b5b49d6c85f416b26196999aadfc0)) +- infinite loop caused within block component ([9e42d11](https://github.com/payloadcms/payload/commit/9e42d119e471b0efe0d6f69e99d0e31ba5e9237f)) +- sets sparse true if field localized and unique ([2bc5c59](https://github.com/payloadcms/payload/commit/2bc5c59fec842cd5c5adf201084cdba9b0cab310)) +- returns entire doc to generatePreviewURL callback of PreviewButton ([9b9d0f2](https://github.com/payloadcms/payload/commit/9b9d0f24b54d46c24734f30ed9640d25e6c19097)) +- log mongoose connect error message ([e36c7d2](https://github.com/payloadcms/payload/commit/e36c7d269c4b5b49d6c85f416b26196999aadfc0)) ### Documentation -* removes incorrect hasMany from upload field type ([e549298](https://github.com/payloadcms/payload/commit/e549298ad5a9a6116659258bb738f5d87abe4ff7)) +- removes incorrect hasMany from upload field type ([e549298](https://github.com/payloadcms/payload/commit/e549298ad5a9a6116659258bb738f5d87abe4ff7)) ## [0.2.12](https://github.com/payloadcms/payload/compare/v0.2.11...v0.2.12) (2021-02-1-0) ### Bug Fixes -* middleware for cors set up on static files -* windows compatible upload filename paths +- middleware for cors set up on static files +- windows compatible upload filename paths ## [0.2.11](https://github.com/payloadcms/payload/compare/v0.2.11...v0.2.12) (2021-02-05) ### Bug Fixes -* middleware for cors set up on static files ([55e0de1](https://github.com/payloadcms/payload/commit/55e0de1719ec387e2182bf33922602243f7eda94)) -* file size in local operations ([0feb7b7](https://github.com/payloadcms/payload/commit/0feb7b7379de6429cf5cb1cdbdad0142f72cc5dc)) +- middleware for cors set up on static files ([55e0de1](https://github.com/payloadcms/payload/commit/55e0de1719ec387e2182bf33922602243f7eda94)) +- file size in local operations ([0feb7b7](https://github.com/payloadcms/payload/commit/0feb7b7379de6429cf5cb1cdbdad0142f72cc5dc)) ## [0.2.11](https://github.com/payloadcms/payload/compare/v0.2.10...v0.2.11) (2021-02-05) ### Features -* allows upload through Local API ([1a59028](https://github.com/payloadcms/payload/commit/1a590287ea181e4548c8e75d8cdb25ada5cbbdbf)) +- allows upload through Local API ([1a59028](https://github.com/payloadcms/payload/commit/1a590287ea181e4548c8e75d8cdb25ada5cbbdbf)) ### Bug Fixes -* fix localization within blocks ([e50fc1f](https://github.com/payloadcms/payload/commit/e50fc1f3142ae5e387cef3c778988c473b04417e)) -* forces fallbackLocale to null in update ops ([3005360](https://github.com/payloadcms/payload/commit/300536033ffe50a2eaedd2a714e844a5282f2ef0)) +- fix localization within blocks ([e50fc1f](https://github.com/payloadcms/payload/commit/e50fc1f3142ae5e387cef3c778988c473b04417e)) +- forces fallbackLocale to null in update ops ([3005360](https://github.com/payloadcms/payload/commit/300536033ffe50a2eaedd2a714e844a5282f2ef0)) ## [0.2.10](https://github.com/payloadcms/payload/compare/v0.2.9...v0.2.10) (2021-02-04) ### Features -* add support for setting mongoose connection options ([82c4898](https://github.com/payloadcms/payload/commit/82c489841c418b953c7f08d30c8b19751ff050f4)) -* admin ui create first user add confirm password field () +- add support for setting mongoose connection options ([82c4898](https://github.com/payloadcms/payload/commit/82c489841c418b953c7f08d30c8b19751ff050f4)) +- admin ui create first user add confirm password field () ### Bug Fixes -* flag scss variables with default ([8916e8a](https://github.com/payloadcms/payload/commit/8916e8af45e179748bf6f2a75216e8d1c35958f2)) -* relationship component hasMany bug ([d540706](https://github.com/payloadcms/payload/commit/d5407060d079c333081b0298e45dfe866d31b86e)) -* hide force unlock in admin ui when creating auth collection item ([3bd0de0](https://github.com/payloadcms/payload/commit/3bd0de0a0b6832f5940474c8c40fd85f6fcd1b74)) +- flag scss variables with default ([8916e8a](https://github.com/payloadcms/payload/commit/8916e8af45e179748bf6f2a75216e8d1c35958f2)) +- relationship component hasMany bug ([d540706](https://github.com/payloadcms/payload/commit/d5407060d079c333081b0298e45dfe866d31b86e)) +- hide force unlock in admin ui when creating auth collection item ([3bd0de0](https://github.com/payloadcms/payload/commit/3bd0de0a0b6832f5940474c8c40fd85f6fcd1b74)) ## [0.2.9](https://github.com/payloadcms/payload/compare/v0.2.6...v0.2.9) (2021-01-27) ### Bug Fixes -* field validation type can return promise ([06ddab1](https://github.com/payloadcms/payload/commit/06ddab124919b28b74667e36e315682a0c9cf459)) +- field validation type can return promise ([06ddab1](https://github.com/payloadcms/payload/commit/06ddab124919b28b74667e36e315682a0c9cf459)) ## [0.2.8](https://github.com/payloadcms/payload/compare/v0.2.6...v0.2.8) (2021-01-25) ### Chore -* add bugs and keywords to package.json ([37f5b32](https://github.com/payloadcms/payload/commit/37f5b3283363220caa63a5066011b1cb9841812d)) +- add bugs and keywords to package.json ([37f5b32](https://github.com/payloadcms/payload/commit/37f5b3283363220caa63a5066011b1cb9841812d)) ## [0.2.6](https://github.com/payloadcms/payload/compare/v0.2.5...v0.2.6) (2021-01-25) @@ -2264,130 +2369,130 @@ If none of your collections or globals should be publicly exposed, you don't nee ### Bug Fixes -* field gutter padding ([90d2078](https://github.com/payloadcms/payload/commit/90d20786c33b2ef4ea937e75769c023c5776db1b)) -* richtext sticky toolbar within block ([8218343](https://github.com/payloadcms/payload/commit/8218343b6cf629faed0f752fb27b546684580ec4)) +- field gutter padding ([90d2078](https://github.com/payloadcms/payload/commit/90d20786c33b2ef4ea937e75769c023c5776db1b)) +- richtext sticky toolbar within block ([8218343](https://github.com/payloadcms/payload/commit/8218343b6cf629faed0f752fb27b546684580ec4)) ## [0.2.4](https://github.com/payloadcms/payload/compare/v0.2.3...v0.2.4) (2021-01-24) ### Bug Fixes -* block field styles ([36f0bd8](https://github.com/payloadcms/payload/commit/36f0bd81eb340b6d8ac3011a4b10e828e79c20d8)) +- block field styles ([36f0bd8](https://github.com/payloadcms/payload/commit/36f0bd81eb340b6d8ac3011a4b10e828e79c20d8)) ## [0.2.3](https://github.com/payloadcms/payload/compare/v0.2.2...v0.2.3) (2021-01-24) ### Bug Fixes -* ensures modal heights are 100% of viewport ([7edab5d](https://github.com/payloadcms/payload/commit/7edab5d3543db27c444b180548fc076dd483848a)) +- ensures modal heights are 100% of viewport ([7edab5d](https://github.com/payloadcms/payload/commit/7edab5d3543db27c444b180548fc076dd483848a)) ## [0.2.2](https://github.com/payloadcms/payload/compare/v0.2.1...v0.2.2) (2021-01-24) ### Bug Fixes -* revert serverURL config change ([f558bd2](https://github.com/payloadcms/payload/commit/f558bd2733a82f1ed9d14604f8b3dea5bb5e8ef5)) +- revert serverURL config change ([f558bd2](https://github.com/payloadcms/payload/commit/f558bd2733a82f1ed9d14604f8b3dea5bb5e8ef5)) ### Features -* adds better serverURL validation ([75056e2](https://github.com/payloadcms/payload/commit/75056e2e13c4d5f9a2d4341282b6c1f4c42e1609)) +- adds better serverURL validation ([75056e2](https://github.com/payloadcms/payload/commit/75056e2e13c4d5f9a2d4341282b6c1f4c42e1609)) ### Reverts -* Revert "docs: configuration overview describe serverURL and removed from code examples where not needed" ([bd446b6](https://github.com/payloadcms/payload/commit/bd446b60b8c56857fb99cda5a9f8a93216efc8b0)) +- Revert "docs: configuration overview describe serverURL and removed from code examples where not needed" ([bd446b6](https://github.com/payloadcms/payload/commit/bd446b60b8c56857fb99cda5a9f8a93216efc8b0)) ## [0.2.1](https://github.com/payloadcms/payload/compare/v0.2.0...v0.2.1) (2021-01-24) ### Features -* exposes further types ([e056348](https://github.com/payloadcms/payload/commit/e056348850638f3c621072668a4a9232492c209b)) +- exposes further types ([e056348](https://github.com/payloadcms/payload/commit/e056348850638f3c621072668a4a9232492c209b)) # [0.2.0](https://github.com/payloadcms/payload/compare/v0.1.146...v0.2.0) (2021-01-23) ### Bug Fixes -* better error handler when sendMail fails ([ea47736](https://github.com/payloadcms/payload/commit/ea47736274b3b176da534b461907da4ddeffa5e9)) -* button css specificity ([d8b5233](https://github.com/payloadcms/payload/commit/d8b52337b2d34785817b536fe7017853bbc3b5a6)) -* migrates Condition UI value/operator pattern ([d23cc20](https://github.com/payloadcms/payload/commit/d23cc20b3d0fa061a2b8111f65e04dd5d35a5557)) -* target es2019, optional chaining not supported for Node < 14 ([52a0096](https://github.com/payloadcms/payload/commit/52a0096d3b8eca47a8afdef42d47117d028b754d)) +- better error handler when sendMail fails ([ea47736](https://github.com/payloadcms/payload/commit/ea47736274b3b176da534b461907da4ddeffa5e9)) +- button css specificity ([d8b5233](https://github.com/payloadcms/payload/commit/d8b52337b2d34785817b536fe7017853bbc3b5a6)) +- migrates Condition UI value/operator pattern ([d23cc20](https://github.com/payloadcms/payload/commit/d23cc20b3d0fa061a2b8111f65e04dd5d35a5557)) +- target es2019, optional chaining not supported for Node < 14 ([52a0096](https://github.com/payloadcms/payload/commit/52a0096d3b8eca47a8afdef42d47117d028b754d)) ### Features -* adds contributing guidelines ([de5bf6e](https://github.com/payloadcms/payload/commit/de5bf6ea280f771e96de703b3732f851903b1fe5)) -* allows admins to autoverify via admin ([a6a23e3](https://github.com/payloadcms/payload/commit/a6a23e3b154802e5ec874760b3d3e44e90f56e7c)) -* auto-removes verificationToken upon manual user verify ([2139eb4](https://github.com/payloadcms/payload/commit/2139eb410f8c95505ef7b90e35a099b0955d4e12)) -* serverURL no longer required in config ([4770f24](https://github.com/payloadcms/payload/commit/4770f24adb50367ec6f6637cafc3f076023b0416)) +- adds contributing guidelines ([de5bf6e](https://github.com/payloadcms/payload/commit/de5bf6ea280f771e96de703b3732f851903b1fe5)) +- allows admins to autoverify via admin ([a6a23e3](https://github.com/payloadcms/payload/commit/a6a23e3b154802e5ec874760b3d3e44e90f56e7c)) +- auto-removes verificationToken upon manual user verify ([2139eb4](https://github.com/payloadcms/payload/commit/2139eb410f8c95505ef7b90e35a099b0955d4e12)) +- serverURL no longer required in config ([4770f24](https://github.com/payloadcms/payload/commit/4770f24adb50367ec6f6637cafc3f076023b0416)) ## [0.1.146](https://github.com/payloadcms/payload/compare/v0.1.145...v0.1.146) (2021-01-18) ### Bug Fixes -* localized groups ([f38e0fc](https://github.com/payloadcms/payload/commit/f38e0fce981a188b0adb2050cfe8a8e0f047e606)) -* textarea handle undefined ([ba31397](https://github.com/payloadcms/payload/commit/ba31397ac15402eb3837bcbe454e0aaf82ecbf03)) +- localized groups ([f38e0fc](https://github.com/payloadcms/payload/commit/f38e0fce981a188b0adb2050cfe8a8e0f047e606)) +- textarea handle undefined ([ba31397](https://github.com/payloadcms/payload/commit/ba31397ac15402eb3837bcbe454e0aaf82ecbf03)) ## [0.1.145](https://github.com/payloadcms/payload/compare/v0.1.144...v0.1.145) (2021-01-17) ### Bug Fixes -* add minLength and maxLength to textarea field validations ([2c98087](https://github.com/payloadcms/payload/commit/2c98087c6f40c32dcbccf557aa61ebf8fc1fe17f)) -* minLength field validation error messages ([5e60b86](https://github.com/payloadcms/payload/commit/5e60b8617e715378831f10b90dedd017ed8d4a8c)) +- add minLength and maxLength to textarea field validations ([2c98087](https://github.com/payloadcms/payload/commit/2c98087c6f40c32dcbccf557aa61ebf8fc1fe17f)) +- minLength field validation error messages ([5e60b86](https://github.com/payloadcms/payload/commit/5e60b8617e715378831f10b90dedd017ed8d4a8c)) ## [0.1.144](https://github.com/payloadcms/payload/compare/v0.1.143...v0.1.144) (2021-01-16) ### Bug Fixes -* add default user to collections before checking for valid relationships ([b2d05c7](https://github.com/payloadcms/payload/commit/b2d05c781d7751bbede9e37996cbdc0736d07a66)) -* handle user collection 'auth: true' ([c303711](https://github.com/payloadcms/payload/commit/c3037118133a242769dfa4a31914e8e61068edcf)) +- add default user to collections before checking for valid relationships ([b2d05c7](https://github.com/payloadcms/payload/commit/b2d05c781d7751bbede9e37996cbdc0736d07a66)) +- handle user collection 'auth: true' ([c303711](https://github.com/payloadcms/payload/commit/c3037118133a242769dfa4a31914e8e61068edcf)) ## [0.1.143](https://github.com/payloadcms/payload/compare/v0.1.142...v0.1.143) (2021-01-14) ### Bug Fixes -* payload schema validation allow '\*' ([bd92b0a](https://github.com/payloadcms/payload/commit/bd92b0a94ba3562b01000a58a4bc0e0071c1f35b)) +- payload schema validation allow '\*' ([bd92b0a](https://github.com/payloadcms/payload/commit/bd92b0a94ba3562b01000a58a4bc0e0071c1f35b)) ### Features -* allows undefined collections ([6bb58ce](https://github.com/payloadcms/payload/commit/6bb58cecd8bc0b8faa42bc8995ec5da0421375db)) +- allows undefined collections ([6bb58ce](https://github.com/payloadcms/payload/commit/6bb58cecd8bc0b8faa42bc8995ec5da0421375db)) ## [0.1.142](https://github.com/payloadcms/payload/compare/v0.1.141...v0.1.142) (2021-01-09) ### Bug Fixes -* adds disableDuplicate to schema validation of collections config ([e9ed7ee](https://github.com/payloadcms/payload/commit/e9ed7ee4bdc99bdcc0d86272816f3d5c6904ac2b)) +- adds disableDuplicate to schema validation of collections config ([e9ed7ee](https://github.com/payloadcms/payload/commit/e9ed7ee4bdc99bdcc0d86272816f3d5c6904ac2b)) ### Features -* add getAdminURL and getAPIURL functions ([8db73bb](https://github.com/payloadcms/payload/commit/8db73bbec22646bc626d17bb783b10ea2d837520)) -* adds build to CI ([87a1717](https://github.com/payloadcms/payload/commit/87a1717dcae8ec30892cebc46e88cabe8e62bf4c)) -* disable graphQL flag that will bypass gql on payload init ([d78c76e](https://github.com/payloadcms/payload/commit/d78c76e0b4b7e2c2cc834a2a1288ec75468852ec)) +- add getAdminURL and getAPIURL functions ([8db73bb](https://github.com/payloadcms/payload/commit/8db73bbec22646bc626d17bb783b10ea2d837520)) +- adds build to CI ([87a1717](https://github.com/payloadcms/payload/commit/87a1717dcae8ec30892cebc46e88cabe8e62bf4c)) +- disable graphQL flag that will bypass gql on payload init ([d78c76e](https://github.com/payloadcms/payload/commit/d78c76e0b4b7e2c2cc834a2a1288ec75468852ec)) ## [0.1.141](https://github.com/payloadcms/payload/compare/v0.1.140...v0.1.141) (2021-01-07) ### Bug Fixes -* properly exports ES6 components ([f493263](https://github.com/payloadcms/payload/commit/f49326395dba523c2193c46a8ca4142ff761f3fd)) +- properly exports ES6 components ([f493263](https://github.com/payloadcms/payload/commit/f49326395dba523c2193c46a8ca4142ff761f3fd)) ## [0.1.140](https://github.com/payloadcms/payload/compare/v0.1.139...v0.1.140) (2021-01-07) ### Bug Fixes -* admin field error messages ([423df3f](https://github.com/payloadcms/payload/commit/423df3f83af0f899b4a9eafa041ab7c79ccfac78)) +- admin field error messages ([423df3f](https://github.com/payloadcms/payload/commit/423df3f83af0f899b4a9eafa041ab7c79ccfac78)) ## [0.1.139](https://github.com/payloadcms/payload/compare/v0.1.138...v0.1.139) (2021-01-06) ### Bug Fixes -* improves typing in delete op ([644519c](https://github.com/payloadcms/payload/commit/644519c539f6fda29d7b61978416b70306d0ea35)) -* use FileSize and ImageSize types ([4d6871a](https://github.com/payloadcms/payload/commit/4d6871abc854385121c761eea4e4705f45c35832)) +- improves typing in delete op ([644519c](https://github.com/payloadcms/payload/commit/644519c539f6fda29d7b61978416b70306d0ea35)) +- use FileSize and ImageSize types ([4d6871a](https://github.com/payloadcms/payload/commit/4d6871abc854385121c761eea4e4705f45c35832)) ## [0.1.138](https://github.com/payloadcms/payload/compare/v0.1.137...v0.1.138) (2021-01-06) ### Bug Fixes -* removes old css ([6066f28](https://github.com/payloadcms/payload/commit/6066f2896a5c1e21137d41404f2a6161ef6de7a2)) +- removes old css ([6066f28](https://github.com/payloadcms/payload/commit/6066f2896a5c1e21137d41404f2a6161ef6de7a2)) ## [0.1.137](https://github.com/payloadcms/payload/compare/v0.1.136...v0.1.137) (2021-01-05) ### Bug Fixes -* removes prod devtool ([6808637](https://github.com/payloadcms/payload/commit/680863702e67d69dc4ec8d6a48b0e1402164cc97)) +- removes prod devtool ([6808637](https://github.com/payloadcms/payload/commit/680863702e67d69dc4ec8d6a48b0e1402164cc97)) ## [0.1.136](https://github.com/payloadcms/payload/compare/v0.1.135...v0.1.136) (2021-01-05) @@ -2397,7 +2502,7 @@ If none of your collections or globals should be publicly exposed, you don't nee ### Bug Fixes -* updates payload-config path within webpack ([6bf141c](https://github.com/payloadcms/payload/commit/6bf141c6d4707e622f56f5df4f8f3f366d847173)) +- updates payload-config path within webpack ([6bf141c](https://github.com/payloadcms/payload/commit/6bf141c6d4707e622f56f5df4f8f3f366d847173)) ## [0.1.133](https://github.com/payloadcms/payload/compare/v0.1.132...v0.1.133) (2021-01-05) @@ -2405,7 +2510,7 @@ If none of your collections or globals should be publicly exposed, you don't nee ### Bug Fixes -* renames webpack config alias ([c0636df](https://github.com/payloadcms/payload/commit/c0636dfe220b72c129c4e2b144e5714755a20043)) +- renames webpack config alias ([c0636df](https://github.com/payloadcms/payload/commit/c0636dfe220b72c129c4e2b144e5714755a20043)) ## [0.1.131](https://github.com/payloadcms/payload/compare/v0.1.130...v0.1.131) (2021-01-05) @@ -2417,76 +2522,76 @@ If none of your collections or globals should be publicly exposed, you don't nee ### Bug Fixes -* adds default thumbnail size ([f582a25](https://github.com/payloadcms/payload/commit/f582a254cd6b6f56bb8146923f3ab0130a4b7859)) -* config validation of block imageURL ([c572057](https://github.com/payloadcms/payload/commit/c572057706f58f7759e167a724837f84e88d0d10)) -* default config value for email removed as the property was moved out of config ([cf89d4c](https://github.com/payloadcms/payload/commit/cf89d4cb56add645e68cf0be31d943b734dabe39)) -* demo email start on payload init ([57d2c86](https://github.com/payloadcms/payload/commit/57d2c8602fb81a5d67d34a38c25a0429c2b9c44b)) -* Edit view main / sidebar widths ([e067fa1](https://github.com/payloadcms/payload/commit/e067fa12b2465d4767bc35b5f1ec0de8096f7439)) -* graphQL access ([4d871c2](https://github.com/payloadcms/payload/commit/4d871c27f6eefea26ec55302e654fc3b0f4a2933)) -* graphQL logout ([709cc9c](https://github.com/payloadcms/payload/commit/709cc9c294d959913b382e24dd0d7002d6a7c9cd)) -* improves edit view layout constraints ([0f7046b](https://github.com/payloadcms/payload/commit/0f7046b98efd82caf98d0d872bd6e68b076452a1)) -* issues with select hasMany ([a0bf503](https://github.com/payloadcms/payload/commit/a0bf503f888b7fde0c9660e9f8a461da2fab5d67)) -* lowecases joi like everywhere else in payload ([5823a86](https://github.com/payloadcms/payload/commit/5823a864f926bc6441267a21277059a368410b92)) -* payload config remove types for email ([faec969](https://github.com/payloadcms/payload/commit/faec969752622c70e9175cc226d888bf32ec732c)) -* reinstate explicit labels for AllFields collection ([885c73c](https://github.com/payloadcms/payload/commit/885c73c838c597ac03f79558af9946686274969f)) -* removes delete and unlock from baseField type and schema ([4fa942f](https://github.com/payloadcms/payload/commit/4fa942f3a02089c8320e483b896a59627c28f11e)) -* removes old reliance on config.email ([e093e06](https://github.com/payloadcms/payload/commit/e093e06926e55916ddb0bdb6f17e0317dfab951c)) +- adds default thumbnail size ([f582a25](https://github.com/payloadcms/payload/commit/f582a254cd6b6f56bb8146923f3ab0130a4b7859)) +- config validation of block imageURL ([c572057](https://github.com/payloadcms/payload/commit/c572057706f58f7759e167a724837f84e88d0d10)) +- default config value for email removed as the property was moved out of config ([cf89d4c](https://github.com/payloadcms/payload/commit/cf89d4cb56add645e68cf0be31d943b734dabe39)) +- demo email start on payload init ([57d2c86](https://github.com/payloadcms/payload/commit/57d2c8602fb81a5d67d34a38c25a0429c2b9c44b)) +- Edit view main / sidebar widths ([e067fa1](https://github.com/payloadcms/payload/commit/e067fa12b2465d4767bc35b5f1ec0de8096f7439)) +- graphQL access ([4d871c2](https://github.com/payloadcms/payload/commit/4d871c27f6eefea26ec55302e654fc3b0f4a2933)) +- graphQL logout ([709cc9c](https://github.com/payloadcms/payload/commit/709cc9c294d959913b382e24dd0d7002d6a7c9cd)) +- improves edit view layout constraints ([0f7046b](https://github.com/payloadcms/payload/commit/0f7046b98efd82caf98d0d872bd6e68b076452a1)) +- issues with select hasMany ([a0bf503](https://github.com/payloadcms/payload/commit/a0bf503f888b7fde0c9660e9f8a461da2fab5d67)) +- lowecases joi like everywhere else in payload ([5823a86](https://github.com/payloadcms/payload/commit/5823a864f926bc6441267a21277059a368410b92)) +- payload config remove types for email ([faec969](https://github.com/payloadcms/payload/commit/faec969752622c70e9175cc226d888bf32ec732c)) +- reinstate explicit labels for AllFields collection ([885c73c](https://github.com/payloadcms/payload/commit/885c73c838c597ac03f79558af9946686274969f)) +- removes delete and unlock from baseField type and schema ([4fa942f](https://github.com/payloadcms/payload/commit/4fa942f3a02089c8320e483b896a59627c28f11e)) +- removes old reliance on config.email ([e093e06](https://github.com/payloadcms/payload/commit/e093e06926e55916ddb0bdb6f17e0317dfab951c)) ### Features -* allows for refresh operation to accept a deliberately specified token ([7d05069](https://github.com/payloadcms/payload/commit/7d05069f361d30ff36d990e0926a60b1c374149a)) -* types this within crreate op ([d43ff8b](https://github.com/payloadcms/payload/commit/d43ff8b4a764dd203fa7eebda28b09dc21a88e31)) +- allows for refresh operation to accept a deliberately specified token ([7d05069](https://github.com/payloadcms/payload/commit/7d05069f361d30ff36d990e0926a60b1c374149a)) +- types this within crreate op ([d43ff8b](https://github.com/payloadcms/payload/commit/d43ff8b4a764dd203fa7eebda28b09dc21a88e31)) ## [0.1.127](https://github.com/payloadcms/payload/compare/v0.1.126...v0.1.127) (2020-12-31) ### Bug Fixes -* converts class methods to arrow functions ([662839f](https://github.com/payloadcms/payload/commit/662839fb06e95001bb0ef20c4f318cc4c2fccc31)) +- converts class methods to arrow functions ([662839f](https://github.com/payloadcms/payload/commit/662839fb06e95001bb0ef20c4f318cc4c2fccc31)) ## [0.1.126](https://github.com/payloadcms/payload/compare/v0.1.125...v0.1.126) (2020-12-30) ### Bug Fixes -* adds delete and unlock to joi baseField schema ([36d51de](https://github.com/payloadcms/payload/commit/36d51de201b27ef91f43f05992d980ad306ba9f3)) +- adds delete and unlock to joi baseField schema ([36d51de](https://github.com/payloadcms/payload/commit/36d51de201b27ef91f43f05992d980ad306ba9f3)) ## [0.1.125](https://github.com/payloadcms/payload/compare/v0.1.124...v0.1.125) (2020-12-30) ### Bug Fixes -* removes prod source maps ([eeea06d](https://github.com/payloadcms/payload/commit/eeea06d6aaa84efdfb479baf1baad7bdf038d7cd)) +- removes prod source maps ([eeea06d](https://github.com/payloadcms/payload/commit/eeea06d6aaa84efdfb479baf1baad7bdf038d7cd)) ## [0.1.124](https://github.com/payloadcms/payload/compare/v0.1.123...v0.1.124) (2020-12-30) ### Bug Fixes -* disable requiring default props in eslint ([64cf321](https://github.com/payloadcms/payload/commit/64cf32146ad75d8ce3e5f3e8e690391ac7884819)) -* disables inline sourcemaps for admin dist ([8090b2a](https://github.com/payloadcms/payload/commit/8090b2a23bb6298fdd998d9a72c6f596e7473cb0)) -* type issues that arose from reorganizing certain config props ([0c03c2e](https://github.com/payloadcms/payload/commit/0c03c2e3af34657e3dde1c3f2b675840147f78ec)) -* updates typing on DatePicker component and joi schema ([5100fd3](https://github.com/payloadcms/payload/commit/5100fd35dc796c5862ef9fd7261abdcba925b020)) -* webpack config override ([8401400](https://github.com/payloadcms/payload/commit/84014001297519ce7f82f691fb2c4d1c525222f9)) +- disable requiring default props in eslint ([64cf321](https://github.com/payloadcms/payload/commit/64cf32146ad75d8ce3e5f3e8e690391ac7884819)) +- disables inline sourcemaps for admin dist ([8090b2a](https://github.com/payloadcms/payload/commit/8090b2a23bb6298fdd998d9a72c6f596e7473cb0)) +- type issues that arose from reorganizing certain config props ([0c03c2e](https://github.com/payloadcms/payload/commit/0c03c2e3af34657e3dde1c3f2b675840147f78ec)) +- updates typing on DatePicker component and joi schema ([5100fd3](https://github.com/payloadcms/payload/commit/5100fd35dc796c5862ef9fd7261abdcba925b020)) +- webpack config override ([8401400](https://github.com/payloadcms/payload/commit/84014001297519ce7f82f691fb2c4d1c525222f9)) ### Features -* allows for adding custom CSS in addition to SCSS overrides ([544a4db](https://github.com/payloadcms/payload/commit/544a4dbd3ab17e1c8c9ed864fe17b7359883d845)) +- allows for adding custom CSS in addition to SCSS overrides ([544a4db](https://github.com/payloadcms/payload/commit/544a4dbd3ab17e1c8c9ed864fe17b7359883d845)) ## [0.1.123](https://github.com/payloadcms/payload/compare/v0.1.123...v0.1.123) (2020-12-28) ### Bug Fixes -* allows config validation to accept esmodules as components ([b8ad84c](https://github.com/payloadcms/payload/commit/b8ad84c525e597e237caf05e00832ded30668a6b)) -* prod webpack publicPath ([8bda6ea](https://github.com/payloadcms/payload/commit/8bda6eaa762dff0027036d918155f4618740a84c)) +- allows config validation to accept esmodules as components ([b8ad84c](https://github.com/payloadcms/payload/commit/b8ad84c525e597e237caf05e00832ded30668a6b)) +- prod webpack publicPath ([8bda6ea](https://github.com/payloadcms/payload/commit/8bda6eaa762dff0027036d918155f4618740a84c)) ## [0.1.122](https://github.com/payloadcms/payload/compare/v0.1.121...v0.1.122) (2020-12-28) ### Bug Fixes -* improves field schema validation ([db13512](https://github.com/payloadcms/payload/commit/db135129d84bab9df03516ebfa2b667acead3cc9)) -* safely accesses field permissions ([1fff737](https://github.com/payloadcms/payload/commit/1fff7374d43921d203b9b655ac64dbed3867ad2a)) +- improves field schema validation ([db13512](https://github.com/payloadcms/payload/commit/db135129d84bab9df03516ebfa2b667acead3cc9)) +- safely accesses field permissions ([1fff737](https://github.com/payloadcms/payload/commit/1fff7374d43921d203b9b655ac64dbed3867ad2a)) ### Features -* sends config through babel/register ([fec718e](https://github.com/payloadcms/payload/commit/fec718e9e523b1e92ca2dc216d99eef2dcbed83a)) -* splits tsconfig between admin and server ([efe0b40](https://github.com/payloadcms/payload/commit/efe0b40aca4b88084c71f851604d08cae1d62a9a)) +- sends config through babel/register ([fec718e](https://github.com/payloadcms/payload/commit/fec718e9e523b1e92ca2dc216d99eef2dcbed83a)) +- splits tsconfig between admin and server ([efe0b40](https://github.com/payloadcms/payload/commit/efe0b40aca4b88084c71f851604d08cae1d62a9a)) ## [0.1.121](https://github.com/payloadcms/payload/compare/v0.1.120...v0.1.121) (2020-12-27) @@ -2494,23 +2599,23 @@ If none of your collections or globals should be publicly exposed, you don't nee ### Bug Fixes -* production webpack css ([6e83edc](https://github.com/payloadcms/payload/commit/6e83edc988e9284ec52164fc6399f45ab5851652)) -* removes unnecessary meta defaults in admin config ([0117f18](https://github.com/payloadcms/payload/commit/0117f18eb1dd163143e18cd8061a4b96d41c411e)) +- production webpack css ([6e83edc](https://github.com/payloadcms/payload/commit/6e83edc988e9284ec52164fc6399f45ab5851652)) +- removes unnecessary meta defaults in admin config ([0117f18](https://github.com/payloadcms/payload/commit/0117f18eb1dd163143e18cd8061a4b96d41c411e)) ### Features -* improves edit scroll UX in Account and Globals ([604922a](https://github.com/payloadcms/payload/commit/604922a26e7aabde71b470c96ff1b27e0f7b6fc8)) -* improves scrolling UX in Edit views ([a715a42](https://github.com/payloadcms/payload/commit/a715a4206ed2cedc9b02b58339e44354c571fec5)) +- improves edit scroll UX in Account and Globals ([604922a](https://github.com/payloadcms/payload/commit/604922a26e7aabde71b470c96ff1b27e0f7b6fc8)) +- improves scrolling UX in Edit views ([a715a42](https://github.com/payloadcms/payload/commit/a715a4206ed2cedc9b02b58339e44354c571fec5)) ## [0.1.19](https://github.com/payloadcms/payload/compare/v0.1.18...v0.1.19) (2020-12-27) ### Bug Fixes -* copyfiles, autocomplete transition ([5b8c721](https://github.com/payloadcms/payload/commit/5b8c721292140e4cd0ed55d13e97c1d4cd359c98)) +- copyfiles, autocomplete transition ([5b8c721](https://github.com/payloadcms/payload/commit/5b8c721292140e4cd0ed55d13e97c1d4cd359c98)) ### Features -* flattens build into one command ([8571dc3](https://github.com/payloadcms/payload/commit/8571dc396591487d2a2854b9fe93f5338eb10659)) +- flattens build into one command ([8571dc3](https://github.com/payloadcms/payload/commit/8571dc396591487d2a2854b9fe93f5338eb10659)) ## [0.1.18](https://github.com/payloadcms/payload/compare/v0.1.17...v0.1.18) (2020-12-27) @@ -2520,8 +2625,8 @@ If none of your collections or globals should be publicly exposed, you don't nee ### Bug Fixes -* handle access result gracefully ([1cd578e](https://github.com/payloadcms/payload/commit/1cd578ef445499ceb3704ab28d736baaae123cbd)) -* undo property fix, field exists - bad typing ([66946c8](https://github.com/payloadcms/payload/commit/66946c86973c252585e98aa3f0a453cae9dff598)) +- handle access result gracefully ([1cd578e](https://github.com/payloadcms/payload/commit/1cd578ef445499ceb3704ab28d736baaae123cbd)) +- undo property fix, field exists - bad typing ([66946c8](https://github.com/payloadcms/payload/commit/66946c86973c252585e98aa3f0a453cae9dff598)) ## [0.1.15](https://github.com/payloadcms/payload/compare/v0.1.14...v0.1.15) (2020-12-02) @@ -2557,13 +2662,13 @@ If none of your collections or globals should be publicly exposed, you don't nee ### Bug Fixes -* **webpack:** more require.resolves needed ([924eb1d](https://github.com/payloadcms/payload/commit/924eb1d0b566eb7bb3912018e06cf431e5a85524)) -* **webpack:** use require.resolve for modules ([badd59a](https://github.com/payloadcms/payload/commit/badd59ac38e10e9caf700eece5761e7d65341c21)) -* add missing webpack dep path-browserify ([8789dae](https://github.com/payloadcms/payload/commit/8789dae155bbb93fdef5104cc616e0a29b1b6409)) +- **webpack:** more require.resolves needed ([924eb1d](https://github.com/payloadcms/payload/commit/924eb1d0b566eb7bb3912018e06cf431e5a85524)) +- **webpack:** use require.resolve for modules ([badd59a](https://github.com/payloadcms/payload/commit/badd59ac38e10e9caf700eece5761e7d65341c21)) +- add missing webpack dep path-browserify ([8789dae](https://github.com/payloadcms/payload/commit/8789dae155bbb93fdef5104cc616e0a29b1b6409)) ### Features -* add initial types ([983bf71](https://github.com/payloadcms/payload/commit/983bf713b395a68d2374f2446a8a759aeda48579)) +- add initial types ([983bf71](https://github.com/payloadcms/payload/commit/983bf713b395a68d2374f2446a8a759aeda48579)) ## [0.0.141](https://github.com/payloadcms/payload/compare/v0.0.140...v0.0.141) (2020-11-20) @@ -2571,27 +2676,27 @@ If none of your collections or globals should be publicly exposed, you don't nee ### Features -* show email creds when explicitly set to 'mock' ([dbd305a](https://github.com/payloadcms/payload/commit/dbd305acc5b083cea08227cbff8afebe8aa4c374)) -* use react-toastify for notifications ([131dd51](https://github.com/payloadcms/payload/commit/131dd51c39b08c2235582d23deb53188a04e5d80)) -* validate admin user ([83d32e4](https://github.com/payloadcms/payload/commit/83d32e44498460584bbc82512df91848bcf7cf47)) +- show email creds when explicitly set to 'mock' ([dbd305a](https://github.com/payloadcms/payload/commit/dbd305acc5b083cea08227cbff8afebe8aa4c374)) +- use react-toastify for notifications ([131dd51](https://github.com/payloadcms/payload/commit/131dd51c39b08c2235582d23deb53188a04e5d80)) +- validate admin user ([83d32e4](https://github.com/payloadcms/payload/commit/83d32e44498460584bbc82512df91848bcf7cf47)) ## [0.0.139](https://github.com/payloadcms/payload/compare/v0.0.138...v0.0.139) (2020-11-17) ### Bug Fixes -* missed a file ([f52836a](https://github.com/payloadcms/payload/commit/f52836a7e342ecccd7409ba382eade43adb18d90)) +- missed a file ([f52836a](https://github.com/payloadcms/payload/commit/f52836a7e342ecccd7409ba382eade43adb18d90)) ## [0.0.138](https://github.com/payloadcms/payload/compare/v0.0.137...v0.0.138) (2020-11-17) ### Bug Fixes -* allow e-mail to be unconfigured, remove default fromName and fromAddress ([dceeeaa](https://github.com/payloadcms/payload/commit/dceeeaac6a1a9057cdd9f973c7500b3763514f0a)) -* auth json schema didn't allow auth as boolean ([0694a09](https://github.com/payloadcms/payload/commit/0694a09abdde59eb8e785301230ed4e8e244c84a)) -* properly concat verification and locking fields ([2624ad5](https://github.com/payloadcms/payload/commit/2624ad5f7e50332eb9212877d0eefcdcb2fa399b)) +- allow e-mail to be unconfigured, remove default fromName and fromAddress ([dceeeaa](https://github.com/payloadcms/payload/commit/dceeeaac6a1a9057cdd9f973c7500b3763514f0a)) +- auth json schema didn't allow auth as boolean ([0694a09](https://github.com/payloadcms/payload/commit/0694a09abdde59eb8e785301230ed4e8e244c84a)) +- properly concat verification and locking fields ([2624ad5](https://github.com/payloadcms/payload/commit/2624ad5f7e50332eb9212877d0eefcdcb2fa399b)) ### Features -* add blind index for encrypting API Keys ([9a1c1f6](https://github.com/payloadcms/payload/commit/9a1c1f64c0ea0066b679195f50e6cb1ac4bf3552)) -* add license key to access routej ([2565005](https://github.com/payloadcms/payload/commit/2565005cc099797a6e3b8995e0984c28b7837e82)) +- add blind index for encrypting API Keys ([9a1c1f6](https://github.com/payloadcms/payload/commit/9a1c1f64c0ea0066b679195f50e6cb1ac4bf3552)) +- add license key to access routej ([2565005](https://github.com/payloadcms/payload/commit/2565005cc099797a6e3b8995e0984c28b7837e82)) -## [0.0.137](https://github.com/payloadcms/payload/commit/5c1e2846a2694a80cc8707703406c2ac1bb6af8a) (2020-11-12) \ No newline at end of file +## [0.0.137](https://github.com/payloadcms/payload/commit/5c1e2846a2694a80cc8707703406c2ac1bb6af8a) (2020-11-12) From 1befe0ce571032f0ed88ff9dd979538c2847e4bc Mon Sep 17 00:00:00 2001 From: Elliot DeNolf Date: Wed, 18 Jan 2023 11:46:23 -0500 Subject: [PATCH 38/46] chore: revert onInit type change --- src/config/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config/types.ts b/src/config/types.ts index 9b4034478b..afbe5a1033 100644 --- a/src/config/types.ts +++ b/src/config/types.ts @@ -100,7 +100,7 @@ export type InitOptions = { /** * A function that is called immediately following startup that receives the Payload instance as it's only argument. */ - onInit?: (payload: Payload) => Promise; + onInit?: (payload: Payload) => Promise | void; /** * Specify options for the built-in Pino logger that Payload uses for internal logging. From caa5cefe532b841e6be7361b7fb902d484826e29 Mon Sep 17 00:00:00 2001 From: James Date: Wed, 18 Jan 2023 11:56:03 -0500 Subject: [PATCH 39/46] chore: leverages swc/register for bin scripts --- package.json | 2 +- src/bin/index.ts | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index aca4ec9949..f9c855bade 100644 --- a/package.json +++ b/package.json @@ -88,6 +88,7 @@ "@faceless-ui/window-info": "^2.0.2", "@monaco-editor/react": "^4.4.6", "@swc/core": "^1.3.24", + "@swc/register": "^0.1.10", "body-parser": "^1.19.0", "bson-objectid": "^2.0.1", "compression": "^1.7.4", @@ -194,7 +195,6 @@ "@playwright/test": "^1.29.2", "@release-it/conventional-changelog": "^5.1.1", "@swc/jest": "^0.2.24", - "@swc/register": "^0.1.10", "@testing-library/jest-dom": "^5.11.4", "@testing-library/react": "^13.0.1", "@trbl/eslint-config": "^1.2.4", diff --git a/src/bin/index.ts b/src/bin/index.ts index bb6526e306..fadce3e854 100755 --- a/src/bin/index.ts +++ b/src/bin/index.ts @@ -1,8 +1,22 @@ /* eslint-disable @typescript-eslint/no-var-requires */ import minimist from 'minimist'; +import swcRegister from '@swc/register'; import { generateTypes } from './generateTypes'; import { generateGraphQLSchema } from './generateGraphQLSchema'; +swcRegister({ + sourceMaps: 'inline', + jsc: { + parser: { + syntax: 'typescript', + tsx: true, + }, + }, + module: { + type: 'commonjs', + }, +}); + const { build } = require('./build'); const args = minimist(process.argv.slice(2)); From 98171abed516d05c4a6a9fcc5de59d8fc1f35b18 Mon Sep 17 00:00:00 2001 From: James Date: Wed, 18 Jan 2023 11:58:35 -0500 Subject: [PATCH 40/46] chore: ensures tsc succeeds --- src/bin/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/bin/index.ts b/src/bin/index.ts index fadce3e854..1dc9018680 100755 --- a/src/bin/index.ts +++ b/src/bin/index.ts @@ -4,6 +4,8 @@ import swcRegister from '@swc/register'; import { generateTypes } from './generateTypes'; import { generateGraphQLSchema } from './generateGraphQLSchema'; +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore - bad @swc/register types swcRegister({ sourceMaps: 'inline', jsc: { From a1f40c73c9337d47ab77ba1c6414e62105719738 Mon Sep 17 00:00:00 2001 From: Elliot DeNolf Date: Wed, 18 Jan 2023 12:01:49 -0500 Subject: [PATCH 41/46] chore: proper generated type default in changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a82b92cd70..ad42ae5de2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -111,7 +111,7 @@ But there's one more thing to do before Payload can automatically type your Loca "paths": { // Tell TS where to find your generated types // This is the default location below - "payload/generated-types": ["./src/generated-types.ts"] + "payload/generated-types": ["./src/payload-types.ts"] } } } From 3c70a15bb6ab35387ce6fa9c19e5fb117166aa21 Mon Sep 17 00:00:00 2001 From: Jarrod Flesch <30633324+JarrodMFlesch@users.noreply.github.com> Date: Wed, 18 Jan 2023 12:05:10 -0500 Subject: [PATCH 42/46] Decorate changelog --- CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad42ae5de2..eac95202f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ ## [1.5.10-canary.0](https://github.com/payloadcms/payload/compare/v1.5.9...v1.5.10-canary.0) (2023-01-18) -### Bug Fixes +### 🐛 Bug Fixes - bump pino and pino-pretty to accommodate yarn 2 ([773fb57](https://github.com/payloadcms/payload/commit/773fb57c71f89d5157847ee4907c1472874f9a61)) - updated nl i18n typos ([cc7257e](https://github.com/payloadcms/payload/commit/cc7257efd529580b1eb7b6c01df9f7420838c345)) @@ -8,7 +8,7 @@ - fixes [#1885](https://github.com/payloadcms/payload/issues/1885) - fixes [#1869](https://github.com/payloadcms/payload/issues/1869) -### Features +### ✨ Features - Roadmap - [improved TypeScript experience](https://github.com/payloadcms/payload/discussions/1563) - begins work to SIGNIFICANTLY improve typing of Payload's Local API, removing the need for generics and inferring types automatically from your generated types - Refactors the Local API to include only the bare minimum code necessary for running local API operations, which will allow us to deploy serverlessly @@ -16,7 +16,7 @@ - requires ts-node to start a project for any config that uses ts or jsx ([f1c342e](https://github.com/payloadcms/payload/commit/f1c342e05eb84254c9d84a425b4f0da1249fcef3)) - simplifies versions logic ([8cfa550](https://github.com/payloadcms/payload/commit/8cfa5509540225100237e6f569eb9eb1a7d5448e)) -### BREAKING CHANGES +### 🚨 BREAKING CHANGES #### Payload now no longer transpiles your config for you From f66dd613e38a1f6b1c8b4ba8b0b1b588c8a0adc8 Mon Sep 17 00:00:00 2001 From: Jarrod Flesch <30633324+JarrodMFlesch@users.noreply.github.com> Date: Wed, 18 Jan 2023 12:13:46 -0500 Subject: [PATCH 43/46] chore: directs attention to breaking changes headings --- CHANGELOG.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eac95202f8..cd39f1237e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,7 +26,7 @@ If you are not using TypeScript, this will be a breaking change. There are many For instructions regarding how to migrate to TS, [review the PR here](https://github.com/payloadcms/payload/pull/1847). -#### Payload `init` is now always async, and `payload.initAsync` has been removed +#### ✋ 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. @@ -78,7 +78,7 @@ 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 +#### ✋ 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: @@ -119,7 +119,7 @@ But there's one more thing to do before Payload can automatically type your Loca 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. -#### Versions may need to be migrated +#### ✋ 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. @@ -210,7 +210,7 @@ Make sure your environment variables match the script's values above and then ru This migration script will ensure that there is at least one corresponding version for each of your draft-enabled documents. It won't modify or delete any of your existing documents at all. -### Example of a properly migrated project +### 👀 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. From 9e7a15c1bef46cb1547be0d2f7b311b894e14bdb Mon Sep 17 00:00:00 2001 From: Elliot DeNolf Date: Wed, 18 Jan 2023 12:26:24 -0500 Subject: [PATCH 44/46] chore: ts-ignore swcRegister in tests --- test/helpers/configHelpers.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/helpers/configHelpers.ts b/test/helpers/configHelpers.ts index 20e386d3eb..f8a5675833 100644 --- a/test/helpers/configHelpers.ts +++ b/test/helpers/configHelpers.ts @@ -41,6 +41,8 @@ export async function initPayloadTest(options: Options): Promise<{ serverURL: st initOptions.express = express(); } + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore - bad @swc/register types swcRegister({ sourceMaps: 'inline', jsc: { From 21c15ae5598fb18d5eed65ff1d2b290dd9051026 Mon Sep 17 00:00:00 2001 From: James Date: Wed, 18 Jan 2023 15:56:03 -0500 Subject: [PATCH 45/46] chore: canary release --- CHANGELOG.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd39f1237e..e1a879a228 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## [1.5.10-canary.0](https://github.com/payloadcms/payload/compare/v1.5.9...v1.5.10-canary.0) (2023-01-18) +## [1.5.11-canary.0](https://github.com/payloadcms/payload/compare/v1.5.9...v1.5.11-canary.0) (2023-01-18) ### 🐛 Bug Fixes diff --git a/package.json b/package.json index f9c855bade..edb8631bfe 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "payload", - "version": "1.5.10-canary.0", + "version": "1.5.11-canary.0", "description": "Node, React and MongoDB Headless CMS and Application Framework", "license": "MIT", "engines": { From 4855ba07c5439c92481f446725d36098e408789c Mon Sep 17 00:00:00 2001 From: James Date: Wed, 18 Jan 2023 16:07:50 -0500 Subject: [PATCH 46/46] chore: canary release --- CHANGELOG.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e1a879a228..06f92a99bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## [1.5.11-canary.0](https://github.com/payloadcms/payload/compare/v1.5.9...v1.5.11-canary.0) (2023-01-18) +## [1.5.12-canary.0](https://github.com/payloadcms/payload/compare/v1.5.9...v1.5.12-canary.0) (2023-01-18) ### 🐛 Bug Fixes diff --git a/package.json b/package.json index edb8631bfe..78c553122e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "payload", - "version": "1.5.11-canary.0", + "version": "1.5.12-canary.0", "description": "Node, React and MongoDB Headless CMS and Application Framework", "license": "MIT", "engines": {