diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 53f970d885..41df58c31e 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -11,6 +11,28 @@ module.exports = { 'perfectionist/sort-objects': 'off', }, }, + { + files: ['package.json', 'tsconfig.json'], + rules: { + 'perfectionist/sort-array-includes': 'off', + 'perfectionist/sort-astro-attributes': 'off', + 'perfectionist/sort-classes': 'off', + 'perfectionist/sort-enums': 'off', + 'perfectionist/sort-exports': 'off', + 'perfectionist/sort-imports': 'off', + 'perfectionist/sort-interfaces': 'off', + 'perfectionist/sort-jsx-props': 'off', + 'perfectionist/sort-keys': 'off', + 'perfectionist/sort-maps': 'off', + 'perfectionist/sort-named-exports': 'off', + 'perfectionist/sort-named-imports': 'off', + 'perfectionist/sort-object-types': 'off', + 'perfectionist/sort-objects': 'off', + 'perfectionist/sort-svelte-attributes': 'off', + 'perfectionist/sort-union-types': 'off', + 'perfectionist/sort-vue-attributes': 'off', + }, + }, ], root: true, } diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index ffdf0d7a0a..880a16605d 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -1,3 +1,9 @@ # lint and format ae7d6f97d205491390f15850e5104c7abded1550 1fbda85cd04a774cb978778b0f813001664c53dd + +# prettier all templates +75a428ddc4672903455998eaba7ae9f9d710bf85 + +# re-run prettier and eslint everywhere again +cdaa0acd61d3001407609915bd573b78565d5571 diff --git a/docs/configuration/overview.mdx b/docs/configuration/overview.mdx index 8f2b87975e..d21497b248 100644 --- a/docs/configuration/overview.mdx +++ b/docs/configuration/overview.mdx @@ -26,6 +26,7 @@ Payload is a _config-based_, code-first CMS and application framework. The Paylo | `cors` | Either a whitelist array of URLS to allow CORS requests from, or a wildcard string (`'*'`) to accept incoming requests from any domain. | | `globals` | An array of all Globals that Payload will manage. For more on Globals and their configs, [click here](/docs/configuration/globals). | | `admin` | Base Payload admin configuration. Specify custom components, control metadata, set the Admin user collection, and [more](/docs/admin/overview#admin-options). | +| `editor` | Default richText editor which will be used by richText fields. | | `localization` | Opt-in and control how Payload handles the translation of your content into multiple locales. [More](/docs/configuration/localization) | | `graphQL` | Manage GraphQL-specific functionality here. Define your own queries and mutations, manage query complexity limits, and [more](/docs/graphql/overview#graphql-options). | | `cookiePrefix` | A string that will be prefixed to all cookies that Payload sets. | diff --git a/docs/fields/rich-text.mdx b/docs/fields/rich-text.mdx index 7501665e92..bbc09cc693 100644 --- a/docs/fields/rich-text.mdx +++ b/docs/fields/rich-text.mdx @@ -21,13 +21,7 @@ keywords: rich text, fields, config, configuration, documentation, Content Manag The Admin component is built on the powerful [`slatejs`](https://docs.slatejs.org/) editor and is meant to be as extensible and customizable as possible. - - Consistent with Payload's goal of making you learn as little of Payload as possible, customizing - and using the Rich Text Editor does not involve learning how to develop for a Payload{' '} - rich text editor. - {' '} - Instead, you can invest your time and effort into learning Slate, an open-source tool that will - allow you to apply your learnings elsewhere as well. + Consistent with Payload's goal of making you learn as little of Payload as possible, customizing and using the Rich Text Editor does not involve learning how to develop for a Payload rich text editor. Instead, you can invest your time and effort into learning Slate, an open-source tool that will allow you to apply your learnings elsewhere as well. ### Config @@ -45,6 +39,7 @@ The Admin component is built on the powerful [`slatejs`](https://docs.slatejs.or | **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. | | **`required`** | Require this field to have a value. | | **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). | +| **`editor`** | RichText editor which will be used by this field. | | **`custom`** | Extension point for adding custom data (e.g. for plugins) | _\* An asterisk denotes that a property is required._ diff --git a/docs/production/deployment.mdx b/docs/production/deployment.mdx index 15a77ab20d..27e2e2c92c 100644 --- a/docs/production/deployment.mdx +++ b/docs/production/deployment.mdx @@ -36,10 +36,7 @@ When you initialize Payload, you provide it with a `secret` property. This prope Because _**you**_ are in complete control of who can do what with your data, you should double and triple-check that you wield that power responsibly before deploying to Production. - - By default, all Access Control functions require that a user is successfully logged in to - Payload to create, read, update, or delete data. - {' '} + By default, all Access Control functions require that a user is successfully logged in to Payload to create, read, update, or delete data.{' '} But, if you allow public user registration, for example, you will want to make sure that your access control functions are more strict - permitting only appropriate users to perform appropriate actions. diff --git a/docs/queries/overview.mdx b/docs/queries/overview.mdx index d54148159b..59ab9b53e3 100644 --- a/docs/queries/overview.mdx +++ b/docs/queries/overview.mdx @@ -9,9 +9,7 @@ keywords: query, documents, overview, documentation, Content Management System, Payload provides an extremely granular querying language through all APIs. Each API takes the same syntax and fully supports all options. - - Here, "querying" relates to filtering or searching through documents within a Collection. - {' '} + Here, "querying" relates to filtering or searching through documents within a Collection.{' '} You can build queries to pass to Find operations as well as to [restrict which documents certain users can access](/docs/access-control/overview) via access control functions. diff --git a/package.json b/package.json index 6bd35587c7..7e8f39207c 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,6 @@ "clean:unix": "find . \\( -type d \\( -name node_modules -o -name dist -o -name .cache \\) -o -type f -name tsconfig.tsbuildinfo \\) -exec rm -rf {} +", "dev": "pnpm --filter payload run dev", "dev:generate-graphql-schema": "ts-node -T ./test/generateGraphQLSchema.ts", - "test:int:postgres": "cross-env PAYLOAD_DATABASE=postgres yarn test:int", "dev:generate-types": "pnpm --filter payload run dev:generate-types", "dev:postgres": "pnpm --filter payload run dev:postgres", "fix": "eslint \"src/**/*.ts\" --fix", @@ -51,7 +50,6 @@ "express": "4.18.2", "form-data": "3.0.1", "get-port": "5.1.1", - "graphql-request": "3.7.0", "isomorphic-fetch": "3.0.0", "jest": "29.6.4", "jest-environment-jsdom": "29.6.4", diff --git a/packages/bundler-vite/.eslintignore b/packages/bundler-vite/.eslintignore new file mode 100644 index 0000000000..247f3f12de --- /dev/null +++ b/packages/bundler-vite/.eslintignore @@ -0,0 +1,10 @@ +.tmp +**/.git +**/.hg +**/.pnp.* +**/.svn +**/.yarn/** +**/build +**/dist/** +**/node_modules +**/temp diff --git a/packages/bundler-vite/.eslintrc.cjs b/packages/bundler-vite/.eslintrc.cjs new file mode 100644 index 0000000000..f0c500c896 --- /dev/null +++ b/packages/bundler-vite/.eslintrc.cjs @@ -0,0 +1,43 @@ +/** @type {import('prettier').Config} */ +module.exports = { + extends: ['@payloadcms'], + overrides: [ + { + extends: ['plugin:@typescript-eslint/disable-type-checked'], + files: ['*.js', '*.cjs', '*.json', '*.md', '*.yml', '*.yaml'], + }, + { + files: ['**/*.ts'], + rules: { + '@typescript-eslint/no-redundant-type-constituents': 'off', + }, + }, + { + files: ['package.json', 'tsconfig.json'], + rules: { + 'perfectionist/sort-array-includes': 'off', + 'perfectionist/sort-astro-attributes': 'off', + 'perfectionist/sort-classes': 'off', + 'perfectionist/sort-enums': 'off', + 'perfectionist/sort-exports': 'off', + 'perfectionist/sort-imports': 'off', + 'perfectionist/sort-interfaces': 'off', + 'perfectionist/sort-jsx-props': 'off', + 'perfectionist/sort-keys': 'off', + 'perfectionist/sort-maps': 'off', + 'perfectionist/sort-named-exports': 'off', + 'perfectionist/sort-named-imports': 'off', + 'perfectionist/sort-object-types': 'off', + 'perfectionist/sort-objects': 'off', + 'perfectionist/sort-svelte-attributes': 'off', + 'perfectionist/sort-union-types': 'off', + 'perfectionist/sort-vue-attributes': 'off', + }, + }, + ], + parserOptions: { + project: ['./tsconfig.json'], + tsconfigRootDir: __dirname, + }, + root: true, +} diff --git a/packages/bundler-vite/.prettierignore b/packages/bundler-vite/.prettierignore new file mode 100644 index 0000000000..247f3f12de --- /dev/null +++ b/packages/bundler-vite/.prettierignore @@ -0,0 +1,10 @@ +.tmp +**/.git +**/.hg +**/.pnp.* +**/.svn +**/.yarn/** +**/build +**/dist/** +**/node_modules +**/temp diff --git a/packages/bundler-vite/package.json b/packages/bundler-vite/package.json index a074ec9d04..e37b9762ea 100644 --- a/packages/bundler-vite/package.json +++ b/packages/bundler-vite/package.json @@ -4,6 +4,7 @@ "description": "The officially supported Vite bundler adapter for Payload", "repository": "https://github.com/payloadcms/payload", "license": "MIT", + "homepage": "https://payloadcms.com", "author": { "email": "info@payloadcms.com", "name": "Payload", @@ -12,9 +13,9 @@ "main": "./src/index.ts", "types": "./src/index.ts", "scripts": { + "build": "pnpm build:swc && pnpm build:types", "build:swc": "swc ./src -d ./dist --config-file .swcrc", - "build:types": "tsc --emitDeclarationOnly --outDir dist", - "build": "pnpm build:swc && pnpm build:types" + "build:types": "tsc --emitDeclarationOnly --outDir dist" }, "dependencies": { "@rollup/plugin-commonjs": "^25.0.4", diff --git a/packages/bundler-vite/src/configs/vite.ts b/packages/bundler-vite/src/configs/vite.ts index 84e380f8c6..c03820624a 100644 --- a/packages/bundler-vite/src/configs/vite.ts +++ b/packages/bundler-vite/src/configs/vite.ts @@ -1,15 +1,16 @@ /* eslint-disable no-param-reassign */ -import path from 'path' +import type { SanitizedConfig } from 'payload/config' // @ts-expect-error import type { InlineConfig } from 'vite' -import viteCommonJS from 'vite-plugin-commonjs' -import virtual from 'vite-plugin-virtual' -import scss from 'rollup-plugin-scss' -import image from '@rollup/plugin-image' + import rollupCommonJS from '@rollup/plugin-commonjs' +import image from '@rollup/plugin-image' import react from '@vitejs/plugin-react' import getPort from 'get-port' -import type { SanitizedConfig } from 'payload/config' +import path from 'path' +import scss from 'rollup-plugin-scss' +import viteCommonJS from 'vite-plugin-commonjs' +import virtual from 'vite-plugin-virtual' const bundlerPath = path.resolve(__dirname, '../') const mockModulePath = path.resolve(__dirname, '../mocks/emptyModule.js') @@ -18,7 +19,7 @@ const mockDotENVPath = path.resolve(__dirname, '../mocks/dotENV.js') export const getViteConfig = async (payloadConfig: SanitizedConfig): Promise => { const { createLogger } = await import('vite') - const logger = createLogger('warn', { prefix: '[VITE-WARNING]', allowClearScreen: false }) + const logger = createLogger('warn', { allowClearScreen: false, prefix: '[VITE-WARNING]' }) const originalWarning = logger.warn logger.warn = (msg, options) => { // TODO: fix this? removed these warnings to make debugging easier @@ -60,9 +61,46 @@ export const getViteConfig = async (payloadConfig: SanitizedConfig): Promise ""', + 'process.env': '{}', + }, optimizeDeps: { exclude: [ // Dependencies that need aliases should be excluded @@ -79,22 +117,6 @@ export const getViteConfig = async (payloadConfig: SanitizedConfig): Promise ""', - 'process.argv': '[]', - }, plugins: [ { name: 'absolute-aliases', @@ -119,8 +141,8 @@ export const getViteConfig = async (payloadConfig: SanitizedConfig): Promise ({ - dev: async (payload) => devAdmin({ payload, viteConfig }), +export const viteBundler: (viteConfig?: InlineConfig) => PayloadBundler = (viteConfig) => ({ build: async (payloadConfig) => buildAdmin({ payloadConfig, viteConfig }), + dev: async (payload) => devAdmin({ payload, viteConfig }), serve: async (payload) => serveAdmin({ payload }), }) diff --git a/packages/bundler-vite/src/mock.js b/packages/bundler-vite/src/mock.js index 2d1ec23827..ead516c976 100644 --- a/packages/bundler-vite/src/mock.js +++ b/packages/bundler-vite/src/mock.js @@ -1 +1 @@ -export default () => {}; +export default () => {} diff --git a/packages/bundler-vite/src/mocks/dotENV.js b/packages/bundler-vite/src/mocks/dotENV.js index 3b2fe989de..9ddda98f1e 100644 --- a/packages/bundler-vite/src/mocks/dotENV.js +++ b/packages/bundler-vite/src/mocks/dotENV.js @@ -1,3 +1,3 @@ export default { config: () => null, -}; +} diff --git a/packages/bundler-vite/src/mocks/emptyModule.js b/packages/bundler-vite/src/mocks/emptyModule.js index eb6d09f48c..ead516c976 100644 --- a/packages/bundler-vite/src/mocks/emptyModule.js +++ b/packages/bundler-vite/src/mocks/emptyModule.js @@ -1 +1 @@ -export default () => { }; +export default () => {} diff --git a/packages/bundler-vite/src/mocks/fileMock.js b/packages/bundler-vite/src/mocks/fileMock.js index bff7823205..e25c9a3dc4 100644 --- a/packages/bundler-vite/src/mocks/fileMock.js +++ b/packages/bundler-vite/src/mocks/fileMock.js @@ -1 +1 @@ -export default 'file-stub'; +export default 'file-stub' diff --git a/packages/bundler-vite/src/scripts/build.ts b/packages/bundler-vite/src/scripts/build.ts index c0675bd407..8d0946b2de 100644 --- a/packages/bundler-vite/src/scripts/build.ts +++ b/packages/bundler-vite/src/scripts/build.ts @@ -1,6 +1,6 @@ -// @ts-expect-error +import type { SanitizedConfig } from 'payload/config' import type { InlineConfig } from 'vite' -import { SanitizedConfig } from 'payload/config' + import { getViteConfig } from '../configs/vite' type BuildAdminType = (options: { diff --git a/packages/bundler-vite/src/scripts/dev.ts b/packages/bundler-vite/src/scripts/dev.ts index f3f277281b..d08b1779f3 100644 --- a/packages/bundler-vite/src/scripts/dev.ts +++ b/packages/bundler-vite/src/scripts/dev.ts @@ -1,8 +1,10 @@ -// @ts-expect-error -import type { InlineConfig } from 'vite' -import express from 'express' import type { PayloadHandler } from 'payload/config' -import { Payload } from '../../../payload' +import type { InlineConfig } from 'vite' + +import express from 'express' + +import type { Payload } from '../../../payload' + import { getViteConfig } from '../configs/vite' const router = express.Router() diff --git a/packages/bundler-vite/src/scripts/serve.ts b/packages/bundler-vite/src/scripts/serve.ts index 6463ca7d4f..c0d6ca5878 100644 --- a/packages/bundler-vite/src/scripts/serve.ts +++ b/packages/bundler-vite/src/scripts/serve.ts @@ -1,8 +1,9 @@ -import express from 'express' +import type { Payload } from 'payload' +import type { PayloadHandler } from 'payload/config' + import compression from 'compression' import history from 'connect-history-api-fallback' -import type { PayloadHandler } from 'payload/config' -import type { Payload } from 'payload' +import express from 'express' const router = express.Router() diff --git a/packages/bundler-vite/src/types.ts b/packages/bundler-vite/src/types.ts index 4f0f154ff0..9b5f3b1b97 100644 --- a/packages/bundler-vite/src/types.ts +++ b/packages/bundler-vite/src/types.ts @@ -1,8 +1,8 @@ -import type { PayloadHandler, SanitizedConfig } from 'payload/config' import type { Payload } from 'payload' +import type { PayloadHandler, SanitizedConfig } from 'payload/config' export interface PayloadBundler { - dev: (payload: Payload) => Promise // this would be a typical Express middleware handler build: (payloadConfig: SanitizedConfig) => Promise // used in `payload build` + dev: (payload: Payload) => Promise // this would be a typical Express middleware handler serve: (payload: Payload) => Promise // serve built files in production } diff --git a/packages/bundler-webpack/.eslintignore b/packages/bundler-webpack/.eslintignore new file mode 100644 index 0000000000..247f3f12de --- /dev/null +++ b/packages/bundler-webpack/.eslintignore @@ -0,0 +1,10 @@ +.tmp +**/.git +**/.hg +**/.pnp.* +**/.svn +**/.yarn/** +**/build +**/dist/** +**/node_modules +**/temp diff --git a/packages/bundler-webpack/.eslintrc.cjs b/packages/bundler-webpack/.eslintrc.cjs new file mode 100644 index 0000000000..f0c500c896 --- /dev/null +++ b/packages/bundler-webpack/.eslintrc.cjs @@ -0,0 +1,43 @@ +/** @type {import('prettier').Config} */ +module.exports = { + extends: ['@payloadcms'], + overrides: [ + { + extends: ['plugin:@typescript-eslint/disable-type-checked'], + files: ['*.js', '*.cjs', '*.json', '*.md', '*.yml', '*.yaml'], + }, + { + files: ['**/*.ts'], + rules: { + '@typescript-eslint/no-redundant-type-constituents': 'off', + }, + }, + { + files: ['package.json', 'tsconfig.json'], + rules: { + 'perfectionist/sort-array-includes': 'off', + 'perfectionist/sort-astro-attributes': 'off', + 'perfectionist/sort-classes': 'off', + 'perfectionist/sort-enums': 'off', + 'perfectionist/sort-exports': 'off', + 'perfectionist/sort-imports': 'off', + 'perfectionist/sort-interfaces': 'off', + 'perfectionist/sort-jsx-props': 'off', + 'perfectionist/sort-keys': 'off', + 'perfectionist/sort-maps': 'off', + 'perfectionist/sort-named-exports': 'off', + 'perfectionist/sort-named-imports': 'off', + 'perfectionist/sort-object-types': 'off', + 'perfectionist/sort-objects': 'off', + 'perfectionist/sort-svelte-attributes': 'off', + 'perfectionist/sort-union-types': 'off', + 'perfectionist/sort-vue-attributes': 'off', + }, + }, + ], + parserOptions: { + project: ['./tsconfig.json'], + tsconfigRootDir: __dirname, + }, + root: true, +} diff --git a/packages/bundler-webpack/.prettierignore b/packages/bundler-webpack/.prettierignore new file mode 100644 index 0000000000..247f3f12de --- /dev/null +++ b/packages/bundler-webpack/.prettierignore @@ -0,0 +1,10 @@ +.tmp +**/.git +**/.hg +**/.pnp.* +**/.svn +**/.yarn/** +**/build +**/dist/** +**/node_modules +**/temp diff --git a/packages/bundler-webpack/package.json b/packages/bundler-webpack/package.json index c6dde39885..85240d5621 100644 --- a/packages/bundler-webpack/package.json +++ b/packages/bundler-webpack/package.json @@ -4,6 +4,7 @@ "description": "The officially supported Webpack bundler adapter for Payload", "repository": "https://github.com/payloadcms/payload", "license": "MIT", + "homepage": "https://payloadcms.com", "author": { "email": "info@payloadcms.com", "name": "Payload", diff --git a/packages/bundler-webpack/src/configs/base.ts b/packages/bundler-webpack/src/configs/base.ts index 99c87b47b5..babcdc262e 100644 --- a/packages/bundler-webpack/src/configs/base.ts +++ b/packages/bundler-webpack/src/configs/base.ts @@ -1,7 +1,9 @@ -import path from 'path' -import HtmlWebpackPlugin from 'html-webpack-plugin' -import webpack, { Configuration } from 'webpack' import type { SanitizedConfig } from 'payload/config' +import type { Configuration } from 'webpack' + +import HtmlWebpackPlugin from 'html-webpack-plugin' +import path from 'path' +import webpack from 'webpack' const mockModulePath = path.resolve(__dirname, '../mocks/emptyModule.js') const mockDotENVPath = path.resolve(__dirname, '../mocks/dotENV.js') @@ -17,8 +19,8 @@ export const getBaseConfig = (payloadConfig: SanitizedConfig): Configuration => module: { rules: [ { - test: /\.(t|j)sx?$/, exclude: /\/node_modules\/(?!.+\.tsx?$).*$/, + test: /\.(t|j)sx?$/, use: [ { loader: require.resolve('swc-loader'), @@ -43,23 +45,6 @@ export const getBaseConfig = (payloadConfig: SanitizedConfig): Configuration => }, ], }, - resolve: { - fallback: { - crypto: false, - https: false, - http: false, - }, - modules: ['node_modules', nodeModulesPath], - alias: { - path: require.resolve('path-browserify'), - 'payload-config': payloadConfig.paths.rawConfig, - payload$: mockModulePath, - 'payload-user-css': payloadConfig.admin.css, - dotenv: mockDotENVPath, - [bundlerPath]: mockModulePath, - }, - extensions: ['.ts', '.tsx', '.js', '.json'], - }, plugins: [ new webpack.ProvidePlugin({ process: require.resolve('process/browser') }), new webpack.DefinePlugin( @@ -75,9 +60,26 @@ export const getBaseConfig = (payloadConfig: SanitizedConfig): Configuration => }, {}), ), new HtmlWebpackPlugin({ - template: payloadConfig.admin.indexHTML, filename: path.normalize('./index.html'), + template: payloadConfig.admin.indexHTML, }), new webpack.HotModuleReplacementPlugin(), ], + resolve: { + alias: { + [bundlerPath]: mockModulePath, + dotenv: mockDotENVPath, + path: require.resolve('path-browserify'), + payload$: mockModulePath, + 'payload-config': payloadConfig.paths.rawConfig, + 'payload-user-css': payloadConfig.admin.css, + }, + extensions: ['.ts', '.tsx', '.js', '.json'], + fallback: { + crypto: false, + http: false, + https: false, + }, + modules: ['node_modules', nodeModulesPath], + }, }) diff --git a/packages/bundler-webpack/src/configs/dev.ts b/packages/bundler-webpack/src/configs/dev.ts index 74aa426914..9308ca4d2a 100644 --- a/packages/bundler-webpack/src/configs/dev.ts +++ b/packages/bundler-webpack/src/configs/dev.ts @@ -1,20 +1,40 @@ -import webpack, { Configuration } from 'webpack' +import type { SanitizedConfig } from 'payload/config' +import type { Configuration } from 'webpack' + import md5 from 'md5' +import webpack from 'webpack' + import { getBaseConfig } from './base' -import { SanitizedConfig } from 'payload/config' export const getDevConfig = (payloadConfig: SanitizedConfig): Configuration => { const baseConfig = getBaseConfig(payloadConfig) as any let webpackConfig: Configuration = { ...baseConfig, + cache: { + type: 'filesystem', + // version cache when there are changes to aliases + buildDependencies: { + config: [__filename], + }, + version: md5(Object.entries(baseConfig.resolve.alias).join()), + }, + devtool: 'inline-source-map', + entry: { + ...baseConfig.entry, + main: [ + `webpack-hot-middleware/client?path=${payloadConfig.routes.admin}/__webpack_hmr`, + ...(baseConfig.entry.main as string[]), + ], + }, + mode: 'development', module: { ...baseConfig.module, rules: [ ...baseConfig.module.rules, { - test: /\.(scss|css)$/, sideEffects: true, + test: /\.(scss|css)$/, /* * The loaders here are run in reverse order. Here is how your loaders are being processed: * 1. sass-loader: This loader compiles your SCSS into CSS. @@ -43,30 +63,13 @@ export const getDevConfig = (payloadConfig: SanitizedConfig): Configuration => { }, ], }, - cache: { - type: 'filesystem', - // version cache when there are changes to aliases - version: md5(Object.entries(baseConfig.resolve.alias).join()), - buildDependencies: { - config: [__filename], - }, - }, - entry: { - ...baseConfig.entry, - main: [ - `webpack-hot-middleware/client?path=${payloadConfig.routes.admin}/__webpack_hmr`, - ...(baseConfig.entry.main as string[]), - ], - }, output: { - publicPath: `${payloadConfig.routes.admin}/`, - path: '/', filename: '[name].js', + path: '/', + publicPath: `${payloadConfig.routes.admin}/`, }, - devtool: 'inline-source-map', - mode: 'development', - stats: 'errors-warnings', plugins: [...baseConfig.plugins, new webpack.HotModuleReplacementPlugin()], + stats: 'errors-warnings', } if (payloadConfig.admin.webpack && typeof payloadConfig.admin.webpack === 'function') { diff --git a/packages/bundler-webpack/src/configs/prod.ts b/packages/bundler-webpack/src/configs/prod.ts index fff3094ce1..4057c70ce6 100644 --- a/packages/bundler-webpack/src/configs/prod.ts +++ b/packages/bundler-webpack/src/configs/prod.ts @@ -1,22 +1,26 @@ -import { Configuration, WebpackPluginInstance } from 'webpack' +import type { SanitizedConfig } from 'payload/config' +import type { Configuration } from 'webpack' + import MiniCSSExtractPlugin from 'mini-css-extract-plugin' -import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer' import { SwcMinifyWebpackPlugin } from 'swc-minify-webpack-plugin' +import { WebpackPluginInstance } from 'webpack' +import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer' + import { getBaseConfig } from './base' -import { SanitizedConfig } from 'payload/config' export const getProdConfig = (payloadConfig: SanitizedConfig): Configuration => { const baseConfig = getBaseConfig(payloadConfig) as any let webpackConfig: Configuration = { ...baseConfig, + mode: 'production', module: { ...baseConfig.module, rules: [ ...baseConfig.module.rules, { - test: /\.(scss|css)$/, sideEffects: true, + test: /\.(scss|css)$/, use: [ MiniCSSExtractPlugin.loader, { @@ -38,27 +42,25 @@ export const getProdConfig = (payloadConfig: SanitizedConfig): Configuration => }, ], }, - output: { - publicPath: `${payloadConfig.routes.admin}/`, - path: payloadConfig.admin.buildPath, - filename: '[name].[chunkhash].js', - chunkFilename: '[name].[chunkhash].js', - }, - mode: 'production', - stats: 'errors-only', optimization: { minimizer: [new SwcMinifyWebpackPlugin()], splitChunks: { cacheGroups: { styles: { name: 'styles', - test: /\.(sa|sc|c)ss$/, chunks: 'all', enforce: true, + test: /\.(sa|sc|c)ss$/, }, }, }, }, + output: { + chunkFilename: '[name].[chunkhash].js', + filename: '[name].[chunkhash].js', + path: payloadConfig.admin.buildPath, + publicPath: `${payloadConfig.routes.admin}/`, + }, plugins: [ ...baseConfig.plugins, new MiniCSSExtractPlugin({ @@ -67,6 +69,7 @@ export const getProdConfig = (payloadConfig: SanitizedConfig): Configuration => }), ...(process.env.PAYLOAD_ANALYZE_BUNDLE ? [new BundleAnalyzerPlugin()] : []), ], + stats: 'errors-only', } if (payloadConfig.admin.webpack && typeof payloadConfig.admin.webpack === 'function') { diff --git a/packages/bundler-webpack/src/index.ts b/packages/bundler-webpack/src/index.ts index e674e9c4aa..7c5da7421b 100644 --- a/packages/bundler-webpack/src/index.ts +++ b/packages/bundler-webpack/src/index.ts @@ -1,11 +1,12 @@ /* eslint-disable @typescript-eslint/no-var-requires */ -import { PayloadBundler } from '../../payload/dist/bundlers/types' -import { devAdmin } from './scripts/dev' +import type { PayloadBundler } from '../../payload/dist/bundlers/types' + import { buildAdmin } from './scripts/build' +import { devAdmin } from './scripts/dev' import { serveAdmin } from './scripts/serve' -export default (): PayloadBundler => ({ - dev: async (payload) => devAdmin({ payload }), +export const webpackBundler: () => PayloadBundler = () => ({ build: async (payloadConfig) => buildAdmin({ payloadConfig }), + dev: async (payload) => devAdmin({ payload }), serve: async (payload) => serveAdmin({ payload }), }) diff --git a/packages/bundler-webpack/src/mocks/emptyModule.js b/packages/bundler-webpack/src/mocks/emptyModule.js index ead516c976..5216fe4191 100644 --- a/packages/bundler-webpack/src/mocks/emptyModule.js +++ b/packages/bundler-webpack/src/mocks/emptyModule.js @@ -1 +1 @@ -export default () => {} +export const webpackBundler = () => {} diff --git a/packages/bundler-webpack/src/scripts/build.ts b/packages/bundler-webpack/src/scripts/build.ts index a9839fc423..23a1da0e46 100644 --- a/packages/bundler-webpack/src/scripts/build.ts +++ b/packages/bundler-webpack/src/scripts/build.ts @@ -1,6 +1,8 @@ +import type { SanitizedConfig } from 'payload/config' + import webpack from 'webpack' + import { getProdConfig } from '../configs/prod' -import { SanitizedConfig } from 'payload/config' type BuildAdminType = (options: { payloadConfig: SanitizedConfig }) => Promise export const buildAdmin: BuildAdminType = async ({ payloadConfig }) => { diff --git a/packages/bundler-webpack/src/scripts/dev.ts b/packages/bundler-webpack/src/scripts/dev.ts index 4226eb1c14..5a29d60f6f 100644 --- a/packages/bundler-webpack/src/scripts/dev.ts +++ b/packages/bundler-webpack/src/scripts/dev.ts @@ -1,10 +1,12 @@ -import webpack from 'webpack' +import type { Payload } from 'payload' +import type { PayloadHandler } from 'payload/config' + +import history from 'connect-history-api-fallback' import express from 'express' +import webpack from 'webpack' import webpackDevMiddleware from 'webpack-dev-middleware' import webpackHotMiddleware from 'webpack-hot-middleware' -import history from 'connect-history-api-fallback' -import type { PayloadHandler } from 'payload/config' -import { Payload } from 'payload' + import { getDevConfig } from '../configs/dev' const router = express.Router() diff --git a/packages/bundler-webpack/src/scripts/serve.ts b/packages/bundler-webpack/src/scripts/serve.ts index ed1fdd5412..e1fccc8def 100644 --- a/packages/bundler-webpack/src/scripts/serve.ts +++ b/packages/bundler-webpack/src/scripts/serve.ts @@ -1,8 +1,9 @@ -import express from 'express' +import type { Payload } from 'payload' +import type { PayloadHandler } from 'payload/config' + import compression from 'compression' import history from 'connect-history-api-fallback' -import type { PayloadHandler } from 'payload/config' -import { Payload } from 'payload' +import express from 'express' const router = express.Router() diff --git a/packages/db-mongodb/.eslintrc.cjs b/packages/db-mongodb/.eslintrc.cjs index 638d7f8131..c1b1716e71 100644 --- a/packages/db-mongodb/.eslintrc.cjs +++ b/packages/db-mongodb/.eslintrc.cjs @@ -6,6 +6,28 @@ module.exports = { extends: ['plugin:@typescript-eslint/disable-type-checked'], files: ['*.js', '*.cjs', '*.json', '*.md', '*.yml', '*.yaml'], }, + { + files: ['package.json', 'tsconfig.json'], + rules: { + 'perfectionist/sort-array-includes': 'off', + 'perfectionist/sort-astro-attributes': 'off', + 'perfectionist/sort-classes': 'off', + 'perfectionist/sort-enums': 'off', + 'perfectionist/sort-exports': 'off', + 'perfectionist/sort-imports': 'off', + 'perfectionist/sort-interfaces': 'off', + 'perfectionist/sort-jsx-props': 'off', + 'perfectionist/sort-keys': 'off', + 'perfectionist/sort-maps': 'off', + 'perfectionist/sort-named-exports': 'off', + 'perfectionist/sort-named-imports': 'off', + 'perfectionist/sort-object-types': 'off', + 'perfectionist/sort-objects': 'off', + 'perfectionist/sort-svelte-attributes': 'off', + 'perfectionist/sort-union-types': 'off', + 'perfectionist/sort-vue-attributes': 'off', + }, + }, ], parserOptions: { project: ['./tsconfig.json'], diff --git a/packages/db-mongodb/src/createVersion.ts b/packages/db-mongodb/src/createVersion.ts index cee989cffa..9fffeebe79 100644 --- a/packages/db-mongodb/src/createVersion.ts +++ b/packages/db-mongodb/src/createVersion.ts @@ -24,9 +24,9 @@ export const createVersion: CreateVersion = async function createVersion( const [doc] = await VersionModel.create( [ { - latest: true, autosave, createdAt, + latest: true, parent, updatedAt, version: versionData, @@ -36,28 +36,31 @@ export const createVersion: CreateVersion = async function createVersion( req, ) - await VersionModel.updateMany({ - $and: [ - { - _id: { - $ne: doc._id, + await VersionModel.updateMany( + { + $and: [ + { + _id: { + $ne: doc._id, + }, }, - }, - { - parent: { - $eq: parent, + { + parent: { + $eq: parent, + }, }, - }, - { - latest: { - $eq: true, + { + latest: { + $eq: true, + }, }, - }, - ], - }, { $unset: { latest: 1 } }); + ], + }, + { $unset: { latest: 1 } }, + ) - const result: Document = JSON.parse(JSON.stringify(doc)); - const verificationToken = doc._verificationToken; + const result: Document = JSON.parse(JSON.stringify(doc)) + const verificationToken = doc._verificationToken // custom id type reset result.id = result._id diff --git a/packages/db-mongodb/src/queries/sanitizeQueryValue.ts b/packages/db-mongodb/src/queries/sanitizeQueryValue.ts index fb799790bc..4d28ec14a4 100644 --- a/packages/db-mongodb/src/queries/sanitizeQueryValue.ts +++ b/packages/db-mongodb/src/queries/sanitizeQueryValue.ts @@ -1,8 +1,7 @@ -import type { Field, TabAsField } from 'payload/types'; - -import mongoose from 'mongoose'; -import { createArrayFromCommaDelineated } from 'payload/utilities'; +import type { Field, TabAsField } from 'payload/types' +import mongoose from 'mongoose' +import { createArrayFromCommaDelineated } from 'payload/utilities' type SanitizeQueryValueArgs = { field: Field | TabAsField diff --git a/packages/db-mongodb/src/queryDrafts.ts b/packages/db-mongodb/src/queryDrafts.ts index 4cf4fc8449..e26dfb45ef 100644 --- a/packages/db-mongodb/src/queryDrafts.ts +++ b/packages/db-mongodb/src/queryDrafts.ts @@ -2,7 +2,7 @@ import type { PaginateOptions } from 'mongoose' import type { QueryDrafts } from 'payload/database' import type { PayloadRequest } from 'payload/types' -import { flattenWhereToOperators, combineQueries } from 'payload/database' +import { combineQueries, flattenWhereToOperators } from 'payload/database' import type { MongooseAdapter } from '.' @@ -18,8 +18,8 @@ export const queryDrafts: QueryDrafts = async function queryDrafts( const collectionConfig = this.payload.collections[collection].config const options = withSession(this, req.transactionID) - let hasNearConstraint; - let sort; + let hasNearConstraint + let sort if (where) { const constraints = flattenWhereToOperators(where) @@ -36,33 +36,33 @@ export const queryDrafts: QueryDrafts = async function queryDrafts( }) } - const combinedWhere = combineQueries({ latest: { equals: true } }, where); + const combinedWhere = combineQueries({ latest: { equals: true } }, where) const versionQuery = await VersionModel.buildQuery({ - where: combinedWhere, locale, payload: this.payload, - }); + where: combinedWhere, + }) const paginationOptions: PaginateOptions = { - page, - sort, + forceCountFn: hasNearConstraint, lean: true, leanWithId: true, - useEstimatedCount: hasNearConstraint, - forceCountFn: hasNearConstraint, - pagination, options, - }; - - if (limit > 0) { - paginationOptions.limit = limit; - // limit must also be set here, it's ignored when pagination is false - paginationOptions.options.limit = limit; + page, + pagination, + sort, + useEstimatedCount: hasNearConstraint, } - const result = await VersionModel.paginate(versionQuery, paginationOptions); - const docs = JSON.parse(JSON.stringify(result.docs)); + if (limit > 0) { + paginationOptions.limit = limit + // limit must also be set here, it's ignored when pagination is false + paginationOptions.options.limit = limit + } + + const result = await VersionModel.paginate(versionQuery, paginationOptions) + const docs = JSON.parse(JSON.stringify(result.docs)) return { ...result, diff --git a/packages/db-mongodb/src/updateOne.ts b/packages/db-mongodb/src/updateOne.ts index b855f71b97..bfed3f4290 100644 --- a/packages/db-mongodb/src/updateOne.ts +++ b/packages/db-mongodb/src/updateOne.ts @@ -11,7 +11,7 @@ import { withSession } from './withSession' export const updateOne: UpdateOne = async function updateOne( this: MongooseAdapter, - { collection, data, id, locale, req = {} as PayloadRequest, where: whereArg }, + { id, collection, data, locale, req = {} as PayloadRequest, where: whereArg }, ) { const where = id ? { id: { equals: id } } : whereArg const Model = this.collections[collection] diff --git a/packages/db-postgres/.eslintrc.cjs b/packages/db-postgres/.eslintrc.cjs index 73cf9d8c7d..f0c500c896 100644 --- a/packages/db-postgres/.eslintrc.cjs +++ b/packages/db-postgres/.eslintrc.cjs @@ -12,6 +12,28 @@ module.exports = { '@typescript-eslint/no-redundant-type-constituents': 'off', }, }, + { + files: ['package.json', 'tsconfig.json'], + rules: { + 'perfectionist/sort-array-includes': 'off', + 'perfectionist/sort-astro-attributes': 'off', + 'perfectionist/sort-classes': 'off', + 'perfectionist/sort-enums': 'off', + 'perfectionist/sort-exports': 'off', + 'perfectionist/sort-imports': 'off', + 'perfectionist/sort-interfaces': 'off', + 'perfectionist/sort-jsx-props': 'off', + 'perfectionist/sort-keys': 'off', + 'perfectionist/sort-maps': 'off', + 'perfectionist/sort-named-exports': 'off', + 'perfectionist/sort-named-imports': 'off', + 'perfectionist/sort-object-types': 'off', + 'perfectionist/sort-objects': 'off', + 'perfectionist/sort-svelte-attributes': 'off', + 'perfectionist/sort-union-types': 'off', + 'perfectionist/sort-vue-attributes': 'off', + }, + }, ], parserOptions: { project: ['./tsconfig.json'], diff --git a/packages/db-postgres/package.json b/packages/db-postgres/package.json index 1f54f318df..d7c94bce6d 100644 --- a/packages/db-postgres/package.json +++ b/packages/db-postgres/package.json @@ -4,6 +4,7 @@ "description": "The officially supported Postgres database adapter for Payload", "repository": "https://github.com/payloadcms/payload", "license": "MIT", + "homepage": "https://payloadcms.com", "author": { "email": "info@payloadcms.com", "name": "Payload", @@ -14,8 +15,7 @@ "scripts": { "build": "pnpm build:swc && pnpm build:types", "build:swc": "swc ./src -d ./dist --config-file .swcrc", - "build:types": "tsc --emitDeclarationOnly --outDir dist", - "builddisabled": "pnpm build:swc && pnpm build:types" + "build:types": "tsc --emitDeclarationOnly --outDir dist" }, "dependencies": { "@libsql/client": "^0.3.1", diff --git a/packages/db-postgres/src/connect.ts b/packages/db-postgres/src/connect.ts index 263923d895..2bf7cd1af1 100644 --- a/packages/db-postgres/src/connect.ts +++ b/packages/db-postgres/src/connect.ts @@ -1,149 +1,149 @@ -import type { Connect } from 'payload/database'; +import type { Connect } from 'payload/database' -import { generateDrizzleJson, pushSchema } from 'drizzle-kit/utils'; -import { eq, sql } from 'drizzle-orm'; -import { drizzle } from 'drizzle-orm/node-postgres'; -import { jsonb, numeric, pgTable, varchar } from 'drizzle-orm/pg-core'; -import fs from 'fs'; -import { configToJSONSchema } from 'payload/utilities'; -import { Client, Pool } from 'pg'; -import prompts from 'prompts'; -import { v4 as uuid } from 'uuid'; +import { generateDrizzleJson, pushSchema } from 'drizzle-kit/utils' +import { eq, sql } from 'drizzle-orm' +import { drizzle } from 'drizzle-orm/node-postgres' +import { jsonb, numeric, pgTable, varchar } from 'drizzle-orm/pg-core' +import fs from 'fs' +import { configToJSONSchema } from 'payload/utilities' +import { Client, Pool } from 'pg' +import prompts from 'prompts' +import { v4 as uuid } from 'uuid' -import type { DrizzleDB, PostgresAdapter } from './types'; +import type { DrizzleDB, PostgresAdapter } from './types' // Migration table def in order to use query using drizzle const migrationsSchema = pgTable('payload_migrations', { - batch: numeric('batch'), name: varchar('name'), + batch: numeric('batch'), schema: jsonb('schema'), -}); +}) -export const connect: Connect = async function connect( - this: PostgresAdapter, - payload, -) { - let db: DrizzleDB; +export const connect: Connect = async function connect(this: PostgresAdapter, payload) { + let db: DrizzleDB this.schema = { ...this.tables, ...this.relations, ...this.enums, - }; + } try { - const sessionID = uuid(); + const sessionID = uuid() if ('pool' in this && this.pool !== false) { - const pool = new Pool(this.pool); - db = drizzle(pool, { schema: this.schema }); - await pool.connect(); + const pool = new Pool(this.pool) + db = drizzle(pool, { schema: this.schema }) + await pool.connect() } if ('client' in this && this.client !== false) { - const client = new Client(this.client); - db = drizzle(client, { schema: this.schema }); - await client.connect(); + const client = new Client(this.client) + db = drizzle(client, { schema: this.schema }) + await client.connect() } - this.sessions[sessionID] = db; + this.sessions[sessionID] = db if (process.env.PAYLOAD_DROP_DATABASE === 'true') { - this.payload.logger.info('---- DROPPING TABLES ----'); - await db.execute(sql`drop schema public cascade;\ncreate schema public;`); - this.payload.logger.info('---- DROPPED TABLES ----'); + this.payload.logger.info('---- DROPPING TABLES ----') + await db.execute(sql`drop schema public cascade;\ncreate schema public;`) + this.payload.logger.info('---- DROPPED TABLES ----') } } catch (err) { - payload.logger.error( - `Error: cannot connect to Postgres. Details: ${err.message}`, - err, - ); - process.exit(1); + payload.logger.error(`Error: cannot connect to Postgres. Details: ${err.message}`, err) + process.exit(1) } - this.payload.logger.info('Connected to Postgres successfully'); - this.db = db; + this.payload.logger.info('Connected to Postgres successfully') + this.db = db // Only push schema if not in production - if (process.env.NODE_ENV === 'production') return; + if (process.env.NODE_ENV === 'production') return // This will prompt if clarifications are needed for Drizzle to push new schema - const { apply, hasDataLoss, statementsToExecute, warnings } = await pushSchema(this.schema, this.db); + const { apply, hasDataLoss, statementsToExecute, warnings } = await pushSchema( + this.schema, + this.db, + ) this.payload.logger.debug({ hasDataLoss, msg: 'Schema push results', statementsToExecute, warnings, - }); + }) if (warnings.length) { this.payload.logger.warn({ msg: `Warnings detected during schema push: ${warnings.join('\n')}`, warnings, - }); + }) if (hasDataLoss) { this.payload.logger.warn({ msg: 'DATA LOSS WARNING: Possible data loss detected if schema is pushed.', - }); + }) } const { confirm: acceptWarnings } = await prompts( { + name: 'confirm', initial: false, message: 'Accept warnings and push schema to database?', - name: 'confirm', type: 'confirm', }, { onCancel: () => { - process.exit(0); + process.exit(0) }, }, - ); + ) // Exit if user does not accept warnings. // Q: Is this the right type of exit for this interaction? if (!acceptWarnings) { - process.exit(0); + process.exit(0) } } - this.migrationDir = '.migrations'; + this.migrationDir = '.migrations' // Create drizzle snapshot if it doesn't exist if (!fs.existsSync(`${this.migrationDir}/drizzle-snapshot.json`)) { // Ensure migration dir exists if (!fs.existsSync(this.migrationDir)) { - fs.mkdirSync(this.migrationDir); + fs.mkdirSync(this.migrationDir) } - const drizzleJSON = generateDrizzleJson(this.schema); + const drizzleJSON = generateDrizzleJson(this.schema) - fs.writeFileSync(`${this.migrationDir}/drizzle-snapshot.json`, JSON.stringify(drizzleJSON, null, 2)); + fs.writeFileSync( + `${this.migrationDir}/drizzle-snapshot.json`, + JSON.stringify(drizzleJSON, null, 2), + ) } - const jsonSchema = configToJSONSchema(this.payload.config); + const jsonSchema = configToJSONSchema(this.payload.config) - await apply(); + await apply() const devPush = await this.db .select() .from(migrationsSchema) - .where(eq(migrationsSchema.batch, '-1')); + .where(eq(migrationsSchema.batch, '-1')) if (!devPush.length) { await this.db.insert(migrationsSchema).values({ - batch: '-1', name: 'dev', + batch: '-1', schema: JSON.stringify(jsonSchema), - }); + }) } else { await this.db .update(migrationsSchema) .set({ schema: JSON.stringify(jsonSchema), }) - .where(eq(migrationsSchema.batch, '-1')); + .where(eq(migrationsSchema.batch, '-1')) } -}; +} diff --git a/packages/db-postgres/src/create/index.ts b/packages/db-postgres/src/create/index.ts index 8f75e0fab9..b87b0268a6 100644 --- a/packages/db-postgres/src/create/index.ts +++ b/packages/db-postgres/src/create/index.ts @@ -1,16 +1,12 @@ -import type { Create } from 'payload/database'; +import type { Create } from 'payload/database' -import toSnakeCase from 'to-snake-case'; +import toSnakeCase from 'to-snake-case' -import { upsertRow } from '../upsertRow'; +import { upsertRow } from '../upsertRow' -export const create: Create = async function create({ - collection: collectionSlug, - data, - req, -}) { - const db = req.transactionID ? this.sessions[req.transactionID] : this.db; - const collection = this.payload.collections[collectionSlug].config; +export const create: Create = async function create({ collection: collectionSlug, data, req }) { + const db = req.transactionID ? this.sessions[req.transactionID] : this.db + const collection = this.payload.collections[collectionSlug].config const result = await upsertRow({ adapter: this, @@ -19,7 +15,7 @@ export const create: Create = async function create({ fields: collection.fields, operation: 'create', tableName: toSnakeCase(collectionSlug), - }); + }) - return result; -}; + return result +} diff --git a/packages/db-postgres/src/createGlobal.ts b/packages/db-postgres/src/createGlobal.ts index 3d5b1a1824..cb2ba7bd2b 100644 --- a/packages/db-postgres/src/createGlobal.ts +++ b/packages/db-postgres/src/createGlobal.ts @@ -1,18 +1,18 @@ -import type { CreateGlobal } from 'payload/database'; -import type { PayloadRequest } from 'payload/types'; +import type { CreateGlobal } from 'payload/database' +import type { PayloadRequest } from 'payload/types' -import toSnakeCase from 'to-snake-case'; +import toSnakeCase from 'to-snake-case' -import type { PostgresAdapter } from './types'; +import type { PostgresAdapter } from './types' -import { upsertRow } from './upsertRow'; +import { upsertRow } from './upsertRow' export const createGlobal: CreateGlobal = async function createGlobal( this: PostgresAdapter, { data, req = {} as PayloadRequest, slug }, ) { - const db = req.transactionID ? this.sessions[req.transactionID] : this.db; - const globalConfig = this.payload.globals.config.find((config) => config.slug === slug); + const db = req.transactionID ? this.sessions[req.transactionID] : this.db + const globalConfig = this.payload.globals.config.find((config) => config.slug === slug) const result = await upsertRow({ adapter: this, @@ -21,7 +21,7 @@ export const createGlobal: CreateGlobal = async function createGlobal( fields: globalConfig.fields, operation: 'create', tableName: toSnakeCase(slug), - }); + }) - return result; -}; + return result +} diff --git a/packages/db-postgres/src/createMigration.ts b/packages/db-postgres/src/createMigration.ts index 65b3b23f04..886b456ae3 100644 --- a/packages/db-postgres/src/createMigration.ts +++ b/packages/db-postgres/src/createMigration.ts @@ -1,16 +1,10 @@ /* eslint-disable no-restricted-syntax, no-await-in-loop */ -import fs from 'fs'; -import { CreateMigration } from 'payload/dist/database/types'; +import type { CreateMigration } from 'payload/database' -import { generateDrizzleJson, generateMigration } from 'drizzle-kit/utils'; -import { eq } from 'drizzle-orm'; -import { jsonb, numeric, pgEnum, pgTable, varchar } from 'drizzle-orm/pg-core'; -import { SanitizedCollectionConfig } from 'payload/dist/collections/config/types'; -import type { DatabaseAdapter, Init } from 'payload/dist/database/types'; -import { configToJSONSchema } from 'payload/dist/utilities/configToJSONSchema'; -import prompts from 'prompts'; -import { buildTable } from './schema/build'; -import type { GenericEnum, GenericRelation, GenericTable, PostgresAdapter } from './types'; +import { generateDrizzleJson, generateMigration } from 'drizzle-kit/utils' +import fs from 'fs' + +import type { PostgresAdapter } from './types' const migrationTemplate = (upSQL?: string) => ` import payload, { Payload } from 'payload'; @@ -22,7 +16,7 @@ export async function up(payload: Payload): Promise { export async function down(payload: Payload): Promise { // Migration code }; -`; +` export const createMigration: CreateMigration = async function createMigration( this: PostgresAdapter, @@ -30,27 +24,30 @@ export const createMigration: CreateMigration = async function createMigration( migrationDir, migrationName, ) { - payload.logger.info({ msg: 'Creating migration from postgres adapter...' }); - const dir = migrationDir || '.migrations'; // TODO: Verify path after linking + payload.logger.info({ msg: 'Creating migration from postgres adapter...' }) + const dir = migrationDir || '.migrations' // TODO: Verify path after linking if (!fs.existsSync(dir)) { - fs.mkdirSync(dir); + fs.mkdirSync(dir) } - const [yyymmdd, hhmmss] = new Date().toISOString().split('T'); - const formattedDate = yyymmdd.replace(/\D/g, ''); - const formattedTime = hhmmss.split('.')[0].replace(/\D/g, ''); + const [yyymmdd, hhmmss] = new Date().toISOString().split('T') + const formattedDate = yyymmdd.replace(/\D/g, '') + const formattedTime = hhmmss.split('.')[0].replace(/\D/g, '') - const timestamp = `${formattedDate}_${formattedTime}`; + const timestamp = `${formattedDate}_${formattedTime}` - const formattedName = migrationName.replace(/\W/g, '_'); - const fileName = `${timestamp}_${formattedName}.ts`; - const filePath = `${dir}/${fileName}`; + const formattedName = migrationName.replace(/\W/g, '_') + const fileName = `${timestamp}_${formattedName}.ts` + const filePath = `${dir}/${fileName}` - const snapshotJSON = fs.readFileSync(`${dir}/drizzle-snapshot.json`, 'utf8'); - const drizzleJsonBefore = generateDrizzleJson(JSON.parse(snapshotJSON)); - const drizzleJsonAfter = generateDrizzleJson(this.schema, drizzleJsonBefore.id); - const sqlStatements = await generateMigration(drizzleJsonBefore, drizzleJsonAfter); - fs.writeFileSync(filePath, migrationTemplate(sqlStatements.length ? sqlStatements?.join('\n') : undefined)); + const snapshotJSON = fs.readFileSync(`${dir}/drizzle-snapshot.json`, 'utf8') + const drizzleJsonBefore = generateDrizzleJson(JSON.parse(snapshotJSON)) + const drizzleJsonAfter = generateDrizzleJson(this.schema, drizzleJsonBefore.id) + const sqlStatements = await generateMigration(drizzleJsonBefore, drizzleJsonAfter) + fs.writeFileSync( + filePath, + migrationTemplate(sqlStatements.length ? sqlStatements?.join('\n') : undefined), + ) // TODO: // Get the most recent migration schema from the file system @@ -61,4 +58,4 @@ export const createMigration: CreateMigration = async function createMigration( // and then inject them each into the `migrationTemplate` above, // outputting the file into the migrations folder accordingly // also make sure to output the JSON schema snapshot into a `./migrationsDir/meta` folder like Drizzle does -}; +} diff --git a/packages/db-postgres/src/createVersion.ts b/packages/db-postgres/src/createVersion.ts index 49b8737b4d..2c11dc04e7 100644 --- a/packages/db-postgres/src/createVersion.ts +++ b/packages/db-postgres/src/createVersion.ts @@ -1,25 +1,18 @@ -import type { CreateVersion } from 'payload/database'; +import type { CreateVersion } from 'payload/database' -import { buildVersionCollectionFields } from 'payload/versions'; -import toSnakeCase from 'to-snake-case'; +import { buildVersionCollectionFields } from 'payload/versions' +import toSnakeCase from 'to-snake-case' -import type { PostgresAdapter } from './types'; +import type { PostgresAdapter } from './types' -import { upsertRow } from './upsertRow'; +import { upsertRow } from './upsertRow' export const createVersion: CreateVersion = async function createVersion( this: PostgresAdapter, - { - autosave, - collectionSlug, - createdAt, - parent, - updatedAt, - versionData, - }, + { autosave, collectionSlug, createdAt, parent, updatedAt, versionData }, ) { - const collection = this.payload.collections[collectionSlug].config; - const tableName = toSnakeCase(collectionSlug); + const collection = this.payload.collections[collectionSlug].config + const tableName = toSnakeCase(collectionSlug) const result = await upsertRow({ adapter: this, @@ -31,10 +24,11 @@ export const createVersion: CreateVersion = async function createVersion( updatedAt, version: versionData, }, + db: this.db, fields: buildVersionCollectionFields(collection), operation: 'create', tableName: `_${tableName}_versions`, - }); + }) // const [doc] = await VersionModel.create( // [ @@ -71,5 +65,5 @@ export const createVersion: CreateVersion = async function createVersion( // ], // }, { $unset: { latest: 1 } }); - return result; -}; + return result +} diff --git a/packages/db-postgres/src/deleteMany.ts b/packages/db-postgres/src/deleteMany.ts index a4427c4fdf..7853f8bc98 100644 --- a/packages/db-postgres/src/deleteMany.ts +++ b/packages/db-postgres/src/deleteMany.ts @@ -1,51 +1,48 @@ -import type { DeleteMany } from 'payload/database'; -import type { PayloadRequest } from 'payload/types'; +import type { DeleteMany } from 'payload/database' +import type { PayloadRequest } from 'payload/types' -import toSnakeCase from 'to-snake-case'; +import toSnakeCase from 'to-snake-case' -import type { PostgresAdapter } from './types'; +import type { PostgresAdapter } from './types' -import { buildFindManyArgs } from './find/buildFindManyArgs'; -import buildQuery from './queries/buildQuery'; -import { transform } from './transform/read'; +import { buildFindManyArgs } from './find/buildFindManyArgs' +import buildQuery from './queries/buildQuery' +import { transform } from './transform/read' -export const deleteMany: DeleteMany = async function deleteMany(this: PostgresAdapter, - { - collection, - req = {} as PayloadRequest, - where: incomingWhere, - }) { - const collectionConfig = this.payload.collections[collection].config; - const tableName = toSnakeCase(collection); +export const deleteMany: DeleteMany = async function deleteMany( + this: PostgresAdapter, + { collection, req = {} as PayloadRequest, where: incomingWhere }, +) { + const collectionConfig = this.payload.collections[collection].config + const tableName = toSnakeCase(collection) const { where } = await buildQuery({ adapter: this, fields: collectionConfig.fields, tableName, where: incomingWhere, - }); + }) const findManyArgs = buildFindManyArgs({ adapter: this, depth: 0, fields: collectionConfig.fields, tableName, - }); + }) - findManyArgs.where = where; + findManyArgs.where = where - const docsToDelete = await this.db.query[tableName].findMany(findManyArgs); + const docsToDelete = await this.db.query[tableName].findMany(findManyArgs) const result = docsToDelete.map((data) => { return transform({ config: this.payload.config, data, fields: collectionConfig.fields, - }); - }); + }) + }) - await this.db.delete(this.tables[tableName]) - .where(where); + await this.db.delete(this.tables[tableName]).where(where) - return result; -}; + return result +} diff --git a/packages/db-postgres/src/deleteOne.ts b/packages/db-postgres/src/deleteOne.ts index 1124bb41b2..76f3c42cc1 100644 --- a/packages/db-postgres/src/deleteOne.ts +++ b/packages/db-postgres/src/deleteOne.ts @@ -1,51 +1,46 @@ -import type { DeleteOne } from 'payload/database'; -import type { PayloadRequest } from 'payload/types'; +import type { DeleteOne } from 'payload/database' +import type { PayloadRequest } from 'payload/types' -import toSnakeCase from 'to-snake-case'; +import toSnakeCase from 'to-snake-case' -import type { PostgresAdapter } from './types'; +import type { PostgresAdapter } from './types' -import { buildFindManyArgs } from './find/buildFindManyArgs'; -import buildQuery from './queries/buildQuery'; -import { transform } from './transform/read'; +import { buildFindManyArgs } from './find/buildFindManyArgs' +import buildQuery from './queries/buildQuery' +import { transform } from './transform/read' export const deleteOne: DeleteOne = async function deleteOne( this: PostgresAdapter, - { - collection, - req = {} as PayloadRequest, - where: incomingWhere, - }, + { collection, req = {} as PayloadRequest, where: incomingWhere }, ) { - const collectionConfig = this.payload.collections[collection].config; - const tableName = toSnakeCase(collection); + const collectionConfig = this.payload.collections[collection].config + const tableName = toSnakeCase(collection) const { where } = await buildQuery({ adapter: this, fields: collectionConfig.fields, tableName, where: incomingWhere, - }); + }) const findManyArgs = buildFindManyArgs({ adapter: this, depth: 0, fields: collectionConfig.fields, tableName, - }); + }) - findManyArgs.where = where; + findManyArgs.where = where - const docToDelete = await this.db.query[tableName].findFirst(findManyArgs); + const docToDelete = await this.db.query[tableName].findFirst(findManyArgs) const result = transform({ config: this.payload.config, data: docToDelete, fields: collectionConfig.fields, - }); + }) - await this.db.delete(this.tables[tableName]) - .where(where); + await this.db.delete(this.tables[tableName]).where(where) - return result; -}; + return result +} diff --git a/packages/db-postgres/src/find.ts b/packages/db-postgres/src/find.ts index 3589ce88c1..4a25afc9f4 100644 --- a/packages/db-postgres/src/find.ts +++ b/packages/db-postgres/src/find.ts @@ -1,14 +1,14 @@ -import type { SQL } from 'drizzle-orm' -import type { PgSelect } from 'drizzle-orm/pg-core' import type { Find } from 'payload/database' import type { PayloadRequest, SanitizedCollectionConfig, TypeWithID } from 'payload/types' import { asc, desc, inArray, sql } from 'drizzle-orm' import toSnakeCase from 'to-snake-case' -import type { GenericColumn, PostgresAdapter } from './types' +import type { ChainedMethods } from './find/chainMethods' +import type { PostgresAdapter } from './types' import { buildFindManyArgs } from './find/buildFindManyArgs' +import { chainMethods } from './find/chainMethods' import buildQuery from './queries/buildQuery' import { transform } from './transform/read' @@ -47,15 +47,11 @@ export const find: Find = async function find( }) const db = this.sessions?.[req.transactionID] || this.db const orderedIDMap: Record = {} - let selectCount: PgSelect }, 'partial', Record> - const methodsToCall: { - args: unknown[] - method: string - }[] = [] + const selectDistinctMethods: ChainedMethods = [] if (orderBy?.order && orderBy?.column) { - methodsToCall.push({ + selectDistinctMethods.push({ args: [orderBy.order(orderBy.column)], method: 'orderBy', }) @@ -71,23 +67,24 @@ export const find: Find = async function find( // only fetch IDs when a sort or where query is used that needs to be done on join tables, otherwise these can be done directly on the table in findMany if (Object.keys(joins).length > 0) { if (where) { - methodsToCall.push({ args: [where], method: 'where' }) + selectDistinctMethods.push({ args: [where], method: 'where' }) } Object.entries(joins).forEach(([joinTable, condition]) => { if (joinTable) { - methodsToCall.push({ + selectDistinctMethods.push({ args: [this.tables[joinTable], condition], method: 'leftJoin', }) } }) - methodsToCall.push({ args: [(page - 1) * limit], method: 'offset' }) - methodsToCall.push({ args: [limit === 0 ? undefined : limit], method: 'limit' }) + selectDistinctMethods.push({ args: [(page - 1) * limit], method: 'offset' }) + selectDistinctMethods.push({ args: [limit === 0 ? undefined : limit], method: 'limit' }) - selectDistinctResult = await methodsToCall.reduce((query, { args, method }) => { - return query[method](...args) - }, db.selectDistinct(selectFields).from(table)) + selectDistinctResult = await chainMethods({ + methods: selectDistinctMethods, + query: db.selectDistinct(selectFields).from(table), + }) if (selectDistinctResult.length === 0) { return { @@ -120,16 +117,22 @@ export const find: Find = async function find( const findPromise = db.query[tableName].findMany(findManyArgs) if (pagination !== false || selectDistinctResult?.length > limit) { - selectCount = db - .select({ count: sql`count(*)` }) - .from(table) - .where(where) + const selectCountMethods: ChainedMethods = [] Object.entries(joins).forEach(([joinTable, condition]) => { if (joinTable) { - selectCount.leftJoin(this.tables[joinTable], condition) + selectCountMethods.push({ + args: [this.tables[joinTable], condition], + method: 'leftJoin', + }) } }) - const countResult = await selectCount + const countResult = await chainMethods({ + methods: selectCountMethods, + query: db + .select({ count: sql`count(*)` }) + .from(table) + .where(where), + }) totalDocs = Number(countResult[0].count) totalPages = typeof limit === 'number' ? Math.ceil(totalDocs / limit) : 1 hasPrevPage = page > 1 diff --git a/packages/db-postgres/src/find/buildFindManyArgs.ts b/packages/db-postgres/src/find/buildFindManyArgs.ts index d611687feb..aa34390e64 100644 --- a/packages/db-postgres/src/find/buildFindManyArgs.ts +++ b/packages/db-postgres/src/find/buildFindManyArgs.ts @@ -1,9 +1,9 @@ -import type { DBQueryConfig } from 'drizzle-orm'; -import type { ArrayField, Block, Field } from 'payload/types'; +import type { DBQueryConfig } from 'drizzle-orm' +import type { ArrayField, Block, Field } from 'payload/types' -import type { PostgresAdapter } from '../types'; +import type { PostgresAdapter } from '../types' -import { traverseFields } from './traverseFields'; +import { traverseFields } from './traverseFields' type BuildFindQueryArgs = { adapter: PostgresAdapter @@ -24,14 +24,14 @@ export const buildFindManyArgs = ({ }: BuildFindQueryArgs): Record => { const result: Result = { with: {}, - }; + } const _locales: Result = { columns: { - _parentID: false, id: false, + _parentID: false, }, - }; + } if (adapter.tables[`${tableName}_relationships`]) { result.with._relationships = { @@ -40,15 +40,15 @@ export const buildFindManyArgs = ({ parent: false, }, orderBy: ({ order }, { asc: ASC }) => [ASC(order)], - }; + } } if (adapter.tables[`${tableName}_locales`]) { - result.with._locales = _locales; + result.with._locales = _locales } - const locatedBlocks: Block[] = []; - const locatedArrays: { [path: string]: ArrayField } = {}; + const locatedBlocks: Block[] = [] + const locatedArrays: { [path: string]: ArrayField } = {} traverseFields({ _locales, @@ -62,7 +62,7 @@ export const buildFindManyArgs = ({ path: '', topLevelArgs: result, topLevelTableName: tableName, - }); + }) - return result; -}; + return result +} diff --git a/packages/db-postgres/src/find/chainMethods.ts b/packages/db-postgres/src/find/chainMethods.ts new file mode 100644 index 0000000000..9bee5149ca --- /dev/null +++ b/packages/db-postgres/src/find/chainMethods.ts @@ -0,0 +1,17 @@ +export type ChainedMethods = { + args: unknown[] + method: string +}[] + +/** + * Call and returning methods that would normally be chained together but cannot be because of control logic + * @param methods + * @param query + */ +const chainMethods = ({ methods, query }): Promise => { + return methods.reduce((query, { args, method }) => { + return query[method](...args) + }, query) +} + +export { chainMethods } diff --git a/packages/db-postgres/src/find/traverseFields.ts b/packages/db-postgres/src/find/traverseFields.ts index cfdeb0a0ba..305fbe5c7a 100644 --- a/packages/db-postgres/src/find/traverseFields.ts +++ b/packages/db-postgres/src/find/traverseFields.ts @@ -1,23 +1,23 @@ /* eslint-disable no-param-reassign */ -import type { ArrayField, Block, Field } from 'payload/types'; +import type { ArrayField, Block, Field } from 'payload/types' -import { fieldAffectsData } from 'payload/types'; -import toSnakeCase from 'to-snake-case'; +import { fieldAffectsData } from 'payload/types' +import toSnakeCase from 'to-snake-case' -import type { PostgresAdapter } from '../tyfpes'; -import type { Result } from './buildFindManyArgs'; +import type { PostgresAdapter } from '../types' +import type { Result } from './buildFindManyArgs' type TraverseFieldArgs = { _locales: Record adapter: PostgresAdapter - currentArgs: Record, + currentArgs: Record currentTableName: string - depth?: number, + depth?: number fields: Field[] - locatedArrays: { [path: string]: ArrayField }, - locatedBlocks: Block[], - path: string, - topLevelArgs: Record, + locatedArrays: { [path: string]: ArrayField } + locatedBlocks: Block[] + path: string + topLevelArgs: Record topLevelTableName: string } @@ -45,12 +45,12 @@ export const traverseFields = ({ }, orderBy: ({ _order }, { asc }) => [asc(_order)], with: {}, - }; + } - const arrayTableName = `${currentTableName}_${toSnakeCase(field.name)}`; + const arrayTableName = `${currentTableName}_${toSnakeCase(field.name)}` - if (adapter.tables[`${arrayTableName}_locales`]) withArray.with._locales = _locales; - currentArgs.with[`${path}${field.name}`] = withArray; + if (adapter.tables[`${arrayTableName}_locales`]) withArray.with._locales = _locales + currentArgs.with[`${path}${field.name}`] = withArray traverseFields({ _locales, @@ -64,14 +64,14 @@ export const traverseFields = ({ path: '', topLevelArgs, topLevelTableName, - }); + }) - break; + break } case 'blocks': field.blocks.forEach((block) => { - const blockKey = `_blocks_${block.slug}`; + const blockKey = `_blocks_${block.slug}` if (!topLevelArgs[blockKey]) { const withBlock: Result = { @@ -80,10 +80,11 @@ export const traverseFields = ({ }, orderBy: ({ _order }, { asc }) => [asc(_order)], with: {}, - }; + } - if (adapter.tables[`${topLevelTableName}_${toSnakeCase(block.slug)}_locales`]) withBlock.with._locales = _locales; - topLevelArgs.with[blockKey] = withBlock; + if (adapter.tables[`${topLevelTableName}_${toSnakeCase(block.slug)}_locales`]) + withBlock.with._locales = _locales + topLevelArgs.with[blockKey] = withBlock traverseFields({ _locales, @@ -97,11 +98,11 @@ export const traverseFields = ({ path, topLevelArgs, topLevelTableName, - }); + }) } - }); + }) - break; + break case 'group': traverseFields({ @@ -116,16 +117,16 @@ export const traverseFields = ({ path: `${path}${field.name}_`, topLevelArgs, topLevelTableName, - }); + }) - break; + break default: { - break; + break } } } - }); + }) - return topLevelArgs; -}; + return topLevelArgs +} diff --git a/packages/db-postgres/src/findGlobal.ts b/packages/db-postgres/src/findGlobal.ts index 4807cef1ce..e64658b5c2 100644 --- a/packages/db-postgres/src/findGlobal.ts +++ b/packages/db-postgres/src/findGlobal.ts @@ -1,20 +1,20 @@ -import type { FindGlobal } from 'payload/database'; +import type { FindGlobal } from 'payload/database' -import toSnakeCase from 'to-snake-case'; +import toSnakeCase from 'to-snake-case' -import type { PostgresAdapter } from './types'; +import type { PostgresAdapter } from './types' -import { buildFindManyArgs } from './find/buildFindManyArgs'; -import buildQuery from './queries/buildQuery'; -import { transform } from './transform/read'; +import { buildFindManyArgs } from './find/buildFindManyArgs' +import buildQuery from './queries/buildQuery' +import { transform } from './transform/read' export const findGlobal: FindGlobal = async function findGlobal( this: PostgresAdapter, { locale, req, slug, where }, ) { - const db = req.transactionID ? this.sessions[req.transactionID] : this.db; - const globalConfig = this.payload.globals.config.find((config) => config.slug === slug); - const tableName = toSnakeCase(slug); + const db = req.transactionID ? this.sessions[req.transactionID] : this.db + const globalConfig = this.payload.globals.config.find((config) => config.slug === slug) + const tableName = toSnakeCase(slug) const query = await buildQuery({ adapter: this, @@ -22,28 +22,28 @@ export const findGlobal: FindGlobal = async function findGlobal( locale, tableName, where, - }); + }) const findManyArgs = buildFindManyArgs({ adapter: this, depth: 0, fields: globalConfig.fields, tableName, - }); + }) - findManyArgs.where = query; + findManyArgs.where = query - const doc = await db.query[tableName].findFirst(findManyArgs); + const doc = await db.query[tableName].findFirst(findManyArgs) if (doc) { const result = transform({ config: this.payload.config, data: doc, fields: globalConfig.fields, - }); + }) - return result; + return result } - return null; -}; + return null +} diff --git a/packages/db-postgres/src/findOne.ts b/packages/db-postgres/src/findOne.ts index b92ff12c2e..965fc63b44 100644 --- a/packages/db-postgres/src/findOne.ts +++ b/packages/db-postgres/src/findOne.ts @@ -1,11 +1,11 @@ -import type { FindOne } from 'payload/database'; -import type { PayloadRequest, SanitizedCollectionConfig } from 'payload/types'; +import type { FindOne } from 'payload/database' +import type { PayloadRequest, SanitizedCollectionConfig } from 'payload/types' -import toSnakeCase from 'to-snake-case'; +import toSnakeCase from 'to-snake-case' -import { buildFindManyArgs } from './find/buildFindManyArgs'; -import buildQuery from './queries/buildQuery'; -import { transform } from './transform/read'; +import { buildFindManyArgs } from './find/buildFindManyArgs' +import buildQuery from './queries/buildQuery' +import { transform } from './transform/read' export const findOne: FindOne = async function findOne({ collection, @@ -13,9 +13,9 @@ export const findOne: FindOne = async function findOne({ req = {} as PayloadRequest, where: incomingWhere, }) { - const db = req.transactionID ? this.sessions[req.transactionID] : this.db; - const collectionConfig: SanitizedCollectionConfig = this.payload.collections[collection].config; - const tableName = toSnakeCase(collection); + const db = req.transactionID ? this.sessions[req.transactionID] : this.db + const collectionConfig: SanitizedCollectionConfig = this.payload.collections[collection].config + const tableName = toSnakeCase(collection) const { where } = await buildQuery({ adapter: this, @@ -23,22 +23,22 @@ export const findOne: FindOne = async function findOne({ locale, tableName, where: incomingWhere, - }); + }) const findManyArgs = buildFindManyArgs({ adapter: this, depth: 0, fields: collectionConfig.fields, tableName, - }); + }) - findManyArgs.where = where; + findManyArgs.where = where - const doc = await db.query[tableName].findFirst(findManyArgs); + const doc = await db.query[tableName].findFirst(findManyArgs) return transform({ config: this.payload.config, data: doc, fields: collectionConfig.fields, - }); -}; + }) +} diff --git a/packages/db-postgres/src/init.ts b/packages/db-postgres/src/init.ts index 4573f3a423..ddce9aa922 100644 --- a/packages/db-postgres/src/init.ts +++ b/packages/db-postgres/src/init.ts @@ -1,14 +1,14 @@ /* eslint-disable no-param-reassign */ -import type { Init } from 'payload/database'; -import type { SanitizedCollectionConfig } from 'payload/types'; +import type { Init } from 'payload/database' +import type { SanitizedCollectionConfig } from 'payload/types' -import { pgEnum } from 'drizzle-orm/pg-core'; -import { buildVersionCollectionFields, buildVersionGlobalFields } from 'payload/versions'; -import toSnakeCase from 'to-snake-case'; +import { pgEnum } from 'drizzle-orm/pg-core' +import { buildVersionCollectionFields, buildVersionGlobalFields } from 'payload/versions' +import toSnakeCase from 'to-snake-case' -import type { PostgresAdapter } from './types'; +import type { PostgresAdapter } from './types' -import { buildTable } from './schema/build'; +import { buildTable } from './schema/build' export const init: Init = async function init(this: PostgresAdapter) { if (this.payload.config.localization) { @@ -16,12 +16,14 @@ export const init: Init = async function init(this: PostgresAdapter) { '_locales', // TODO: types out of sync with core, monorepo please // this.payload.config.localization.localeCodes, - (this.payload.config.localization.locales as unknown as { code: string }[]).map(({ code }) => code) as [string, ...string[]], - ); + (this.payload.config.localization.locales as unknown as { code: string }[]).map( + ({ code }) => code, + ) as [string, ...string[]], + ) } this.payload.config.collections.forEach((collection: SanitizedCollectionConfig) => { - const tableName = toSnakeCase(collection.slug); + const tableName = toSnakeCase(collection.slug) buildTable({ adapter: this, @@ -29,11 +31,11 @@ export const init: Init = async function init(this: PostgresAdapter) { fields: collection.fields, tableName, timestamps: collection.timestamps, - }); + }) if (collection.versions) { - const versionsTableName = `_${tableName}_versions`; - const versionFields = buildVersionCollectionFields(collection); + const versionsTableName = `_${tableName}_versions` + const versionFields = buildVersionCollectionFields(collection) buildTable({ adapter: this, @@ -41,12 +43,12 @@ export const init: Init = async function init(this: PostgresAdapter) { fields: versionFields, tableName: versionsTableName, timestamps: true, - }); + }) } - }); + }) this.payload.config.globals.forEach((global) => { - const tableName = toSnakeCase(global.slug); + const tableName = toSnakeCase(global.slug) buildTable({ adapter: this, @@ -54,11 +56,11 @@ export const init: Init = async function init(this: PostgresAdapter) { fields: global.fields, tableName, timestamps: false, - }); + }) if (global.versions) { - const versionsTableName = `_${tableName}_versions`; - const versionFields = buildVersionGlobalFields(global); + const versionsTableName = `_${tableName}_versions` + const versionFields = buildVersionGlobalFields(global) buildTable({ adapter: this, @@ -66,7 +68,7 @@ export const init: Init = async function init(this: PostgresAdapter) { fields: versionFields, tableName: versionsTableName, timestamps: true, - }); + }) } - }); -}; + }) +} diff --git a/packages/db-postgres/src/queries/buildAndOrConditions.ts b/packages/db-postgres/src/queries/buildAndOrConditions.ts index 3d73a16041..538ebcb2aa 100644 --- a/packages/db-postgres/src/queries/buildAndOrConditions.ts +++ b/packages/db-postgres/src/queries/buildAndOrConditions.ts @@ -1,10 +1,10 @@ -import type { SQL } from 'drizzle-orm'; -import type { Field, Where } from 'payload/types'; +import type { SQL } from 'drizzle-orm' +import type { Field, Where } from 'payload/types' -import type { GenericColumn, PostgresAdapter } from '../types'; -import type { BuildQueryJoins } from './buildQuery'; +import type { GenericColumn, PostgresAdapter } from '../types' +import type { BuildQueryJoins } from './buildQuery' -import { parseParams } from './parseParams'; +import { parseParams } from './parseParams' export async function buildAndOrConditions({ adapter, @@ -16,16 +16,16 @@ export async function buildAndOrConditions({ where, }: { adapter: PostgresAdapter - collectionSlug?: string, - fields: Field[], - globalSlug?: string, - joins: BuildQueryJoins, - locale?: string, + collectionSlug?: string + fields: Field[] + globalSlug?: string + joins: BuildQueryJoins + locale?: string selectFields: Record - tableName: string, - where: Where[], + tableName: string + where: Where[] }): Promise { - const completedConditions = []; + const completedConditions = [] // Loop over all AND / OR operations and add them to the AND / OR query param // Operations should come through as an array // eslint-disable-next-line no-restricted-syntax @@ -41,11 +41,11 @@ export async function buildAndOrConditions({ selectFields, tableName, where: condition, - }); + }) if (result && Object.keys(result).length > 0) { - completedConditions.push(result); + completedConditions.push(result) } } } - return completedConditions; + return completedConditions } diff --git a/packages/db-postgres/src/queries/buildQuery.ts b/packages/db-postgres/src/queries/buildQuery.ts index ee98ca6cfb..88e44a4bdb 100644 --- a/packages/db-postgres/src/queries/buildQuery.ts +++ b/packages/db-postgres/src/queries/buildQuery.ts @@ -62,7 +62,7 @@ const buildQuery = async function buildQuery({ fields, joins, locale, - pathSegments: sortPath.split('.'), + pathSegments: sortPath.replace(/__/g, '.').split('.'), selectFields, tableName, }) diff --git a/packages/db-postgres/src/queries/getTableColumnFromPath.ts b/packages/db-postgres/src/queries/getTableColumnFromPath.ts index f605de6804..98c03dd823 100644 --- a/packages/db-postgres/src/queries/getTableColumnFromPath.ts +++ b/packages/db-postgres/src/queries/getTableColumnFromPath.ts @@ -1,15 +1,15 @@ /* eslint-disable no-param-reassign */ -import type { SQL } from 'drizzle-orm'; -import type { Field, FieldAffectingData, TabAsField } from 'payload/types'; +import type { SQL } from 'drizzle-orm' +import type { Field, FieldAffectingData, TabAsField } from 'payload/types' -import { and, eq, sql } from 'drizzle-orm'; -import { APIError } from 'payload/errors'; -import { fieldAffectsData, tabHasName } from 'payload/types'; -import { flattenTopLevelFields } from 'payload/utilities'; -import toSnakeCase from 'to-snake-case'; +import { and, eq, sql } from 'drizzle-orm' +import { APIError } from 'payload/errors' +import { fieldAffectsData, tabHasName } from 'payload/types' +import { flattenTopLevelFields } from 'payload/utilities' +import toSnakeCase from 'to-snake-case' -import type { GenericColumn, GenericTable, PostgresAdapter } from '../types'; -import type { BuildQueryJoins } from './buildQuery'; +import type { GenericColumn, GenericTable, PostgresAdapter } from '../types' +import type { BuildQueryJoins } from './buildQuery' type Constraint = { columnName: string @@ -26,7 +26,7 @@ type TableColumn = { } type Args = { - adapter: PostgresAdapter, + adapter: PostgresAdapter collectionPath: string columnPrefix?: string constraints?: Constraint[] @@ -54,13 +54,14 @@ export const getTableColumnFromPath = ({ selectFields, tableName, }: Args): TableColumn => { - const fieldPath = pathSegments[0]; - const field = flattenTopLevelFields(fields as Field[]) - .find((fieldToFind) => fieldAffectsData(fieldToFind) && fieldToFind.name === fieldPath) as Field | TabAsField; - let newTableName = tableName; + const fieldPath = pathSegments[0] + const field = flattenTopLevelFields(fields as Field[]).find( + (fieldToFind) => fieldAffectsData(fieldToFind) && fieldToFind.name === fieldPath, + ) as Field | TabAsField + let newTableName = tableName if (!field && fieldPath === 'id') { - selectFields.id = adapter.tables[newTableName].id; + selectFields.id = adapter.tables[newTableName].id return { columnName: 'id', constraints, @@ -69,7 +70,7 @@ export const getTableColumnFromPath = ({ type: 'number', }, table: adapter.tables[newTableName], - }; + } } if (field) { @@ -89,7 +90,7 @@ export const getTableColumnFromPath = ({ pathSegments: pathSegments.slice(1), selectFields, tableName: newTableName, - }); + }) } case 'tab': { if (tabHasName(field)) { @@ -98,38 +99,41 @@ export const getTableColumnFromPath = ({ collectionPath, columnPrefix: `${columnPrefix}${field.name}_`, constraints, - fields: field.fields , + fields: field.fields, joins, locale, pathSegments: pathSegments.slice(1), selectFields, tableName: newTableName, - }); + }) } return getTableColumnFromPath({ adapter, collectionPath, columnPrefix, constraints, - fields: field.fields , + fields: field.fields, joins, locale, pathSegments: pathSegments.slice(1), selectFields, tableName: newTableName, - }); + }) } case 'group': { if (locale && field.localized && adapter.payload.config.localization) { - newTableName = `${tableName}_locales`; - joins[tableName] = eq(adapter.tables[tableName].id, adapter.tables[newTableName]._parentID); + newTableName = `${tableName}_locales` + joins[tableName] = eq( + adapter.tables[tableName].id, + adapter.tables[newTableName]._parentID, + ) if (locale !== 'all') { constraints.push({ - columnName: '_locale', - table: adapter.tables[newTableName], - value: locale, - }); + columnName: '_locale', + table: adapter.tables[newTableName], + value: locale, + }) } } return getTableColumnFromPath({ @@ -137,31 +141,34 @@ export const getTableColumnFromPath = ({ collectionPath, columnPrefix: `${columnPrefix}${field.name}_`, constraints, - fields: field.fields , + fields: field.fields, joins, locale, pathSegments: pathSegments.slice(1), selectFields, tableName: newTableName, - }); + }) } case 'array': { - newTableName = `${tableName}_${toSnakeCase(field.name)}`; + newTableName = `${tableName}_${toSnakeCase(field.name)}` if (locale && field.localized && adapter.payload.config.localization) { joins[newTableName] = and( eq(adapter.tables[tableName].id, adapter.tables[newTableName]._parentID), eq(adapter.tables[newTableName]._locale, locale), - ); + ) if (locale !== 'all') { constraints.push({ columnName: '_locale', table: adapter.tables[newTableName], value: locale, - }); + }) } } else { - joins[newTableName] = eq(adapter.tables[tableName].id, adapter.tables[newTableName]._parentID); + joins[newTableName] = eq( + adapter.tables[tableName].id, + adapter.tables[newTableName]._parentID, + ) } return getTableColumnFromPath({ adapter, @@ -173,17 +180,17 @@ export const getTableColumnFromPath = ({ pathSegments: pathSegments.slice(1), selectFields, tableName: newTableName, - }); + }) } case 'blocks': { - let blockTableColumn: TableColumn; - let newTableName: string; + let blockTableColumn: TableColumn + let newTableName: string const hasBlockField = field.blocks.some((block) => { - newTableName = `${tableName}_${toSnakeCase(block.slug)}`; - let result; - const blockConstraints = []; - const blockSelectFields = {}; + newTableName = `${tableName}_${toSnakeCase(block.slug)}` + let result + const blockConstraints = [] + const blockSelectFields = {} try { result = getTableColumnFromPath({ adapter, @@ -195,33 +202,36 @@ export const getTableColumnFromPath = ({ pathSegments: pathSegments.slice(1), selectFields: blockSelectFields, tableName: newTableName, - }); + }) } catch (error) { // this is fine, not every block will have the field } - if (!result) { - return; - } - blockTableColumn = result; - constraints = constraints.concat(blockConstraints); - selectFields = {...selectFields, ...blockSelectFields}; - if (field.localized && adapter.payload.config.localization) { - joins[newTableName] = and( - eq(adapter.tables[tableName].id, adapter.tables[newTableName]._parentID), - eq(adapter.tables[newTableName]._locale, locale), - ); - if (locale) { - constraints.push({ - columnName: '_locale', - table: adapter.tables[newTableName], - value: locale, - }); + if (!result) { + return } - } else { - joins[newTableName] = eq(adapter.tables[tableName].id, adapter.tables[newTableName]._parentID); - } - return result; - }); + blockTableColumn = result + constraints = constraints.concat(blockConstraints) + selectFields = { ...selectFields, ...blockSelectFields } + if (field.localized && adapter.payload.config.localization) { + joins[newTableName] = and( + eq(adapter.tables[tableName].id, adapter.tables[newTableName]._parentID), + eq(adapter.tables[newTableName]._locale, locale), + ) + if (locale) { + constraints.push({ + columnName: '_locale', + table: adapter.tables[newTableName], + value: locale, + }) + } + } else { + joins[newTableName] = eq( + adapter.tables[tableName].id, + adapter.tables[newTableName]._parentID, + ) + } + return result + }) if (hasBlockField) { return { columnName: blockTableColumn.columnName, @@ -229,49 +239,57 @@ export const getTableColumnFromPath = ({ field: blockTableColumn.field, rawColumn: blockTableColumn.rawColumn, table: adapter.tables[newTableName], - }; + } } - break; + break } case 'relationship': case 'upload': { - let relationshipFields; - const relationTableName = `${tableName}_relationships`; - const newCollectionPath = pathSegments.slice(1).join('.'); + let relationshipFields + const relationTableName = `${tableName}_relationships` + const newCollectionPath = pathSegments.slice(1).join('.') // Join in the relationships table - joins[relationTableName] = eq(adapter.tables[tableName].id, adapter.tables[relationTableName].parent); - selectFields[`${relationTableName}.path`] = adapter.tables[relationTableName].path; + joins[relationTableName] = eq( + adapter.tables[tableName].id, + adapter.tables[relationTableName].parent, + ) + selectFields[`${relationTableName}.path`] = adapter.tables[relationTableName].path constraints.push({ columnName: 'path', table: adapter.tables[relationTableName], value: field.name, - }); + }) if (typeof field.relationTo === 'string') { - newTableName = `${toSnakeCase(field.relationTo)}`; + newTableName = `${toSnakeCase(field.relationTo)}` // parent to relationship join table - relationshipFields = adapter.payload.collections[field.relationTo].config.fields; - joins[newTableName] = eq(adapter.tables[newTableName].id, adapter.tables[`${tableName}_relationships`][`${field.relationTo}ID`]); + relationshipFields = adapter.payload.collections[field.relationTo].config.fields + joins[newTableName] = eq( + adapter.tables[newTableName].id, + adapter.tables[`${tableName}_relationships`][`${field.relationTo}ID`], + ) if (newCollectionPath === '') { return { columnName: `${field.relationTo}ID`, constraints, field, table: adapter.tables[relationTableName], - }; + } } } else if (newCollectionPath === 'value') { - const tableColumnsNames = field.relationTo.map((relationTo) => `"${relationTableName}"."${toSnakeCase(relationTo)}_id"`); + const tableColumnsNames = field.relationTo.map( + (relationTo) => `"${relationTableName}"."${toSnakeCase(relationTo)}_id"`, + ) return { constraints, field, rawColumn: sql.raw(`COALESCE(${tableColumnsNames.join(', ')})`), table: adapter.tables[relationTableName], - }; + } } else { - throw new APIError('Not supported'); + throw new APIError('Not supported') } return getTableColumnFromPath({ @@ -284,7 +302,7 @@ export const getTableColumnFromPath = ({ pathSegments: pathSegments.slice(1), selectFields, tableName: newTableName, - }); + }) } default: { @@ -302,28 +320,31 @@ export const getTableColumnFromPath = ({ // case 'point': if (fieldAffectsData(field)) { if (field.localized && adapter.payload.config.localization) { - newTableName = `${tableName}_locales`; - joins[newTableName] = eq(adapter.tables[tableName].id, adapter.tables[newTableName]._parentID); + newTableName = `${tableName}_locales` + joins[newTableName] = eq( + adapter.tables[tableName].id, + adapter.tables[newTableName]._parentID, + ) if (locale !== 'all') { constraints.push({ columnName: '_locale', table: adapter.tables[newTableName], value: locale, - }); + }) } } - selectFields[`${newTableName}.${field.name}`] = adapter.tables[newTableName][field.name]; + selectFields[`${newTableName}.${field.name}`] = adapter.tables[newTableName][field.name] return { columnName: `${columnPrefix}${field.name}`, constraints, field, table: adapter.tables[newTableName], - }; + } } } } } - throw new APIError(`Cannot find field for path at ${fieldPath}`); -}; + throw new APIError(`Cannot find field for path at ${fieldPath}`) +} diff --git a/packages/db-postgres/src/queries/parseParams.ts b/packages/db-postgres/src/queries/parseParams.ts index 3899de76ea..e1ea78382d 100644 --- a/packages/db-postgres/src/queries/parseParams.ts +++ b/packages/db-postgres/src/queries/parseParams.ts @@ -83,7 +83,7 @@ export async function parseParams({ fields, joins, locale, - pathSegments: relationOrPath.split('.'), + pathSegments: relationOrPath.replace(/__/g, '.').split('.'), selectFields, tableName, }) @@ -97,9 +97,6 @@ export async function parseParams({ queryConstraints.forEach(({ columnName: col, table: constraintTable, value }) => { constraints.push(operatorMap.equals(constraintTable[col], value)) }) - if (!operatorMap[queryOperator]) { - console.log('found it') - } constraints.push( operatorMap[queryOperator](rawColumn || table[columnName], queryValue), ) diff --git a/packages/db-postgres/src/queryDrafts.ts b/packages/db-postgres/src/queryDrafts.ts index b78025ce8c..7d80e9ae07 100644 --- a/packages/db-postgres/src/queryDrafts.ts +++ b/packages/db-postgres/src/queryDrafts.ts @@ -1,13 +1,13 @@ -import type { QueryDrafts } from 'payload/database'; -import type { PayloadRequest, SanitizedCollectionConfig } from 'payload/types'; +import type { QueryDrafts } from 'payload/database' +import type { PayloadRequest, SanitizedCollectionConfig } from 'payload/types' -import { sql } from 'drizzle-orm'; -import { buildVersionCollectionFields } from 'payload/versions'; -import toSnakeCase from 'to-snake-case'; +import { sql } from 'drizzle-orm' +import { buildVersionCollectionFields } from 'payload/versions' +import toSnakeCase from 'to-snake-case' -import { buildFindManyArgs } from './find/buildFindManyArgs'; -import buildQuery from './queries/buildQuery'; -import { transform } from './transform/read'; +import { buildFindManyArgs } from './find/buildFindManyArgs' +import buildQuery from './queries/buildQuery' +import { transform } from './transform/read' export const queryDrafts: QueryDrafts = async function queryDrafts({ collection, @@ -19,20 +19,21 @@ export const queryDrafts: QueryDrafts = async function queryDrafts({ sort: sortArg, where: whereArg, }) { - const db = req.transactionID ? this.sessions[req.transactionID] : this.db; - const collectionConfig: SanitizedCollectionConfig = this.payload.collections[collection].config; - const tableName = toSnakeCase(collection); - const versionsTableName = `_${tableName}_versions`; - const table = this.tables[versionsTableName]; - const limit = typeof limitArg === 'number' ? limitArg : collectionConfig.admin.pagination.defaultLimit; + const db = req.transactionID ? this.sessions[req.transactionID] : this.db + const collectionConfig: SanitizedCollectionConfig = this.payload.collections[collection].config + const tableName = toSnakeCase(collection) + const versionsTableName = `_${tableName}_versions` + const table = this.tables[versionsTableName] + const limit = + typeof limitArg === 'number' ? limitArg : collectionConfig.admin.pagination.defaultLimit // TODO: use sort - const sort = typeof sortArg === 'string' ? sortArg : collectionConfig.defaultSort; + const sort = typeof sortArg === 'string' ? sortArg : collectionConfig.defaultSort - let totalDocs; - let totalPages; - let hasPrevPage; - let hasNextPage; - let pagingCounter; + let totalDocs + let totalPages + let hasPrevPage + let hasNextPage + let pagingCounter const { where } = await buildQuery({ adapter: this, @@ -40,16 +41,19 @@ export const queryDrafts: QueryDrafts = async function queryDrafts({ locale, sort, tableName: versionsTableName, - where: whereArg - }); + where: whereArg, + }) if (pagination !== false) { - const countResult = await db.select({ count: sql`count(*)` }).from(table).where(where); - totalDocs = Number(countResult[0].count); - totalPages = Math.ceil(totalDocs / limit); - hasPrevPage = page > 1; - hasNextPage = totalPages > page; - pagingCounter = ((page - 1) * limit) + 1; + const countResult = await db + .select({ count: sql`count(*)` }) + .from(table) + .where(where) + totalDocs = Number(countResult[0].count) + totalPages = Math.ceil(totalDocs / limit) + hasPrevPage = page > 1 + hasNextPage = totalPages > page + pagingCounter = (page - 1) * limit + 1 } const findManyArgs = buildFindManyArgs({ @@ -57,21 +61,21 @@ export const queryDrafts: QueryDrafts = async function queryDrafts({ depth: 0, fields: collectionConfig.fields, tableName, - }); + }) - findManyArgs.limit = limit === 0 ? undefined : limit; - findManyArgs.offset = (page - 1) * limit; - findManyArgs.where = where; + findManyArgs.limit = limit === 0 ? undefined : limit + findManyArgs.offset = (page - 1) * limit + findManyArgs.where = where - const rawDocs = await db.query[tableName].findMany(findManyArgs); + const rawDocs = await db.query[tableName].findMany(findManyArgs) const docs = rawDocs.map((data) => { return transform({ config: this.payload.config, data, fields: collectionConfig.fields, - }); - }); + }) + }) return { docs, // : T[] @@ -84,5 +88,5 @@ export const queryDrafts: QueryDrafts = async function queryDrafts({ prevPage: hasPrevPage ? page - 1 : null, // ?: number | null | undefined totalDocs, // : number totalPages, // : number - }; -}; + } +} diff --git a/packages/db-postgres/src/reference.ts b/packages/db-postgres/src/reference.ts index 5c4726480e..8d7911f7ee 100644 --- a/packages/db-postgres/src/reference.ts +++ b/packages/db-postgres/src/reference.ts @@ -4,40 +4,40 @@ // type PushDiff = (schema: DrizzleSchemaExports) => Promise<{ warnings: string[], apply: () => Promise }> - // drizzle-kit@utils -import { generateDrizzleJson, generateMigration, pushSchema } from 'drizzle-kit/utils'; -import { drizzle } from 'drizzle-orm/node-postgres'; -import { Pool } from 'pg'; +import { generateDrizzleJson, generateMigration, pushSchema } from 'drizzle-kit/utils' +import { drizzle } from 'drizzle-orm/node-postgres' +import { Pool } from 'pg' async function generateUsage() { - const schema = await import('./data/users'); - const schemaAfter = await import('./data/users-after'); + // @ts-expect-error Just TypeScript being broken // TODO: Open TypeScript issue + const schema = await import('./data/users') + // @ts-expect-error Just TypeScript being broken // TODO: Open TypeScript issue + const schemaAfter = await import('./data/users-after') - const drizzleJsonBefore = generateDrizzleJson(schema); - const drizzleJsonAfter = generateDrizzleJson(schemaAfter); + const drizzleJsonBefore = generateDrizzleJson(schema) + const drizzleJsonAfter = generateDrizzleJson(schemaAfter) - const sqlStatements = await generateMigration(drizzleJsonBefore, drizzleJsonAfter); + const sqlStatements = await generateMigration(drizzleJsonBefore, drizzleJsonAfter) - console.log(sqlStatements); + console.log(sqlStatements) } async function pushUsage() { - const schemaAfter = await import('./data/users-after'); + // @ts-expect-error Just TypeScript being broken // TODO: Open TypeScript issue + const schemaAfter = await import('./data/users-after') - const db = drizzle( - new Pool({ connectionString: '' }), - ); + const db = drizzle(new Pool({ connectionString: '' })) - const response = await pushSchema(schemaAfter, db); + const response = await pushSchema(schemaAfter, db) - console.log('\n'); - console.log('hasDataLoss: ', response.hasDataLoss); - console.log('warnings: ', response.warnings); - console.log('statements: ', response.statementsToExecute); + console.log('\n') + console.log('hasDataLoss: ', response.hasDataLoss) + console.log('warnings: ', response.warnings) + console.log('statements: ', response.statementsToExecute) - await response.apply(); + await response.apply() - process.exit(0); + process.exit(0) } diff --git a/packages/db-postgres/src/schema/build.ts b/packages/db-postgres/src/schema/build.ts index 0f00d5ecba..9cb23f2abf 100644 --- a/packages/db-postgres/src/schema/build.ts +++ b/packages/db-postgres/src/schema/build.ts @@ -1,21 +1,30 @@ /* eslint-disable no-param-reassign */ -import type { Relation } from 'drizzle-orm'; -import type { IndexBuilder, PgColumnBuilder, UniqueConstraintBuilder } from 'drizzle-orm/pg-core'; -import type { Field } from 'payload/types'; +import type { Relation } from 'drizzle-orm' +import type { IndexBuilder, PgColumnBuilder, UniqueConstraintBuilder } from 'drizzle-orm/pg-core' +import type { Field } from 'payload/types' -import { relations } from 'drizzle-orm'; -import { index, integer, numeric, pgTable, serial, timestamp, unique, varchar, } from 'drizzle-orm/pg-core'; -import { fieldAffectsData } from 'payload/types'; -import toSnakeCase from 'to-snake-case'; +import { relations } from 'drizzle-orm' +import { + index, + integer, + numeric, + pgTable, + serial, + timestamp, + unique, + varchar, +} from 'drizzle-orm/pg-core' +import { fieldAffectsData } from 'payload/types' +import toSnakeCase from 'to-snake-case' -import type { GenericColumns, GenericTable, PostgresAdapter } from '../types'; +import type { GenericColumns, GenericTable, PostgresAdapter } from '../types' -import { parentIDColumnMap } from './parentIDColumnMap'; -import { traverseFields } from './traverseFields'; +import { parentIDColumnMap } from './parentIDColumnMap' +import { traverseFields } from './traverseFields' type Args = { adapter: PostgresAdapter - baseColumns?: Record, + baseColumns?: Record baseExtraConfig?: Record IndexBuilder | UniqueConstraintBuilder> buildRelationships?: boolean fields: Field[] @@ -36,38 +45,38 @@ export const buildTable = ({ tableName, timestamps, }: Args): Result => { - const columns: Record = baseColumns; - const indexes: Record IndexBuilder> = {}; + const columns: Record = baseColumns + const indexes: Record IndexBuilder> = {} - let hasLocalizedField = false; - let hasLocalizedRelationshipField = false; - const localesColumns: Record = {}; - const localesIndexes: Record IndexBuilder> = {}; - let localesTable: GenericTable; + let hasLocalizedField = false + let hasLocalizedRelationshipField = false + const localesColumns: Record = {} + const localesIndexes: Record IndexBuilder> = {} + let localesTable: GenericTable - const relationships: Set = new Set(); - let relationshipsTable: GenericTable; + const relationships: Set = new Set() + let relationshipsTable: GenericTable - const arrayBlockRelations: Map = new Map(); + const arrayBlockRelations: Map = new Map() - const idField = fields.find((field) => fieldAffectsData(field) && field.name === 'id'); - let idColType = 'integer'; + const idField = fields.find((field) => fieldAffectsData(field) && field.name === 'id') + let idColType = 'integer' if (idField) { if (idField.type === 'number') { - idColType = 'numeric'; - columns.id = numeric('id').primaryKey(); + idColType = 'numeric' + columns.id = numeric('id').primaryKey() } if (idField.type === 'text') { - idColType = 'varchar'; - columns.id = varchar('id').primaryKey(); + idColType = 'varchar' + columns.id = varchar('id').primaryKey() } } else { - columns.id = serial('id').primaryKey(); + columns.id = serial('id').primaryKey() } - ({ hasLocalizedField, hasLocalizedRelationshipField } = traverseFields({ + ;({ hasLocalizedField, hasLocalizedRelationshipField } = traverseFields({ adapter, arrayBlockRelations, buildRelationships, @@ -79,52 +88,57 @@ export const buildTable = ({ newTableName: tableName, parentTableName: tableName, relationships, - })); + })) if (timestamps) { - columns.createdAt = timestamp('created_at').defaultNow().notNull(); - columns.updatedAt = timestamp('updated_at').defaultNow().notNull(); + columns.createdAt = timestamp('created_at').defaultNow().notNull() + columns.updatedAt = timestamp('updated_at').defaultNow().notNull() } const table = pgTable(tableName, columns, (cols) => { const extraConfig = Object.entries(baseExtraConfig).reduce((config, [key, func]) => { - config[key] = func(cols); - return config; - }, {}); + config[key] = func(cols) + return config + }, {}) return Object.entries(indexes).reduce((acc, [colName, func]) => { - acc[colName] = func(cols); - return acc; - }, extraConfig); - }); + acc[colName] = func(cols) + return acc + }, extraConfig) + }) - adapter.tables[tableName] = table; + adapter.tables[tableName] = table if (hasLocalizedField) { - const localeTableName = `${tableName}_locales`; - localesColumns.id = serial('id').primaryKey(); - localesColumns._locale = adapter.enums._locales('_locale').notNull(); - localesColumns._parentID = parentIDColumnMap[idColType]('_parent_id').references(() => table.id, { onDelete: 'cascade' }).notNull(); + const localeTableName = `${tableName}_locales` + localesColumns.id = serial('id').primaryKey() + localesColumns._locale = adapter.enums._locales('_locale').notNull() + localesColumns._parentID = parentIDColumnMap[idColType]('_parent_id') + .references(() => table.id, { onDelete: 'cascade' }) + .notNull() localesTable = pgTable(localeTableName, localesColumns, (cols) => { - return Object.entries(localesIndexes).reduce((acc, [colName, func]) => { - acc[colName] = func(cols); - return acc; - }, { - _localeParent: unique().on(cols._locale, cols._parentID), - }); - }); + return Object.entries(localesIndexes).reduce( + (acc, [colName, func]) => { + acc[colName] = func(cols) + return acc + }, + { + _localeParent: unique().on(cols._locale, cols._parentID), + }, + ) + }) - adapter.tables[localeTableName] = localesTable; + adapter.tables[localeTableName] = localesTable const localesTableRelations = relations(localesTable, ({ one }) => ({ _parentID: one(table, { fields: [localesTable._parentID], references: [table.id], }), - })); + })) - adapter.relations[`relations_${localeTableName}`] = localesTableRelations; + adapter.relations[`relations_${localeTableName}`] = localesTableRelations } if (buildRelationships) { @@ -132,40 +146,51 @@ export const buildTable = ({ const relationshipColumns: Record = { id: serial('id').primaryKey(), order: integer('order'), - parent: parentIDColumnMap[idColType]('parent_id').references(() => table.id, { onDelete: 'cascade' }).notNull(), + parent: parentIDColumnMap[idColType]('parent_id') + .references(() => table.id, { onDelete: 'cascade' }) + .notNull(), path: varchar('path').notNull(), - }; + } if (hasLocalizedRelationshipField) { - relationshipColumns.locale = adapter.enums._locales('locale'); + relationshipColumns.locale = adapter.enums._locales('locale') } relationships.forEach((relationTo) => { - const formattedRelationTo = toSnakeCase(relationTo); - let colType = 'integer'; - const relatedCollectionCustomID = adapter.payload.collections[relationTo].config.fields.find((field) => fieldAffectsData(field) && field.name === 'id'); - if (relatedCollectionCustomID?.type === 'number') colType = 'numeric'; - if (relatedCollectionCustomID?.type === 'text') colType = 'varchar'; + const formattedRelationTo = toSnakeCase(relationTo) + let colType = 'integer' + const relatedCollectionCustomID = adapter.payload.collections[ + relationTo + ].config.fields.find((field) => fieldAffectsData(field) && field.name === 'id') + if (relatedCollectionCustomID?.type === 'number') colType = 'numeric' + if (relatedCollectionCustomID?.type === 'text') colType = 'varchar' - relationshipColumns[`${relationTo}ID`] = parentIDColumnMap[colType](`${formattedRelationTo}_id`).references(() => adapter.tables[formattedRelationTo].id); - }); + relationshipColumns[`${relationTo}ID`] = parentIDColumnMap[colType]( + `${formattedRelationTo}_id`, + ).references(() => adapter.tables[formattedRelationTo].id) + }) - const relationshipsTableName = `${tableName}_relationships`; + const relationshipsTableName = `${tableName}_relationships` relationshipsTable = pgTable(relationshipsTableName, relationshipColumns, (cols) => { - const result: Record = {}; + const result: Record = {} if (hasLocalizedRelationshipField) { - result.localeIdx = index('locale_idx').on(cols.locale); - result.parentPathOrderLocale = unique().on(cols.parent, cols.path, cols.order, cols.locale); + result.localeIdx = index('locale_idx').on(cols.locale) + result.parentPathOrderLocale = unique().on( + cols.parent, + cols.path, + cols.order, + cols.locale, + ) } else { - result.parentPathOrder = unique().on(cols.parent, cols.path, cols.order); + result.parentPathOrder = unique().on(cols.parent, cols.path, cols.order) } - return result; - }); + return result + }) - adapter.tables[relationshipsTableName] = relationshipsTable; + adapter.tables[relationshipsTableName] = relationshipsTable const relationshipsTableRelations = relations(relationshipsTable, ({ one }) => { const result: Record> = { @@ -174,45 +199,45 @@ export const buildTable = ({ references: [table.id], relationName: '_relationships', }), - }; + } relationships.forEach((relationTo) => { - const relatedTableName = toSnakeCase(relationTo); - const idColumnName = `${relationTo}ID`; + const relatedTableName = toSnakeCase(relationTo) + const idColumnName = `${relationTo}ID` result[idColumnName] = one(adapter.tables[relatedTableName], { fields: [relationshipsTable[idColumnName]], references: [adapter.tables[relatedTableName].id], - }); - }); + }) + }) - return result; - }); + return result + }) - adapter.relations[`relations_${relationshipsTableName}`] = relationshipsTableRelations; + adapter.relations[`relations_${relationshipsTableName}`] = relationshipsTableRelations } } const tableRelations = relations(table, ({ many }) => { - const result: Record> = {}; + const result: Record> = {} arrayBlockRelations.forEach((val, key) => { - result[key] = many(adapter.tables[val]); - }); + result[key] = many(adapter.tables[val]) + }) if (hasLocalizedField) { - result._locales = many(localesTable); + result._locales = many(localesTable) } if (relationships.size && relationshipsTable) { result._relationships = many(relationshipsTable, { relationName: '_relationships', - }); + }) } - return result; - }); + return result + }) - adapter.relations[`relations_${tableName}`] = tableRelations; + adapter.relations[`relations_${tableName}`] = tableRelations - return { arrayBlockRelations }; -}; + return { arrayBlockRelations } +} diff --git a/packages/db-postgres/src/schema/createIndex.ts b/packages/db-postgres/src/schema/createIndex.ts index 9eef4e8f40..04435b67a3 100644 --- a/packages/db-postgres/src/schema/createIndex.ts +++ b/packages/db-postgres/src/schema/createIndex.ts @@ -1,7 +1,7 @@ /* eslint-disable no-param-reassign */ -import { index, uniqueIndex } from 'drizzle-orm/pg-core'; +import { index, uniqueIndex } from 'drizzle-orm/pg-core' -import type { GenericColumn } from '../types'; +import type { GenericColumn } from '../types' type CreateIndexArgs = { columnName: string @@ -9,9 +9,9 @@ type CreateIndexArgs = { unique?: boolean } -export const createIndex = ({ columnName, name, unique }: CreateIndexArgs) => { +export const createIndex = ({ name, columnName, unique }: CreateIndexArgs) => { return (table: { [x: string]: GenericColumn }) => { - if (unique) return uniqueIndex(`${columnName}_idx`).on(table[name]); - return index(`${columnName}_idx`).on(table[name]); - }; -}; + if (unique) return uniqueIndex(`${columnName}_idx`).on(table[name]) + return index(`${columnName}_idx`).on(table[name]) + } +} diff --git a/packages/db-postgres/src/schema/parentIDColumnMap.ts b/packages/db-postgres/src/schema/parentIDColumnMap.ts index 965300de27..eba60e8d08 100644 --- a/packages/db-postgres/src/schema/parentIDColumnMap.ts +++ b/packages/db-postgres/src/schema/parentIDColumnMap.ts @@ -1,7 +1,7 @@ -import { integer, numeric, varchar } from 'drizzle-orm/pg-core'; +import { integer, numeric, varchar } from 'drizzle-orm/pg-core' export const parentIDColumnMap = { integer, numeric, varchar, -}; +} diff --git a/packages/db-postgres/src/transactions/commitTransaction.ts b/packages/db-postgres/src/transactions/commitTransaction.ts index f1f9150f1a..d70e096f1f 100644 --- a/packages/db-postgres/src/transactions/commitTransaction.ts +++ b/packages/db-postgres/src/transactions/commitTransaction.ts @@ -1,19 +1,18 @@ -import type { CommitTransaction } from 'payload/database'; - -import { sql } from 'drizzle-orm'; +import type { CommitTransaction } from 'payload/database' +import { sql } from 'drizzle-orm' export const commitTransaction: CommitTransaction = async function commitTransaction(id) { if (!this.sessions[id]) { - this.payload.logger.warn('commitTransaction called when no transaction exists'); - return; + this.payload.logger.warn('commitTransaction called when no transaction exists') + return } try { - await this.sessions[id].execute(sql`COMMIT;`); + await this.sessions[id].execute(sql`COMMIT;`) } catch (err: unknown) { - await this.sessions[id].execute(sql`ROLLBACK;`); + await this.sessions[id].execute(sql`ROLLBACK;`) } - delete this.sessions[id]; -}; + delete this.sessions[id] +} diff --git a/packages/db-postgres/src/transactions/rollbackTransaction.ts b/packages/db-postgres/src/transactions/rollbackTransaction.ts index ff92025b3a..8d8038d38d 100644 --- a/packages/db-postgres/src/transactions/rollbackTransaction.ts +++ b/packages/db-postgres/src/transactions/rollbackTransaction.ts @@ -1,13 +1,14 @@ -import type { RollbackTransaction } from 'payload/database'; +import type { RollbackTransaction } from 'payload/database' -import { sql } from 'drizzle-orm'; +import { sql } from 'drizzle-orm' - -export const rollbackTransaction: RollbackTransaction = async function rollbackTransaction(id = '') { +export const rollbackTransaction: RollbackTransaction = async function rollbackTransaction( + id = '', +) { if (!this.sessions[id]) { - this.payload.logger.warn('rollbackTransaction called when no transaction exists'); - return; + this.payload.logger.warn('rollbackTransaction called when no transaction exists') + return } - await this.sessions[id].execute(sql`ROLLBACK;`); - delete this.sessions[id]; -}; + await this.sessions[id].execute(sql`ROLLBACK;`) + delete this.sessions[id] +} diff --git a/packages/db-postgres/src/transform/read/relationship.ts b/packages/db-postgres/src/transform/read/relationship.ts index 9a8af3ab6c..a6cb3846c0 100644 --- a/packages/db-postgres/src/transform/read/relationship.ts +++ b/packages/db-postgres/src/transform/read/relationship.ts @@ -1,5 +1,5 @@ /* eslint-disable no-param-reassign */ -import { RelationshipField } from 'payload/types'; +import type { RelationshipField } from 'payload/types' type Args = { field: RelationshipField @@ -8,68 +8,67 @@ type Args = { relations: Record[] } -export const transformRelationship = ({ - field, - locale, - ref, - relations, -}: Args) => { - let result: unknown; +export const transformRelationship = ({ field, locale, ref, relations }: Args) => { + let result: unknown if (!field.hasMany) { - const relation = relations[0]; + const relation = relations[0] if (relation) { // Handle hasOne Poly if (Array.isArray(field.relationTo)) { - const matchedRelation = Object.entries(relation).find(([key, val]) => val !== null && !['order', 'id', 'parent', 'locale'].includes(key)); + const matchedRelation = Object.entries(relation).find( + ([key, val]) => val !== null && !['id', 'locale', 'order', 'parent'].includes(key), + ) if (matchedRelation) { - const relationTo = matchedRelation[0].replace('ID', ''); + const relationTo = matchedRelation[0].replace('ID', '') result = { relationTo, value: matchedRelation[1], - }; + } } } else { // Handle hasOne - const relatedData = relation[`${field.relationTo}ID`]; - result = relatedData; + const relatedData = relation[`${field.relationTo}ID`] + result = relatedData } } } else { - const transformedRelations = []; + const transformedRelations = [] relations.forEach((relation) => { // Handle hasMany if (!Array.isArray(field.relationTo)) { - const relatedData = relation[`${field.relationTo}ID`]; + const relatedData = relation[`${field.relationTo}ID`] if (relatedData) { - transformedRelations.push(relatedData); + transformedRelations.push(relatedData) } } else { // Handle hasMany Poly - const matchedRelation = Object.entries(relation).find(([key, val]) => val !== null && !['order', 'parent', 'id', 'locale'].includes(key)); + const matchedRelation = Object.entries(relation).find( + ([key, val]) => val !== null && !['id', 'locale', 'order', 'parent'].includes(key), + ) if (matchedRelation) { - const relationTo = matchedRelation[0].replace('ID', ''); + const relationTo = matchedRelation[0].replace('ID', '') transformedRelations.push({ relationTo, value: matchedRelation[1], - }); + }) } } - }); + }) - result = transformedRelations; + result = transformedRelations } if (locale) { - ref[field.name][locale] = result; + ref[field.name][locale] = result } else { - ref[field.name] = result; + ref[field.name] = result } -}; +} diff --git a/packages/db-postgres/src/transform/read/traverseFields.ts b/packages/db-postgres/src/transform/read/traverseFields.ts index 1cb6983e4d..fcd4ccea87 100644 --- a/packages/db-postgres/src/transform/read/traverseFields.ts +++ b/packages/db-postgres/src/transform/read/traverseFields.ts @@ -1,9 +1,15 @@ /* eslint-disable no-param-reassign */ import type { SanitizedConfig } from 'payload/config' +<<<<<<< HEAD import type { Field, TabAsField } from 'payload/types' import { fieldAffectsData, tabHasName } from 'payload/types' import toSnakeCase from 'to-snake-case' +======= +import type { Field } from 'payload/types' + +import { fieldAffectsData } from 'payload/types' +>>>>>>> 463a39e8223464012ef67564d46eae5a4cf83280 import type { BlocksMap } from '../../utilities/createBlocksMap' @@ -205,12 +211,18 @@ export const traverseFields = >({ const localizedFieldData = {} const valuesToTransform: { +<<<<<<< HEAD ref: Record table: Record +======= + localeRow: Record + ref: Record +>>>>>>> 463a39e8223464012ef67564d46eae5a4cf83280 }[] = [] if (field.localized && Array.isArray(table._locales)) { table._locales.forEach((localeRow) => { +<<<<<<< HEAD valuesToTransform.push({ ref: localizedFieldData, table: localeRow }) }) } else { @@ -220,10 +232,22 @@ export const traverseFields = >({ valuesToTransform.forEach(({ ref, table }) => { const fieldData = table[field.name] const locale = table?._locale +======= + valuesToTransform.push({ localeRow, ref: localizedFieldData }) + }) + } else { + valuesToTransform.push({ localeRow: undefined, ref: result }) + } + + valuesToTransform.forEach(({ localeRow, ref }) => { + const fieldData = localeRow?.[field.name] || ref[field.name] + const locale = localeRow?._locale +>>>>>>> 463a39e8223464012ef67564d46eae5a4cf83280 switch (field.type) { case 'tab': case 'group': { +<<<<<<< HEAD // if (field.type === 'tab') { // console.log('got one') // } @@ -245,6 +269,25 @@ export const traverseFields = >({ const groupColumnPrefix = `${columnPrefix || ''}${toSnakeCase(field.name)}_` const groupData = {} +======= + const groupData = {} + + field.fields.forEach((subField) => { + if (fieldAffectsData(subField)) { + const subFieldKey = `${sanitizedPath.replace(/\./g, '_')}${field.name}_${ + subField.name + }` + + if (typeof locale === 'string') { + if (!ref[locale]) ref[locale] = {} + ref[locale][subField.name] = localeRow[subFieldKey] + } else { + groupData[subField.name] = table[subFieldKey] + delete table[subFieldKey] + } + } + }) +>>>>>>> 463a39e8223464012ef67564d46eae5a4cf83280 if (field.localized) { if (typeof locale === 'string' && !ref[locale]) ref[locale] = {} @@ -326,6 +369,7 @@ export const traverseFields = >({ return result } +<<<<<<< HEAD if (field.type === 'tabs') { traverseFields({ blocks, @@ -355,5 +399,10 @@ export const traverseFields = >({ return dataRef }, dataRef) +======= + return siblingData + }, siblingData) + +>>>>>>> 463a39e8223464012ef67564d46eae5a4cf83280 return formatted as T } diff --git a/packages/db-postgres/src/transform/write/array.ts b/packages/db-postgres/src/transform/write/array.ts index 6e639073d0..87b0c21b7c 100644 --- a/packages/db-postgres/src/transform/write/array.ts +++ b/packages/db-postgres/src/transform/write/array.ts @@ -1,10 +1,10 @@ /* eslint-disable no-param-reassign */ -import type { ArrayField } from 'payload/types'; +import type { ArrayField } from 'payload/types' -import type { ArrayRowToInsert, BlockRowToInsert } from './types'; +import type { ArrayRowToInsert, BlockRowToInsert } from './types' -import { isArrayOfRows } from '../../utilities/isArrayOfRows'; -import { traverseFields } from './traverseFields'; +import { isArrayOfRows } from '../../utilities/isArrayOfRows' +import { traverseFields } from './traverseFields' type Args = { arrayTableName: string @@ -29,7 +29,7 @@ export const transformArray = ({ path, relationships, }: Args) => { - const newRows: ArrayRowToInsert[] = []; + const newRows: ArrayRowToInsert[] = [] if (isArrayOfRows(data)) { data.forEach((arrayRow, i) => { @@ -40,16 +40,16 @@ export const transformArray = ({ row: { _order: i + 1, }, - }; + } if (locale) { newRow.locales[locale] = { _locale: locale, - }; + } } if (field.localized) { - newRow.row._locale = locale; + newRow.row._locale = locale } traverseFields({ @@ -64,11 +64,11 @@ export const transformArray = ({ path: `${path || ''}${field.name}.${i}.`, relationships, row: newRow.row, - }); + }) - newRows.push(newRow); - }); + newRows.push(newRow) + }) } - return newRows; -}; + return newRows +} diff --git a/packages/db-postgres/src/transform/write/blocks.ts b/packages/db-postgres/src/transform/write/blocks.ts index 5a50e0cefe..a80a3f913d 100644 --- a/packages/db-postgres/src/transform/write/blocks.ts +++ b/packages/db-postgres/src/transform/write/blocks.ts @@ -1,11 +1,11 @@ /* eslint-disable no-param-reassign */ -import type { BlockField } from 'payload/types'; +import type { BlockField } from 'payload/types' -import toSnakeCase from 'to-snake-case'; +import toSnakeCase from 'to-snake-case' -import type { BlockRowToInsert } from './types'; +import type { BlockRowToInsert } from './types' -import { traverseFields } from './traverseFields'; +import { traverseFields } from './traverseFields' type Args = { blocks: { @@ -28,11 +28,11 @@ export const transformBlocks = ({ tableName, }: Args) => { data.forEach((blockRow, i) => { - if (typeof blockRow.blockType !== 'string') return; - const matchedBlock = field.blocks.find(({ slug }) => slug === blockRow.blockType); - if (!matchedBlock) return; + if (typeof blockRow.blockType !== 'string') return + const matchedBlock = field.blocks.find(({ slug }) => slug === blockRow.blockType) + if (!matchedBlock) return - if (!blocks[blockRow.blockType]) blocks[blockRow.blockType] = []; + if (!blocks[blockRow.blockType]) blocks[blockRow.blockType] = [] const newRow: BlockRowToInsert = { arrays: {}, @@ -41,11 +41,11 @@ export const transformBlocks = ({ _order: i + 1, _path: `${path}${field.name}`, }, - }; + } - if (field.localized && locale) newRow.row._locale = locale; + if (field.localized && locale) newRow.row._locale = locale - const blockTableName = `${tableName}_${toSnakeCase(blockRow.blockType)}`; + const blockTableName = `${tableName}_${toSnakeCase(blockRow.blockType)}` traverseFields({ arrays: newRow.arrays, @@ -59,8 +59,8 @@ export const transformBlocks = ({ path: `${path || ''}${field.name}.${i}.`, relationships, row: newRow.row, - }); + }) - blocks[blockRow.blockType].push(newRow); - }); -}; + blocks[blockRow.blockType].push(newRow) + }) +} diff --git a/packages/db-postgres/src/transform/write/index.ts b/packages/db-postgres/src/transform/write/index.ts index fa4e92e89d..5783f889e8 100644 --- a/packages/db-postgres/src/transform/write/index.ts +++ b/packages/db-postgres/src/transform/write/index.ts @@ -1,10 +1,9 @@ /* eslint-disable no-param-reassign */ -import type { Field } from 'payload/types'; +import type { Field } from 'payload/types' -import type { RowToInsert } from './types'; - -import { traverseFields } from './traverseFields'; +import type { RowToInsert } from './types' +import { traverseFields } from './traverseFields' type Args = { data: Record @@ -13,12 +12,7 @@ type Args = { tableName: string } -export const transformForWrite = ({ - data, - fields, - path = '', - tableName, -}: Args): RowToInsert => { +export const transformForWrite = ({ data, fields, path = '', tableName }: Args): RowToInsert => { // Split out the incoming data into the corresponding: // base row, locales, relationships, blocks, and arrays const rowToInsert: RowToInsert = { @@ -27,7 +21,7 @@ export const transformForWrite = ({ locales: {}, relationships: [], row: {}, - }; + } // This function is responsible for building up the // above rowToInsert @@ -43,7 +37,7 @@ export const transformForWrite = ({ path, relationships: rowToInsert.relationships, row: rowToInsert.row, - }); + }) - return rowToInsert; -}; + return rowToInsert +} diff --git a/packages/db-postgres/src/transform/write/relationships.ts b/packages/db-postgres/src/transform/write/relationships.ts index 47f87572c6..b7c4e23eda 100644 --- a/packages/db-postgres/src/transform/write/relationships.ts +++ b/packages/db-postgres/src/transform/write/relationships.ts @@ -1,6 +1,6 @@ -import type { RelationshipField, UploadField } from 'payload/types'; +import type { RelationshipField, UploadField } from 'payload/types' -import { valueIsValueWithRelation } from 'payload/types'; +import { valueIsValueWithRelation } from 'payload/types' type Args = { baseRow: Record @@ -9,26 +9,21 @@ type Args = { relationships: Record[] } -export const transformRelationship = ({ - baseRow, - data, - field, - relationships, -}: Args) => { - const relations = Array.isArray(data) ? data : [data]; +export const transformRelationship = ({ baseRow, data, field, relationships }: Args) => { + const relations = Array.isArray(data) ? data : [data] relations.forEach((relation, i) => { if (relation) { - const relationRow = { ...baseRow }; - if ('hasMany' in field && field.hasMany) relationRow.order = i + 1; + const relationRow = { ...baseRow } + if ('hasMany' in field && field.hasMany) relationRow.order = i + 1 if (Array.isArray(field.relationTo) && valueIsValueWithRelation(relation)) { - relationRow[`${relation.relationTo}ID`] = relation.value; - relationships.push(relationRow); + relationRow[`${relation.relationTo}ID`] = relation.value + relationships.push(relationRow) } else { - relationRow[`${field.relationTo}ID`] = relation; - if (relation) relationships.push(relationRow); + relationRow[`${field.relationTo}ID`] = relation + if (relation) relationships.push(relationRow) } } - }); -}; + }) +} diff --git a/packages/db-postgres/src/transform/write/traverseFields.ts b/packages/db-postgres/src/transform/write/traverseFields.ts index c3f8871d23..7e5949ef42 100644 --- a/packages/db-postgres/src/transform/write/traverseFields.ts +++ b/packages/db-postgres/src/transform/write/traverseFields.ts @@ -324,26 +324,6 @@ export const traverseFields = ({ break } - case 'row': - case 'collapsible': { - traverseFields({ - adapter, - arrayRowPromises, - blockRows, - columnPrefix, - data, - fields: field.fields, - locale, - localeRow, - operation, - path, - relationshipRows, - row, - tableName, - }) - break - } - default: { break } diff --git a/packages/db-postgres/src/transform/write/types.ts b/packages/db-postgres/src/transform/write/types.ts index c7401a28f2..332eb57ba8 100644 --- a/packages/db-postgres/src/transform/write/types.ts +++ b/packages/db-postgres/src/transform/write/types.ts @@ -6,7 +6,7 @@ export type ArrayRowToInsert = { locales: { [locale: string]: Record } - row: Record, + row: Record } export type BlockRowToInsert = { @@ -16,7 +16,7 @@ export type BlockRowToInsert = { locales: { [locale: string]: Record } - row: Record, + row: Record } export type RowToInsert = { @@ -29,6 +29,6 @@ export type RowToInsert = { locales: { [locale: string]: Record } - relationships: Record[], - row: Record, + relationships: Record[] + row: Record } diff --git a/packages/db-postgres/src/types.ts b/packages/db-postgres/src/types.ts index 5c1ed11ace..da6fa08e11 100644 --- a/packages/db-postgres/src/types.ts +++ b/packages/db-postgres/src/types.ts @@ -1,14 +1,14 @@ -import type { ColumnBaseConfig, ColumnDataType, Relation, Relations } from 'drizzle-orm'; -import type { NodePgDatabase } from 'drizzle-orm/node-postgres'; -import type { PgColumn, PgEnum, PgTableWithColumns } from 'drizzle-orm/pg-core'; -import type { DatabaseAdapter, Payload } from 'payload'; -import type { ClientConfig, PoolConfig } from 'pg'; +import type { ColumnBaseConfig, ColumnDataType, Relation, Relations } from 'drizzle-orm' +import type { NodePgDatabase } from 'drizzle-orm/node-postgres' +import type { PgColumn, PgEnum, PgTableWithColumns } from 'drizzle-orm/pg-core' +import type { DatabaseAdapter, Payload } from 'payload' +import type { ClientConfig, PoolConfig } from 'pg' export type DrizzleDB = NodePgDatabase> type BaseArgs = { - migrationDir?: string; - migrationName?: string; + migrationDir?: string + migrationName?: string } type ClientArgs = { @@ -23,27 +23,34 @@ type PoolArgs = { export type Args = ClientArgs | PoolArgs -export type GenericColumn = PgColumn, Record> +export type GenericColumn = PgColumn< + ColumnBaseConfig, + Record +> export type GenericColumns = { [x: string]: GenericColumn } export type GenericTable = PgTableWithColumns<{ - columns: GenericColumns, dialect: string, name: string, schema: undefined + columns: GenericColumns + dialect: string + name: string + schema: undefined }> export type GenericEnum = PgEnum<[string, ...string[]]> export type GenericRelation = Relations>> -export type PostgresAdapter = DatabaseAdapter & Args & { - db: DrizzleDB - enums: Record - relations: Record - schema: Record - sessions: Record - tables: Record -} +export type PostgresAdapter = DatabaseAdapter & + Args & { + db: DrizzleDB + enums: Record + relations: Record + schema: Record + sessions: Record + tables: Record + } export type PostgresAdapterResult = (args: { payload: Payload }) => PostgresAdapter diff --git a/packages/db-postgres/src/updateGlobal.ts b/packages/db-postgres/src/updateGlobal.ts index f932036adc..69d37f96c0 100644 --- a/packages/db-postgres/src/updateGlobal.ts +++ b/packages/db-postgres/src/updateGlobal.ts @@ -1,31 +1,31 @@ -import type { UpdateGlobal } from 'payload/database'; -import type { PayloadRequest } from 'payload/types'; +import type { UpdateGlobal } from 'payload/database' +import type { PayloadRequest } from 'payload/types' -import toSnakeCase from 'to-snake-case'; +import toSnakeCase from 'to-snake-case' -import type { PostgresAdapter } from './types'; +import type { PostgresAdapter } from './types' -import { upsertRow } from './upsertRow'; +import { upsertRow } from './upsertRow' export const updateGlobal: UpdateGlobal = async function updateGlobal( this: PostgresAdapter, { data, req = {} as PayloadRequest, slug }, ) { - const db = req.transactionID ? this.sessions[req.transactionID] : this.db; - const globalConfig = this.payload.globals.config.find((config) => config.slug === slug); - const tableName = toSnakeCase(slug); + const db = req.transactionID ? this.sessions[req.transactionID] : this.db + const globalConfig = this.payload.globals.config.find((config) => config.slug === slug) + const tableName = toSnakeCase(slug) - const existingGlobal = await this.db.query[tableName].findFirst({}); + const existingGlobal = await this.db.query[tableName].findFirst({}) const result = await upsertRow({ + id: existingGlobal.id, adapter: this, data, db, fields: globalConfig.fields, - id: existingGlobal.id, operation: 'update', tableName: toSnakeCase(slug), - }); + }) - return result; -}; + return result +} diff --git a/packages/db-postgres/src/upsertRow/deleteExistingArrayRows.ts b/packages/db-postgres/src/upsertRow/deleteExistingArrayRows.ts index bc9d2646dc..d67140ec62 100644 --- a/packages/db-postgres/src/upsertRow/deleteExistingArrayRows.ts +++ b/packages/db-postgres/src/upsertRow/deleteExistingArrayRows.ts @@ -1,5 +1,6 @@ -import { and, eq } from 'drizzle-orm'; -import { PostgresAdapter } from '../types'; +import { and, eq } from 'drizzle-orm' + +import type { PostgresAdapter } from '../types' type Args = { adapter: PostgresAdapter @@ -13,14 +14,9 @@ export const deleteExistingArrayRows = async ({ parentID, tableName, }: Args): Promise => { - const table = adapter.tables[tableName]; + const table = adapter.tables[tableName] - const whereConstraints = [ - eq(table._parentID, parentID), - ]; + const whereConstraints = [eq(table._parentID, parentID)] - await adapter.db.delete(table) - .where( - and(...whereConstraints), - ); -}; + await adapter.db.delete(table).where(and(...whereConstraints)) +} diff --git a/packages/db-postgres/src/upsertRow/deleteExistingRowsByPath.ts b/packages/db-postgres/src/upsertRow/deleteExistingRowsByPath.ts index de6f917079..b3b3134450 100644 --- a/packages/db-postgres/src/upsertRow/deleteExistingRowsByPath.ts +++ b/packages/db-postgres/src/upsertRow/deleteExistingRowsByPath.ts @@ -1,64 +1,57 @@ -import { and, eq, inArray } from 'drizzle-orm'; -import { PostgresAdapter } from '../types'; +import { and, eq, inArray } from 'drizzle-orm' + +import type { PostgresAdapter } from '../types' type Args = { adapter: PostgresAdapter localeColumnName?: string + newRows: Record[] parentColumnName?: string parentID: unknown pathColumnName?: string - newRows: Record[] tableName: string } export const deleteExistingRowsByPath = async ({ adapter, localeColumnName = '_locale', + newRows, parentColumnName = '_parentID', parentID, pathColumnName = '_path', - newRows, tableName, }: Args): Promise => { - const localizedPathsToDelete = new Set(); - const pathsToDelete = new Set(); - const table = adapter.tables[tableName]; + const localizedPathsToDelete = new Set() + const pathsToDelete = new Set() + const table = adapter.tables[tableName] newRows.forEach((row) => { - const path = row[pathColumnName]; - const localeData = row[localeColumnName]; + const path = row[pathColumnName] + const localeData = row[localeColumnName] if (typeof path === 'string') { if (typeof localeData === 'string') { - localizedPathsToDelete.add(path); + localizedPathsToDelete.add(path) } else { - pathsToDelete.add(path); + pathsToDelete.add(path) } } - }); + }) if (localizedPathsToDelete.size > 0) { - const whereConstraints = [ - eq(table[parentColumnName], parentID), - ]; + const whereConstraints = [eq(table[parentColumnName], parentID)] - if (pathColumnName) whereConstraints.push(inArray(table[pathColumnName], Array.from(localizedPathsToDelete))); + if (pathColumnName) + whereConstraints.push(inArray(table[pathColumnName], Array.from(localizedPathsToDelete))) - await adapter.db.delete(table) - .where( - and(...whereConstraints), - ); + await adapter.db.delete(table).where(and(...whereConstraints)) } if (pathsToDelete.size > 0) { - const whereConstraints = [ - eq(table[parentColumnName], parentID), - ]; + const whereConstraints = [eq(table[parentColumnName], parentID)] - if (pathColumnName) whereConstraints.push(inArray(table[pathColumnName], Array.from(pathsToDelete))); + if (pathColumnName) + whereConstraints.push(inArray(table[pathColumnName], Array.from(pathsToDelete))) - await adapter.db.delete(table) - .where( - and(...whereConstraints), - ); + await adapter.db.delete(table).where(and(...whereConstraints)) } -}; +} diff --git a/packages/db-postgres/src/upsertRow/index.ts b/packages/db-postgres/src/upsertRow/index.ts index 90cabbf7ca..76904025a8 100644 --- a/packages/db-postgres/src/upsertRow/index.ts +++ b/packages/db-postgres/src/upsertRow/index.ts @@ -1,22 +1,22 @@ /* eslint-disable no-param-reassign */ -import { eq } from 'drizzle-orm'; +import { eq } from 'drizzle-orm' -import type { BlockRowToInsert } from '../transform/write/types'; -import type { Args } from './types'; +import type { BlockRowToInsert } from '../transform/write/types' +import type { Args } from './types' -import { buildFindManyArgs } from '../find/buildFindManyArgs'; -import { transform } from '../transform/read'; -import { transformForWrite } from '../transform/write'; -import { deleteExistingArrayRows } from './deleteExistingArrayRows'; -import { deleteExistingRowsByPath } from './deleteExistingRowsByPath'; -import { insertArrays } from './insertArrays'; +import { buildFindManyArgs } from '../find/buildFindManyArgs' +import { transform } from '../transform/read' +import { transformForWrite } from '../transform/write' +import { deleteExistingArrayRows } from './deleteExistingArrayRows' +import { deleteExistingRowsByPath } from './deleteExistingRowsByPath' +import { insertArrays } from './insertArrays' export const upsertRow = async ({ + id, adapter, data, db, fields, - id, operation, path = '', tableName, @@ -30,80 +30,81 @@ export const upsertRow = async ({ fields, path, tableName, - }); + }) // First, we insert the main row - let insertedRow: Record; + let insertedRow: Record if (operation === 'update') { - const target = upsertTarget || adapter.tables[tableName].id; + const target = upsertTarget || adapter.tables[tableName].id if (id) { - rowToInsert.row.id = id; - [insertedRow] = await db.insert(adapter.tables[tableName]) + rowToInsert.row.id = id + ;[insertedRow] = await db + .insert(adapter.tables[tableName]) .values(rowToInsert.row) .onConflictDoUpdate({ set: rowToInsert.row, target }) - .returning(); + .returning() } else { - [insertedRow] = await db.insert(adapter.tables[tableName]) + ;[insertedRow] = await db + .insert(adapter.tables[tableName]) .values(rowToInsert.row) .onConflictDoUpdate({ set: rowToInsert.row, target, where }) - .returning(); + .returning() } } else { - [insertedRow] = await db.insert(adapter.tables[tableName]) - .values(rowToInsert.row).returning(); + ;[insertedRow] = await db.insert(adapter.tables[tableName]).values(rowToInsert.row).returning() } - const localesToInsert: Record[] = []; - const relationsToInsert: Record[] = []; - const blocksToInsert: { [blockType: string]: BlockRowToInsert[] } = {}; + const localesToInsert: Record[] = [] + const relationsToInsert: Record[] = [] + const blocksToInsert: { [blockType: string]: BlockRowToInsert[] } = {} // Maintain a list of promises to run locale, blocks, and relationships // all in parallel - const promises = []; + const promises = [] // If there are locale rows with data, add the parent and locale to each if (Object.keys(rowToInsert.locales).length > 0) { Object.entries(rowToInsert.locales).forEach(([locale, localeRow]) => { - localeRow._parentID = insertedRow.id; - localeRow._locale = locale; - localesToInsert.push(localeRow); - }); + localeRow._parentID = insertedRow.id + localeRow._locale = locale + localesToInsert.push(localeRow) + }) } // If there are relationships, add parent to each if (rowToInsert.relationships.length > 0) { rowToInsert.relationships.forEach((relation) => { - relation.parent = insertedRow.id; - relationsToInsert.push(relation); - }); + relation.parent = insertedRow.id + relationsToInsert.push(relation) + }) } // If there are blocks, add parent to each, and then // store by table name and rows Object.keys(rowToInsert.blocks).forEach((blockName) => { rowToInsert.blocks[blockName].forEach((blockRow) => { - blockRow.row._parentID = insertedRow.id; - if (!blocksToInsert[blockName]) blocksToInsert[blockName] = []; - blocksToInsert[blockName].push(blockRow); - }); - }); + blockRow.row._parentID = insertedRow.id + if (!blocksToInsert[blockName]) blocksToInsert[blockName] = [] + blocksToInsert[blockName].push(blockRow) + }) + }) // ////////////////////////////////// // INSERT LOCALES // ////////////////////////////////// if (localesToInsert.length > 0) { - const localeTable = adapter.tables[`${tableName}_locales`]; + const localeTable = adapter.tables[`${tableName}_locales`] promises.push(async () => { if (operation === 'update') { - await db.delete(localeTable).where(eq(localeTable._parentID, insertedRow.id)); + await db.delete(localeTable).where(eq(localeTable._parentID, insertedRow.id)) } - await db.insert(localeTable).values(localesToInsert); - }); + await db.insert(localeTable).values(localesToInsert) + }) } // ////////////////////////////////// @@ -112,7 +113,7 @@ export const upsertRow = async ({ if (relationsToInsert.length > 0) { promises.push(async () => { - const relationshipsTableName = `${tableName}_relationships`; + const relationshipsTableName = `${tableName}_relationships` if (operation === 'update') { await deleteExistingRowsByPath({ adapter, @@ -122,19 +123,18 @@ export const upsertRow = async ({ parentID: insertedRow.id, pathColumnName: 'path', tableName: relationshipsTableName, - }); + }) } - await db.insert(adapter.tables[relationshipsTableName]) - .values(relationsToInsert).returning(); - }); + await db.insert(adapter.tables[relationshipsTableName]).values(relationsToInsert).returning() + }) } // ////////////////////////////////// // INSERT BLOCKS // ////////////////////////////////// - const insertedBlockRows: Record[]> = {}; + const insertedBlockRows: Record[]> = {} Object.entries(blocksToInsert).forEach(([blockName, blockRows]) => { // For each block, push insert into promises to run parallel @@ -146,45 +146,49 @@ export const upsertRow = async ({ parentID: insertedRow.id, pathColumnName: '_path', tableName: `${tableName}_${blockName}`, - }); + }) } - insertedBlockRows[blockName] = await db.insert(adapter.tables[`${tableName}_${blockName}`]) - .values(blockRows.map(({ row }) => row)).returning(); + insertedBlockRows[blockName] = await db + .insert(adapter.tables[`${tableName}_${blockName}`]) + .values(blockRows.map(({ row }) => row)) + .returning() insertedBlockRows[blockName].forEach((row, i) => { - blockRows[i].row = row; - }); + blockRows[i].row = row + }) - const blockLocaleIndexMap: number[] = []; + const blockLocaleIndexMap: number[] = [] const blockLocaleRowsToInsert = blockRows.reduce((acc, blockRow, i) => { if (Object.entries(blockRow.locales).length > 0) { Object.entries(blockRow.locales).forEach(([blockLocale, blockLocaleData]) => { if (Object.keys(blockLocaleData).length > 0) { - blockLocaleData._parentID = blockRow.row.id; - blockLocaleData._locale = blockLocale; - acc.push(blockLocaleData); - blockLocaleIndexMap.push(i); + blockLocaleData._parentID = blockRow.row.id + blockLocaleData._locale = blockLocale + acc.push(blockLocaleData) + blockLocaleIndexMap.push(i) } - }); + }) } - return acc; - }, []); + return acc + }, []) if (blockLocaleRowsToInsert.length > 0) { - await db.insert(adapter.tables[`${tableName}_${blockName}_locales`]) - .values(blockLocaleRowsToInsert).returning(); + await db + .insert(adapter.tables[`${tableName}_${blockName}_locales`]) + .values(blockLocaleRowsToInsert) + .returning() } await insertArrays({ adapter, arrays: blockRows.map(({ arrays }) => arrays), parentRows: insertedBlockRows[blockName], - }); - }); - }); + }) + }) + }) // ////////////////////////////////// // INSERT ARRAYS RECURSIVELY @@ -192,23 +196,25 @@ export const upsertRow = async ({ promises.push(async () => { if (operation === 'update') { - await Promise.all(Object.entries(rowToInsert.arrays).map(async ([arrayTableName, tableRows]) => { - await deleteExistingArrayRows({ - adapter, - parentID: insertedRow.id, - tableName: arrayTableName, - }); - })); + await Promise.all( + Object.entries(rowToInsert.arrays).map(async ([arrayTableName, tableRows]) => { + await deleteExistingArrayRows({ + adapter, + parentID: insertedRow.id, + tableName: arrayTableName, + }) + }), + ) } await insertArrays({ adapter, arrays: [rowToInsert.arrays], parentRows: [insertedRow], - }); - }); + }) + }) - await Promise.all(promises.map((promise) => promise())); + await Promise.all(promises.map((promise) => promise())) // ////////////////////////////////// // RETRIEVE NEWLY UPDATED ROW @@ -219,11 +225,11 @@ export const upsertRow = async ({ depth: 0, fields, tableName, - }); + }) - findManyArgs.where = eq(adapter.tables[tableName].id, insertedRow.id); + findManyArgs.where = eq(adapter.tables[tableName].id, insertedRow.id) - const doc = await db.query[tableName].findFirst(findManyArgs); + const doc = await db.query[tableName].findFirst(findManyArgs) // ////////////////////////////////// // TRANSFORM DATA @@ -233,7 +239,7 @@ export const upsertRow = async ({ config: adapter.payload.config, data: doc, fields, - }); + }) - return result; -}; + return result +} diff --git a/packages/db-postgres/src/upsertRow/insertArrays.ts b/packages/db-postgres/src/upsertRow/insertArrays.ts index 89bc1181da..4e836b2d12 100644 --- a/packages/db-postgres/src/upsertRow/insertArrays.ts +++ b/packages/db-postgres/src/upsertRow/insertArrays.ts @@ -1,6 +1,6 @@ /* eslint-disable no-param-reassign */ -import { PostgresAdapter } from '../types'; -import { ArrayRowToInsert } from '../transform/write/types'; +import type { ArrayRowToInsert } from '../transform/write/types' +import type { PostgresAdapter } from '../types' type Args = { adapter: PostgresAdapter @@ -20,13 +20,9 @@ type RowsByTable = { } } -export const insertArrays = async ({ - adapter, - arrays, - parentRows, -}: Args): Promise => { +export const insertArrays = async ({ adapter, arrays, parentRows }: Args): Promise => { // Maintain a map of flattened rows by table - const rowsByTable: RowsByTable = {}; + const rowsByTable: RowsByTable = {} arrays.forEach((arraysByTable, parentRowIndex) => { Object.entries(arraysByTable).forEach(([tableName, arrayRows]) => { @@ -36,52 +32,53 @@ export const insertArrays = async ({ arrays: [], locales: [], rows: [], - }; + } } - const parentID = parentRows[parentRowIndex].id; + const parentID = parentRows[parentRowIndex].id // Add any sub arrays that need to be created // We will call this recursively below arrayRows.forEach((arrayRow) => { if (Object.keys(arrayRow.arrays).length > 0) { - rowsByTable[tableName].arrays.push(arrayRow.arrays); + rowsByTable[tableName].arrays.push(arrayRow.arrays) } // Set up parent IDs for both row and locale row - arrayRow.row._parentID = parentID; - rowsByTable[tableName].rows.push(arrayRow.row); + arrayRow.row._parentID = parentID + rowsByTable[tableName].rows.push(arrayRow.row) Object.entries(arrayRow.locales).forEach(([arrayRowLocale, arrayRowLocaleData]) => { - arrayRowLocaleData._parentID = arrayRow.row.id; - arrayRowLocaleData._locale = arrayRowLocale; - rowsByTable[tableName].locales.push(arrayRowLocaleData); - }); - }); - }); - }); + arrayRowLocaleData._parentID = arrayRow.row.id + arrayRowLocaleData._locale = arrayRowLocale + rowsByTable[tableName].locales.push(arrayRowLocaleData) + }) + }) + }) + }) // Insert all corresponding arrays in parallel // (one insert per array table) - await Promise.all(Object.entries(rowsByTable).map(async ( - [tableName, row], - ) => { - await adapter.db.insert(adapter.tables[tableName]) - .values(row.rows).returning(); + await Promise.all( + Object.entries(rowsByTable).map(async ([tableName, row]) => { + await adapter.db.insert(adapter.tables[tableName]).values(row.rows).returning() - // Insert locale rows - if (adapter.tables[`${tableName}_locales`]) { - await adapter.db.insert(adapter.tables[`${tableName}_locales`]) - .values(row.locales).returning(); - } + // Insert locale rows + if (adapter.tables[`${tableName}_locales`]) { + await adapter.db + .insert(adapter.tables[`${tableName}_locales`]) + .values(row.locales) + .returning() + } - // If there are sub arrays, call this function recursively - if (row.arrays.length > 0) { - await insertArrays({ - adapter, - arrays: row.arrays, - parentRows: row.rows, - }); - } - })); -}; + // If there are sub arrays, call this function recursively + if (row.arrays.length > 0) { + await insertArrays({ + adapter, + arrays: row.arrays, + parentRows: row.rows, + }) + } + }), + ) +} diff --git a/packages/db-postgres/src/upsertRow/types.ts b/packages/db-postgres/src/upsertRow/types.ts index 86ea8fabed..0fd582e16c 100644 --- a/packages/db-postgres/src/upsertRow/types.ts +++ b/packages/db-postgres/src/upsertRow/types.ts @@ -1,8 +1,8 @@ -import type { SQL } from 'drizzle-orm'; -import type { Field } from 'payload/types'; +import type { SQL } from 'drizzle-orm' +import type { Field } from 'payload/types' -import type { GenericColumn, PostgresAdapter } from '../types'; -import type { DrizzleDB } from '../types'; +import type { GenericColumn, PostgresAdapter } from '../types' +import type { DrizzleDB } from '../types' type BaseArgs = { adapter: PostgresAdapter diff --git a/packages/db-postgres/src/utilities/createBlocksMap.ts b/packages/db-postgres/src/utilities/createBlocksMap.ts index 44366c4fec..e64d145983 100644 --- a/packages/db-postgres/src/utilities/createBlocksMap.ts +++ b/packages/db-postgres/src/utilities/createBlocksMap.ts @@ -4,38 +4,38 @@ export type BlocksMap = { } export const createBlocksMap = (data: Record): BlocksMap => { - const blocksMap: BlocksMap = {}; + const blocksMap: BlocksMap = {} Object.entries(data).forEach(([key, rows]) => { if (key.startsWith('_blocks_') && Array.isArray(rows)) { - const blockType = key.replace('_blocks_', ''); + const blockType = key.replace('_blocks_', '') rows.forEach((row) => { if ('_path' in row) { - if (!(row._path in blocksMap)) blocksMap[row._path] = []; + if (!(row._path in blocksMap)) blocksMap[row._path] = [] - row.blockType = blockType; - blocksMap[row._path].push(row); + row.blockType = blockType + blocksMap[row._path].push(row) - delete row._path; + delete row._path } - }); + }) - delete data[key]; + delete data[key] } - }); + }) Object.entries(blocksMap).reduce((sortedBlocksMap, [path, blocks]) => { sortedBlocksMap[path] = blocks.sort((a, b) => { if (typeof a._order === 'number' && typeof b._order === 'number') { - return a._order - b._order; + return a._order - b._order } - return 0; - }); + return 0 + }) - return sortedBlocksMap; - }, {}); + return sortedBlocksMap + }, {}) - return blocksMap; -}; + return blocksMap +} diff --git a/packages/db-postgres/src/utilities/createRelationshipMap.ts b/packages/db-postgres/src/utilities/createRelationshipMap.ts index e2f1cca16a..2ea7b27662 100644 --- a/packages/db-postgres/src/utilities/createRelationshipMap.ts +++ b/packages/db-postgres/src/utilities/createRelationshipMap.ts @@ -1,22 +1,24 @@ // Flatten relationships to object with path keys // for easier retrieval -export const createRelationshipMap = (rawRelationships: unknown): Record[]> => { - let relationships = {}; +export const createRelationshipMap = ( + rawRelationships: unknown, +): Record[]> => { + let relationships = {} if (Array.isArray(rawRelationships)) { relationships = rawRelationships.reduce((res, relation) => { const formattedRelation = { ...relation, - }; + } - delete formattedRelation.path; + delete formattedRelation.path - if (!res[relation.path]) res[relation.path] = []; - res[relation.path].push(formattedRelation); + if (!res[relation.path]) res[relation.path] = [] + res[relation.path].push(formattedRelation) - return res; - }, {}); + return res + }, {}) } - return relationships; -}; + return relationships +} diff --git a/packages/db-postgres/src/utilities/hasLocalesTable.ts b/packages/db-postgres/src/utilities/hasLocalesTable.ts index 18f2e42dd7..ef49631246 100644 --- a/packages/db-postgres/src/utilities/hasLocalesTable.ts +++ b/packages/db-postgres/src/utilities/hasLocalesTable.ts @@ -1,12 +1,12 @@ -import type { Field} from 'payload/types'; +import type { Field } from 'payload/types' -import { fieldAffectsData, fieldHasSubFields } from 'payload/types'; +import { fieldAffectsData, fieldHasSubFields } from 'payload/types' export const hasLocalesTable = (fields: Field[]): boolean => { return fields.some((field) => { - if (fieldAffectsData(field) && field.localized) return true; - if (fieldHasSubFields(field) && field.type !== 'array') return hasLocalesTable(field.fields); - if (field.type === 'tabs') return field.tabs.some((tab) => hasLocalesTable(tab.fields)); - return false; - }); -}; + if (fieldAffectsData(field) && field.localized) return true + if (fieldHasSubFields(field) && field.type !== 'array') return hasLocalesTable(field.fields) + if (field.type === 'tabs') return field.tabs.some((tab) => hasLocalesTable(tab.fields)) + return false + }) +} diff --git a/packages/db-postgres/src/utilities/isArrayOfRows.ts b/packages/db-postgres/src/utilities/isArrayOfRows.ts index 3390d67739..ef8528bfab 100644 --- a/packages/db-postgres/src/utilities/isArrayOfRows.ts +++ b/packages/db-postgres/src/utilities/isArrayOfRows.ts @@ -1,3 +1,3 @@ export function isArrayOfRows(data: unknown): data is Record[] { - return Array.isArray(data); + return Array.isArray(data) } diff --git a/packages/eslint-config-payload/package.json b/packages/eslint-config-payload/package.json index de42b1976b..cb00f21338 100644 --- a/packages/eslint-config-payload/package.json +++ b/packages/eslint-config-payload/package.json @@ -3,6 +3,12 @@ "version": "0.0.1", "private": true, "description": "Payload styles for ESLint and Prettier", + "license": "MIT", + "author": { + "email": "info@payloadcms.com", + "name": "Payload", + "url": "https://payloadcms.com" + }, "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" @@ -24,7 +30,5 @@ "eslint-plugin-react-hooks": "4.6.0", "eslint-plugin-regexp": "1.15.0" }, - "keywords": [], - "author": "", - "license": "MIT" + "keywords": [] } diff --git a/packages/payload/.eslintrc.cjs b/packages/payload/.eslintrc.cjs index 70f9d200ec..e28b97e4b6 100644 --- a/packages/payload/.eslintrc.cjs +++ b/packages/payload/.eslintrc.cjs @@ -27,6 +27,28 @@ module.exports = { 'jest/expect-expect': 'off', }, }, + { + files: ['package.json', 'tsconfig.json'], + rules: { + 'perfectionist/sort-array-includes': 'off', + 'perfectionist/sort-astro-attributes': 'off', + 'perfectionist/sort-classes': 'off', + 'perfectionist/sort-enums': 'off', + 'perfectionist/sort-exports': 'off', + 'perfectionist/sort-imports': 'off', + 'perfectionist/sort-interfaces': 'off', + 'perfectionist/sort-jsx-props': 'off', + 'perfectionist/sort-keys': 'off', + 'perfectionist/sort-maps': 'off', + 'perfectionist/sort-named-exports': 'off', + 'perfectionist/sort-named-imports': 'off', + 'perfectionist/sort-object-types': 'off', + 'perfectionist/sort-objects': 'off', + 'perfectionist/sort-svelte-attributes': 'off', + 'perfectionist/sort-union-types': 'off', + 'perfectionist/sort-vue-attributes': 'off', + }, + }, ], parserOptions: { project: ['./tsconfig.json'], diff --git a/packages/payload/auth.d.ts b/packages/payload/auth.d.ts index 86d16a82ef..e173302b6c 100644 --- a/packages/payload/auth.d.ts +++ b/packages/payload/auth.d.ts @@ -1,2 +1,2 @@ -export * from './dist/auth'; -//# sourceMappingURL=auth.d.ts.map \ No newline at end of file +export * from './dist/auth' +//# sourceMappingURL=auth.d.ts.map diff --git a/packages/payload/auth.js b/packages/payload/auth.js index f271d615ec..e915cb9846 100644 --- a/packages/payload/auth.js +++ b/packages/payload/auth.js @@ -1,20 +1,20 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { - value: true -}); -_export_star(require("./dist/auth"), exports); +'use strict' +Object.defineProperty(exports, '__esModule', { + value: true, +}) +_export_star(require('./dist/auth'), exports) function _export_star(from, to) { - Object.keys(from).forEach(function(k) { - if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) { - Object.defineProperty(to, k, { - enumerable: true, - get: function() { - return from[k]; - } - }); - } - }); - return from; + Object.keys(from).forEach(function (k) { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(to, k)) { + Object.defineProperty(to, k, { + enumerable: true, + get: function () { + return from[k] + }, + }) + } + }) + return from } -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9leHBvcnRzL2F1dGgudHMiXSwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0ICogZnJvbSAnLi4vYXV0aCdcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7O3FCQUFjIn0= \ No newline at end of file +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9leHBvcnRzL2F1dGgudHMiXSwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0ICogZnJvbSAnLi4vYXV0aCdcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7O3FCQUFjIn0= diff --git a/packages/payload/components.d.ts b/packages/payload/components.d.ts index 7c41320cb6..eac0f1ceaa 100644 --- a/packages/payload/components.d.ts +++ b/packages/payload/components.d.ts @@ -1,11 +1,13 @@ -export { default as Banner } from './dist/admin/components/elements/Banner'; -export { default as Button } from './dist/admin/components/elements/Button'; -export { default as Pill } from './dist/admin/components/elements/Pill'; -export { default as Popup } from './dist/admin/components/elements/Popup'; -export { default as Check } from './dist/admin/components/icons/Check'; -export { default as Chevron } from './dist/admin/components/icons/Chevron'; -export { default as Menu } from './dist/admin/components/icons/Menu'; -export { default as Search } from './dist/admin/components/icons/Search'; -export { default as X } from './dist/admin/components/icons/X'; -export { default as MinimalTemplate } from './dist/admin/components/templates/Minimal'; -//# sourceMappingURL=components.d.ts.map \ No newline at end of file +export { default as Banner } from './dist/admin/components/elements/Banner' +export { default as Button } from './dist/admin/components/elements/Button' +export { default as Pill } from './dist/admin/components/elements/Pill' +export { default as Popup } from './dist/admin/components/elements/Popup' +export { ShimmerEffect } from './dist/admin/components/elements/ShimmerEffect' +export { default as Tooltip } from './dist/admin/components/elements/Tooltip' +export { default as Check } from './dist/admin/components/icons/Check' +export { default as Chevron } from './dist/admin/components/icons/Chevron' +export { default as Menu } from './dist/admin/components/icons/Menu' +export { default as Search } from './dist/admin/components/icons/Search' +export { default as X } from './dist/admin/components/icons/X' +export { default as MinimalTemplate } from './dist/admin/components/templates/Minimal' +//# sourceMappingURL=components.d.ts.map diff --git a/packages/payload/components.js b/packages/payload/components.js index ac8bf714f2..61d89a576e 100644 --- a/packages/payload/components.js +++ b/packages/payload/components.js @@ -1,59 +1,88 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { - value: true -}); +'use strict' +Object.defineProperty(exports, '__esModule', { + value: true, +}) function _export(target, all) { - for(var name in all)Object.defineProperty(target, name, { - enumerable: true, - get: all[name] - }); + for (var name in all) + Object.defineProperty(target, name, { + enumerable: true, + get: all[name], + }) } _export(exports, { - Banner: function() { - return _Banner.default; - }, - Button: function() { - return _Button.default; - }, - Pill: function() { - return _Pill.default; - }, - Popup: function() { - return _Popup.default; - }, - Check: function() { - return _Check.default; - }, - Chevron: function() { - return _Chevron.default; - }, - Menu: function() { - return _Menu.default; - }, - Search: function() { - return _Search.default; - }, - X: function() { - return _X.default; - }, - MinimalTemplate: function() { - return _Minimal.default; - } -}); -const _Banner = /*#__PURE__*/ _interop_require_default(require("./dist/admin/components/elements/Banner")); -const _Button = /*#__PURE__*/ _interop_require_default(require("./dist/admin/components/elements/Button")); -const _Pill = /*#__PURE__*/ _interop_require_default(require("./dist/admin/components/elements/Pill")); -const _Popup = /*#__PURE__*/ _interop_require_default(require("./dist/admin/components/elements/Popup")); -const _Check = /*#__PURE__*/ _interop_require_default(require("./dist/admin/components/icons/Check")); -const _Chevron = /*#__PURE__*/ _interop_require_default(require("./dist/admin/components/icons/Chevron")); -const _Menu = /*#__PURE__*/ _interop_require_default(require("./dist/admin/components/icons/Menu")); -const _Search = /*#__PURE__*/ _interop_require_default(require("./dist/admin/components/icons/Search")); -const _X = /*#__PURE__*/ _interop_require_default(require("./dist/admin/components/icons/X")); -const _Minimal = /*#__PURE__*/ _interop_require_default(require("./dist/admin/components/templates/Minimal")); + Banner: function () { + return _Banner.default + }, + Button: function () { + return _Button.default + }, + Check: function () { + return _Check.default + }, + Chevron: function () { + return _Chevron.default + }, + Menu: function () { + return _Menu.default + }, + MinimalTemplate: function () { + return _Minimal.default + }, + Pill: function () { + return _Pill.default + }, + Popup: function () { + return _Popup.default + }, + Search: function () { + return _Search.default + }, + ShimmerEffect: function () { + return _ShimmerEffect.ShimmerEffect + }, + Tooltip: function () { + return _Tooltip.default + }, + X: function () { + return _X.default + }, +}) +const _Banner = /*#__PURE__*/ _interop_require_default( + require('./dist/admin/components/elements/Banner'), +) +const _Button = /*#__PURE__*/ _interop_require_default( + require('./dist/admin/components/elements/Button'), +) +const _Pill = /*#__PURE__*/ _interop_require_default( + require('./dist/admin/components/elements/Pill'), +) +const _Popup = /*#__PURE__*/ _interop_require_default( + require('./dist/admin/components/elements/Popup'), +) +const _ShimmerEffect = require('./dist/admin/components/elements/ShimmerEffect') +const _Tooltip = /*#__PURE__*/ _interop_require_default( + require('./dist/admin/components/elements/Tooltip'), +) +const _Check = /*#__PURE__*/ _interop_require_default( + require('./dist/admin/components/icons/Check'), +) +const _Chevron = /*#__PURE__*/ _interop_require_default( + require('./dist/admin/components/icons/Chevron'), +) +const _Menu = /*#__PURE__*/ _interop_require_default(require('./dist/admin/components/icons/Menu')) +const _Search = /*#__PURE__*/ _interop_require_default( + require('./dist/admin/components/icons/Search'), +) +const _X = /*#__PURE__*/ _interop_require_default(require('./dist/admin/components/icons/X')) +const _Minimal = /*#__PURE__*/ _interop_require_default( + require('./dist/admin/components/templates/Minimal'), +) function _interop_require_default(obj) { - return obj && obj.__esModule ? obj : { - default: obj - }; + return obj && obj.__esModule + ? obj + : { + default: obj, + } } -//# sourceMappingURL=data:application/json;base64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0lBRUpDLEtBQUs7ZUFBTEEsY0FBSzs7SUFFaEJDLGFBQWE7ZUFBYkEsNEJBQWE7O0lBQ0ZDLE9BQU87ZUFBUEEsZ0JBQU87O0lBQ1BDLEtBQUs7ZUFBTEEsY0FBSzs7SUFDTEMsT0FBTztlQUFQQSxnQkFBTzs7SUFDUEMsSUFBSTtlQUFKQSxhQUFJOztJQUNKQyxNQUFNO2VBQU5BLGVBQU07O0lBQ05DLENBQUM7ZUFBREEsVUFBQzs7SUFDREMsZUFBZTtlQUFmQSxnQkFBZTs7OytEQWREOytEQUNBOzZEQUVGOzhEQUVDOytCQUVIO2dFQUNLOzhEQUNGO2dFQUNFOzZEQUNIOytEQUNFOzBEQUNMO2dFQUNjIn0= diff --git a/packages/payload/components/elements.d.ts b/packages/payload/components/elements.d.ts index cdff7846d6..2d78afeb9f 100644 --- a/packages/payload/components/elements.d.ts +++ b/packages/payload/components/elements.d.ts @@ -1,6 +1,21 @@ -export { default as Button } from '../dist/admin/components/elements/Button'; -export { default as Card } from '../dist/admin/components/elements/Card'; -export { default as Eyebrow } from '../dist/admin/components/elements/Eyebrow'; -export { Gutter } from '../dist/admin/components/elements/Gutter'; -export { default as Nav } from '../dist/admin/components/elements/Nav'; -//# sourceMappingURL=elements.d.ts.map \ No newline at end of file +export { default as Button } from '../dist/admin/components/elements/Button' +export { default as Card } from '../dist/admin/components/elements/Card' +export { + DocumentDrawer, + DocumentDrawerToggler, + baseClass as DocumentDrawerBaseClass, + useDocumentDrawer, +} from '../dist/admin/components/elements/DocumentDrawer' +export { Drawer, DrawerToggler, formatDrawerSlug } from '../dist/admin/components/elements/Drawer' +export { useDrawerSlug } from '../dist/admin/components/elements/Drawer/useDrawerSlug' +export { default as Eyebrow } from '../dist/admin/components/elements/Eyebrow' +export { Gutter } from '../dist/admin/components/elements/Gutter' +export { + ListDrawer, + ListDrawerToggler, + baseClass as ListDrawerBaseClass, + formatListDrawerSlug, + useListDrawer, +} from '../dist/admin/components/elements/ListDrawer' +export { default as Nav } from '../dist/admin/components/elements/Nav' +//# sourceMappingURL=elements.d.ts.map diff --git a/packages/payload/components/elements.js b/packages/payload/components/elements.js index c15b726bed..a0c7205f3b 100644 --- a/packages/payload/components/elements.js +++ b/packages/payload/components/elements.js @@ -1,39 +1,93 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { - value: true -}); +'use strict' +Object.defineProperty(exports, '__esModule', { + value: true, +}) function _export(target, all) { - for(var name in all)Object.defineProperty(target, name, { - enumerable: true, - get: all[name] - }); + for (var name in all) + Object.defineProperty(target, name, { + enumerable: true, + get: all[name], + }) } _export(exports, { - Button: function() { - return _Button.default; - }, - Card: function() { - return _Card.default; - }, - Eyebrow: function() { - return _Eyebrow.default; - }, - Gutter: function() { - return _Gutter.Gutter; - }, - Nav: function() { - return _Nav.default; - } -}); -const _Button = /*#__PURE__*/ _interop_require_default(require("../dist/admin/components/elements/Button")); -const _Card = /*#__PURE__*/ _interop_require_default(require("../dist/admin/components/elements/Card")); -const _Eyebrow = /*#__PURE__*/ _interop_require_default(require("../dist/admin/components/elements/Eyebrow")); -const _Gutter = require("../dist/admin/components/elements/Gutter"); -const _Nav = /*#__PURE__*/ _interop_require_default(require("../dist/admin/components/elements/Nav")); + Button: function () { + return _Button.default + }, + Card: function () { + return _Card.default + }, + DocumentDrawer: function () { + return _DocumentDrawer.DocumentDrawer + }, + DocumentDrawerBaseClass: function () { + return _DocumentDrawer.baseClass + }, + DocumentDrawerToggler: function () { + return _DocumentDrawer.DocumentDrawerToggler + }, + Drawer: function () { + return _Drawer.Drawer + }, + DrawerToggler: function () { + return _Drawer.DrawerToggler + }, + Eyebrow: function () { + return _Eyebrow.default + }, + Gutter: function () { + return _Gutter.Gutter + }, + ListDrawer: function () { + return _ListDrawer.ListDrawer + }, + ListDrawerBaseClass: function () { + return _ListDrawer.baseClass + }, + ListDrawerToggler: function () { + return _ListDrawer.ListDrawerToggler + }, + Nav: function () { + return _Nav.default + }, + formatDrawerSlug: function () { + return _Drawer.formatDrawerSlug + }, + formatListDrawerSlug: function () { + return _ListDrawer.formatListDrawerSlug + }, + useDocumentDrawer: function () { + return _DocumentDrawer.useDocumentDrawer + }, + useDrawerSlug: function () { + return _useDrawerSlug.useDrawerSlug + }, + useListDrawer: function () { + return _ListDrawer.useListDrawer + }, +}) +const _Button = /*#__PURE__*/ _interop_require_default( + require('../dist/admin/components/elements/Button'), +) +const _Card = /*#__PURE__*/ _interop_require_default( + require('../dist/admin/components/elements/Card'), +) +const _DocumentDrawer = require('../dist/admin/components/elements/DocumentDrawer') +const _Drawer = require('../dist/admin/components/elements/Drawer') +const _useDrawerSlug = require('../dist/admin/components/elements/Drawer/useDrawerSlug') +const _Eyebrow = /*#__PURE__*/ _interop_require_default( + require('../dist/admin/components/elements/Eyebrow'), +) +const _Gutter = require('../dist/admin/components/elements/Gutter') +const _ListDrawer = require('../dist/admin/components/elements/ListDrawer') +const _Nav = /*#__PURE__*/ _interop_require_default( + require('../dist/admin/components/elements/Nav'), +) function _interop_require_default(obj) { - return obj && obj.__esModule ? obj : { - default: obj - }; + return obj && obj.__esModule + ? obj + : { + default: obj, + } } -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9leHBvcnRzL2NvbXBvbmVudHMvZWxlbWVudHMudHMiXSwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IHsgZGVmYXVsdCBhcyBCdXR0b24gfSBmcm9tICcuLi8uLi9hZG1pbi9jb21wb25lbnRzL2VsZW1lbnRzL0J1dHRvbidcbmV4cG9ydCB7IGRlZmF1bHQgYXMgQ2FyZCB9IGZyb20gJy4uLy4uL2FkbWluL2NvbXBvbmVudHMvZWxlbWVudHMvQ2FyZCdcbmV4cG9ydCB7IGRlZmF1bHQgYXMgRXllYnJvdyB9IGZyb20gJy4uLy4uL2FkbWluL2NvbXBvbmVudHMvZWxlbWVudHMvRXllYnJvdydcbmV4cG9ydCB7IEd1dHRlci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2xlciIsIkxpc3REcmF3ZXJCYXNlQ2xhc3MiLCJmb3JtYXRMaXN0RHJhd2VyU2x1ZyIsInVzZUxpc3REcmF3ZXIiLCJOYXYiXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7O0lBQW9CQSxNQUFNO2VBQU5BLGVBQU07O0lBQ05DLElBQUk7ZUFBSkEsYUFBSTs7SUFFdEJDLGNBQWM7ZUFBZEEsOEJBQWM7O0lBQ2RDLHFCQUFxQjtlQUFyQkEscUNBQXFCOztJQUNSQyx1QkFBdUI7ZUFBcENDLHlCQUFTOztJQUNUQyxpQkFBaUI7ZUFBakJBLGlDQUFpQjs7SUFFVkMsTUFBTTtlQUFOQSxjQUFNOztJQUFFQyxhQUFhO2VBQWJBLHFCQUFhOztJQUFFQyxnQkFBZ0I7ZUFBaEJBLHdCQUFnQjs7SUFDdkNDLGFBQWE7ZUFBYkEsNEJBQWE7O0lBRUZDLE9BQU87ZUFBUEEsZ0JBQU87O0lBRWxCQyxNQUFNO2VBQU5BLGNBQU07O0lBRWJDLFVBQVU7ZUFBVkEsc0JBQVU7O0lBQ1ZDLGlCQUFpQjtlQUFqQkEsNkJBQWlCOztJQUNKQyxtQkFBbUI7ZUFBaENWLHFCQUFTOztJQUNUVyxvQkFBb0I7ZUFBcEJBLGdDQUFvQjs7SUFDcEJDLGFBQWE7ZUFBYkEseUJBQWE7O0lBRUtDLEdBQUc7ZUFBSEEsWUFBRzs7OytEQXJCVzs2REFDRjtnQ0FNekI7d0JBQ2lEOytCQUMxQjtnRUFFSzt3QkFFWjs0QkFPaEI7NERBQ3dCIn0= diff --git a/packages/payload/components/fields/Array.d.ts b/packages/payload/components/fields/Array.d.ts index 725ef9ec41..de9f124c7a 100644 --- a/packages/payload/components/fields/Array.d.ts +++ b/packages/payload/components/fields/Array.d.ts @@ -1,2 +1,2 @@ -export type { Props } from '../../dist/admin/components/forms/field-types/Array/types'; -//# sourceMappingURL=Array.d.ts.map \ No newline at end of file +export type { Props } from '../../dist/admin/components/forms/field-types/Array/types' +//# sourceMappingURL=Array.d.ts.map diff --git a/packages/payload/components/fields/Array.js b/packages/payload/components/fields/Array.js index b775d337d8..d7080c8135 100644 --- a/packages/payload/components/fields/Array.js +++ b/packages/payload/components/fields/Array.js @@ -1,6 +1,6 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { - value: true -}); +'use strict' +Object.defineProperty(exports, '__esModule', { + value: true, +}) -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 \ No newline at end of file +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 diff --git a/packages/payload/components/fields/Blocks.d.ts b/packages/payload/components/fields/Blocks.d.ts index 5f4fad256c..f1a2e8dbe1 100644 --- a/packages/payload/components/fields/Blocks.d.ts +++ b/packages/payload/components/fields/Blocks.d.ts @@ -1,2 +1,2 @@ -export type { Props } from '../../dist/admin/components/forms/field-types/Blocks/types'; -//# sourceMappingURL=Blocks.d.ts.map \ No newline at end of file +export type { Props } from '../../dist/admin/components/forms/field-types/Blocks/types' +//# sourceMappingURL=Blocks.d.ts.map diff --git a/packages/payload/components/fields/Blocks.js b/packages/payload/components/fields/Blocks.js index b775d337d8..d7080c8135 100644 --- a/packages/payload/components/fields/Blocks.js +++ b/packages/payload/components/fields/Blocks.js @@ -1,6 +1,6 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { - value: true -}); +'use strict' +Object.defineProperty(exports, '__esModule', { + value: true, +}) -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 \ No newline at end of file +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 diff --git a/packages/payload/components/fields/Cell.d.ts b/packages/payload/components/fields/Cell.d.ts index 9ea060a7b9..ebc2b10524 100644 --- a/packages/payload/components/fields/Cell.d.ts +++ b/packages/payload/components/fields/Cell.d.ts @@ -1,2 +1,2 @@ -export type { Props } from '../../dist/admin/components/views/collections/List/Cell/types'; -//# sourceMappingURL=Cell.d.ts.map \ No newline at end of file +export type { Props } from '../../dist/admin/components/views/collections/List/Cell/types' +//# sourceMappingURL=Cell.d.ts.map diff --git a/packages/payload/components/fields/Cell.js b/packages/payload/components/fields/Cell.js index b775d337d8..d7080c8135 100644 --- a/packages/payload/components/fields/Cell.js +++ b/packages/payload/components/fields/Cell.js @@ -1,6 +1,6 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { - value: true -}); +'use strict' +Object.defineProperty(exports, '__esModule', { + value: true, +}) -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 \ No newline at end of file +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 diff --git a/packages/payload/components/fields/Checkbox.d.ts b/packages/payload/components/fields/Checkbox.d.ts index 2b03cbcc7d..f8a284a846 100644 --- a/packages/payload/components/fields/Checkbox.d.ts +++ b/packages/payload/components/fields/Checkbox.d.ts @@ -1,2 +1,2 @@ -export type { Props } from '../../dist/admin/components/forms/field-types/Checkbox/types'; -//# sourceMappingURL=Checkbox.d.ts.map \ No newline at end of file +export type { Props } from '../../dist/admin/components/forms/field-types/Checkbox/types' +//# sourceMappingURL=Checkbox.d.ts.map diff --git a/packages/payload/components/fields/Checkbox.js b/packages/payload/components/fields/Checkbox.js index b775d337d8..d7080c8135 100644 --- a/packages/payload/components/fields/Checkbox.js +++ b/packages/payload/components/fields/Checkbox.js @@ -1,6 +1,6 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { - value: true -}); +'use strict' +Object.defineProperty(exports, '__esModule', { + value: true, +}) -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 \ No newline at end of file +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 diff --git a/packages/payload/components/fields/Code.d.ts b/packages/payload/components/fields/Code.d.ts index 1d5956877e..0aa806d0bd 100644 --- a/packages/payload/components/fields/Code.d.ts +++ b/packages/payload/components/fields/Code.d.ts @@ -1,2 +1,2 @@ -export type { Props } from '../../dist/admin/components/forms/field-types/Code/types'; -//# sourceMappingURL=Code.d.ts.map \ No newline at end of file +export type { Props } from '../../dist/admin/components/forms/field-types/Code/types' +//# sourceMappingURL=Code.d.ts.map diff --git a/packages/payload/components/fields/Code.js b/packages/payload/components/fields/Code.js index b775d337d8..d7080c8135 100644 --- a/packages/payload/components/fields/Code.js +++ b/packages/payload/components/fields/Code.js @@ -1,6 +1,6 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { - value: true -}); +'use strict' +Object.defineProperty(exports, '__esModule', { + value: true, +}) -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 \ No newline at end of file +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 diff --git a/packages/payload/components/fields/DateTime.d.ts b/packages/payload/components/fields/DateTime.d.ts index ed5813483d..ca873cccf6 100644 --- a/packages/payload/components/fields/DateTime.d.ts +++ b/packages/payload/components/fields/DateTime.d.ts @@ -1,2 +1,2 @@ -export type { Props } from '../../dist/admin/components/forms/field-types/DateTime/types'; -//# sourceMappingURL=DateTime.d.ts.map \ No newline at end of file +export type { Props } from '../../dist/admin/components/forms/field-types/DateTime/types' +//# sourceMappingURL=DateTime.d.ts.map diff --git a/packages/payload/components/fields/DateTime.js b/packages/payload/components/fields/DateTime.js index b775d337d8..d7080c8135 100644 --- a/packages/payload/components/fields/DateTime.js +++ b/packages/payload/components/fields/DateTime.js @@ -1,6 +1,6 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { - value: true -}); +'use strict' +Object.defineProperty(exports, '__esModule', { + value: true, +}) -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 \ No newline at end of file +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 diff --git a/packages/payload/components/fields/Email.d.ts b/packages/payload/components/fields/Email.d.ts index 94f9d20bef..ca08a0524f 100644 --- a/packages/payload/components/fields/Email.d.ts +++ b/packages/payload/components/fields/Email.d.ts @@ -1,2 +1,2 @@ -export type { Props } from '../../dist/admin/components/forms/field-types/Email/types'; -//# sourceMappingURL=Email.d.ts.map \ No newline at end of file +export type { Props } from '../../dist/admin/components/forms/field-types/Email/types' +//# sourceMappingURL=Email.d.ts.map diff --git a/packages/payload/components/fields/Email.js b/packages/payload/components/fields/Email.js index b775d337d8..d7080c8135 100644 --- a/packages/payload/components/fields/Email.js +++ b/packages/payload/components/fields/Email.js @@ -1,6 +1,6 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { - value: true -}); +'use strict' +Object.defineProperty(exports, '__esModule', { + value: true, +}) -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 \ No newline at end of file +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 diff --git a/packages/payload/components/fields/Group.d.ts b/packages/payload/components/fields/Group.d.ts index 310839c340..39849bc3bc 100644 --- a/packages/payload/components/fields/Group.d.ts +++ b/packages/payload/components/fields/Group.d.ts @@ -1,2 +1,2 @@ -export type { Props } from '../../dist/admin/components/forms/field-types/Group/types'; -//# sourceMappingURL=Group.d.ts.map \ No newline at end of file +export type { Props } from '../../dist/admin/components/forms/field-types/Group/types' +//# sourceMappingURL=Group.d.ts.map diff --git a/packages/payload/components/fields/Group.js b/packages/payload/components/fields/Group.js index b775d337d8..d7080c8135 100644 --- a/packages/payload/components/fields/Group.js +++ b/packages/payload/components/fields/Group.js @@ -1,6 +1,6 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { - value: true -}); +'use strict' +Object.defineProperty(exports, '__esModule', { + value: true, +}) -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 \ No newline at end of file +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 diff --git a/packages/payload/components/fields/Json.d.ts b/packages/payload/components/fields/Json.d.ts index ed4eb022bb..2227a6e0a7 100644 --- a/packages/payload/components/fields/Json.d.ts +++ b/packages/payload/components/fields/Json.d.ts @@ -1,2 +1,2 @@ -export type { Props } from '../../dist/admin/components/forms/field-types/JSON/types'; -//# sourceMappingURL=Json.d.ts.map \ No newline at end of file +export type { Props } from '../../dist/admin/components/forms/field-types/JSON/types' +//# sourceMappingURL=Json.d.ts.map diff --git a/packages/payload/components/fields/Json.js b/packages/payload/components/fields/Json.js index b775d337d8..d7080c8135 100644 --- a/packages/payload/components/fields/Json.js +++ b/packages/payload/components/fields/Json.js @@ -1,6 +1,6 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { - value: true -}); +'use strict' +Object.defineProperty(exports, '__esModule', { + value: true, +}) -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 \ No newline at end of file +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 diff --git a/packages/payload/components/fields/Number.d.ts b/packages/payload/components/fields/Number.d.ts index 289c971d41..eada17d341 100644 --- a/packages/payload/components/fields/Number.d.ts +++ b/packages/payload/components/fields/Number.d.ts @@ -1,2 +1,2 @@ -export type { Props } from '../../dist/admin/components/forms/field-types/Number/types'; -//# sourceMappingURL=Number.d.ts.map \ No newline at end of file +export type { Props } from '../../dist/admin/components/forms/field-types/Number/types' +//# sourceMappingURL=Number.d.ts.map diff --git a/packages/payload/components/fields/Number.js b/packages/payload/components/fields/Number.js index b775d337d8..d7080c8135 100644 --- a/packages/payload/components/fields/Number.js +++ b/packages/payload/components/fields/Number.js @@ -1,6 +1,6 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { - value: true -}); +'use strict' +Object.defineProperty(exports, '__esModule', { + value: true, +}) -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 \ No newline at end of file +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 diff --git a/packages/payload/components/fields/Password.d.ts b/packages/payload/components/fields/Password.d.ts index ba7c510507..d748f75fd1 100644 --- a/packages/payload/components/fields/Password.d.ts +++ b/packages/payload/components/fields/Password.d.ts @@ -1,2 +1,2 @@ -export type { Props } from '../../dist/admin/components/forms/field-types/Password/types'; -//# sourceMappingURL=Password.d.ts.map \ No newline at end of file +export type { Props } from '../../dist/admin/components/forms/field-types/Password/types' +//# sourceMappingURL=Password.d.ts.map diff --git a/packages/payload/components/fields/Password.js b/packages/payload/components/fields/Password.js index b775d337d8..d7080c8135 100644 --- a/packages/payload/components/fields/Password.js +++ b/packages/payload/components/fields/Password.js @@ -1,6 +1,6 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { - value: true -}); +'use strict' +Object.defineProperty(exports, '__esModule', { + value: true, +}) -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 \ No newline at end of file +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 diff --git a/packages/payload/components/fields/RadioGroup/RadioInput.d.ts b/packages/payload/components/fields/RadioGroup/RadioInput.d.ts index a09f32e0b6..33ea228f68 100644 --- a/packages/payload/components/fields/RadioGroup/RadioInput.d.ts +++ b/packages/payload/components/fields/RadioGroup/RadioInput.d.ts @@ -1,2 +1,2 @@ -export type { Props } from '../../../dist/admin/components/forms/field-types/RadioGroup/RadioInput/types'; -//# sourceMappingURL=RadioInput.d.ts.map \ No newline at end of file +export type { Props } from '../../../dist/admin/components/forms/field-types/RadioGroup/RadioInput/types' +//# sourceMappingURL=RadioInput.d.ts.map diff --git a/packages/payload/components/fields/RadioGroup/RadioInput.js b/packages/payload/components/fields/RadioGroup/RadioInput.js index b775d337d8..d7080c8135 100644 --- a/packages/payload/components/fields/RadioGroup/RadioInput.js +++ b/packages/payload/components/fields/RadioGroup/RadioInput.js @@ -1,6 +1,6 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { - value: true -}); +'use strict' +Object.defineProperty(exports, '__esModule', { + value: true, +}) -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 \ No newline at end of file +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 diff --git a/packages/payload/components/fields/RadioGroup/index.d.ts b/packages/payload/components/fields/RadioGroup/index.d.ts index 5cd79f1802..4cb0c9b1c4 100644 --- a/packages/payload/components/fields/RadioGroup/index.d.ts +++ b/packages/payload/components/fields/RadioGroup/index.d.ts @@ -1,2 +1,2 @@ -export type { Props } from '../../../dist/admin/components/forms/field-types/RadioGroup/types'; -//# sourceMappingURL=index.d.ts.map \ No newline at end of file +export type { Props } from '../../../dist/admin/components/forms/field-types/RadioGroup/types' +//# sourceMappingURL=index.d.ts.map diff --git a/packages/payload/components/fields/RadioGroup/index.js b/packages/payload/components/fields/RadioGroup/index.js index b775d337d8..d7080c8135 100644 --- a/packages/payload/components/fields/RadioGroup/index.js +++ b/packages/payload/components/fields/RadioGroup/index.js @@ -1,6 +1,6 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { - value: true -}); +'use strict' +Object.defineProperty(exports, '__esModule', { + value: true, +}) -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 \ No newline at end of file +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 diff --git a/packages/payload/components/fields/Relationship.d.ts b/packages/payload/components/fields/Relationship.d.ts index b32261546c..ec108b84a8 100644 --- a/packages/payload/components/fields/Relationship.d.ts +++ b/packages/payload/components/fields/Relationship.d.ts @@ -1,2 +1,7 @@ -export type { Option, Props, ValueWithRelation, } from '../../dist/admin/components/forms/field-types/Relationship/types'; -//# sourceMappingURL=Relationship.d.ts.map \ No newline at end of file +export { default as RelationshipComponent } from '../../dist/admin/components/forms/field-types/Relationship' +export type { + Option, + Props, + ValueWithRelation, +} from '../../dist/admin/components/forms/field-types/Relationship/types' +//# sourceMappingURL=Relationship.d.ts.map diff --git a/packages/payload/components/fields/Relationship.js b/packages/payload/components/fields/Relationship.js index b775d337d8..3953aed893 100644 --- a/packages/payload/components/fields/Relationship.js +++ b/packages/payload/components/fields/Relationship.js @@ -1,6 +1,22 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { - value: true -}); +'use strict' +Object.defineProperty(exports, '__esModule', { + value: true, +}) +Object.defineProperty(exports, 'RelationshipComponent', { + enumerable: true, + get: function () { + return _Relationship.default + }, +}) +const _Relationship = /*#__PURE__*/ _interop_require_default( + require('../../dist/admin/components/forms/field-types/Relationship'), +) +function _interop_require_default(obj) { + return obj && obj.__esModule + ? obj + : { + default: obj, + } +} -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 \ No newline at end of file +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9leHBvcnRzL2NvbXBvbmVudHMvZmllbGRzL1JlbGF0aW9uc2hpcC50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgeyBkZWZhdWx0IGFzIFJlbGF0aW9uc2hpcENvbXBvbmVudCB9IGZyb20gJy4uLy4uLy4uL2FkbWluL2NvbXBvbmVudHMvZm9ybXMvZmllbGQtdHlwZXMvUmVsYXRpb25zaGlwJ1xuZXhwb3J0IHR5cGUge1xuICBPcHRpb24sXG4gIFByb3BzLFxuICBWYWx1ZVdpdGhSZWxhdGlvbixcbn0gZnJvbSAnLi4vLi4vLi4vYWRtaW4vY29tcG9uZW50cy9mb3Jtcy9maWVsZC10eXBlcy9SZWxhdGlvbnNoaXAvdHlwZXMnXG4iXSwibmFtZXMiOlsiUmVsYXRpb25zaGlwQ29tcG9uZW50Il0sIm1hcHBpbmdzIjoiOzs7OytCQUFvQkE7OztlQUFBQSxxQkFBcUI7OztxRUFBUSJ9 diff --git a/packages/payload/components/fields/RichText.d.ts b/packages/payload/components/fields/RichText.d.ts index e96c145667..0a968bcdb5 100644 --- a/packages/payload/components/fields/RichText.d.ts +++ b/packages/payload/components/fields/RichText.d.ts @@ -1,2 +1,2 @@ -export type { Props } from '../../dist/admin/components/forms/field-types/RichText/types'; -//# sourceMappingURL=RichText.d.ts.map \ No newline at end of file +export type { RichTextFieldProps } from '../../dist/admin/components/forms/field-types/RichText/types' +//# sourceMappingURL=RichText.d.ts.map diff --git a/packages/payload/components/fields/RichText.js b/packages/payload/components/fields/RichText.js index b775d337d8..d7080c8135 100644 --- a/packages/payload/components/fields/RichText.js +++ b/packages/payload/components/fields/RichText.js @@ -1,6 +1,6 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { - value: true -}); +'use strict' +Object.defineProperty(exports, '__esModule', { + value: true, +}) -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 \ No newline at end of file +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 diff --git a/packages/payload/components/fields/Row.d.ts b/packages/payload/components/fields/Row.d.ts index 943559f41a..539de331f1 100644 --- a/packages/payload/components/fields/Row.d.ts +++ b/packages/payload/components/fields/Row.d.ts @@ -1,2 +1,2 @@ -export type { Props } from '../../dist/admin/components/forms/field-types/Row/types'; -//# sourceMappingURL=Row.d.ts.map \ No newline at end of file +export type { Props } from '../../dist/admin/components/forms/field-types/Row/types' +//# sourceMappingURL=Row.d.ts.map diff --git a/packages/payload/components/fields/Row.js b/packages/payload/components/fields/Row.js index b775d337d8..d7080c8135 100644 --- a/packages/payload/components/fields/Row.js +++ b/packages/payload/components/fields/Row.js @@ -1,6 +1,6 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { - value: true -}); +'use strict' +Object.defineProperty(exports, '__esModule', { + value: true, +}) -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 \ No newline at end of file +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 diff --git a/packages/payload/components/fields/Select.d.ts b/packages/payload/components/fields/Select.d.ts index 8fe093d68c..6a6a1f484b 100644 --- a/packages/payload/components/fields/Select.d.ts +++ b/packages/payload/components/fields/Select.d.ts @@ -1,2 +1,3 @@ -export type { Props } from '../../dist/admin/components/forms/field-types/Select/types'; -//# sourceMappingURL=Select.d.ts.map \ No newline at end of file +export { default as SelectComponent } from '../../dist/admin/components/forms/field-types/Select' +export type { Props } from '../../dist/admin/components/forms/field-types/Select/types' +//# sourceMappingURL=Select.d.ts.map diff --git a/packages/payload/components/fields/Select.js b/packages/payload/components/fields/Select.js index b775d337d8..db20fb032a 100644 --- a/packages/payload/components/fields/Select.js +++ b/packages/payload/components/fields/Select.js @@ -1,6 +1,22 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { - value: true -}); +'use strict' +Object.defineProperty(exports, '__esModule', { + value: true, +}) +Object.defineProperty(exports, 'SelectComponent', { + enumerable: true, + get: function () { + return _Select.default + }, +}) +const _Select = /*#__PURE__*/ _interop_require_default( + require('../../dist/admin/components/forms/field-types/Select'), +) +function _interop_require_default(obj) { + return obj && obj.__esModule + ? obj + : { + default: obj, + } +} -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 \ No newline at end of file +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9leHBvcnRzL2NvbXBvbmVudHMvZmllbGRzL1NlbGVjdC50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgeyBkZWZhdWx0IGFzIFNlbGVjdENvbXBvbmVudCB9IGZyb20gJy4uLy4uLy4uL2FkbWluL2NvbXBvbmVudHMvZm9ybXMvZmllbGQtdHlwZXMvU2VsZWN0J1xuZXhwb3J0IHR5cGUgeyBQcm9wcyB9IGZyb20gJy4uLy4uLy4uL2FkbWluL2NvbXBvbmVudHMvZm9ybXMvZmllbGQtdHlwZXMvU2VsZWN0L3R5cGVzJ1xuIl0sIm5hbWVzIjpbIlNlbGVjdENvbXBvbmVudCJdLCJtYXBwaW5ncyI6Ijs7OzsrQkFBb0JBOzs7ZUFBQUEsZUFBZTs7OytEQUFRIn0= diff --git a/packages/payload/components/fields/Text.d.ts b/packages/payload/components/fields/Text.d.ts index 27ec5e619e..60853a6f17 100644 --- a/packages/payload/components/fields/Text.d.ts +++ b/packages/payload/components/fields/Text.d.ts @@ -1,2 +1,2 @@ -export type { Props } from '../../dist/admin/components/forms/field-types/Text/types'; -//# sourceMappingURL=Text.d.ts.map \ No newline at end of file +export type { Props } from '../../dist/admin/components/forms/field-types/Text/types' +//# sourceMappingURL=Text.d.ts.map diff --git a/packages/payload/components/fields/Text.js b/packages/payload/components/fields/Text.js index b775d337d8..d7080c8135 100644 --- a/packages/payload/components/fields/Text.js +++ b/packages/payload/components/fields/Text.js @@ -1,6 +1,6 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { - value: true -}); +'use strict' +Object.defineProperty(exports, '__esModule', { + value: true, +}) -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 \ No newline at end of file +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 diff --git a/packages/payload/components/fields/Textarea.d.ts b/packages/payload/components/fields/Textarea.d.ts index 4527e4408c..b5a3ce0b70 100644 --- a/packages/payload/components/fields/Textarea.d.ts +++ b/packages/payload/components/fields/Textarea.d.ts @@ -1,2 +1,2 @@ -export type { Props } from '../../dist/admin/components/forms/field-types/Textarea/types'; -//# sourceMappingURL=Textarea.d.ts.map \ No newline at end of file +export type { Props } from '../../dist/admin/components/forms/field-types/Textarea/types' +//# sourceMappingURL=Textarea.d.ts.map diff --git a/packages/payload/components/fields/Textarea.js b/packages/payload/components/fields/Textarea.js index b775d337d8..d7080c8135 100644 --- a/packages/payload/components/fields/Textarea.js +++ b/packages/payload/components/fields/Textarea.js @@ -1,6 +1,6 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { - value: true -}); +'use strict' +Object.defineProperty(exports, '__esModule', { + value: true, +}) -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 \ No newline at end of file +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 diff --git a/packages/payload/components/fields/Upload.d.ts b/packages/payload/components/fields/Upload.d.ts index 3c204461eb..b161add13a 100644 --- a/packages/payload/components/fields/Upload.d.ts +++ b/packages/payload/components/fields/Upload.d.ts @@ -1,2 +1,2 @@ -export type { Props } from '../../dist/admin/components/forms/field-types/Upload/types'; -//# sourceMappingURL=Upload.d.ts.map \ No newline at end of file +export type { Props } from '../../dist/admin/components/forms/field-types/Upload/types' +//# sourceMappingURL=Upload.d.ts.map diff --git a/packages/payload/components/fields/Upload.js b/packages/payload/components/fields/Upload.js index b775d337d8..d7080c8135 100644 --- a/packages/payload/components/fields/Upload.js +++ b/packages/payload/components/fields/Upload.js @@ -1,6 +1,6 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { - value: true -}); +'use strict' +Object.defineProperty(exports, '__esModule', { + value: true, +}) -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 \ No newline at end of file +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 diff --git a/packages/payload/components/forms.d.ts b/packages/payload/components/forms.d.ts index 40edd754db..a6d0fa1254 100644 --- a/packages/payload/components/forms.d.ts +++ b/packages/payload/components/forms.d.ts @@ -1,23 +1,34 @@ -export { default as Form } from '../dist/admin/components/forms/Form'; -export { useAllFormFields, useForm, useFormFields, useFormModified, useFormProcessing, useFormSubmitted, -/** - * @deprecated useWatchForm is no longer preferred. If you need all form fields, prefer `useAllFormFields`. - */ -useWatchForm, } from '../dist/admin/components/forms/Form/context'; -export { default as getSiblingData } from '../dist/admin/components/forms/Form/getSiblingData'; -export { default as reduceFieldsToValues } from '../dist/admin/components/forms/Form/reduceFieldsToValues'; -export { default as Label } from '../dist/admin/components/forms/Label'; -export { default as Submit } from '../dist/admin/components/forms/Submit'; -export { default as Checkbox } from '../dist/admin/components/forms/field-types/Checkbox'; -export { default as Group } from '../dist/admin/components/forms/field-types/Group'; -export { default as Select } from '../dist/admin/components/forms/field-types/Select'; -export { default as SelectInput } from '../dist/admin/components/forms/field-types/Select/Input'; -export { default as Text } from '../dist/admin/components/forms/field-types/Text'; -export { default as TextInput } from '../dist/admin/components/forms/field-types/Text/Input'; +export { default as Error } from '../dist/admin/components/forms/Error' +export { default as FieldDescription } from '../dist/admin/components/forms/FieldDescription' +export { default as Form } from '../dist/admin/components/forms/Form' +export { + useAllFormFields, + useForm, + useFormFields, + useFormModified, + useFormProcessing, + useFormSubmitted, + /** + * @deprecated useWatchForm is no longer preferred. If you need all form fields, prefer `useAllFormFields`. + */ + useWatchForm, +} from '../dist/admin/components/forms/Form/context' +export { default as getSiblingData } from '../dist/admin/components/forms/Form/getSiblingData' +export { default as reduceFieldsToValues } from '../dist/admin/components/forms/Form/reduceFieldsToValues' +export { default as Label } from '../dist/admin/components/forms/Label' +export { default as RenderFields } from '../dist/admin/components/forms/RenderFields' +export { default as Submit } from '../dist/admin/components/forms/Submit' +export { default as FormSubmit } from '../dist/admin/components/forms/Submit' +export { default as Checkbox } from '../dist/admin/components/forms/field-types/Checkbox' +export { default as Group } from '../dist/admin/components/forms/field-types/Group' +export { default as Select } from '../dist/admin/components/forms/field-types/Select' +export { default as SelectInput } from '../dist/admin/components/forms/field-types/Select/Input' +export { default as Text } from '../dist/admin/components/forms/field-types/Text' +export { default as TextInput } from '../dist/admin/components/forms/field-types/Text/Input' /** * @deprecated This method is now called useField. The useFieldType alias will be removed in an upcoming version. */ -export { default as useFieldType } from '../dist/admin/components/forms/useField'; -export { default as useField } from '../dist/admin/components/forms/useField'; -export { default as withCondition } from '../dist/admin/components/forms/withCondition'; -//# sourceMappingURL=forms.d.ts.map \ No newline at end of file +export { default as useFieldType } from '../dist/admin/components/forms/useField' +export { default as useField } from '../dist/admin/components/forms/useField' +export { default as withCondition } from '../dist/admin/components/forms/withCondition' +//# sourceMappingURL=forms.d.ts.map diff --git a/packages/payload/components/forms.js b/packages/payload/components/forms.js index df5b224911..f4fed44b9e 100644 --- a/packages/payload/components/forms.js +++ b/packages/payload/components/forms.js @@ -1,98 +1,146 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { - value: true -}); +'use strict' +Object.defineProperty(exports, '__esModule', { + value: true, +}) function _export(target, all) { - for(var name in all)Object.defineProperty(target, name, { - enumerable: true, - get: all[name] - }); + for (var name in all) + Object.defineProperty(target, name, { + enumerable: true, + get: all[name], + }) } _export(exports, { - Form: function() { - return _Form.default; - }, - useAllFormFields: function() { - return _context.useAllFormFields; - }, - useForm: function() { - return _context.useForm; - }, - useFormFields: function() { - return _context.useFormFields; - }, - useFormModified: function() { - return _context.useFormModified; - }, - useFormProcessing: function() { - return _context.useFormProcessing; - }, - useFormSubmitted: function() { - return _context.useFormSubmitted; - }, - /** + Error: function () { + return _Error.default + }, + FieldDescription: function () { + return _FieldDescription.default + }, + Form: function () { + return _Form.default + }, + useAllFormFields: function () { + return _context.useAllFormFields + }, + useForm: function () { + return _context.useForm + }, + useFormFields: function () { + return _context.useFormFields + }, + useFormModified: function () { + return _context.useFormModified + }, + useFormProcessing: function () { + return _context.useFormProcessing + }, + useFormSubmitted: function () { + return _context.useFormSubmitted + }, + /** * @deprecated useWatchForm is no longer preferred. If you need all form fields, prefer `useAllFormFields`. - */ useWatchForm: function() { - return _context.useWatchForm; - }, - getSiblingData: function() { - return _getSiblingData.default; - }, - reduceFieldsToValues: function() { - return _reduceFieldsToValues.default; - }, - Label: function() { - return _Label.default; - }, - Submit: function() { - return _Submit.default; - }, - Checkbox: function() { - return _Checkbox.default; - }, - Group: function() { - return _Group.default; - }, - Select: function() { - return _Select.default; - }, - SelectInput: function() { - return _Input.default; - }, - Text: function() { - return _Text.default; - }, - TextInput: function() { - return _Input1.default; - }, - useFieldType: function() { - return _useField.default; - }, - useField: function() { - return _useField.default; - }, - withCondition: function() { - return _withCondition.default; - } -}); -const _Form = /*#__PURE__*/ _interop_require_default(require("../dist/admin/components/forms/Form")); -const _context = require("../dist/admin/components/forms/Form/context"); -const _getSiblingData = /*#__PURE__*/ _interop_require_default(require("../dist/admin/components/forms/Form/getSiblingData")); -const _reduceFieldsToValues = /*#__PURE__*/ _interop_require_default(require("../dist/admin/components/forms/Form/reduceFieldsToValues")); -const _Label = /*#__PURE__*/ _interop_require_default(require("../dist/admin/components/forms/Label")); -const _Submit = /*#__PURE__*/ _interop_require_default(require("../dist/admin/components/forms/Submit")); -const _Checkbox = /*#__PURE__*/ _interop_require_default(require("../dist/admin/components/forms/field-types/Checkbox")); -const _Group = /*#__PURE__*/ _interop_require_default(require("../dist/admin/components/forms/field-types/Group")); -const _Select = /*#__PURE__*/ _interop_require_default(require("../dist/admin/components/forms/field-types/Select")); -const _Input = /*#__PURE__*/ _interop_require_default(require("../dist/admin/components/forms/field-types/Select/Input")); -const _Text = /*#__PURE__*/ _interop_require_default(require("../dist/admin/components/forms/field-types/Text")); -const _Input1 = /*#__PURE__*/ _interop_require_default(require("../dist/admin/components/forms/field-types/Text/Input")); -const _useField = /*#__PURE__*/ _interop_require_default(require("../dist/admin/components/forms/useField")); -const _withCondition = /*#__PURE__*/ _interop_require_default(require("../dist/admin/components/forms/withCondition")); + */ Checkbox: function () { + return _Checkbox.default + }, + FormSubmit: function () { + return _Submit.default + }, + Group: function () { + return _Group.default + }, + Label: function () { + return _Label.default + }, + RenderFields: function () { + return _RenderFields.default + }, + Select: function () { + return _Select.default + }, + SelectInput: function () { + return _Input.default + }, + Submit: function () { + return _Submit.default + }, + Text: function () { + return _Text.default + }, + TextInput: function () { + return _Input1.default + }, + getSiblingData: function () { + return _getSiblingData.default + }, + reduceFieldsToValues: function () { + return _reduceFieldsToValues.default + }, + useField: function () { + return _useField.default + }, + useFieldType: function () { + return _useField.default + }, + useWatchForm: function () { + return _context.useWatchForm + }, + withCondition: function () { + return _withCondition.default + }, +}) +const _Error = /*#__PURE__*/ _interop_require_default( + require('../dist/admin/components/forms/Error'), +) +const _FieldDescription = /*#__PURE__*/ _interop_require_default( + require('../dist/admin/components/forms/FieldDescription'), +) +const _Form = /*#__PURE__*/ _interop_require_default(require('../dist/admin/components/forms/Form')) +const _context = require('../dist/admin/components/forms/Form/context') +const _getSiblingData = /*#__PURE__*/ _interop_require_default( + require('../dist/admin/components/forms/Form/getSiblingData'), +) +const _reduceFieldsToValues = /*#__PURE__*/ _interop_require_default( + require('../dist/admin/components/forms/Form/reduceFieldsToValues'), +) +const _Label = /*#__PURE__*/ _interop_require_default( + require('../dist/admin/components/forms/Label'), +) +const _RenderFields = /*#__PURE__*/ _interop_require_default( + require('../dist/admin/components/forms/RenderFields'), +) +const _Submit = /*#__PURE__*/ _interop_require_default( + require('../dist/admin/components/forms/Submit'), +) +const _Checkbox = /*#__PURE__*/ _interop_require_default( + require('../dist/admin/components/forms/field-types/Checkbox'), +) +const _Group = /*#__PURE__*/ _interop_require_default( + require('../dist/admin/components/forms/field-types/Group'), +) +const _Select = /*#__PURE__*/ _interop_require_default( + require('../dist/admin/components/forms/field-types/Select'), +) +const _Input = /*#__PURE__*/ _interop_require_default( + require('../dist/admin/components/forms/field-types/Select/Input'), +) +const _Text = /*#__PURE__*/ _interop_require_default( + require('../dist/admin/components/forms/field-types/Text'), +) +const _Input1 = /*#__PURE__*/ _interop_require_default( + require('../dist/admin/components/forms/field-types/Text/Input'), +) +const _useField = /*#__PURE__*/ _interop_require_default( + require('../dist/admin/components/forms/useField'), +) +const _withCondition = /*#__PURE__*/ _interop_require_default( + require('../dist/admin/components/forms/withCondition'), +) function _interop_require_default(obj) { - return obj && obj.__esModule ? obj : { - default: obj - }; + return obj && obj.__esModule + ? obj + : { + default: obj, + } } -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9leHBvcnRzL2NvbXBvbmVudHMvZm9ybXMudHMiXSwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IHsgZGVmYXVsdCBhcyBGb3JtIH0gZnJvbSAnLi4vLi4vYWRtaW4vY29tcG9uZW50cy9mb3Jtcy9Gb3JtJ1xuXG5leHBvcnQge1xuICB1c2VBbGxGb3JtRmllbGRzLFxuICB1c2VGb3JtLFxuICB1c2VGb3JtRmllbGRzLFxuICB1c2VGb3JtTW9kaWZpZWQsXG4gIHVzZUZvcm1Qcm9jZXNzaW5nLFxuICB1c2VGb3JtU3VibWl0dGVkLFxuICAvKipcbiAgICogQGRlcHJlY2F0ZWQgdXNlV2F0Y2hGb3JtIGlzIG5vIGxvbmdlciBwcmVmZXJyZWQuIElmIHlvdSBuZWVkIGFsbCBmb3JtIGZpZWxkcywgcHJlZmVyIGB1c2VBb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new file mode 100644 index 0000000000..0ef7a2ca12 --- /dev/null +++ b/packages/payload/components/graphics.d.ts @@ -0,0 +1,7 @@ +export { default as AccountGraphic } from '../dist/admin/components/graphics/Account' +export { default as DefaultBlockImageGraphic } from '../dist/admin/components/graphics/DefaultBlockImage' +export { default as FileGraphic } from '../dist/admin/components/graphics/File' +export { default as IconGraphic } from '../dist/admin/components/graphics/Icon' +export { default as LogoGraphic } from '../dist/admin/components/graphics/Logo' +export { default as SearchGraphic } from '../dist/admin/components/graphics/Search' +//# sourceMappingURL=graphics.d.ts.map diff --git a/packages/payload/components/graphics.js b/packages/payload/components/graphics.js new file mode 100644 index 0000000000..2f3d453035 --- /dev/null +++ b/packages/payload/components/graphics.js @@ -0,0 +1,58 @@ +'use strict' +Object.defineProperty(exports, '__esModule', { + value: true, +}) +function _export(target, all) { + for (var name in all) + Object.defineProperty(target, name, { + enumerable: true, + get: all[name], + }) +} +_export(exports, { + AccountGraphic: function () { + return _Account.default + }, + DefaultBlockImageGraphic: function () { + return _DefaultBlockImage.default + }, + FileGraphic: function () { + return _File.default + }, + IconGraphic: function () { + return _Icon.default + }, + LogoGraphic: function () { + return _Logo.default + }, + SearchGraphic: function () { + return _Search.default + }, +}) +const _Account = /*#__PURE__*/ _interop_require_default( + require('../dist/admin/components/graphics/Account'), +) +const _DefaultBlockImage = /*#__PURE__*/ _interop_require_default( + require('../dist/admin/components/graphics/DefaultBlockImage'), +) +const _File = /*#__PURE__*/ _interop_require_default( + require('../dist/admin/components/graphics/File'), +) +const _Icon = /*#__PURE__*/ _interop_require_default( + require('../dist/admin/components/graphics/Icon'), +) +const _Logo = /*#__PURE__*/ _interop_require_default( + require('../dist/admin/components/graphics/Logo'), +) +const _Search = /*#__PURE__*/ _interop_require_default( + require('../dist/admin/components/graphics/Search'), +) +function _interop_require_default(obj) { + return obj && obj.__esModule + ? obj + : { + default: obj, + } +} + +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjp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QUFXOztJQUNYQyxXQUFXO2VBQVhBLGFBQVc7O0lBQ1hDLFdBQVc7ZUFBWEEsYUFBVzs7SUFDWEMsYUFBYTtlQUFiQSxlQUFhOzs7Z0VBTFM7MEVBQ1U7NkRBQ2I7NkRBQ0E7NkRBQ0E7K0RBQ0UifQ== diff --git a/packages/payload/components/hooks.d.ts b/packages/payload/components/hooks.d.ts index 68eb2ef27b..33ae6aae1e 100644 --- a/packages/payload/components/hooks.d.ts +++ b/packages/payload/components/hooks.d.ts @@ -1,2 +1,13 @@ -export { useStepNav } from '../dist/admin/components/elements/StepNav'; -//# sourceMappingURL=hooks.d.ts.map \ No newline at end of file +export { useStepNav } from '../dist/admin/components/elements/StepNav' +export { default as useDebounce } from '../dist/admin/hooks/useDebounce' +export { useDebouncedCallback } from '../dist/admin/hooks/useDebouncedCallback' +export { useDelay } from '../dist/admin/hooks/useDelay' +export { useDelayedRender } from '../dist/admin/hooks/useDelayedRender' +export { default as useHotkey } from '../dist/admin/hooks/useHotkey' +export { default as useIntersect } from '../dist/admin/hooks/useIntersect' +export { default as useMountEffect } from '../dist/admin/hooks/useMountEffect' +export { default as usePayloadAPI } from '../dist/admin/hooks/usePayloadAPI' +export { default as useThrottledEffect } from '../dist/admin/hooks/useThrottledEffect' +export { default as useThumbnail } from '../dist/admin/hooks/useThumbnail' +export { default as useTitle, formatUseAsTitle } from '../dist/admin/hooks/useTitle' +//# sourceMappingURL=hooks.d.ts.map diff --git a/packages/payload/components/hooks.js b/packages/payload/components/hooks.js index fbd14257b2..93484fe672 100644 --- a/packages/payload/components/hooks.js +++ b/packages/payload/components/hooks.js @@ -1,13 +1,124 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { - value: true -}); -Object.defineProperty(exports, "useStepNav", { - enumerable: true, - get: function() { - return _StepNav.useStepNav; +'use strict' +Object.defineProperty(exports, '__esModule', { + value: true, +}) +function _export(target, all) { + for (var name in all) + Object.defineProperty(target, name, { + enumerable: true, + get: all[name], + }) +} +_export(exports, { + formatUseAsTitle: function () { + return _useTitle.formatUseAsTitle + }, + useDebounce: function () { + return _useDebounce.default + }, + useDebouncedCallback: function () { + return _useDebouncedCallback.useDebouncedCallback + }, + useDelay: function () { + return _useDelay.useDelay + }, + useDelayedRender: function () { + return _useDelayedRender.useDelayedRender + }, + useHotkey: function () { + return _useHotkey.default + }, + useIntersect: function () { + return _useIntersect.default + }, + useMountEffect: function () { + return _useMountEffect.default + }, + usePayloadAPI: function () { + return _usePayloadAPI.default + }, + useStepNav: function () { + return _StepNav.useStepNav + }, + useThrottledEffect: function () { + return _useThrottledEffect.default + }, + useThumbnail: function () { + return _useThumbnail.default + }, + useTitle: function () { + return _useTitle.default + }, +}) +const _StepNav = require('../dist/admin/components/elements/StepNav') +const _useDebounce = /*#__PURE__*/ _interop_require_default( + require('../dist/admin/hooks/useDebounce'), +) +const _useDebouncedCallback = require('../dist/admin/hooks/useDebouncedCallback') +const _useDelay = require('../dist/admin/hooks/useDelay') +const _useDelayedRender = require('../dist/admin/hooks/useDelayedRender') +const _useHotkey = /*#__PURE__*/ _interop_require_default(require('../dist/admin/hooks/useHotkey')) +const _useIntersect = /*#__PURE__*/ _interop_require_default( + require('../dist/admin/hooks/useIntersect'), +) +const _useMountEffect = /*#__PURE__*/ _interop_require_default( + require('../dist/admin/hooks/useMountEffect'), +) +const _usePayloadAPI = /*#__PURE__*/ _interop_require_default( + require('../dist/admin/hooks/usePayloadAPI'), +) +const _useThrottledEffect = /*#__PURE__*/ _interop_require_default( + require('../dist/admin/hooks/useThrottledEffect'), +) +const _useThumbnail = /*#__PURE__*/ _interop_require_default( + require('../dist/admin/hooks/useThumbnail'), +) +const _useTitle = /*#__PURE__*/ _interop_require_wildcard(require('../dist/admin/hooks/useTitle')) +function _interop_require_default(obj) { + return obj && obj.__esModule + ? obj + : { + default: obj, + } +} +function _getRequireWildcardCache(nodeInterop) { + if (typeof WeakMap !== 'function') return null + var cacheBabelInterop = new WeakMap() + var cacheNodeInterop = new WeakMap() + return (_getRequireWildcardCache = function (nodeInterop) { + return nodeInterop ? cacheNodeInterop : cacheBabelInterop + })(nodeInterop) +} +function _interop_require_wildcard(obj, nodeInterop) { + if (!nodeInterop && obj && obj.__esModule) { + return obj + } + if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) { + return { + default: obj, } -}); -const _StepNav = require("../dist/admin/components/elements/StepNav"); + } + var cache = _getRequireWildcardCache(nodeInterop) + if (cache && cache.has(obj)) { + return cache.get(obj) + } + var newObj = {} + var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor + for (var key in obj) { + if (key !== 'default' && Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null + if (desc && (desc.get || desc.set)) { + Object.defineProperty(newObj, key, desc) + } else { + newObj[key] = obj[key] + } + } + } + newObj.default = obj + if (cache) { + cache.set(obj, newObj) + } + return newObj +} -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9leHBvcnRzL2NvbXBvbmVudHMvaG9va3MudHMiXSwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IHsgdXNlU3RlcE5hdiB9IGZyb20gJy4uLy4uL2FkbWluL2NvbXBvbmVudHMvZWxlbWVudHMvU3RlcE5hdidcbiJdLCJuYW1lcyI6WyJ1c2VTdGVwTmF2Il0sIm1hcHBpbmdzIjoiOzs7OytCQUFTQTs7O2VBQUFBLG1CQUFVOzs7eUJBQVEifQ== \ No newline at end of file +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9leHBvcnRzL2NvbXBvbmVudHMvaG9va3MudHMiXSwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IHsgdXNlU3RlcE5hdiB9IGZyb20gJy4uLy4uL2FkbWluL2NvbXBvbmVudHMvZWxlbWVudHMvU3RlcE5hdid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YWRtaW4vaG9va3MvdXNlVGl0bGUnXG4iXSwibmFtZXMiOlsidXNlU3RlcE5hdiIsInVzZURlYm91bmNlIiwidXNlRGVib3VuY2VkQ2FsbGJhY2siLCJ1c2VEZWxheSIsInVzZURlbGF5ZWRSZW5kZXIiLCJ1c2VIb3RrZXkiLCJ1c2VJbnRlcnNlY3QiLCJ1c2VNb3VudEVmZmVjdCIsInVzZVBheWxvYWRBUEkiLCJ1c2VUaHJvdHRsZWRFZmZlY3QiLCJ1c2VUaHVtYm5haWwiLCJ1c2VUaXRsZSIsImZvcm1hdFVzZUFzVGl0bGUiXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7O0lBQVNBLFVBQVU7ZUFBVkEsbUJBQVU7O0lBQ0NDLFdBQVc7ZUFBWEEsb0JBQVc7O0lBQ3RCQyxvQkFBb0I7ZUFBcEJBLDBDQUFvQjs7SUFDcEJDLFFBQVE7ZUFBUkEsa0JBQVE7O0lBQ1JDLGdCQUFnQjtlQUFoQkEsa0NBQWdCOztJQUNMQyxTQUFTO2VBQVRBLGtCQUFTOztJQUNUQyxZQUFZO2VBQVpBLHFCQUFZOztJQUNaQyxjQUFjO2VBQWRBLHVCQUFjOztJQUNkQyxhQUFhO2VBQWJBLHNCQUFhOztJQUNiQyxrQkFBa0I7ZUFBbEJBLDJCQUFrQjs7SUFDbEJDLFlBQVk7ZUFBWkEscUJBQVk7O0lBQ1pDLFFBQVE7ZUFBUkEsaUJBQVE7O0lBQUVDLGdCQUFnQjtlQUFoQkEsMEJBQWdCOzs7eUJBWG5CO29FQUNZO3NDQUNGOzBCQUNaO2tDQUNRO2tFQUNJO3FFQUNHO3VFQUNFO3NFQUNEOzJFQUNLO3FFQUNOO2tFQUNjIn0= diff --git a/packages/payload/components/icons.d.ts b/packages/payload/components/icons.d.ts index 8593acaa61..63984d7e6a 100644 --- a/packages/payload/components/icons.d.ts +++ b/packages/payload/components/icons.d.ts @@ -1,3 +1,3 @@ -export { default as Chevron } from '../dist/admin/components/icons/Chevron'; -export { default as X } from '../dist/admin/components/icons/X'; -//# sourceMappingURL=icons.d.ts.map \ No newline at end of file +export { default as Chevron } from '../dist/admin/components/icons/Chevron' +export { default as X } from '../dist/admin/components/icons/X' +//# sourceMappingURL=icons.d.ts.map diff --git a/packages/payload/components/icons.js b/packages/payload/components/icons.js index 42edf0e715..c9ebf59f90 100644 --- a/packages/payload/components/icons.js +++ b/packages/payload/components/icons.js @@ -1,27 +1,32 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { - value: true -}); +'use strict' +Object.defineProperty(exports, '__esModule', { + value: true, +}) function _export(target, all) { - for(var name in all)Object.defineProperty(target, name, { - enumerable: true, - get: all[name] - }); + for (var name in all) + Object.defineProperty(target, name, { + enumerable: true, + get: all[name], + }) } _export(exports, { - Chevron: function() { - return _Chevron.default; - }, - X: function() { - return _X.default; - } -}); -const _Chevron = /*#__PURE__*/ _interop_require_default(require("../dist/admin/components/icons/Chevron")); -const _X = /*#__PURE__*/ _interop_require_default(require("../dist/admin/components/icons/X")); + Chevron: function () { + return _Chevron.default + }, + X: function () { + return _X.default + }, +}) +const _Chevron = /*#__PURE__*/ _interop_require_default( + require('../dist/admin/components/icons/Chevron'), +) +const _X = /*#__PURE__*/ _interop_require_default(require('../dist/admin/components/icons/X')) function _interop_require_default(obj) { - return obj && obj.__esModule ? obj : { - default: obj - }; + return obj && obj.__esModule + ? obj + : { + default: obj, + } } -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9leHBvcnRzL2NvbXBvbmVudHMvaWNvbnMudHMiXSwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IHsgZGVmYXVsdCBhcyBDaGV2cm9uIH0gZnJvbSAnLi4vLi4vYWRtaW4vY29tcG9uZW50cy9pY29ucy9DaGV2cm9uJ1xuZXhwb3J0IHsgZGVmYXVsdCBhcyBYIH0gZnJvbSAnLi4vLi4vYWRtaW4vY29tcG9uZW50cy9pY29ucy9YJ1xuIl0sIm5hbWVzIjpbIkNoZXZyb24iLCJYIl0sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7OztJQUFvQkEsT0FBTztlQUFQQSxnQkFBTzs7SUFDUEMsQ0FBQztlQUFEQSxVQUFDOzs7Z0VBRGM7MERBQ04ifQ== \ No newline at end of file +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9leHBvcnRzL2NvbXBvbmVudHMvaWNvbnMudHMiXSwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IHsgZGVmYXVsdCBhcyBDaGV2cm9uIH0gZnJvbSAnLi4vLi4vYWRtaW4vY29tcG9uZW50cy9pY29ucy9DaGV2cm9uJ1xuZXhwb3J0IHsgZGVmYXVsdCBhcyBYIH0gZnJvbSAnLi4vLi4vYWRtaW4vY29tcG9uZW50cy9pY29ucy9YJ1xuIl0sIm5hbWVzIjpbIkNoZXZyb24iLCJYIl0sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7OztJQUFvQkEsT0FBTztlQUFQQSxnQkFBTzs7SUFDUEMsQ0FBQztlQUFEQSxVQUFDOzs7Z0VBRGM7MERBQ04ifQ== diff --git a/packages/payload/components/index.js b/packages/payload/components/index.js index 93d8f03fd3..efd0c3c540 100644 --- a/packages/payload/components/index.js +++ b/packages/payload/components/index.js @@ -1,27 +1,12593 @@ -(()=>{var e={9509:(e,t,n)=>{"use strict";n.r(t),n.d(t,{SortableContext:()=>je,arrayMove:()=>Ce,arraySwap:()=>_e,defaultAnimateLayoutChanges:()=>Ae,defaultNewIndexGetter:()=>Fe,hasSortableData:()=>Ve,horizontalListSortingStrategy:()=>Me,rectSortingStrategy:()=>Te,rectSwappingStrategy:()=>Le,sortableKeyboardCoordinates:()=>Ke,useSortable:()=>He,verticalListSortingStrategy:()=>ze});var r=n(9497),a=n.n(r);n(3730);const o="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement;function l(e){const t=Object.prototype.toString.call(e);return"[object Window]"===t||"[object global]"===t}function i(e){return"nodeType"in e}function u(e){var t,n;return e?l(e)?e:i(e)&&null!=(t=null==(n=e.ownerDocument)?void 0:n.defaultView)?t:window:window}function s(e){const{Document:t}=u(e);return e instanceof t}function c(e){return!l(e)&&e instanceof u(e).HTMLElement}function f(e){return e?l(e)?e.document:i(e)?s(e)?e:c(e)?e.ownerDocument:document:document:document}const d=o?r.useLayoutEffect:r.useEffect;function p(e){const t=(0,r.useRef)(e);return d((()=>{t.current=e})),(0,r.useCallback)((function(){for(var e=arguments.length,n=new Array(e),r=0;r{n.current!==e&&(n.current=e)}),t),n}function m(e){const t=p(e),n=(0,r.useRef)(null),a=(0,r.useCallback)((e=>{e!==n.current&&(null==t||t(e,n.current)),n.current=e}),[]);return[n,a]}let v={};function g(e,t){return(0,r.useMemo)((()=>{if(t)return t;const n=null==v[e]?0:v[e]+1;return v[e]=n,e+"-"+n}),[e,t])}function y(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),a=1;a{const r=Object.entries(n);for(const[n,a]of r){const r=t[n];null!=r&&(t[n]=r+e*a)}return t}),{...t})}}const b=y(1),w=y(-1);function k(e){if(!e)return!1;const{KeyboardEvent:t}=u(e.target);return t&&e instanceof t}function x(e){if(function(e){if(!e)return!1;const{TouchEvent:t}=u(e.target);return t&&e instanceof t}(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return function(e){return"clientX"in e&&"clientY"in e}(e)?{x:e.clientX,y:e.clientY}:null}const S=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[S.Translate.toString(e),S.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}});var E;function C(){}!function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"}(E||(E={}));const _=Object.freeze({x:0,y:0});function P(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function N(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function O(e){let{left:t,top:n,height:r,width:a}=e;return[{x:t,y:n},{x:t+a,y:n},{x:t,y:n+r},{x:t+a,y:n+r}]}function M(e,t){if(!e||0===e.length)return null;const[n]=e;return t?n[t]:n}function T(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}const L={ignoreTransform:!1};function R(e,t){void 0===t&&(t=L);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:t,transformOrigin:r}=u(e).getComputedStyle(e);t&&(n=function(e,t,n){const r=T(t);if(!r)return e;const{scaleX:a,scaleY:o,x:l,y:i}=r,u=e.left-l-(1-a)*parseFloat(n),s=e.top-i-(1-o)*parseFloat(n.slice(n.indexOf(" ")+1)),c=a?e.width/a:e.width,f=o?e.height/o:e.height;return{width:c,height:f,top:s,right:u+c,bottom:s+f,left:u}}(n,t,r))}const{top:r,left:a,width:o,height:l,bottom:i,right:s}=n;return{top:r,left:a,width:o,height:l,bottom:i,right:s}}function z(e){return R(e,{ignoreTransform:!0})}function D(e,t){const n=[];return e?function r(a){if(null!=t&&n.length>=t)return n;if(!a)return n;if(s(a)&&null!=a.scrollingElement&&!n.includes(a.scrollingElement))return n.push(a.scrollingElement),n;if(!c(a)||function(e){return e instanceof u(e).SVGElement}(a))return n;if(n.includes(a))return n;const o=u(e).getComputedStyle(a);return a!==e&&function(e,t){void 0===t&&(t=u(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some((e=>{const r=t[e];return"string"==typeof r&&n.test(r)}))}(a,o)&&n.push(a),function(e,t){return void 0===t&&(t=u(e).getComputedStyle(e)),"fixed"===t.position}(a,o)?n:r(a.parentNode)}(e):n}function I(e){const[t]=D(e,1);return null!=t?t:null}var j;function F(e){return!(!o||!e)&&e===document.scrollingElement}function A(e){const t={x:0,y:0},n=F(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}!function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"}(j||(j={}));function $(e){if(e===document.scrollingElement){const{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}const{top:t,left:n,right:r,bottom:a}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:a,width:e.clientWidth,height:e.clientHeight}}function U(e,t){if(void 0===t&&(t=R),!e)return;const{top:n,left:r,bottom:a,right:o}=t(e);I(e)&&(a<=0||o<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}class B{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach((e=>{var t;return null==(t=this.target)?void 0:t.removeEventListener(...e)}))},this.target=e}add(e,t,n){var r;null==(r=this.target)||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}}function W(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return"number"==typeof t?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t&&r>t.y}var H,V;function Q(e){e.preventDefault()}function K(e){e.stopPropagation()}!function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"}(H||(H={})),function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter"}(V||(V={}));const q={start:[V.Space,V.Enter],cancel:[V.Esc],end:[V.Space,V.Enter]},Y=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case V.Right:return{...n,x:n.x+25};case V.Left:return{...n,x:n.x-25};case V.Down:return{...n,y:n.y+25};case V.Up:return{...n,y:n.y-25}}};class X{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:t}}=e;this.props=e,this.listeners=new B(f(t)),this.windowListeners=new B(u(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(H.Resize,this.handleCancel),this.windowListeners.add(H.VisibilityChange,this.handleCancel),setTimeout((()=>this.listeners.add(H.Keydown,this.handleKeyDown)))}handleStart(){const{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&U(n),t(_)}handleKeyDown(e){if(k(e)){const{active:t,context:n,options:r}=this.props,{keyboardCodes:a=q,coordinateGetter:o=Y,scrollBehavior:l="smooth"}=r,{code:i}=e;if(a.end.includes(i))return void this.handleEnd(e);if(a.cancel.includes(i))return void this.handleCancel(e);const{collisionRect:u}=n.current,s=u?{x:u.left,y:u.top}:_;this.referenceCoordinates||(this.referenceCoordinates=s);const c=o(e,{active:t,context:n.current,currentCoordinates:s});if(c){const t=w(c,s),r={x:0,y:0},{scrollableAncestors:a}=n.current;for(const n of a){const a=e.code,{isTop:o,isRight:i,isLeft:u,isBottom:s,maxScroll:f,minScroll:d}=A(n),p=$(n),h={x:Math.min(a===V.Right?p.right-p.width/2:p.right,Math.max(a===V.Right?p.left:p.left+p.width/2,c.x)),y:Math.min(a===V.Down?p.bottom-p.height/2:p.bottom,Math.max(a===V.Down?p.top:p.top+p.height/2,c.y))},m=a===V.Right&&!i||a===V.Left&&!u,v=a===V.Down&&!s||a===V.Up&&!o;if(m&&h.x!==c.x){const e=n.scrollLeft+t.x,o=a===V.Right&&e<=f.x||a===V.Left&&e>=d.x;if(o&&!t.y)return void n.scrollTo({left:e,behavior:l});r.x=o?n.scrollLeft-e:a===V.Right?n.scrollLeft-f.x:n.scrollLeft-d.x,r.x&&n.scrollBy({left:-r.x,behavior:l});break}if(v&&h.y!==c.y){const e=n.scrollTop+t.y,o=a===V.Down&&e<=f.y||a===V.Up&&e>=d.y;if(o&&!t.x)return void n.scrollTo({top:e,behavior:l});r.y=o?n.scrollTop-e:a===V.Down?n.scrollTop-f.y:n.scrollTop-d.y,r.y&&n.scrollBy({top:-r.y,behavior:l});break}}this.handleMove(e,b(w(c,this.referenceCoordinates),r))}}}handleMove(e,t){const{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){const{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){const{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}function G(e){return Boolean(e&&"distance"in e)}function J(e){return Boolean(e&&"delay"in e)}X.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=q,onActivation:a}=t,{active:o}=n;const{code:l}=e.nativeEvent;if(r.start.includes(l)){const t=o.activatorNode.current;return(!t||e.target===t)&&(e.preventDefault(),null==a||a({event:e.nativeEvent}),!0)}return!1}}];class Z{constructor(e,t,n){var r;void 0===n&&(n=function(e){const{EventTarget:t}=u(e);return e instanceof t?e:f(e)}(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;const{event:a}=e,{target:o}=a;this.props=e,this.events=t,this.document=f(o),this.documentListeners=new B(this.document),this.listeners=new B(n),this.windowListeners=new B(u(o)),this.initialCoordinates=null!=(r=x(a))?r:_,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:t}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),this.windowListeners.add(H.Resize,this.handleCancel),this.windowListeners.add(H.DragStart,Q),this.windowListeners.add(H.VisibilityChange,this.handleCancel),this.windowListeners.add(H.ContextMenu,Q),this.documentListeners.add(H.Keydown,this.handleKeydown),t){if(G(t))return;if(J(t))return void(this.timeoutId=setTimeout(this.handleStart,t.delay))}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),null!==this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handleStart(){const{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(H.Click,K,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(H.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){var t;const{activated:n,initialCoordinates:r,props:a}=this,{onMove:o,options:{activationConstraint:l}}=a;if(!r)return;const i=null!=(t=x(e))?t:_,u=w(r,i);if(!n&&l){if(J(l))return W(u,l.tolerance)?this.handleCancel():void 0;if(G(l))return null!=l.tolerance&&W(u,l.tolerance)?this.handleCancel():W(u,l.distance)?this.handleStart():void 0}e.cancelable&&e.preventDefault(),o(i)}handleEnd(){const{onEnd:e}=this.props;this.detach(),e()}handleCancel(){const{onCancel:e}=this.props;this.detach(),e()}handleKeydown(e){e.code===V.Esc&&this.handleCancel()}removeTextSelection(){var e;null==(e=this.document.getSelection())||e.removeAllRanges()}}const ee={move:{name:"pointermove"},end:{name:"pointerup"}};class te extends Z{constructor(e){const{event:t}=e,n=f(t.target);super(e,ee,n)}}te.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!(!n.isPrimary||0!==n.button)&&(null==r||r({event:n}),!0)}}];const ne={move:{name:"mousemove"},end:{name:"mouseup"}};var re;!function(e){e[e.RightClick=2]="RightClick"}(re||(re={}));(class extends Z{constructor(e){super(e,ne,f(e.event.target))}}).activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button!==re.RightClick&&(null==r||r({event:n}),!0)}}];const ae={move:{name:"touchmove"},end:{name:"touchend"}};var oe,le;(class extends Z{constructor(e){super(e,ae)}static setup(){return window.addEventListener(ae.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(ae.move.name,e)};function e(){}}}).activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:a}=n;return!(a.length>1)&&(null==r||r({event:n}),!0)}}],function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"}(oe||(oe={})),function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"}(le||(le={}));j.Backward,j.Forward,j.Backward,j.Forward;var ie,ue;!function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"}(ie||(ie={})),function(e){e.Optimized="optimized"}(ue||(ue={}));function se(e){let{callback:t,disabled:n}=e;const a=p(t),o=(0,r.useMemo)((()=>{if(n||"undefined"==typeof window||void 0===window.ResizeObserver)return;const{ResizeObserver:e}=window;return new e(a)}),[n]);return(0,r.useEffect)((()=>()=>null==o?void 0:o.disconnect()),[o]),o}const ce={draggable:{measure:z},droppable:{measure:z,strategy:ie.WhileDragging,frequency:ue.Optimized},dragOverlay:{measure:R}};class fe extends Map{get(e){var t;return null!=e&&null!=(t=super.get(e))?t:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter((e=>{let{disabled:t}=e;return!t}))}getNodeFor(e){var t,n;return null!=(t=null==(n=this.get(e))?void 0:n.node.current)?t:void 0}}const de={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new fe,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:C},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:ce,measureDroppableContainers:C,windowRect:null,measuringScheduled:!1},pe={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:C,draggableNodes:new Map,over:null,measureDroppableContainers:C},he=(0,r.createContext)(pe),me=(0,r.createContext)(de);const ve=(0,r.createContext)({..._,scaleX:1,scaleY:1});var ge;!function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"}(ge||(ge={}));const ye=(0,r.createContext)(null),be="button",we="Droppable";function ke(e){let{id:t,data:n,disabled:a=!1,attributes:o}=e;const l=g(we),{activators:i,activatorEvent:u,active:s,activeNodeRect:c,ariaDescribedById:f,draggableNodes:p,over:v}=(0,r.useContext)(he),{role:y=be,roleDescription:b="draggable",tabIndex:w=0}=null!=o?o:{},k=(null==s?void 0:s.id)===t,x=(0,r.useContext)(k?ve:ye),[S,E]=m(),[C,_]=m(),P=function(e,t){return(0,r.useMemo)((()=>e.reduce(((e,n)=>{let{eventName:r,handler:a}=n;return e[r]=e=>{a(e,t)},e}),{})),[e,t])}(i,t),N=h(n);d((()=>(p.set(t,{id:t,key:l,node:S,activatorNode:C,data:N}),()=>{const e=p.get(t);e&&e.key===l&&p.delete(t)})),[p,t]);return{active:s,activatorEvent:u,activeNodeRect:c,attributes:(0,r.useMemo)((()=>({role:y,tabIndex:w,"aria-disabled":a,"aria-pressed":!(!k||y!==be)||void 0,"aria-roledescription":b,"aria-describedby":f.draggable})),[a,y,w,k,b,f.draggable]),isDragging:k,listeners:a?void 0:P,node:S,over:v,setNodeRef:E,setActivatorNodeRef:_,transform:x}}function xe(){return(0,r.useContext)(me)}const Se="Droppable",Ee={timeout:25};function Ce(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function _e(e,t,n){const r=e.slice();return r[t]=e[n],r[n]=e[t],r}function Pe(e,t){return e.reduce(((e,n,r)=>{const a=t.get(n);return a&&(e[r]=a),e}),Array(e.length))}function Ne(e){return null!==e&&e>=0}const Oe={scaleX:1,scaleY:1},Me=e=>{var t;let{rects:n,activeNodeRect:r,activeIndex:a,overIndex:o,index:l}=e;const i=null!=(t=n[a])?t:r;if(!i)return null;const u=function(e,t,n){const r=e[t],a=e[t-1],o=e[t+1];if(!r||!a&&!o)return 0;if(na&&l<=o?{x:-i.width-u,y:0,...Oe}:l=o?{x:i.width+u,y:0,...Oe}:{x:0,y:0,...Oe}};const Te=e=>{let{rects:t,activeIndex:n,overIndex:r,index:a}=e;const o=Ce(t,r,n),l=t[a],i=o[a];return i&&l?{x:i.left-l.left,y:i.top-l.top,scaleX:i.width/l.width,scaleY:i.height/l.height}:null},Le=e=>{let t,n,{activeIndex:r,index:a,rects:o,overIndex:l}=e;return a===r&&(t=o[a],n=o[l]),a===l&&(t=o[a],n=o[r]),n&&t?{x:n.left-t.left,y:n.top-t.top,scaleX:n.width/t.width,scaleY:n.height/t.height}:null},Re={scaleX:1,scaleY:1},ze=e=>{var t;let{activeIndex:n,activeNodeRect:r,index:a,rects:o,overIndex:l}=e;const i=null!=(t=o[n])?t:r;if(!i)return null;if(a===n){const e=o[l];return e?{x:0,y:nn&&a<=l?{x:0,y:-i.height-u,...Re}:a=l?{x:0,y:i.height+u,...Re}:{x:0,y:0,...Re}};const De="Sortable",Ie=a().createContext({activeIndex:-1,containerId:De,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Te,disabled:{draggable:!1,droppable:!1}});function je(e){let{children:t,id:n,items:o,strategy:l=Te,disabled:i=!1}=e;const{active:u,dragOverlay:s,droppableRects:c,over:f,measureDroppableContainers:p}=xe(),h=g(De,n),m=Boolean(null!==s.rect),v=(0,r.useMemo)((()=>o.map((e=>"object"==typeof e&&"id"in e?e.id:e))),[o]),y=null!=u,b=u?v.indexOf(u.id):-1,w=f?v.indexOf(f.id):-1,k=(0,r.useRef)(v),x=!function(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n{x&&y&&p(v)}),[x,v,y,p]),(0,r.useEffect)((()=>{k.current=v}),[v]);const C=(0,r.useMemo)((()=>({activeIndex:b,containerId:h,disabled:E,disableTransforms:S,items:v,overIndex:w,useDragOverlay:m,sortedRects:Pe(v,c),strategy:l})),[b,h,E.draggable,E.droppable,S,v,w,c,m,l]);return a().createElement(Ie.Provider,{value:C},t)}const Fe=e=>{let{id:t,items:n,activeIndex:r,overIndex:a}=e;return Ce(n,r,a).indexOf(t)},Ae=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:a,items:o,newIndex:l,previousItems:i,previousContainerId:u,transition:s}=e;return!(!s||!r)&&((i===o||a!==l)&&(!!n||l!==a&&t===u))},$e={duration:200,easing:"ease"},Ue="transform",Be=S.Transition.toString({property:Ue,duration:0,easing:"linear"}),We={roleDescription:"sortable"};function He(e){let{animateLayoutChanges:t=Ae,attributes:n,disabled:a,data:o,getNewIndex:l=Fe,id:i,strategy:u,resizeObserverConfig:s,transition:c=$e}=e;const{items:f,containerId:p,activeIndex:v,disabled:y,disableTransforms:b,sortedRects:w,overIndex:x,useDragOverlay:C,strategy:_}=(0,r.useContext)(Ie),P=function(e,t){var n,r;if("boolean"==typeof e)return{draggable:e,droppable:!1};return{draggable:null!=(n=null==e?void 0:e.draggable)?n:t.draggable,droppable:null!=(r=null==e?void 0:e.droppable)?r:t.droppable}}(a,y),N=f.indexOf(i),O=(0,r.useMemo)((()=>({sortable:{containerId:p,index:N,items:f},...o})),[p,o,N,f]),M=(0,r.useMemo)((()=>f.slice(f.indexOf(i))),[f,i]),{rect:T,node:L,isOver:z,setNodeRef:D}=function(e){let{data:t,disabled:n=!1,id:a,resizeObserverConfig:o}=e;const l=g(Se),{active:i,dispatch:u,over:s,measureDroppableContainers:c}=(0,r.useContext)(he),f=(0,r.useRef)({disabled:n}),p=(0,r.useRef)(!1),v=(0,r.useRef)(null),y=(0,r.useRef)(null),{disabled:b,updateMeasurementsFor:w,timeout:k}={...Ee,...o},x=h(null!=w?w:a),S=se({callback:(0,r.useCallback)((()=>{p.current?(null!=y.current&&clearTimeout(y.current),y.current=setTimeout((()=>{c(Array.isArray(x.current)?x.current:[x.current]),y.current=null}),k)):p.current=!0}),[k]),disabled:b||!i}),C=(0,r.useCallback)(((e,t)=>{S&&(t&&(S.unobserve(t),p.current=!1),e&&S.observe(e))}),[S]),[_,P]=m(C),N=h(t);return(0,r.useEffect)((()=>{S&&_.current&&(S.disconnect(),p.current=!1,S.observe(_.current))}),[_,S]),d((()=>(u({type:E.RegisterDroppable,element:{id:a,key:l,disabled:n,node:_,rect:v,data:N}}),()=>u({type:E.UnregisterDroppable,key:l,id:a}))),[a]),(0,r.useEffect)((()=>{n!==f.current.disabled&&(u({type:E.SetDroppableDisabled,id:a,key:l,disabled:n}),f.current.disabled=n)}),[a,l,n,u]),{active:i,rect:v,isOver:(null==s?void 0:s.id)===a,node:_,over:s,setNodeRef:P}}({id:i,data:O,disabled:P.droppable,resizeObserverConfig:{updateMeasurementsFor:M,...s}}),{active:I,activatorEvent:j,activeNodeRect:F,attributes:A,setNodeRef:$,listeners:U,isDragging:B,over:W,setActivatorNodeRef:H,transform:V}=ke({id:i,data:O,attributes:{...We,...n},disabled:P.draggable}),Q=function(){for(var e=arguments.length,t=new Array(e),n=0;ne=>{t.forEach((t=>t(e)))}),t)}(D,$),K=Boolean(I),q=K&&!b&&Ne(v)&&Ne(x),Y=!C&&B,X=Y&&q?V:null,G=q?null!=X?X:(null!=u?u:_)({rects:w,activeNodeRect:F,activeIndex:v,overIndex:x,index:N}):null,J=Ne(v)&&Ne(x)?l({id:i,items:f,activeIndex:v,overIndex:x}):N,Z=null==I?void 0:I.id,ee=(0,r.useRef)({activeId:Z,items:f,newIndex:J,containerId:p}),te=f!==ee.current.items,ne=t({active:I,containerId:p,isDragging:B,isSorting:K,id:i,index:N,items:f,newIndex:ee.current.newIndex,previousItems:ee.current.items,previousContainerId:ee.current.containerId,transition:c,wasDragging:null!=ee.current.activeId}),re=function(e){let{disabled:t,index:n,node:a,rect:o}=e;const[l,i]=(0,r.useState)(null),u=(0,r.useRef)(n);return d((()=>{if(!t&&n!==u.current&&a.current){const e=o.current;if(e){const t=R(a.current,{ignoreTransform:!0}),n={x:e.left-t.left,y:e.top-t.top,scaleX:e.width/t.width,scaleY:e.height/t.height};(n.x||n.y)&&i(n)}}n!==u.current&&(u.current=n)}),[t,n,a,o]),(0,r.useEffect)((()=>{l&&i(null)}),[l]),l}({disabled:!ne,index:N,node:L,rect:T});return(0,r.useEffect)((()=>{K&&ee.current.newIndex!==J&&(ee.current.newIndex=J),p!==ee.current.containerId&&(ee.current.containerId=p),f!==ee.current.items&&(ee.current.items=f)}),[K,J,p,f]),(0,r.useEffect)((()=>{if(Z===ee.current.activeId)return;if(Z&&!ee.current.activeId)return void(ee.current.activeId=Z);const e=setTimeout((()=>{ee.current.activeId=Z}),50);return()=>clearTimeout(e)}),[Z]),{active:I,activeIndex:v,attributes:A,data:O,rect:T,index:N,newIndex:J,items:f,isOver:z,isSorting:K,isDragging:B,listeners:U,node:L,overIndex:x,over:W,setNodeRef:Q,setActivatorNodeRef:H,setDroppableNodeRef:D,setDraggableNodeRef:$,transform:null!=re?re:G,transition:function(){if(re||te&&ee.current.newIndex===N)return Be;if(Y&&!k(j)||!c)return;if(K||ne)return S.Transition.toString({...c,property:Ue});return}()}}function Ve(e){if(!e)return!1;const t=e.data.current;return!!(t&&"sortable"in t&&"object"==typeof t.sortable&&"containerId"in t.sortable&&"items"in t.sortable&&"index"in t.sortable)}const Qe=[V.Down,V.Right,V.Up,V.Left],Ke=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:a,droppableContainers:o,over:l,scrollableAncestors:i}}=t;if(Qe.includes(e.code)){if(e.preventDefault(),!n||!r)return;const t=[];o.getEnabled().forEach((n=>{if(!n||null!=n&&n.disabled)return;const o=a.get(n.id);if(o)switch(e.code){case V.Down:r.topo.top&&t.push(n);break;case V.Left:r.left>o.left&&t.push(n);break;case V.Right:r.left{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const a=O(t),o=[];for(const e of r){const{id:t}=e,r=n.get(t);if(r){const n=O(r),l=a.reduce(((e,t,r)=>e+P(n[r],t)),0),i=Number((l/4).toFixed(4));o.push({id:t,data:{droppableContainer:e,value:i}})}}return o.sort(N)})({active:n,collisionRect:r,droppableRects:a,droppableContainers:t,pointerCoordinates:null});let s=M(u,"id");if(s===(null==l?void 0:l.id)&&u.length>1&&(s=u[1].id),null!=s){const e=o.get(n.id),t=o.get(s),l=t?a.get(t.id):null,u=null==t?void 0:t.node.current;if(u&&l&&e&&t){const n=D(u).some(((e,t)=>i[t]!==e)),a=qe(e,t),o=function(e,t){if(!Ve(e)||!Ve(t))return!1;if(!qe(e,t))return!1;return e.data.current.sortable.index{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=(0,n(9497).createContext)({});t.default=r},2767:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n{"use strict";var r=n(9415),a={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},o={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},l={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},i={};function u(e){return r.isMemo(e)?l:i[e.$$typeof]||a}i[r.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},i[r.Memo]=l;var s=Object.defineProperty,c=Object.getOwnPropertyNames,f=Object.getOwnPropertySymbols,d=Object.getOwnPropertyDescriptor,p=Object.getPrototypeOf,h=Object.prototype;e.exports=function e(t,n,r){if("string"!=typeof n){if(h){var a=p(n);a&&a!==h&&e(t,a,r)}var l=c(n);f&&(l=l.concat(f(n)));for(var i=u(t),m=u(n),v=0;v{e.exports=Array.isArray||function(e){return"[object Array]"==Object.prototype.toString.call(e)}},7366:(e,t,n)=>{"use strict";n.r(t)},1117:(e,t,n)=>{"use strict";n.r(t)},9279:(e,t,n)=>{"use strict";n.r(t)},4717:(e,t,n)=>{"use strict";n.r(t)},4393:(e,t,n)=>{"use strict";n.r(t)},754:(e,t,n)=>{"use strict";n.r(t)},5809:(e,t,n)=>{"use strict";n.r(t)},2862:(e,t,n)=>{"use strict";n.r(t)},5734:(e,t,n)=>{"use strict";n.r(t)},4574:(e,t,n)=>{"use strict";n.r(t)},3369:(e,t,n)=>{"use strict";n.r(t)},3617:(e,t,n)=>{"use strict";n.r(t)},3174:(e,t,n)=>{"use strict";n.r(t)},254:(e,t,n)=>{"use strict";n.r(t)},7345:(e,t,n)=>{"use strict";n.r(t)},2367:(e,t,n)=>{"use strict";n.r(t)},5415:(e,t,n)=>{var r=n(8967);e.exports=p,e.exports.parse=o,e.exports.compile=function(e,t){return i(o(e,t),t)},e.exports.tokensToFunction=i,e.exports.tokensToRegExp=d;var a=new RegExp(["(\\\\.)","([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))"].join("|"),"g");function o(e,t){for(var n,r=[],o=0,l=0,i="",c=t&&t.delimiter||"/";null!=(n=a.exec(e));){var f=n[0],d=n[1],p=n.index;if(i+=e.slice(l,p),l=p+f.length,d)i+=d[1];else{var h=e[l],m=n[2],v=n[3],g=n[4],y=n[5],b=n[6],w=n[7];i&&(r.push(i),i="");var k=null!=m&&null!=h&&h!==m,x="+"===b||"*"===b,S="?"===b||"*"===b,E=n[2]||c,C=g||y;r.push({name:v||o++,prefix:m||"",delimiter:E,optional:S,repeat:x,partial:k,asterisk:!!w,pattern:C?s(C):w?".*":"[^"+u(E)+"]+?"})}}return l{"use strict";var r=n(5148);function a(){}function o(){}o.resetWarningCache=a,e.exports=function(){function e(e,t,n,a,o,l){if(l!==r){var i=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw i.name="Invariant Violation",i}}function t(){return e}e.isRequired=e;var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:o,resetWarningCache:a};return n.PropTypes=n,n}},7862:(e,t,n)=>{e.exports=n(1772)()},5148:e=>{"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},5565:(e,t,n)=>{"use strict";var r=n(9497),a=n(5655); -/** - * @license React - * react-dom.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */function o(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n