Compare commits

..

19 Commits

Author SHA1 Message Date
Elliot DeNolf
2a8bd4c775 chore(release): v3.0.0-beta.96 [skip ci] 2024-08-29 11:25:10 -04:00
James Mikrut
ac10bad723 fix(db-postgres): nested localized arrays (#7962)
## Description

Fixes a bug with nested arrays within either localized blocks or arrays.
2024-08-29 15:01:53 +00:00
Elliot DeNolf
142616e6ad chore(eslint): curly [skip-lint] (#7959)
Now enforcing curly brackets on all if statements. Includes auto-fixer.


```ts
//  Bad
if (foo) foo++;

//  Good
if (foo) {
  foo++;
}
```




Note: this did not lint the `drizzle` package or any `db-*` packages.
This will be done in the future.
2024-08-29 10:15:36 -04:00
Jarrod Flesch
dd3d985091 chore: upload field style fix (#7942) 2024-08-29 00:11:56 -04:00
Jarrod Flesch
de3d7c95e7 fix: prevents duplicate active nav indicators (#7943) 2024-08-29 00:11:42 -04:00
Elliot DeNolf
570422ff9a chore(db-mongodb): adjust default exports (#7945) 2024-08-29 04:09:44 +00:00
Elliot DeNolf
53c41bdfd8 chore(cpa): unused vars (#7944) 2024-08-29 03:59:44 +00:00
Elliot DeNolf
e5c34ead16 chore: plugin lint fixes (#7947) 2024-08-29 03:59:16 +00:00
Elliot DeNolf
6e561b11ca chore(graphql): adjust default exports (#7946) 2024-08-29 03:51:03 +00:00
Jarrod Flesch
f7146362df chore: brings back tests from has many PR (#7917) 2024-08-28 22:44:58 -04:00
Elliot DeNolf
ec9d1cda2d chore(eslint): lint:fix on all packages (#7941)
- Run `lint:fix` on all packages to fix anything that may have slipped
through without being autofixed
- A few manual fixes as well.
2024-08-29 02:35:17 +00:00
Elliot DeNolf
657326b528 chore(eslint): remove unused .eslintignore files [skip ci] 2024-08-28 22:12:19 -04:00
James Mikrut
538b7ee616 feat!: auto-removes localized property from localized fields within other localized fields (#7933)
## Description

Payload localization works on a field-by-field basis. As you can nest
fields within other fields, you could potentially nest a localized field
within a localized field—but this would be redundant and unnecessary.
There would be no reason to define a localized field within a localized
parent field, given that the entire data structure from the parent field
onward would be localized.

Up until this point, Payload would _allow_ you to nest a localized field
within another localized field, and this might have worked in MongoDB
but it will throw errors in Postgres.

Now, Payload will automatically remove the `localized: true` property
from sub-fields within `sanitizeFields` if a parent field is localized.

This could potentially be a breaking change if you have a configuration
with MongoDB that nests localized fields within localized fields.

## Migrating

You probably only need to migrate if you are using MongoDB, as there,
you may not have noticed any problems. But in Postgres or SQLite, this
would have caused issues so it's unlikely that you've made it too far
without experiencing issues due to a nested localized fields config.

In the event you would like to keep existing data in this fashion, we
have added a `compatibility.allowLocalizedWithinLocalized` flag to the
Payload config, which you can set to `true`, and Payload will then
disable this new sanitization step.

Set this compatibility flag to `true` only if you have an existing
Payload MongoDB database from pre-3.0, and you have nested localized
fields that you would like to maintain without migrating.
2024-08-29 01:56:17 +00:00
Elliot DeNolf
828f5d866d build(scripts): add lint scripts to all, turbo lint tasks [skip ci] 2024-08-28 21:55:51 -04:00
Alessio Gravili
e375f6e727 feat: significantly reduce payload install size by removing unnecessary monaco-editor dependency (#7939)
This reduces the total install size of `payload` from 115 MB to 34 MB. 

We never used monaco-editor within payload - we were only using
`@monaco-editor/react` which is a lot smaller.

Since we expose its types to the end user, we have to add it to our
`dependencies`, not `devDependencies`.

Before:
https://npmgraph.js.org/?q=payload@3.0.0-canary.1a675ae#select=exact%3Apayload%403.0.0-canary.1a675ae&zoom=w

After:
https://npmgraph.js.org/?q=payload%403.0.0-canary.cdb9474#zoom=h&select=exact%3Apayload%403.0.0-canary.cdb9474
2024-08-28 23:24:42 +00:00
Paul
cc9b877e88 fix: improve validation errors for unique fields (#7937) 2024-08-28 16:10:54 -06:00
Alessio Gravili
dc12047723 feat: reduce package size and amount of dependencies by upgrading json-schema-to-typescript (#7938)
Closes https://github.com/payloadcms/payload/issues/7934
2024-08-28 21:59:32 +00:00
Jarrod Flesch
12fb691e4f chore: upload dropzone style changes (#7932) 2024-08-28 15:49:14 -04:00
Alessio Gravili
0962850086 fix: incorrect config.upload types (#7874)
Fixes https://github.com/payloadcms/payload/issues/7698

Now exporting `FetchAPIFileUploadOptions` from payload, as that type is
now used in `config.upload`.
2024-08-28 15:39:51 -04:00
457 changed files with 3366 additions and 1930 deletions

View File

@@ -71,6 +71,7 @@ The following options are available:
| **`db`** \* | The Database Adapter which will be used by Payload. [More details](../database/overview). |
| **`serverURL`** | A string used to define the absolute URL of your app. This includes the protocol, for example `https://example.com`. No paths allowed, only protocol, domain and (optionally) port. |
| **`collections`** | An array of Collections for Payload to manage. [More details](./collections). |
| **`compatibility`** | Compatibility flags for earlier versions of Payload. [More details](#compatibility-flags). |
| **`globals`** | An array of Globals for Payload to manage. [More details](./globals). |
| **`cors`** | Cross-origin resource sharing (CORS) is a mechanism that accept incoming requests from given domains. You can also customize the `Access-Control-Allow-Headers` header. [More details](#cors). |
| **`localization`** | Opt-in to translate your content into multiple locales. [More details](./localization). |
@@ -253,3 +254,13 @@ import type { Config, SanitizedConfig } from 'payload'
The Payload Config only lives on the server and is not allowed to contain any client-side code. That way, you can load up the Payload Config in any server environment or standalone script, without having to use Bundlers or Node.js loaders to handle importing client-only modules (e.g. scss files or React Components) without any errors.
Behind the curtains, the Next.js-based Admin Panel generates a ClientConfig, which strips away any server-only code and enriches the config with React Components.
## Compatibility flags
The Payload Config can accept compatibility flags for running the newest versions but with older databases. You should only use these flags if you need to, and should confirm that you need to prior to enabling these flags.
`allowLocalizedWithinLocalized`
Payload localization works on a field-by-field basis. As you can nest fields within other fields, you could potentially nest a localized field within a localized field—but this would be redundant and unnecessary. There would be no reason to define a localized field within a localized parent field, given that the entire data structure from the parent field onward would be localized.
By default, Payload will remove the `localized: true` property from sub-fields if a parent field is localized. Set this compatibility flag to `true` only if you have an existing Payload MongoDB database from pre-3.0, and you have nested localized fields that you would like to maintain without migrating.

View File

@@ -40,6 +40,7 @@ export const rootEslintConfig = [
{
ignores: [
...defaultESLintIgnores,
'packages/eslint-*/**',
'test/live-preview/next-app',
'packages/**/*.spec.ts',
'templates/**',

View File

@@ -1,6 +1,6 @@
{
"name": "payload-monorepo",
"version": "3.0.0-beta.95",
"version": "3.0.0-beta.96",
"private": true,
"type": "module",
"scripts": {
@@ -64,10 +64,10 @@
"docker:restart": "pnpm docker:stop --remove-orphans && pnpm docker:start",
"docker:start": "docker compose -f packages/plugin-cloud-storage/docker-compose.yml up -d",
"docker:stop": "docker compose -f packages/plugin-cloud-storage/docker-compose.yml down",
"fix": "eslint \"packages/**/*.ts\" --fix",
"force:build": "pnpm run build:core:force",
"lint": "eslint \"packages/**/*.ts\"",
"lint": "turbo run lint --concurrency 1 --continue",
"lint-staged": "lint-staged",
"lint:fix": "turbo run lint:fix --concurrency 1 --continue",
"obliterate-playwright-cache-macos": "rm -rf ~/Library/Caches/ms-playwright && find /System/Volumes/Data/private/var/folders -type d -name 'playwright*' -exec rm -rf {} +",
"prepare": "husky",
"reinstall": "pnpm clean:all && pnpm install",

View File

@@ -1,6 +1,6 @@
{
"name": "create-payload-app",
"version": "3.0.0-beta.95",
"version": "3.0.0-beta.96",
"homepage": "https://payloadcms.com",
"repository": {
"type": "git",
@@ -42,6 +42,8 @@
"build": "pnpm pack-template-files && pnpm typecheck && pnpm build:swc",
"build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
"clean": "rimraf {dist,*.tsbuildinfo}",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"pack-template-files": "node --no-deprecation --import @swc-node/register/esm-register src/scripts/pack-template-files.ts",
"prepublishOnly": "pnpm clean && pnpm build",
"test": "jest",

View File

@@ -14,6 +14,7 @@ import { getValidTemplates } from './templates.js'
describe('createProject', () => {
let projectDir: string
beforeAll(() => {
// eslint-disable-next-line no-console
console.log = jest.fn()
})
@@ -57,7 +58,7 @@ describe('createProject', () => {
const packageJson = fse.readJsonSync(packageJsonPath)
// Check package name and description
expect(packageJson.name).toEqual(projectName)
expect(packageJson.name).toStrictEqual(projectName)
})
describe('creates project from template', () => {
@@ -115,10 +116,6 @@ describe('createProject', () => {
})
)?.[0]
if (!payloadConfigPath) {
throw new Error(`Could not find payload.config.ts inside ${projectDir}`)
}
const content = fse.readFileSync(payloadConfigPath, 'utf-8')
// Check payload.config.ts

View File

@@ -2,7 +2,6 @@ import type { CompilerOptions } from 'typescript'
import * as p from '@clack/prompts'
import { parse, stringify } from 'comment-json'
import execa from 'execa'
import fs from 'fs'
import fse from 'fs-extra'
import globby from 'globby'
@@ -53,8 +52,7 @@ export async function initNext(args: InitNextArgs): Promise<InitNextResult> {
nextAppDetails.nextAppDir = createdAppDir
}
const { hasTopLevelLayout, isPayloadInstalled, isSrcDir, nextAppDir, nextConfigType } =
nextAppDetails
const { hasTopLevelLayout, isSrcDir, nextAppDir, nextConfigType } = nextAppDetails
if (!nextConfigType) {
return {
@@ -169,7 +167,9 @@ async function installAndConfigurePayload(
}
const logDebug = (message: string) => {
if (debug) origDebug(message)
if (debug) {
origDebug(message)
}
}
if (!fs.existsSync(projectDir)) {
@@ -210,7 +210,7 @@ async function installAndConfigurePayload(
)
// This is a little clunky and needs to account for isSrcDir
copyRecursiveSync(templateSrcDir, path.dirname(nextConfigPath), debug)
copyRecursiveSync(templateSrcDir, path.dirname(nextConfigPath))
// Wrap next.config.js with withPayload
await wrapNextConfig({ nextConfigPath, nextConfigType })

View File

@@ -4,13 +4,19 @@ import slugify from '@sindresorhus/slugify'
import type { CliArgs } from '../types.js'
export async function parseProjectName(args: CliArgs): Promise<string> {
if (args['--name']) return slugify(args['--name'])
if (args._[0]) return slugify(args._[0])
if (args['--name']) {
return slugify(args['--name'])
}
if (args._[0]) {
return slugify(args._[0])
}
const projectName = await p.text({
message: 'Project name?',
validate: (value) => {
if (!value) return 'Please enter a project name.'
if (!value) {
return 'Please enter a project name.'
}
},
})
if (p.isCancel(projectName)) {

View File

@@ -9,7 +9,9 @@ export async function parseTemplate(
if (args['--template']) {
const templateName = args['--template']
const template = validTemplates.find((t) => t.name === templateName)
if (!template) throw new Error('Invalid template given')
if (!template) {
throw new Error('Invalid template given')
}
return template
}

View File

@@ -54,7 +54,9 @@ export async function selectDb(args: CliArgs, projectName: string): Promise<DbDe
value: dbChoice.value,
})),
})
if (p.isCancel(dbType)) process.exit(0)
if (p.isCancel(dbType)) {
process.exit(0)
}
}
const dbChoice = dbChoiceRecord[dbType]
@@ -73,7 +75,9 @@ export async function selectDb(args: CliArgs, projectName: string): Promise<DbDe
initialValue: initialDbUri,
message: `Enter ${dbChoice.title.split(' ')[0]} connection string`, // strip beta from title
})
if (p.isCancel(dbUri)) process.exit(0)
if (p.isCancel(dbUri)) {
process.exit(0)
}
}
return {

View File

@@ -16,7 +16,9 @@ import { installPackages } from './install-packages.js'
export async function updatePayloadInProject(
appDetails: NextAppDetails,
): Promise<{ message: string; success: boolean }> {
if (!appDetails.nextConfigPath) return { message: 'No Next.js config found', success: false }
if (!appDetails.nextConfigPath) {
return { message: 'No Next.js config found', success: false }
}
const projectDir = path.dirname(appDetails.nextConfigPath)

View File

@@ -42,8 +42,6 @@ export async function parseAndModifyConfigContent(
): Promise<{ modifiedConfigContent: string; success: boolean }> {
content = withPayloadStatement[configType] + '\n' + content
console.log({ configType, content })
if (configType === 'cjs' || configType === 'esm') {
try {
const ast = parseModule(content, { loc: true })

View File

@@ -36,7 +36,9 @@ export async function writeEnvFile(args: {
.split('\n')
.filter((e) => e)
.map((line) => {
if (line.startsWith('#') || !line.includes('=')) return line
if (line.startsWith('#') || !line.includes('=')) {
return line
}
const split = line.split('=')
const key = split[0]

View File

@@ -6,7 +6,7 @@ import path from 'path'
*
* @internal
*/
export function copyRecursiveSync(src: string, dest: string, debug?: boolean) {
export function copyRecursiveSync(src: string, dest: string) {
const exists = fs.existsSync(src)
const stats = exists && fs.statSync(src)
const isDirectory = exists && stats !== false && stats.isDirectory()

View File

@@ -1,6 +1,6 @@
{
"name": "@payloadcms/db-mongodb",
"version": "3.0.0-beta.95",
"version": "3.0.0-beta.96",
"description": "The officially supported MongoDB database adapter for Payload",
"homepage": "https://payloadcms.com",
"repository": {
@@ -30,6 +30,8 @@
"build:swc": "swc ./src -d ./dist --config-file .swcrc-build --strip-leading-paths",
"build:types": "tsc --emitDeclarationOnly --outDir dist",
"clean": "rimraf {dist,*.tsbuildinfo}",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"prepublishOnly": "pnpm clean && pnpm turbo build"
},
"dependencies": {

View File

@@ -59,8 +59,10 @@ export const connect: Connect = async function connect(
await this.migrate({ migrations: this.prodMigrations })
}
} catch (err) {
console.log(err)
this.payload.logger.error(`Error: cannot connect to MongoDB. Details: ${err.message}`, err)
this.payload.logger.error({
err,
msg: `Error: cannot connect to MongoDB. Details: ${err.message}`,
})
process.exit(1)
}
}

View File

@@ -2,7 +2,7 @@ import type { CreateGlobal, PayloadRequest } from 'payload'
import type { MongooseAdapter } from './index.js'
import sanitizeInternalFields from './utilities/sanitizeInternalFields.js'
import { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js'
import { withSession } from './withSession.js'
export const createGlobal: CreateGlobal = async function createGlobal(

View File

@@ -2,7 +2,7 @@ import type { DeleteOne, Document, PayloadRequest } from 'payload'
import type { MongooseAdapter } from './index.js'
import sanitizeInternalFields from './utilities/sanitizeInternalFields.js'
import { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js'
import { withSession } from './withSession.js'
export const deleteOne: DeleteOne = async function deleteOne(

View File

@@ -6,7 +6,7 @@ import { flattenWhereToOperators } from 'payload'
import type { MongooseAdapter } from './index.js'
import { buildSortParam } from './queries/buildSortParam.js'
import sanitizeInternalFields from './utilities/sanitizeInternalFields.js'
import { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js'
import { withSession } from './withSession.js'
export const find: Find = async function find(

View File

@@ -4,7 +4,7 @@ import { combineQueries } from 'payload'
import type { MongooseAdapter } from './index.js'
import sanitizeInternalFields from './utilities/sanitizeInternalFields.js'
import { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js'
import { withSession } from './withSession.js'
export const findGlobal: FindGlobal = async function findGlobal(

View File

@@ -6,7 +6,7 @@ import { buildVersionGlobalFields, flattenWhereToOperators } from 'payload'
import type { MongooseAdapter } from './index.js'
import { buildSortParam } from './queries/buildSortParam.js'
import sanitizeInternalFields from './utilities/sanitizeInternalFields.js'
import { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js'
import { withSession } from './withSession.js'
export const findGlobalVersions: FindGlobalVersions = async function findGlobalVersions(

View File

@@ -3,7 +3,7 @@ import type { Document, FindOne, PayloadRequest } from 'payload'
import type { MongooseAdapter } from './index.js'
import sanitizeInternalFields from './utilities/sanitizeInternalFields.js'
import { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js'
import { withSession } from './withSession.js'
export const findOne: FindOne = async function findOne(

View File

@@ -6,7 +6,7 @@ import { flattenWhereToOperators } from 'payload'
import type { MongooseAdapter } from './index.js'
import { buildSortParam } from './queries/buildSortParam.js'
import sanitizeInternalFields from './utilities/sanitizeInternalFields.js'
import { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js'
import { withSession } from './withSession.js'
export const findVersions: FindVersions = async function findVersions(

View File

@@ -8,10 +8,10 @@ import { buildVersionCollectionFields, buildVersionGlobalFields } from 'payload'
import type { MongooseAdapter } from './index.js'
import type { CollectionModel } from './types.js'
import buildCollectionSchema from './models/buildCollectionSchema.js'
import { buildCollectionSchema } from './models/buildCollectionSchema.js'
import { buildGlobalModel } from './models/buildGlobalModel.js'
import buildSchema from './models/buildSchema.js'
import getBuildQueryPlugin from './queries/buildQuery.js'
import { buildSchema } from './models/buildSchema.js'
import { getBuildQueryPlugin } from './queries/buildQuery.js'
import { getDBName } from './utilities/getDBName.js'
export const init: Init = function init(this: MongooseAdapter) {

View File

@@ -3,10 +3,10 @@ import type { SanitizedCollectionConfig, SanitizedConfig } from 'payload'
import paginate from 'mongoose-paginate-v2'
import getBuildQueryPlugin from '../queries/buildQuery.js'
import buildSchema from './buildSchema.js'
import { getBuildQueryPlugin } from '../queries/buildQuery.js'
import { buildSchema } from './buildSchema.js'
const buildCollectionSchema = (
export const buildCollectionSchema = (
collection: SanitizedCollectionConfig,
config: SanitizedConfig,
schemaOptions = {},
@@ -44,5 +44,3 @@ const buildCollectionSchema = (
return schema
}
export default buildCollectionSchema

View File

@@ -4,8 +4,8 @@ import mongoose from 'mongoose'
import type { GlobalModel } from '../types.js'
import getBuildQueryPlugin from '../queries/buildQuery.js'
import buildSchema from './buildSchema.js'
import { getBuildQueryPlugin } from '../queries/buildQuery.js'
import { buildSchema } from './buildSchema.js'
export const buildGlobalModel = (config: SanitizedConfig): GlobalModel | null => {
if (config.globals && config.globals.length > 0) {

View File

@@ -111,7 +111,7 @@ const localizeSchema = (
return schema
}
const buildSchema = (
export const buildSchema = (
config: SanitizedConfig,
configFields: Field[],
buildSchemaOptions: BuildSchemaOptions = {},
@@ -669,5 +669,3 @@ const fieldToSchemaMap: Record<string, FieldSchemaGenerator> = {
})
},
}
export default buildSchema

View File

@@ -18,7 +18,10 @@ export type BuildQueryArgs = {
// This plugin asynchronously builds a list of Mongoose query constraints
// which can then be used in subsequent Mongoose queries.
const getBuildQueryPlugin = ({ collectionSlug, versionsFields }: GetBuildQueryPluginArgs = {}) => {
export const getBuildQueryPlugin = ({
collectionSlug,
versionsFields,
}: GetBuildQueryPluginArgs = {}) => {
return function buildQueryPlugin(schema) {
const modifiedSchema = schema
async function buildQuery({
@@ -57,5 +60,3 @@ const getBuildQueryPlugin = ({ collectionSlug, versionsFields }: GetBuildQueryPl
modifiedSchema.statics.buildQuery = buildQuery
}
}
export default getBuildQueryPlugin

View File

@@ -16,7 +16,7 @@ describe('get localized sort property', () => {
},
} as Config)
})
it('passes through a non-localized sort property', async () => {
it('passes through a non-localized sort property', () => {
const result = getLocalizedSortProperty({
config,
fields: [

View File

@@ -6,7 +6,7 @@ import { combineQueries, flattenWhereToOperators } from 'payload'
import type { MongooseAdapter } from './index.js'
import { buildSortParam } from './queries/buildSortParam.js'
import sanitizeInternalFields from './utilities/sanitizeInternalFields.js'
import { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js'
import { withSession } from './withSession.js'
export const queryDrafts: QueryDrafts = async function queryDrafts(

View File

@@ -6,6 +6,8 @@ import { v4 as uuid } from 'uuid'
import type { MongooseAdapter } from '../index.js'
// Needs await to fulfill the interface
// eslint-disable-next-line @typescript-eslint/require-await
export const beginTransaction: BeginTransaction = async function beginTransaction(
this: MongooseAdapter,
options: TransactionOptions,

View File

@@ -2,7 +2,7 @@ import type { PayloadRequest, UpdateGlobal } from 'payload'
import type { MongooseAdapter } from './index.js'
import sanitizeInternalFields from './utilities/sanitizeInternalFields.js'
import { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js'
import { withSession } from './withSession.js'
export const updateGlobal: UpdateGlobal = async function updateGlobal(

View File

@@ -3,7 +3,7 @@ import type { PayloadRequest, UpdateOne } from 'payload'
import type { MongooseAdapter } from './index.js'
import { handleError } from './utilities/handleError.js'
import sanitizeInternalFields from './utilities/sanitizeInternalFields.js'
import { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js'
import { withSession } from './withSession.js'
export const updateOne: UpdateOne = async function updateOne(

View File

@@ -1,6 +1,6 @@
const internalFields = ['__v']
const sanitizeInternalFields = <T extends Record<string, unknown>>(incomingDoc: T): T =>
export const sanitizeInternalFields = <T extends Record<string, unknown>>(incomingDoc: T): T =>
Object.entries(incomingDoc).reduce((newDoc, [key, val]): T => {
if (key === '_id') {
return {
@@ -18,5 +18,3 @@ const sanitizeInternalFields = <T extends Record<string, unknown>>(incomingDoc:
[key]: val,
}
}, {} as T)
export default sanitizeInternalFields

View File

@@ -1,6 +1,6 @@
{
"name": "@payloadcms/db-postgres",
"version": "3.0.0-beta.95",
"version": "3.0.0-beta.96",
"description": "The officially supported Postgres database adapter for Payload",
"homepage": "https://payloadcms.com",
"repository": {
@@ -40,6 +40,8 @@
"build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
"build:types": "tsc --emitDeclarationOnly --outDir dist",
"clean": "rimraf {dist,*.tsbuildinfo}",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"prepack": "pnpm clean && pnpm turbo build",
"prepublishOnly": "pnpm clean && pnpm turbo build",
"renamePredefinedMigrations": "node --no-deprecation --import @swc-node/register/esm-register ./scripts/renamePredefinedMigrations.ts"

View File

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

View File

@@ -1,6 +1,6 @@
{
"name": "@payloadcms/db-sqlite",
"version": "3.0.0-beta.95",
"version": "3.0.0-beta.96",
"description": "The officially supported SQLite database adapter for Payload",
"homepage": "https://payloadcms.com",
"repository": {
@@ -39,6 +39,8 @@
"build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
"build:types": "tsc --emitDeclarationOnly --outDir dist",
"clean": "rimraf {dist,*.tsbuildinfo}",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"prepack": "pnpm clean && pnpm turbo build",
"prepublishOnly": "pnpm clean && pnpm turbo build"
},

View File

@@ -1,6 +1,6 @@
{
"name": "@payloadcms/db-vercel-postgres",
"version": "3.0.0-beta.95",
"version": "3.0.0-beta.96",
"description": "Vercel Postgres adapter for Payload",
"homepage": "https://payloadcms.com",
"repository": {
@@ -40,6 +40,8 @@
"build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
"build:types": "tsc --emitDeclarationOnly --outDir dist",
"clean": "rimraf {dist,*.tsbuildinfo}",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"prepack": "pnpm clean && pnpm turbo build",
"prepublishOnly": "pnpm clean && pnpm turbo build",
"renamePredefinedMigrations": "node --no-deprecation --import @swc-node/register/esm-register ./scripts/renamePredefinedMigrations.ts"

View File

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

View File

@@ -1,6 +1,6 @@
{
"name": "@payloadcms/drizzle",
"version": "3.0.0-beta.95",
"version": "3.0.0-beta.96",
"description": "A library of shared functions used by different payload database adapters",
"homepage": "https://payloadcms.com",
"repository": {
@@ -39,6 +39,8 @@
"build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
"build:types": "tsc --emitDeclarationOnly --outDir dist",
"clean": "rimraf {dist,*.tsbuildinfo}",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"prepack": "pnpm clean && pnpm turbo build",
"prepublishOnly": "pnpm clean && pnpm turbo build"
},

View File

@@ -12,11 +12,11 @@ type BuildFindQueryArgs = {
tableName: string
}
export type Result = DBQueryConfig<'many', true, any, any> & {
with?: DBQueryConfig<'many', true, any, any> & {
export type Result = {
with?: {
_locales?: DBQueryConfig<'many', true, any, any>
}
}
} & DBQueryConfig<'many', true, any, any>
} & DBQueryConfig<'many', true, any, any>
// Generate the Drizzle query for findMany based on
// a collection field structure

View File

@@ -1,4 +1,3 @@
/* eslint-disable no-restricted-syntax, no-await-in-loop */
import type { PayloadRequest } from 'payload'
import {

View File

@@ -1,4 +1,3 @@
/* eslint-disable no-restricted-syntax, no-await-in-loop */
import type { PayloadRequest } from 'payload'
import {

View File

@@ -1,4 +1,3 @@
/* eslint-disable no-restricted-syntax, no-await-in-loop */
import type { PayloadRequest } from 'payload'
import {

View File

@@ -30,7 +30,7 @@ export async function migrateStatus(this: DrizzleAdapter): Promise<void> {
const existingMigration = existingMigrations.find((m) => m.name === migration.name)
return {
Name: migration.name,
// eslint-disable-next-line perfectionist/sort-objects
Batch: existingMigration?.batch,
Ran: existingMigration ? 'Yes' : 'No',
}

View File

@@ -28,11 +28,10 @@ export async function buildAndOrConditions({
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
for (const condition of where) {
// If the operation is properly formatted as an object
if (typeof condition === 'object') {
// eslint-disable-next-line no-await-in-loop
const result = await parseParams({
adapter,
fields,

View File

@@ -1,4 +1,3 @@
/* eslint-disable no-await-in-loop */
import type { SQL } from 'drizzle-orm'
import type { Field, Operator, Where } from 'payload'

View File

@@ -5,6 +5,7 @@ import type { ChainedMethods } from '../find/chainMethods.js'
import type {
DrizzleAdapter,
DrizzleTransaction,
GenericColumn,
GenericPgColumn,
TransactionPg,
TransactionSQLite,
@@ -12,7 +13,6 @@ import type {
import type { BuildQueryJoinAliases } from './buildQuery.js'
import { chainMethods } from '../find/chainMethods.js'
import { type GenericColumn } from '../types.js'
type Args = {
adapter: DrizzleAdapter
@@ -35,7 +35,7 @@ export const selectDistinct = ({
selectFields,
tableName,
where,
}: Args): QueryPromise<Record<string, GenericColumn> & { id: number | string }[]> => {
}: Args): QueryPromise<{ id: number | string }[] & Record<string, GenericColumn>> => {
if (Object.keys(joins).length > 0) {
if (where) {
chainedMethods.push({ args: [where], method: 'where' })

View File

@@ -35,7 +35,6 @@ export const queryDrafts: QueryDrafts = async function queryDrafts(
return {
...result,
docs: result.docs.map((doc) => {
// eslint-disable-next-line no-param-reassign
doc = {
id: doc.parent,
...doc.version,

View File

@@ -1,4 +1,3 @@
/* eslint-disable no-param-reassign */
import type { Field, SanitizedConfig, TypeWithID } from 'payload'
import type { DrizzleAdapter } from '../../types.js'

View File

@@ -177,7 +177,7 @@ export const traverseFields = <T extends Record<string, unknown>>({
return arrayResult
}, {})
} else {
result[field.name] = fieldData.map((row, i) => {
result[field.name] = fieldData.reduce((acc, row, i) => {
if (row._uuid) {
row.id = row._uuid
delete row._uuid
@@ -187,22 +187,35 @@ export const traverseFields = <T extends Record<string, unknown>>({
delete row._order
}
return traverseFields<T>({
adapter,
blocks,
config,
dataRef: row,
deletions,
fieldPrefix: '',
fields: field.fields,
numbers,
path: `${sanitizedPath}${field.name}.${i}`,
relationships,
table: row,
texts,
withinArrayOrBlockLocale,
})
})
if (
!withinArrayOrBlockLocale ||
(withinArrayOrBlockLocale && withinArrayOrBlockLocale === row._locale)
) {
if (row._locale) {
delete row._locale
}
acc.push(
traverseFields<T>({
adapter,
blocks,
config,
dataRef: row,
deletions,
fieldPrefix: '',
fields: field.fields,
numbers,
path: `${sanitizedPath}${field.name}.${i}`,
relationships,
table: row,
texts,
withinArrayOrBlockLocale,
}),
)
}
return acc
}, [])
}
}

View File

@@ -1,4 +1,3 @@
/* eslint-disable no-param-reassign */
import type { Field } from 'payload'
import type { DrizzleAdapter } from '../../types.js'

View File

@@ -1,4 +1,3 @@
/* eslint-disable no-param-reassign */
import { isArrayOfRows } from '../../utilities/isArrayOfRows.js'
type Args = {

View File

@@ -348,20 +348,52 @@ export const upsertRow = async <T extends Record<string, unknown> | TypeWithID>(
// Error Handling
// //////////////////////////////////
} catch (error) {
throw error.code === '23505'
? new ValidationError(
{
id,
errors: [
{
field: adapter.fieldConstraints[tableName][error.constraint],
message: req.t('error:valueMustBeUnique'),
},
],
},
req.t,
)
: error
if (error.code === '23505') {
let fieldName: null | string = null
// We need to try and find the right constraint for the field but if we can't we fallback to a generic message
if (adapter.fieldConstraints?.[tableName]) {
if (adapter.fieldConstraints[tableName]?.[error.constraint]) {
fieldName = adapter.fieldConstraints[tableName]?.[error.constraint]
} else {
const replacement = `${tableName}_`
if (error.constraint.includes(replacement)) {
const replacedConstraint = error.constraint.replace(replacement, '')
if (replacedConstraint && adapter.fieldConstraints[tableName]?.[replacedConstraint])
fieldName = adapter.fieldConstraints[tableName][replacedConstraint]
}
}
}
if (!fieldName) {
// Last case scenario we extract the key and value from the detail on the error
const detail = error.detail
const regex = /Key \(([^)]+)\)=\(([^)]+)\)/
const match = detail.match(regex)
if (match) {
const key = match[1]
fieldName = key
}
}
throw new ValidationError(
{
id,
errors: [
{
field: fieldName,
message: req.t('error:valueMustBeUnique'),
},
],
},
req.t,
)
} else {
throw error
}
}
if (ignoreResult) return data as T

View File

@@ -1,4 +1,3 @@
/* eslint-disable no-param-reassign */
import type { ArrayRowToInsert } from '../transform/write/types.js'
import type { DrizzleAdapter, DrizzleTransaction } from '../types.js'

View File

@@ -18,18 +18,18 @@ type BaseArgs = {
tableName: string
}
type CreateArgs = BaseArgs & {
type CreateArgs = {
id?: never
operation: 'create'
upsertTarget?: never
where?: never
}
} & BaseArgs
type UpdateArgs = BaseArgs & {
type UpdateArgs = {
id?: number | string
operation: 'update'
upsertTarget?: GenericColumn
where?: SQL<unknown>
}
} & BaseArgs
export type Args = CreateArgs | UpdateArgs

View File

@@ -1,4 +1,3 @@
/* eslint-disable no-param-reassign */
export type BlocksMap = {
[path: string]: Record<string, unknown>[]
}

View File

@@ -1,6 +1,6 @@
{
"name": "@payloadcms/email-nodemailer",
"version": "3.0.0-beta.95",
"version": "3.0.0-beta.96",
"description": "Payload Nodemailer Email Adapter",
"homepage": "https://payloadcms.com",
"repository": {
@@ -29,6 +29,8 @@
"build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
"build:types": "tsc --emitDeclarationOnly --outDir dist",
"clean": "rimraf {dist,*.tsbuildinfo}",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"prepublishOnly": "pnpm clean && pnpm turbo build"
},
"dependencies": {

View File

@@ -47,7 +47,9 @@ async function buildEmail(emailConfig?: NodemailerAdapterArgs): Promise<{
}> {
if (!emailConfig) {
const transport = await createMockAccount(emailConfig)
if (!transport) throw new InvalidConfiguration('Unable to create Nodemailer test account.')
if (!transport) {
throw new InvalidConfiguration('Unable to create Nodemailer test account.')
}
return {
defaultFromAddress: 'info@payloadcms.com',

View File

@@ -1,7 +1,11 @@
import { jest } from '@jest/globals'
import type { Transporter } from 'nodemailer'
import nodemailer, { Transporter } from 'nodemailer'
import { nodemailerAdapter, NodemailerAdapterArgs } from './index.js'
import { jest } from '@jest/globals'
import nodemailer from 'nodemailer'
import type { NodemailerAdapterArgs } from './index.js'
import { nodemailerAdapter } from './index.js'
const defaultArgs: NodemailerAdapterArgs = {
defaultFromAddress: 'test@test.com',
@@ -9,7 +13,6 @@ const defaultArgs: NodemailerAdapterArgs = {
}
describe('email-nodemailer', () => {
describe('transport verification', () => {
let mockedVerify: jest.Mock<Transporter['verify']>
let mockTransport: Transporter
@@ -18,20 +21,21 @@ describe('email-nodemailer', () => {
mockedVerify = jest.fn<Transporter['verify']>()
mockTransport = nodemailer.createTransport({
name: 'existing-transport',
// eslint-disable-next-line @typescript-eslint/require-await
// eslint-disable-next-line @typescript-eslint/require-await, @typescript-eslint/no-misused-promises
send: async (mail) => {
// eslint-disable-next-line no-console
console.log('mock send', mail)
},
version: '0.0.1',
verify: mockedVerify,
version: '0.0.1',
})
})
it('should be invoked when skipVerify = false', async () => {
await nodemailerAdapter({
...defaultArgs,
transport: mockTransport,
skipVerify: false,
transport: mockTransport,
})
expect(mockedVerify.mock.calls).toHaveLength(1)
@@ -40,8 +44,8 @@ describe('email-nodemailer', () => {
it('should be invoked when skipVerify is undefined', async () => {
await nodemailerAdapter({
...defaultArgs,
transport: mockTransport,
skipVerify: false,
transport: mockTransport,
})
expect(mockedVerify.mock.calls).toHaveLength(1)
@@ -50,8 +54,8 @@ describe('email-nodemailer', () => {
it('should not be invoked when skipVerify = true', async () => {
await nodemailerAdapter({
...defaultArgs,
transport: mockTransport,
skipVerify: true,
transport: mockTransport,
})
expect(mockedVerify.mock.calls).toHaveLength(0)

View File

@@ -1,6 +1,6 @@
{
"name": "@payloadcms/email-resend",
"version": "3.0.0-beta.95",
"version": "3.0.0-beta.96",
"description": "Payload Resend Email Adapter",
"homepage": "https://payloadcms.com",
"repository": {
@@ -28,6 +28,8 @@
"build:swc": "swc ./src -d ./dist --config-file .swcrc-build --strip-leading-paths",
"build:types": "tsc --emitDeclarationOnly --outDir dist",
"clean": "rimraf {dist,*.tsbuildinfo}",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"prepublishOnly": "pnpm clean && pnpm turbo build",
"test": "jest"
},

View File

@@ -14,6 +14,7 @@ import { deepMerge } from './deepMerge.js'
const baseRules = {
// This rule makes no sense when overriding class methods. This is used a lot in richtext-lexical.
'class-methods-use-this': 'off',
curly: ['warn', 'all'],
'arrow-body-style': 0,
'import-x/prefer-default-export': 'off',
'no-restricted-exports': ['warn', { restrictDefaultExports: { direct: true } }],

View File

@@ -1,6 +1,6 @@
{
"name": "@payloadcms/graphql",
"version": "3.0.0-beta.95",
"version": "3.0.0-beta.96",
"homepage": "https://payloadcms.com",
"repository": {
"type": "git",
@@ -38,6 +38,8 @@
"build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
"build:types": "tsc --emitDeclarationOnly --outDir dist",
"clean": "rimraf {dist,*.tsbuildinfo}",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"prepublishOnly": "pnpm clean && pnpm turbo build"
},
"dependencies": {

View File

@@ -8,12 +8,12 @@ import {
fieldExtensionsEstimator,
simpleEstimator,
} from './packages/graphql-query-complexity/index.js'
import accessResolver from './resolvers/auth/access.js'
import buildFallbackLocaleInputType from './schema/buildFallbackLocaleInputType.js'
import buildLocaleInputType from './schema/buildLocaleInputType.js'
import buildPoliciesType from './schema/buildPoliciesType.js'
import initCollections from './schema/initCollections.js'
import initGlobals from './schema/initGlobals.js'
import { accessResolver } from './resolvers/auth/access.js'
import { buildFallbackLocaleInputType } from './schema/buildFallbackLocaleInputType.js'
import { buildLocaleInputType } from './schema/buildLocaleInputType.js'
import { buildPoliciesType } from './schema/buildPoliciesType.js'
import { initCollections } from './schema/initCollections.js'
import { initGlobals } from './schema/initGlobals.js'
import { wrapCustomFields } from './utilities/wrapCustomResolver.js'
export function configToSchema(config: SanitizedConfig): {

View File

@@ -122,7 +122,7 @@ export function getComplexity(options: {
return visitor.complexity
}
export default class QueryComplexity {
export class QueryComplexity {
OperationDefinition: Record<string, any>
complexity: number
context: ValidationContext

View File

@@ -2,7 +2,7 @@ import type { ValidationContext } from 'graphql'
import type { QueryComplexityOptions } from './QueryComplexity.js'
import QueryComplexity from './QueryComplexity.js'
import { QueryComplexity } from './QueryComplexity.js'
export function createComplexityRule(
options: QueryComplexityOptions,

View File

@@ -4,7 +4,7 @@ import { accessOperation, isolateObjectProperty } from 'payload'
import type { Context } from '../types.js'
import formatName from '../../utilities/formatName.js'
import { formatName } from '../../utilities/formatName.js'
const formatConfigNames = (results, configs) => {
const formattedResults = { ...results }
@@ -17,7 +17,7 @@ const formatConfigNames = (results, configs) => {
return formattedResults
}
function accessResolver(config: SanitizedConfig) {
export function accessResolver(config: SanitizedConfig) {
async function resolver(_, args, context: Context) {
const options = {
req: isolateObjectProperty<any>(context.req, 'transactionID'),
@@ -34,5 +34,3 @@ function accessResolver(config: SanitizedConfig) {
return resolver
}
export default accessResolver

View File

@@ -4,7 +4,7 @@ import { forgotPasswordOperation, isolateObjectProperty } from 'payload'
import type { Context } from '../types.js'
function forgotPasswordResolver(collection: Collection): any {
export function forgotPassword(collection: Collection): any {
async function resolver(_, args, context: Context) {
const options = {
collection,
@@ -23,5 +23,3 @@ function forgotPasswordResolver(collection: Collection): any {
return resolver
}
export default forgotPasswordResolver

View File

@@ -2,7 +2,7 @@ import { initOperation, isolateObjectProperty } from 'payload'
import type { Context } from '../types.js'
function initResolver(collection: string) {
export function init(collection: string) {
async function resolver(_, args, context: Context) {
const options = {
collection,
@@ -14,5 +14,3 @@ function initResolver(collection: string) {
return resolver
}
export default initResolver

View File

@@ -4,7 +4,7 @@ import { generatePayloadCookie, isolateObjectProperty, loginOperation } from 'pa
import type { Context } from '../types.js'
function loginResolver(collection: Collection): any {
export function login(collection: Collection): any {
async function resolver(_, args, context: Context) {
const options = {
collection,
@@ -35,5 +35,3 @@ function loginResolver(collection: Collection): any {
return resolver
}
export default loginResolver

View File

@@ -4,7 +4,7 @@ import { generateExpiredPayloadCookie, isolateObjectProperty, logoutOperation }
import type { Context } from '../types.js'
function logoutResolver(collection: Collection): any {
export function logout(collection: Collection): any {
async function resolver(_, args, context: Context) {
const options = {
collection,
@@ -22,5 +22,3 @@ function logoutResolver(collection: Collection): any {
return resolver
}
export default logoutResolver

View File

@@ -4,7 +4,7 @@ import { extractJWT, isolateObjectProperty, meOperation } from 'payload'
import type { Context } from '../types.js'
function meResolver(collection: Collection): any {
export function me(collection: Collection): any {
async function resolver(_, args, context: Context) {
const currentToken = extractJWT(context.req)
@@ -26,5 +26,3 @@ function meResolver(collection: Collection): any {
return resolver
}
export default meResolver

View File

@@ -4,7 +4,7 @@ import { generatePayloadCookie, isolateObjectProperty, refreshOperation } from '
import type { Context } from '../types.js'
function refreshResolver(collection: Collection): any {
export function refresh(collection: Collection): any {
async function resolver(_, __, context: Context) {
const options = {
collection,
@@ -29,5 +29,3 @@ function refreshResolver(collection: Collection): any {
return resolver
}
export default refreshResolver

View File

@@ -4,10 +4,14 @@ import { generatePayloadCookie, isolateObjectProperty, resetPasswordOperation }
import type { Context } from '../types.js'
function resetPasswordResolver(collection: Collection): any {
export function resetPassword(collection: Collection): any {
async function resolver(_, args, context: Context) {
if (args.locale) context.req.locale = args.locale
if (args.fallbackLocale) context.req.fallbackLocale = args.fallbackLocale
if (args.locale) {
context.req.locale = args.locale
}
if (args.fallbackLocale) {
context.req.fallbackLocale = args.fallbackLocale
}
const options = {
api: 'GraphQL',
@@ -34,5 +38,3 @@ function resetPasswordResolver(collection: Collection): any {
return resolver
}
export default resetPasswordResolver

View File

@@ -4,7 +4,7 @@ import { isolateObjectProperty, unlockOperation } from 'payload'
import type { Context } from '../types.js'
function unlockResolver(collection: Collection) {
export function unlock(collection: Collection) {
async function resolver(_, args, context: Context) {
const options = {
collection,
@@ -18,5 +18,3 @@ function unlockResolver(collection: Collection) {
return resolver
}
export default unlockResolver

View File

@@ -4,10 +4,14 @@ import { isolateObjectProperty, verifyEmailOperation } from 'payload'
import type { Context } from '../types.js'
function verifyEmailResolver(collection: Collection) {
export function verifyEmail(collection: Collection) {
async function resolver(_, args, context: Context) {
if (args.locale) context.req.locale = args.locale
if (args.fallbackLocale) context.req.fallbackLocale = args.fallbackLocale
if (args.locale) {
context.req.locale = args.locale
}
if (args.fallbackLocale) {
context.req.fallbackLocale = args.fallbackLocale
}
const options = {
api: 'GraphQL',
@@ -22,5 +26,3 @@ function verifyEmailResolver(collection: Collection) {
return resolver
}
export default verifyEmailResolver

View File

@@ -22,7 +22,7 @@ export type Resolver<TSlug extends CollectionSlug> = (
},
) => Promise<DataFromCollectionSlug<TSlug>>
export default function createResolver<TSlug extends CollectionSlug>(
export function createResolver<TSlug extends CollectionSlug>(
collection: Collection,
): Resolver<TSlug> {
return async function resolver(_, args, context: Context) {

View File

@@ -28,7 +28,9 @@ export function getDeleteResolver<TSlug extends CollectionSlug>(
req = isolateObjectProperty(req, 'fallbackLocale')
req.locale = args.locale || locale
req.fallbackLocale = args.fallbackLocale || fallbackLocale
if (!req.query) req.query = {}
if (!req.query) {
req.query = {}
}
const draft: boolean =
args.draft ?? req.query?.draft === 'false'
@@ -36,7 +38,9 @@ export function getDeleteResolver<TSlug extends CollectionSlug>(
: req.query?.draft === 'true'
? true
: undefined
if (typeof draft === 'boolean') req.query.draft = String(draft)
if (typeof draft === 'boolean') {
req.query.draft = String(draft)
}
context.req = req

View File

@@ -17,7 +17,7 @@ export type Resolver<TData> = (
},
) => Promise<TData>
export default function duplicateResolver<TSlug extends CollectionSlug>(
export function duplicateResolver<TSlug extends CollectionSlug>(
collection: Collection,
): Resolver<DataFromCollectionSlug<TSlug>> {
return async function resolver(_, args, context: Context) {

View File

@@ -31,7 +31,9 @@ export function findResolver(collection: Collection): Resolver {
req = isolateObjectProperty(req, ['locale', 'fallbackLocale', 'transactionID'])
req.locale = args.locale || locale
req.fallbackLocale = args.fallbackLocale || fallbackLocale
if (!req.query) req.query = {}
if (!req.query) {
req.query = {}
}
const draft: boolean =
args.draft ?? req.query?.draft === 'false'
@@ -39,7 +41,9 @@ export function findResolver(collection: Collection): Resolver {
: req.query?.draft === 'true'
? true
: undefined
if (typeof draft === 'boolean') req.query.draft = String(draft)
if (typeof draft === 'boolean') {
req.query.draft = String(draft)
}
context.req = req

View File

@@ -28,7 +28,9 @@ export function findByIDResolver<TSlug extends CollectionSlug>(
req = isolateObjectProperty(req, 'fallbackLocale')
req.locale = args.locale || locale
req.fallbackLocale = args.fallbackLocale || fallbackLocale
if (!req.query) req.query = {}
if (!req.query) {
req.query = {}
}
const draft: boolean =
args.draft ?? req.query?.draft === 'false'
@@ -36,7 +38,9 @@ export function findByIDResolver<TSlug extends CollectionSlug>(
: req.query?.draft === 'true'
? true
: undefined
if (typeof draft === 'boolean') req.query.draft = String(draft)
if (typeof draft === 'boolean') {
req.query.draft = String(draft)
}
context.req = req

View File

@@ -29,7 +29,9 @@ export function findVersionsResolver(collection: Collection): Resolver {
req = isolateObjectProperty(req, 'fallbackLocale')
req.locale = args.locale || locale
req.fallbackLocale = args.fallbackLocale || fallbackLocale
if (!req.query) req.query = {}
if (!req.query) {
req.query = {}
}
const draft: boolean =
args.draft ?? req.query?.draft === 'false'
@@ -37,7 +39,9 @@ export function findVersionsResolver(collection: Collection): Resolver {
: req.query?.draft === 'true'
? true
: undefined
if (typeof draft === 'boolean') req.query.draft = String(draft)
if (typeof draft === 'boolean') {
req.query.draft = String(draft)
}
context.req = req

View File

@@ -15,7 +15,7 @@ export type Resolver = (
},
) => Promise<Document>
export default function restoreVersionResolver(collection: Collection): Resolver {
export function restoreVersionResolver(collection: Collection): Resolver {
async function resolver(_, args, context: Context) {
const options = {
id: args.id,

View File

@@ -30,7 +30,9 @@ export function updateResolver<TSlug extends CollectionSlug>(
req = isolateObjectProperty(req, 'fallbackLocale')
req.locale = args.locale || locale
req.fallbackLocale = args.fallbackLocale || fallbackLocale
if (!req.query) req.query = {}
if (!req.query) {
req.query = {}
}
const draft: boolean =
args.draft ?? req.query?.draft === 'false'
@@ -38,7 +40,9 @@ export function updateResolver<TSlug extends CollectionSlug>(
: req.query?.draft === 'true'
? true
: undefined
if (typeof draft === 'boolean') req.query.draft = String(draft)
if (typeof draft === 'boolean') {
req.query.draft = String(draft)
}
context.req = req

View File

@@ -4,10 +4,14 @@ import { findOneOperation, isolateObjectProperty } from 'payload'
import type { Context } from '../types.js'
export default function findOneResolver(globalConfig: SanitizedGlobalConfig): Document {
export function findOne(globalConfig: SanitizedGlobalConfig): Document {
return async function resolver(_, args, context: Context) {
if (args.locale) context.req.locale = args.locale
if (args.fallbackLocale) context.req.fallbackLocale = args.fallbackLocale
if (args.locale) {
context.req.locale = args.locale
}
if (args.fallbackLocale) {
context.req.fallbackLocale = args.fallbackLocale
}
const { slug } = globalConfig

View File

@@ -17,10 +17,14 @@ export type Resolver = (
},
) => Promise<Document>
export default function findVersionByIDResolver(globalConfig: SanitizedGlobalConfig): Resolver {
export function findVersionByID(globalConfig: SanitizedGlobalConfig): Resolver {
return async function resolver(_, args, context: Context) {
if (args.locale) context.req.locale = args.locale
if (args.fallbackLocale) context.req.fallbackLocale = args.fallbackLocale
if (args.locale) {
context.req.locale = args.locale
}
if (args.fallbackLocale) {
context.req.fallbackLocale = args.fallbackLocale
}
const options = {
id: args.id,

View File

@@ -19,7 +19,7 @@ export type Resolver = (
},
) => Promise<Document>
export default function findVersionsResolver(globalConfig: SanitizedGlobalConfig): Resolver {
export function findVersions(globalConfig: SanitizedGlobalConfig): Resolver {
return async function resolver(_, args, context: Context) {
const options = {
depth: 0,

View File

@@ -1,7 +1,7 @@
import findOne from './findOne.js'
import findVersionByID from './findVersionByID.js'
import findVersions from './findVersions.js'
import restoreVersion from './restoreVersion.js'
import update from './update.js'
import { findOne } from './findOne.js'
import { findVersionByID } from './findVersionByID.js'
import { findVersions } from './findVersions.js'
import { restoreVersion } from './restoreVersion.js'
import { update } from './update.js'
export { findOne, findVersionByID, findVersions, restoreVersion, update }

View File

@@ -14,7 +14,7 @@ type Resolver = (
req: PayloadRequest
},
) => Promise<Document>
export default function restoreVersionResolver(globalConfig: SanitizedGlobalConfig): Resolver {
export function restoreVersion(globalConfig: SanitizedGlobalConfig): Resolver {
return async function resolver(_, args, context: Context) {
const options = {
id: args.id,

View File

@@ -18,12 +18,16 @@ type Resolver<TSlug extends GlobalSlug> = (
},
) => Promise<DataFromGlobalSlug<TSlug>>
export default function updateResolver<TSlug extends GlobalSlug>(
export function update<TSlug extends GlobalSlug>(
globalConfig: SanitizedGlobalConfig,
): Resolver<TSlug> {
return async function resolver(_, args, context: Context) {
if (args.locale) context.req.locale = args.locale
if (args.fallbackLocale) context.req.fallbackLocale = args.fallbackLocale
if (args.locale) {
context.req.locale = args.locale
}
if (args.fallbackLocale) {
context.req.fallbackLocale = args.fallbackLocale
}
const { slug } = globalConfig

View File

@@ -2,9 +2,9 @@ import type { SanitizedLocalizationConfig } from 'payload'
import { GraphQLEnumType } from 'graphql'
import formatName from '../utilities/formatName.js'
import { formatName } from '../utilities/formatName.js'
const buildFallbackLocaleInputType = (
export const buildFallbackLocaleInputType = (
localization: SanitizedLocalizationConfig,
): GraphQLEnumType => {
return new GraphQLEnumType({
@@ -20,5 +20,3 @@ const buildFallbackLocaleInputType = (
),
})
}
export default buildFallbackLocaleInputType

View File

@@ -3,9 +3,9 @@ import type { SanitizedLocalizationConfig } from 'payload'
import { GraphQLEnumType } from 'graphql'
import formatName from '../utilities/formatName.js'
import { formatName } from '../utilities/formatName.js'
const buildLocaleInputType = (
export const buildLocaleInputType = (
localization: SanitizedLocalizationConfig,
): GraphQLEnumType | GraphQLScalarType => {
return new GraphQLEnumType({
@@ -21,5 +21,3 @@ const buildLocaleInputType = (
),
})
}
export default buildLocaleInputType

View File

@@ -40,10 +40,10 @@ import { flattenTopLevelFields, toWords } from 'payload'
import { fieldAffectsData, optionIsObject, tabHasName } from 'payload/shared'
import { GraphQLJSON } from '../packages/graphql-type-json/index.js'
import combineParentName from '../utilities/combineParentName.js'
import formatName from '../utilities/formatName.js'
import { combineParentName } from '../utilities/combineParentName.js'
import { formatName } from '../utilities/formatName.js'
import { groupOrTabHasRequiredSubfield } from '../utilities/groupOrTabHasRequiredSubfield.js'
import withNullableType from './withNullableType.js'
import { withNullableType } from './withNullableType.js'
const idFieldTypes = {
number: GraphQLInt,
@@ -97,7 +97,9 @@ export function buildMutationInputType({
parentName: fullName,
})
if (!type) return inputObjectTypeConfig
if (!type) {
return inputObjectTypeConfig
}
type = new GraphQLList(withNullableType(field, type, forceNullable))
return {
@@ -120,7 +122,9 @@ export function buildMutationInputType({
collapsible: (inputObjectTypeConfig: InputObjectTypeConfig, field: CollapsibleField) =>
field.fields.reduce((acc, subField: CollapsibleField) => {
const addSubField = fieldToSchemaMap[subField.type]
if (addSubField) return addSubField(acc, subField)
if (addSubField) {
return addSubField(acc, subField)
}
return acc
}, inputObjectTypeConfig),
date: (inputObjectTypeConfig: InputObjectTypeConfig, field: DateField) => ({
@@ -142,9 +146,13 @@ export function buildMutationInputType({
parentName: fullName,
})
if (!type) return inputObjectTypeConfig
if (!type) {
return inputObjectTypeConfig
}
if (requiresAtLeastOneField) type = new GraphQLNonNull(type)
if (requiresAtLeastOneField) {
type = new GraphQLNonNull(type)
}
return {
...inputObjectTypeConfig,
[field.name]: { type },
@@ -227,7 +235,9 @@ export function buildMutationInputType({
row: (inputObjectTypeConfig: InputObjectTypeConfig, field: RowField) =>
field.fields.reduce((acc, subField: Field) => {
const addSubField = fieldToSchemaMap[subField.type]
if (addSubField) return addSubField(acc, subField)
if (addSubField) {
return addSubField(acc, subField)
}
return acc
}, inputObjectTypeConfig),
select: (inputObjectTypeConfig: InputObjectTypeConfig, field: SelectField) => {
@@ -274,9 +284,13 @@ export function buildMutationInputType({
parentName: fullName,
})
if (!type) return acc
if (!type) {
return acc
}
if (requiresAtLeastOneField) type = new GraphQLNonNull(type)
if (requiresAtLeastOneField) {
type = new GraphQLNonNull(type)
}
return {
...acc,
[tab.name]: { type },
@@ -287,7 +301,9 @@ export function buildMutationInputType({
...acc,
...tab.fields.reduce((subFieldSchema, subField) => {
const addSubField = fieldToSchemaMap[subField.type]
if (addSubField) return addSubField(subFieldSchema, subField)
if (addSubField) {
return addSubField(subFieldSchema, subField)
}
return subFieldSchema
}, acc),
}

View File

@@ -44,24 +44,11 @@ import { tabHasName } from 'payload/shared'
import type { Context } from '../resolvers/types.js'
import { GraphQLJSON } from '../packages/graphql-type-json/index.js'
import combineParentName from '../utilities/combineParentName.js'
import formatName from '../utilities/formatName.js'
import formatOptions from '../utilities/formatOptions.js'
import buildWhereInputType from './buildWhereInputType.js'
import isFieldNullable from './isFieldNullable.js'
import withNullableType from './withNullableType.js'
type LocaleInputType = {
fallbackLocale: {
type: GraphQLType
}
locale: {
type: GraphQLType
}
where: {
type: GraphQLType
}
}
import { combineParentName } from '../utilities/combineParentName.js'
import { formatName } from '../utilities/formatName.js'
import { formatOptions } from '../utilities/formatOptions.js'
import { isFieldNullable } from './isFieldNullable.js'
import { withNullableType } from './withNullableType.js'
export type ObjectTypeConfig = {
[path: string]: GraphQLFieldConfig<any, any>
@@ -184,7 +171,9 @@ export function buildObjectType({
collapsible: (objectTypeConfig: ObjectTypeConfig, field: CollapsibleField) =>
field.fields.reduce((objectTypeConfigWithCollapsibleFields, subField) => {
const addSubField = fieldToSchemaMap[subField.type]
if (addSubField) return addSubField(objectTypeConfigWithCollapsibleFields, subField)
if (addSubField) {
return addSubField(objectTypeConfigWithCollapsibleFields, subField)
}
return objectTypeConfigWithCollapsibleFields
}, objectTypeConfig),
date: (objectTypeConfig: ObjectTypeConfig, field: DateField) => ({
@@ -297,7 +286,7 @@ export function buildObjectType({
value: {
type: new GraphQLUnionType({
name: relationshipName,
resolveType(data, { req }) {
resolveType(data) {
return graphqlResult.collections[data.collection].graphQL.type.name
},
types,
@@ -472,7 +461,9 @@ export function buildObjectType({
},
async resolve(parent, args, context: Context) {
let depth = config.defaultDepth
if (typeof args.depth !== 'undefined') depth = args.depth
if (typeof args.depth !== 'undefined') {
depth = args.depth
}
if (!field?.editor) {
throw new MissingEditorProp(field) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor
}
@@ -519,7 +510,9 @@ export function buildObjectType({
row: (objectTypeConfig: ObjectTypeConfig, field: RowField) =>
field.fields.reduce((objectTypeConfigWithRowFields, subField) => {
const addSubField = fieldToSchemaMap[subField.type]
if (addSubField) return addSubField(objectTypeConfigWithRowFields, subField)
if (addSubField) {
return addSubField(objectTypeConfigWithRowFields, subField)
}
return objectTypeConfigWithRowFields
}, objectTypeConfig),
select: (objectTypeConfig: ObjectTypeConfig, field: SelectField) => {
@@ -573,7 +566,9 @@ export function buildObjectType({
...tabSchema,
...tab.fields.reduce((subFieldSchema, subField) => {
const addSubField = fieldToSchemaMap[subField.type]
if (addSubField) return addSubField(subFieldSchema, subField)
if (addSubField) {
return addSubField(subFieldSchema, subField)
}
return subFieldSchema
}, tabSchema),
}
@@ -626,7 +621,7 @@ export function buildObjectType({
value: {
type: new GraphQLUnionType({
name: relationshipName,
resolveType(data, { req }) {
resolveType(data) {
return graphqlResult.collections[data.collection].graphQL.type.name
},
types,
@@ -704,7 +699,7 @@ export function buildObjectType({
const result = await context.req.payloadDataLoader.load(
createDataloaderCacheKey({
collectionSlug: collectionSlug as string,
collectionSlug,
currentDepth: 0,
depth: 0,
docID: id,
@@ -751,7 +746,7 @@ export function buildObjectType({
if (id) {
const relatedDocument = await context.req.payloadDataLoader.load(
createDataloaderCacheKey({
collectionSlug: relatedCollectionSlug as string,
collectionSlug: relatedCollectionSlug,
currentDepth: 0,
depth: 0,
docID: id,

View File

@@ -11,7 +11,7 @@ import { GraphQLBoolean, GraphQLNonNull, GraphQLObjectType } from 'graphql'
import { toWords } from 'payload'
import { GraphQLJSONObject } from '../packages/graphql-type-json/index.js'
import formatName from '../utilities/formatName.js'
import { formatName } from '../utilities/formatName.js'
type OperationType = 'create' | 'delete' | 'read' | 'readVersions' | 'unlock' | 'update'
@@ -148,7 +148,9 @@ export function buildPolicyType(args: BuildPolicyType): GraphQLObjectType {
let operations = []
if (graphQL === false) return null
if (graphQL === false) {
return null
}
if (type === 'collection') {
operations = ['create', 'read', 'update', 'delete']
@@ -199,7 +201,7 @@ export function buildPolicyType(args: BuildPolicyType): GraphQLObjectType {
})
}
export default function buildPoliciesType(config: SanitizedConfig): GraphQLObjectType {
export function buildPoliciesType(config: SanitizedConfig): GraphQLObjectType {
const fields = {
canAccessAdmin: {
type: new GraphQLNonNull(GraphQLBoolean),

View File

@@ -4,8 +4,8 @@ import { GraphQLInputObjectType, GraphQLList } from 'graphql'
import { flattenTopLevelFields } from 'payload'
import { fieldAffectsData, fieldHasSubFields, fieldIsPresentationalOnly } from 'payload/shared'
import formatName from '../utilities/formatName.js'
import fieldToSchemaMap from './fieldToWhereInputSchemaMap.js'
import { formatName } from '../utilities/formatName.js'
import { fieldToSchemaMap } from './fieldToWhereInputSchemaMap.js'
import { withOperators } from './withOperators.js'
type Args = {
@@ -28,7 +28,7 @@ type Args = {
* directly searchable. Instead, we need to build a chained pathname
* using dot notation so MongoDB can properly search nested paths.
*/
const buildWhereInputType = ({ name, fields, parentName }: Args): GraphQLInputObjectType => {
export const buildWhereInputType = ({ name, fields, parentName }: Args): GraphQLInputObjectType => {
// This is the function that builds nested paths for all
// field types with nested paths.
@@ -109,5 +109,3 @@ const buildWhereInputType = ({ name, fields, parentName }: Args): GraphQLInputOb
},
})
}
export default buildWhereInputType

View File

@@ -23,9 +23,9 @@ import type {
import { GraphQLEnumType, GraphQLInputObjectType } from 'graphql'
import { GraphQLJSON } from '../packages/graphql-type-json/index.js'
import combineParentName from '../utilities/combineParentName.js'
import formatName from '../utilities/formatName.js'
import recursivelyBuildNestedPaths from './recursivelyBuildNestedPaths.js'
import { combineParentName } from '../utilities/combineParentName.js'
import { formatName } from '../utilities/formatName.js'
import { recursivelyBuildNestedPaths } from './recursivelyBuildNestedPaths.js'
import { withOperators } from './withOperators.js'
type Args = {
@@ -33,7 +33,7 @@ type Args = {
parentName: string
}
const fieldToSchemaMap = ({ nestedFieldName, parentName }: Args): any => ({
export const fieldToSchemaMap = ({ nestedFieldName, parentName }: Args): any => ({
array: (field: ArrayField) =>
recursivelyBuildNestedPaths({
field,
@@ -161,5 +161,3 @@ const fieldToSchemaMap = ({ nestedFieldName, parentName }: Args): any => ({
}
},
})
export default fieldToSchemaMap

View File

@@ -18,38 +18,38 @@ import { fieldAffectsData } from 'payload/shared'
import type { ObjectTypeConfig } from './buildObjectType.js'
import forgotPassword from '../resolvers/auth/forgotPassword.js'
import init from '../resolvers/auth/init.js'
import login from '../resolvers/auth/login.js'
import logout from '../resolvers/auth/logout.js'
import me from '../resolvers/auth/me.js'
import refresh from '../resolvers/auth/refresh.js'
import resetPassword from '../resolvers/auth/resetPassword.js'
import unlock from '../resolvers/auth/unlock.js'
import verifyEmail from '../resolvers/auth/verifyEmail.js'
import { forgotPassword } from '../resolvers/auth/forgotPassword.js'
import { init } from '../resolvers/auth/init.js'
import { login } from '../resolvers/auth/login.js'
import { logout } from '../resolvers/auth/logout.js'
import { me } from '../resolvers/auth/me.js'
import { refresh } from '../resolvers/auth/refresh.js'
import { resetPassword } from '../resolvers/auth/resetPassword.js'
import { unlock } from '../resolvers/auth/unlock.js'
import { verifyEmail } from '../resolvers/auth/verifyEmail.js'
import { countResolver } from '../resolvers/collections/count.js'
import createResolver from '../resolvers/collections/create.js'
import { createResolver } from '../resolvers/collections/create.js'
import { getDeleteResolver } from '../resolvers/collections/delete.js'
import { docAccessResolver } from '../resolvers/collections/docAccess.js'
import duplicateResolver from '../resolvers/collections/duplicate.js'
import { duplicateResolver } from '../resolvers/collections/duplicate.js'
import { findResolver } from '../resolvers/collections/find.js'
import { findByIDResolver } from '../resolvers/collections/findByID.js'
import { findVersionByIDResolver } from '../resolvers/collections/findVersionByID.js'
import { findVersionsResolver } from '../resolvers/collections/findVersions.js'
import restoreVersionResolver from '../resolvers/collections/restoreVersion.js'
import { restoreVersionResolver } from '../resolvers/collections/restoreVersion.js'
import { updateResolver } from '../resolvers/collections/update.js'
import formatName from '../utilities/formatName.js'
import { formatName } from '../utilities/formatName.js'
import { buildMutationInputType, getCollectionIDType } from './buildMutationInputType.js'
import { buildObjectType } from './buildObjectType.js'
import { buildPaginatedListType } from './buildPaginatedListType.js'
import { buildPolicyType } from './buildPoliciesType.js'
import buildWhereInputType from './buildWhereInputType.js'
import { buildWhereInputType } from './buildWhereInputType.js'
type InitCollectionsGraphQLArgs = {
config: SanitizedConfig
graphqlResult: GraphQLInfo
}
function initCollectionsGraphQL({ config, graphqlResult }: InitCollectionsGraphQLArgs): void {
export function initCollections({ config, graphqlResult }: InitCollectionsGraphQLArgs): void {
Object.keys(graphqlResult.collections).forEach((slug) => {
const collection: Collection = graphqlResult.collections[slug]
const {
@@ -57,7 +57,9 @@ function initCollectionsGraphQL({ config, graphqlResult }: InitCollectionsGraphQ
config: { fields, graphQL = {} as SanitizedCollectionConfig['graphQL'], versions },
} = collection
if (!graphQL) return
if (!graphQL) {
return
}
let singularName
let pluralName
@@ -514,5 +516,3 @@ function initCollectionsGraphQL({ config, graphqlResult }: InitCollectionsGraphQ
}
})
}
export default initCollectionsGraphQL

View File

@@ -7,23 +7,23 @@ import type { Field, GraphQLInfo, SanitizedConfig, SanitizedGlobalConfig } from
import { buildVersionGlobalFields, toWords } from 'payload'
import { docAccessResolver } from '../resolvers/globals/docAccess.js'
import findOneResolver from '../resolvers/globals/findOne.js'
import findVersionByIDResolver from '../resolvers/globals/findVersionByID.js'
import findVersionsResolver from '../resolvers/globals/findVersions.js'
import restoreVersionResolver from '../resolvers/globals/restoreVersion.js'
import updateResolver from '../resolvers/globals/update.js'
import formatName from '../utilities/formatName.js'
import { findOne } from '../resolvers/globals/findOne.js'
import { findVersionByID } from '../resolvers/globals/findVersionByID.js'
import { findVersions } from '../resolvers/globals/findVersions.js'
import { restoreVersion } from '../resolvers/globals/restoreVersion.js'
import { update } from '../resolvers/globals/update.js'
import { formatName } from '../utilities/formatName.js'
import { buildMutationInputType } from './buildMutationInputType.js'
import { buildObjectType } from './buildObjectType.js'
import { buildPaginatedListType } from './buildPaginatedListType.js'
import { buildPolicyType } from './buildPoliciesType.js'
import buildWhereInputType from './buildWhereInputType.js'
import { buildWhereInputType } from './buildWhereInputType.js'
type InitGlobalsGraphQLArgs = {
config: SanitizedConfig
graphqlResult: GraphQLInfo
}
function initGlobalsGraphQL({ config, graphqlResult }: InitGlobalsGraphQLArgs): void {
export function initGlobals({ config, graphqlResult }: InitGlobalsGraphQLArgs): void {
Object.keys(graphqlResult.globals.config).forEach((slug) => {
const global: SanitizedGlobalConfig = graphqlResult.globals.config[slug]
const { fields, graphQL, versions } = global
@@ -36,7 +36,9 @@ function initGlobalsGraphQL({ config, graphqlResult }: InitGlobalsGraphQLArgs):
const forceNullableObjectType = Boolean(versions?.drafts)
if (!graphqlResult.globals.graphQL) graphqlResult.globals.graphQL = {}
if (!graphqlResult.globals.graphQL) {
graphqlResult.globals.graphQL = {}
}
const updateMutationInputType = buildMutationInputType({
name: formattedName,
@@ -70,7 +72,7 @@ function initGlobalsGraphQL({ config, graphqlResult }: InitGlobalsGraphQLArgs):
}
: {}),
},
resolve: findOneResolver(global),
resolve: findOne(global),
}
graphqlResult.Mutation.fields[`update${formattedName}`] = {
@@ -86,7 +88,7 @@ function initGlobalsGraphQL({ config, graphqlResult }: InitGlobalsGraphQLArgs):
}
: {}),
},
resolve: updateResolver(global),
resolve: update(global),
}
graphqlResult.Query.fields[`docAccess${formattedName}`] = {
@@ -141,7 +143,7 @@ function initGlobalsGraphQL({ config, graphqlResult }: InitGlobalsGraphQLArgs):
}
: {}),
},
resolve: findVersionByIDResolver(global),
resolve: findVersionByID(global),
}
graphqlResult.Query.fields[`versions${formattedName}`] = {
type: buildPaginatedListType(
@@ -166,7 +168,7 @@ function initGlobalsGraphQL({ config, graphqlResult }: InitGlobalsGraphQLArgs):
page: { type: GraphQLInt },
sort: { type: GraphQLString },
},
resolve: findVersionsResolver(global),
resolve: findVersions(global),
}
graphqlResult.Mutation.fields[`restoreVersion${formatName(formattedName)}`] = {
type: graphqlResult.globals.graphQL[slug].type,
@@ -174,10 +176,8 @@ function initGlobalsGraphQL({ config, graphqlResult }: InitGlobalsGraphQLArgs):
id: { type: idType },
draft: { type: GraphQLBoolean },
},
resolve: restoreVersionResolver(global),
resolve: restoreVersion(global),
}
}
})
}
export default initGlobalsGraphQL

View File

@@ -2,7 +2,7 @@ import type { FieldAffectingData } from 'payload'
import { fieldAffectsData } from 'payload/shared'
const isFieldNullable = (field: FieldAffectingData, force: boolean): boolean => {
export const isFieldNullable = (field: FieldAffectingData, force: boolean): boolean => {
const hasReadAccessControl = field.access && field.access.read
const condition = field.admin && field.admin.condition
return !(
@@ -15,5 +15,3 @@ const isFieldNullable = (field: FieldAffectingData, force: boolean): boolean =>
!hasReadAccessControl
)
}
export default isFieldNullable

View File

@@ -1,4 +1,4 @@
const operators = {
export const operators = {
comparison: ['greater_than_equal', 'greater_than', 'less_than_equal', 'less_than'],
contains: ['in', 'not_in', 'all'],
equality: ['equals', 'not_equals'],
@@ -6,5 +6,3 @@ const operators = {
geojson: ['within', 'intersects'],
partial: ['like', 'contains'],
}
export default operators

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