Compare commits
10 Commits
fix/plugin
...
fix/field-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c550411a86 | ||
|
|
172ecc014f | ||
|
|
da1c3ff9b4 | ||
|
|
35c0404817 | ||
|
|
cfe8c97ab7 | ||
|
|
6133a1d183 | ||
|
|
710fe0949b | ||
|
|
4a56597b92 | ||
|
|
27d644f2f9 | ||
|
|
564fdb0e17 |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "payload-monorepo",
|
||||
"version": "3.36.0",
|
||||
"version": "3.36.1",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/admin-bar",
|
||||
"version": "3.36.0",
|
||||
"version": "3.36.1",
|
||||
"description": "An admin bar for React apps using Payload",
|
||||
"homepage": "https://payloadcms.com",
|
||||
"repository": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "create-payload-app",
|
||||
"version": "3.36.0",
|
||||
"version": "3.36.1",
|
||||
"homepage": "https://payloadcms.com",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/db-mongodb",
|
||||
"version": "3.36.0",
|
||||
"version": "3.36.1",
|
||||
"description": "The officially supported MongoDB database adapter for Payload",
|
||||
"homepage": "https://payloadcms.com",
|
||||
"repository": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/db-postgres",
|
||||
"version": "3.36.0",
|
||||
"version": "3.36.1",
|
||||
"description": "The officially supported Postgres database adapter for Payload",
|
||||
"homepage": "https://payloadcms.com",
|
||||
"repository": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/db-sqlite",
|
||||
"version": "3.36.0",
|
||||
"version": "3.36.1",
|
||||
"description": "The officially supported SQLite database adapter for Payload",
|
||||
"homepage": "https://payloadcms.com",
|
||||
"repository": {
|
||||
|
||||
@@ -16,7 +16,7 @@ export const countDistinct: CountDistinct = async function countDistinct(
|
||||
})
|
||||
.from(this.tables[tableName])
|
||||
.where(where)
|
||||
return Number(countResult[0]?.count)
|
||||
return Number(countResult?.[0]?.count ?? 0)
|
||||
}
|
||||
|
||||
let query: SQLiteSelect = db
|
||||
@@ -39,5 +39,5 @@ export const countDistinct: CountDistinct = async function countDistinct(
|
||||
// Instead, COUNT (GROUP BY id) can be used which is still slower than COUNT(*) but acceptable.
|
||||
const countResult = await query
|
||||
|
||||
return Number(countResult[0]?.count)
|
||||
return Number(countResult?.[0]?.count ?? 0)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/db-vercel-postgres",
|
||||
"version": "3.36.0",
|
||||
"version": "3.36.1",
|
||||
"description": "Vercel Postgres adapter for Payload",
|
||||
"homepage": "https://payloadcms.com",
|
||||
"repository": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/drizzle",
|
||||
"version": "3.36.0",
|
||||
"version": "3.36.1",
|
||||
"description": "A library of shared functions used by different payload database adapters",
|
||||
"homepage": "https://payloadcms.com",
|
||||
"repository": {
|
||||
|
||||
@@ -46,6 +46,7 @@ export const findMany = async function find({
|
||||
const offset = skip || (page - 1) * limit
|
||||
|
||||
if (limit === 0) {
|
||||
pagination = false
|
||||
limit = undefined
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,8 @@ export const countDistinct: CountDistinct = async function countDistinct(
|
||||
})
|
||||
.from(this.tables[tableName])
|
||||
.where(where)
|
||||
return Number(countResult[0].count)
|
||||
|
||||
return Number(countResult?.[0]?.count ?? 0)
|
||||
}
|
||||
|
||||
let query = db
|
||||
@@ -39,5 +40,5 @@ export const countDistinct: CountDistinct = async function countDistinct(
|
||||
// Instead, COUNT (GROUP BY id) can be used which is still slower than COUNT(*) but acceptable.
|
||||
const countResult = await query
|
||||
|
||||
return Number(countResult[0].count)
|
||||
return Number(countResult?.[0]?.count ?? 0)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/email-nodemailer",
|
||||
"version": "3.36.0",
|
||||
"version": "3.36.1",
|
||||
"description": "Payload Nodemailer Email Adapter",
|
||||
"homepage": "https://payloadcms.com",
|
||||
"repository": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/email-resend",
|
||||
"version": "3.36.0",
|
||||
"version": "3.36.1",
|
||||
"description": "Payload Resend Email Adapter",
|
||||
"homepage": "https://payloadcms.com",
|
||||
"repository": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/graphql",
|
||||
"version": "3.36.0",
|
||||
"version": "3.36.1",
|
||||
"homepage": "https://payloadcms.com",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/live-preview-react",
|
||||
"version": "3.36.0",
|
||||
"version": "3.36.1",
|
||||
"description": "The official React SDK for Payload Live Preview",
|
||||
"homepage": "https://payloadcms.com",
|
||||
"repository": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/live-preview-vue",
|
||||
"version": "3.36.0",
|
||||
"version": "3.36.1",
|
||||
"description": "The official Vue SDK for Payload Live Preview",
|
||||
"homepage": "https://payloadcms.com",
|
||||
"repository": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/live-preview",
|
||||
"version": "3.36.0",
|
||||
"version": "3.36.1",
|
||||
"description": "The official live preview JavaScript SDK for Payload",
|
||||
"homepage": "https://payloadcms.com",
|
||||
"repository": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { FieldSchemaJSON } from 'payload'
|
||||
|
||||
import type { LivePreviewMessageEvent } from './types.js'
|
||||
import type { CollectionPopulationRequestHandler, LivePreviewMessageEvent } from './types.js'
|
||||
|
||||
import { isLivePreviewEvent } from './isLivePreviewEvent.js'
|
||||
import { mergeData } from './mergeData.js'
|
||||
@@ -29,9 +29,10 @@ export const handleMessage = async <T extends Record<string, any>>(args: {
|
||||
depth?: number
|
||||
event: LivePreviewMessageEvent<T>
|
||||
initialData: T
|
||||
requestHandler?: CollectionPopulationRequestHandler
|
||||
serverURL: string
|
||||
}): Promise<T> => {
|
||||
const { apiRoute, depth, event, initialData, serverURL } = args
|
||||
const { apiRoute, depth, event, initialData, requestHandler, serverURL } = args
|
||||
|
||||
if (isLivePreviewEvent(event, serverURL)) {
|
||||
const { data, externallyUpdatedRelationship, fieldSchemaJSON, locale } = event.data
|
||||
@@ -57,6 +58,7 @@ export const handleMessage = async <T extends Record<string, any>>(args: {
|
||||
incomingData: data,
|
||||
initialData: _payloadLivePreview?.previousData || initialData,
|
||||
locale,
|
||||
requestHandler,
|
||||
serverURL,
|
||||
})
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { DocumentEvent, FieldSchemaJSON, PaginatedDocs } from 'payload'
|
||||
|
||||
import type { PopulationsByCollection } from './types.js'
|
||||
import type { CollectionPopulationRequestHandler, PopulationsByCollection } from './types.js'
|
||||
|
||||
import { traverseFields } from './traverseFields.js'
|
||||
|
||||
@@ -29,21 +29,17 @@ let prevLocale: string | undefined
|
||||
|
||||
export const mergeData = async <T extends Record<string, any>>(args: {
|
||||
apiRoute?: string
|
||||
collectionPopulationRequestHandler?: ({
|
||||
apiPath,
|
||||
endpoint,
|
||||
serverURL,
|
||||
}: {
|
||||
apiPath: string
|
||||
endpoint: string
|
||||
serverURL: string
|
||||
}) => Promise<Response>
|
||||
/**
|
||||
* @deprecated Use `requestHandler` instead
|
||||
*/
|
||||
collectionPopulationRequestHandler?: CollectionPopulationRequestHandler
|
||||
depth?: number
|
||||
externallyUpdatedRelationship?: DocumentEvent
|
||||
fieldSchema: FieldSchemaJSON
|
||||
incomingData: Partial<T>
|
||||
initialData: T
|
||||
locale?: string
|
||||
requestHandler?: CollectionPopulationRequestHandler
|
||||
returnNumberOfRequests?: boolean
|
||||
serverURL: string
|
||||
}): Promise<
|
||||
@@ -81,7 +77,8 @@ export const mergeData = async <T extends Record<string, any>>(args: {
|
||||
let res: PaginatedDocs
|
||||
|
||||
const ids = new Set(populations.map(({ id }) => id))
|
||||
const requestHandler = args.collectionPopulationRequestHandler || defaultRequestHandler
|
||||
const requestHandler =
|
||||
args.collectionPopulationRequestHandler || args.requestHandler || defaultRequestHandler
|
||||
|
||||
try {
|
||||
res = await requestHandler({
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { CollectionPopulationRequestHandler } from './types.js'
|
||||
|
||||
import { handleMessage } from './handleMessage.js'
|
||||
|
||||
export const subscribe = <T extends Record<string, any>>(args: {
|
||||
@@ -5,9 +7,10 @@ export const subscribe = <T extends Record<string, any>>(args: {
|
||||
callback: (data: T) => void
|
||||
depth?: number
|
||||
initialData: T
|
||||
requestHandler?: CollectionPopulationRequestHandler
|
||||
serverURL: string
|
||||
}): ((event: MessageEvent) => Promise<void> | void) => {
|
||||
const { apiRoute, callback, depth, initialData, serverURL } = args
|
||||
const { apiRoute, callback, depth, initialData, requestHandler, serverURL } = args
|
||||
|
||||
const onMessage = async (event: MessageEvent) => {
|
||||
const mergedData = await handleMessage<T>({
|
||||
@@ -15,6 +18,7 @@ export const subscribe = <T extends Record<string, any>>(args: {
|
||||
depth,
|
||||
event,
|
||||
initialData,
|
||||
requestHandler,
|
||||
serverURL,
|
||||
})
|
||||
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
import type { DocumentEvent, FieldSchemaJSON } from 'payload'
|
||||
|
||||
export type CollectionPopulationRequestHandler = ({
|
||||
apiPath,
|
||||
endpoint,
|
||||
serverURL,
|
||||
}: {
|
||||
apiPath: string
|
||||
endpoint: string
|
||||
serverURL: string
|
||||
}) => Promise<Response>
|
||||
|
||||
export type LivePreviewArgs = {}
|
||||
|
||||
export type LivePreview = void
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/next",
|
||||
"version": "3.36.0",
|
||||
"version": "3.36.1",
|
||||
"homepage": "https://payloadcms.com",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/payload-cloud",
|
||||
"version": "3.36.0",
|
||||
"version": "3.36.1",
|
||||
"description": "The official Payload Cloud plugin",
|
||||
"homepage": "https://payloadcms.com",
|
||||
"repository": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "payload",
|
||||
"version": "3.36.0",
|
||||
"version": "3.36.1",
|
||||
"description": "Node, React, Headless CMS and Application Framework built on Next.js",
|
||||
"keywords": [
|
||||
"admin panel",
|
||||
|
||||
@@ -22,6 +22,7 @@ import type {
|
||||
type ArrayFieldClientWithoutType = MarkOptional<ArrayFieldClient, 'type'>
|
||||
|
||||
type ArrayFieldBaseClientProps = {
|
||||
readonly potentiallyStalePath?: string
|
||||
readonly validate?: ArrayFieldValidation
|
||||
} & FieldPaths
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import type {
|
||||
type BlocksFieldClientWithoutType = MarkOptional<BlocksFieldClient, 'type'>
|
||||
|
||||
type BlocksFieldBaseClientProps = {
|
||||
readonly potentiallyStalePath?: string
|
||||
readonly validate?: BlocksFieldValidation
|
||||
} & FieldPaths
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ type CheckboxFieldBaseClientProps = {
|
||||
readonly onChange?: (value: boolean) => void
|
||||
readonly partialChecked?: boolean
|
||||
readonly path: string
|
||||
readonly potentiallyStalePath?: string
|
||||
readonly validate?: CheckboxFieldValidation
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ type CodeFieldBaseClientProps = {
|
||||
readonly autoComplete?: string
|
||||
readonly onMount?: EditorProps['onMount']
|
||||
readonly path: string
|
||||
readonly potentiallyStalePath?: string
|
||||
readonly validate?: CodeFieldValidation
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,9 @@ import type {
|
||||
FieldLabelServerComponent,
|
||||
} from '../types.js'
|
||||
|
||||
type CollapsibleFieldBaseClientProps = FieldPaths
|
||||
type CollapsibleFieldBaseClientProps = {
|
||||
readonly potentiallyStalePath?: string
|
||||
} & FieldPaths
|
||||
|
||||
type CollapsibleFieldClientWithoutType = MarkOptional<CollapsibleFieldClient, 'type'>
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ type DateFieldClientWithoutType = MarkOptional<DateFieldClient, 'type'>
|
||||
|
||||
type DateFieldBaseClientProps = {
|
||||
readonly path: string
|
||||
readonly potentiallyStalePath?: string
|
||||
readonly validate?: DateFieldValidation
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ type EmailFieldClientWithoutType = MarkOptional<EmailFieldClient, 'type'>
|
||||
|
||||
type EmailFieldBaseClientProps = {
|
||||
readonly path: string
|
||||
readonly potentiallyStalePath?: string
|
||||
readonly validate?: EmailFieldValidation
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,9 @@ type GroupFieldClientWithoutType = MarkOptional<GroupFieldClient, 'type'>
|
||||
|
||||
type GroupFieldBaseServerProps = Pick<FieldPaths, 'path'>
|
||||
|
||||
export type GroupFieldBaseClientProps = FieldPaths
|
||||
export type GroupFieldBaseClientProps = {
|
||||
readonly potentiallyStalePath?: string
|
||||
} & FieldPaths
|
||||
|
||||
export type GroupFieldClientProps = ClientFieldBase<GroupFieldClientWithoutType> &
|
||||
GroupFieldBaseClientProps
|
||||
|
||||
@@ -4,6 +4,7 @@ type HiddenFieldBaseClientProps = {
|
||||
readonly disableModifyingForm?: false
|
||||
readonly field?: never
|
||||
readonly path: string
|
||||
readonly potentiallyStalePath?: string
|
||||
readonly value?: unknown
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ type JSONFieldClientWithoutType = MarkOptional<JSONFieldClient, 'type'>
|
||||
|
||||
type JSONFieldBaseClientProps = {
|
||||
readonly path: string
|
||||
readonly potentiallyStalePath?: string
|
||||
readonly validate?: JSONFieldValidation
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ type JoinFieldClientWithoutType = MarkOptional<JoinFieldClient, 'type'>
|
||||
|
||||
type JoinFieldBaseClientProps = {
|
||||
readonly path: string
|
||||
readonly potentiallyStalePath?: string
|
||||
}
|
||||
|
||||
type JoinFieldBaseServerProps = Pick<FieldPaths, 'path'>
|
||||
|
||||
@@ -24,6 +24,7 @@ type NumberFieldClientWithoutType = MarkOptional<NumberFieldClient, 'type'>
|
||||
type NumberFieldBaseClientProps = {
|
||||
readonly onChange?: (e: number) => void
|
||||
readonly path: string
|
||||
readonly potentiallyStalePath?: string
|
||||
readonly validate?: NumberFieldValidation
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ type PointFieldClientWithoutType = MarkOptional<PointFieldClient, 'type'>
|
||||
|
||||
type PointFieldBaseClientProps = {
|
||||
readonly path: string
|
||||
readonly potentiallyStalePath?: string
|
||||
readonly validate?: PointFieldValidation
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ type RadioFieldBaseClientProps = {
|
||||
readonly disableModifyingForm?: boolean
|
||||
readonly onChange?: OnChange
|
||||
readonly path: string
|
||||
readonly potentiallyStalePath?: string
|
||||
readonly validate?: RadioFieldValidation
|
||||
readonly value?: string
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ type RelationshipFieldClientWithoutType = MarkOptional<RelationshipFieldClient,
|
||||
|
||||
type RelationshipFieldBaseClientProps = {
|
||||
readonly path: string
|
||||
readonly potentiallyStalePath?: string
|
||||
readonly validate?: RelationshipFieldValidation
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ type RichTextFieldBaseClientProps<
|
||||
TExtraProperties = object,
|
||||
> = {
|
||||
readonly path: string
|
||||
readonly potentiallyStalePath?: string
|
||||
readonly validate?: RichTextFieldValidation
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ type SelectFieldClientWithoutType = MarkOptional<SelectFieldClient, 'type'>
|
||||
type SelectFieldBaseClientProps = {
|
||||
readonly onChange?: (e: string | string[]) => void
|
||||
readonly path: string
|
||||
readonly potentiallyStalePath?: string
|
||||
readonly validate?: SelectFieldValidation
|
||||
readonly value?: string
|
||||
}
|
||||
|
||||
@@ -31,7 +31,9 @@ export type ClientTab =
|
||||
>)
|
||||
| ({ fields: ClientField[]; passesCondition?: boolean } & Omit<UnnamedTab, 'fields'>)
|
||||
|
||||
type TabsFieldBaseClientProps = FieldPaths
|
||||
type TabsFieldBaseClientProps = {
|
||||
potentiallyStalePath?: string
|
||||
} & FieldPaths
|
||||
|
||||
type TabsFieldClientWithoutType = MarkOptional<TabsFieldClient, 'type'>
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ type TextFieldBaseClientProps = {
|
||||
readonly inputRef?: React.RefObject<HTMLInputElement>
|
||||
readonly onKeyDown?: React.KeyboardEventHandler<HTMLInputElement>
|
||||
readonly path: string
|
||||
readonly potentiallyStalePath?: string
|
||||
readonly validate?: TextFieldValidation
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ type TextareaFieldBaseClientProps = {
|
||||
readonly inputRef?: React.Ref<HTMLInputElement>
|
||||
readonly onKeyDown?: React.KeyboardEventHandler<HTMLInputElement>
|
||||
readonly path: string
|
||||
readonly potentiallyStalePath?: string
|
||||
readonly validate?: TextareaFieldValidation
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ type UIFieldClientWithoutType = MarkOptional<UIFieldClient, 'type'>
|
||||
|
||||
type UIFieldBaseClientProps = {
|
||||
readonly path: string
|
||||
readonly potentiallyStalePath?: string
|
||||
}
|
||||
|
||||
type UIFieldBaseServerProps = Pick<FieldPaths, 'path'>
|
||||
|
||||
@@ -23,6 +23,7 @@ type UploadFieldClientWithoutType = MarkOptional<UploadFieldClient, 'type'>
|
||||
|
||||
type UploadFieldBaseClientProps = {
|
||||
readonly path: string
|
||||
readonly potentiallyStalePath?: string
|
||||
readonly validate?: UploadFieldValidation
|
||||
}
|
||||
|
||||
|
||||
@@ -247,6 +247,7 @@ export const createOperation = async <
|
||||
let doc
|
||||
|
||||
const select = sanitizeSelect({
|
||||
fields: collectionConfig.flattenedFields,
|
||||
forceSelect: collectionConfig.forceSelect,
|
||||
select: incomingSelect,
|
||||
})
|
||||
|
||||
@@ -110,6 +110,7 @@ export const deleteOperation = async <
|
||||
const fullWhere = combineQueries(where, accessResult)
|
||||
|
||||
const select = sanitizeSelect({
|
||||
fields: collectionConfig.flattenedFields,
|
||||
forceSelect: collectionConfig.forceSelect,
|
||||
select: incomingSelect,
|
||||
})
|
||||
|
||||
@@ -168,6 +168,7 @@ export const deleteByIDOperation = async <TSlug extends CollectionSlug, TSelect
|
||||
}
|
||||
|
||||
const select = sanitizeSelect({
|
||||
fields: collectionConfig.flattenedFields,
|
||||
forceSelect: collectionConfig.forceSelect,
|
||||
select: incomingSelect,
|
||||
})
|
||||
|
||||
@@ -102,6 +102,7 @@ export const findOperation = async <
|
||||
} = args
|
||||
|
||||
const select = sanitizeSelect({
|
||||
fields: collectionConfig.flattenedFields,
|
||||
forceSelect: collectionConfig.forceSelect,
|
||||
select: incomingSelect,
|
||||
})
|
||||
|
||||
@@ -87,6 +87,7 @@ export const findByIDOperation = async <
|
||||
} = args
|
||||
|
||||
const select = sanitizeSelect({
|
||||
fields: collectionConfig.flattenedFields,
|
||||
forceSelect: collectionConfig.forceSelect,
|
||||
select: incomingSelect,
|
||||
})
|
||||
|
||||
@@ -11,6 +11,7 @@ import { APIError, Forbidden, NotFound } from '../../errors/index.js'
|
||||
import { afterRead } from '../../fields/hooks/afterRead/index.js'
|
||||
import { killTransaction } from '../../utilities/killTransaction.js'
|
||||
import { sanitizeSelect } from '../../utilities/sanitizeSelect.js'
|
||||
import { buildVersionCollectionFields } from '../../versions/buildCollectionFields.js'
|
||||
import { getQueryDraftsSelect } from '../../versions/drafts/getQueryDraftsSelect.js'
|
||||
|
||||
export type Arguments = {
|
||||
@@ -70,8 +71,10 @@ export const findVersionByIDOperation = async <TData extends TypeWithID = any>(
|
||||
// /////////////////////////////////////
|
||||
|
||||
const select = sanitizeSelect({
|
||||
fields: buildVersionCollectionFields(payload.config, collectionConfig, true),
|
||||
forceSelect: getQueryDraftsSelect({ select: collectionConfig.forceSelect }),
|
||||
select: incomingSelect,
|
||||
versions: true,
|
||||
})
|
||||
|
||||
const versionsQuery = await payload.db.findVersions<TData>({
|
||||
|
||||
@@ -72,8 +72,10 @@ export const findVersionsOperation = async <TData extends TypeWithVersion<TData>
|
||||
const fullWhere = combineQueries(where, accessResults)
|
||||
|
||||
const select = sanitizeSelect({
|
||||
fields: buildVersionCollectionFields(payload.config, collectionConfig, true),
|
||||
forceSelect: getQueryDraftsSelect({ select: collectionConfig.forceSelect }),
|
||||
select: incomingSelect,
|
||||
versions: true,
|
||||
})
|
||||
|
||||
// /////////////////////////////////////
|
||||
|
||||
@@ -117,6 +117,7 @@ export const restoreVersionOperation = async <TData extends TypeWithID = any>(
|
||||
// /////////////////////////////////////
|
||||
|
||||
const select = sanitizeSelect({
|
||||
fields: collectionConfig.flattenedFields,
|
||||
forceSelect: collectionConfig.forceSelect,
|
||||
select: incomingSelect,
|
||||
})
|
||||
|
||||
@@ -201,6 +201,7 @@ export const updateOperation = async <
|
||||
|
||||
try {
|
||||
const select = sanitizeSelect({
|
||||
fields: collectionConfig.flattenedFields,
|
||||
forceSelect: collectionConfig.forceSelect,
|
||||
select: incomingSelect,
|
||||
})
|
||||
|
||||
@@ -161,6 +161,7 @@ export const updateByIDOperation = async <
|
||||
})
|
||||
|
||||
const select = sanitizeSelect({
|
||||
fields: collectionConfig.flattenedFields,
|
||||
forceSelect: collectionConfig.forceSelect,
|
||||
select: incomingSelect,
|
||||
})
|
||||
|
||||
@@ -83,6 +83,13 @@ export const addOrderableFieldsAndHook = (
|
||||
hidden: true,
|
||||
readOnly: true,
|
||||
},
|
||||
hooks: {
|
||||
beforeDuplicate: [
|
||||
({ siblingData }) => {
|
||||
delete siblingData[orderableFieldName]
|
||||
},
|
||||
],
|
||||
},
|
||||
index: true,
|
||||
required: true,
|
||||
// override the schema to make order fields optional for payload.create()
|
||||
@@ -275,5 +282,6 @@ export const addOrderableEndpoint = (config: SanitizedConfig) => {
|
||||
if (!config.endpoints) {
|
||||
config.endpoints = []
|
||||
}
|
||||
|
||||
config.endpoints.push(reorderEndpoint)
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ const sanitizeAdminConfig = (configToSanitize: Config): Partial<SanitizedConfig>
|
||||
// add default user collection if none provided
|
||||
if (!sanitizedConfig?.admin?.user) {
|
||||
const firstCollectionWithAuth = sanitizedConfig.collections.find(({ auth }) => Boolean(auth))
|
||||
|
||||
if (firstCollectionWithAuth) {
|
||||
sanitizedConfig.admin.user = firstCollectionWithAuth.slug
|
||||
} else {
|
||||
@@ -69,6 +70,7 @@ const sanitizeAdminConfig = (configToSanitize: Config): Partial<SanitizedConfig>
|
||||
const userCollection = sanitizedConfig.collections.find(
|
||||
({ slug }) => slug === sanitizedConfig.admin.user,
|
||||
)
|
||||
|
||||
if (!userCollection || !userCollection.auth) {
|
||||
throw new InvalidConfiguration(
|
||||
`${sanitizedConfig.admin.user} is not a valid admin user collection`,
|
||||
|
||||
@@ -53,6 +53,7 @@ export const findOneOperation = async <T extends Record<string, unknown>>(
|
||||
}
|
||||
|
||||
const select = sanitizeSelect({
|
||||
fields: globalConfig.flattenedFields,
|
||||
forceSelect: globalConfig.forceSelect,
|
||||
select: incomingSelect,
|
||||
})
|
||||
|
||||
@@ -11,6 +11,8 @@ import { afterRead } from '../../fields/hooks/afterRead/index.js'
|
||||
import { deepCopyObjectSimple } from '../../utilities/deepCopyObject.js'
|
||||
import { killTransaction } from '../../utilities/killTransaction.js'
|
||||
import { sanitizeSelect } from '../../utilities/sanitizeSelect.js'
|
||||
import { buildVersionCollectionFields } from '../../versions/buildCollectionFields.js'
|
||||
import { buildVersionGlobalFields } from '../../versions/buildGlobalFields.js'
|
||||
import { getQueryDraftsSelect } from '../../versions/drafts/getQueryDraftsSelect.js'
|
||||
|
||||
export type Arguments = {
|
||||
@@ -60,8 +62,10 @@ export const findVersionByIDOperation = async <T extends TypeWithVersion<T> = an
|
||||
const hasWhereAccess = typeof accessResults === 'object'
|
||||
|
||||
const select = sanitizeSelect({
|
||||
fields: buildVersionGlobalFields(payload.config, globalConfig, true),
|
||||
forceSelect: getQueryDraftsSelect({ select: globalConfig.forceSelect }),
|
||||
select: incomingSelect,
|
||||
versions: true,
|
||||
})
|
||||
|
||||
const findGlobalVersionsArgs: FindGlobalVersionsArgs = {
|
||||
|
||||
@@ -70,8 +70,10 @@ export const findVersionsOperation = async <T extends TypeWithVersion<T>>(
|
||||
const fullWhere = combineQueries(where, accessResults)
|
||||
|
||||
const select = sanitizeSelect({
|
||||
fields: buildVersionGlobalFields(payload.config, globalConfig, true),
|
||||
forceSelect: getQueryDraftsSelect({ select: globalConfig.forceSelect }),
|
||||
select: incomingSelect,
|
||||
versions: true,
|
||||
})
|
||||
|
||||
// /////////////////////////////////////
|
||||
|
||||
@@ -246,6 +246,7 @@ export const updateOperation = async <
|
||||
// /////////////////////////////////////
|
||||
|
||||
const select = sanitizeSelect({
|
||||
fields: globalConfig.flattenedFields,
|
||||
forceSelect: globalConfig.forceSelect,
|
||||
select: incomingSelect,
|
||||
})
|
||||
|
||||
@@ -10,7 +10,7 @@ import type { SanitizedConfig } from '../config/types.js'
|
||||
import type { PayloadRequest } from '../types/index.js'
|
||||
import type { FileData, FileToSave, ProbedImageSize, UploadEdits } from './types.js'
|
||||
|
||||
import { FileRetrievalError, FileUploadError, MissingFile } from '../errors/index.js'
|
||||
import { FileRetrievalError, FileUploadError, Forbidden, MissingFile } from '../errors/index.js'
|
||||
import { canResizeImage } from './canResizeImage.js'
|
||||
import { cropImage } from './cropImage.js'
|
||||
import { getExternalFile } from './getExternalFile.js'
|
||||
@@ -85,6 +85,10 @@ export const generateFileData = async <T>({
|
||||
if (!file && uploadEdits && incomingFileData) {
|
||||
const { filename, url } = incomingFileData as FileData
|
||||
|
||||
if (filename && (filename.includes('../') || filename.includes('..\\'))) {
|
||||
throw new Forbidden(req.t)
|
||||
}
|
||||
|
||||
try {
|
||||
if (url && url.startsWith('/') && !disableLocalStorage) {
|
||||
const filePath = `${staticPath}/${filename}`
|
||||
|
||||
@@ -5,28 +5,28 @@ import path from 'path'
|
||||
|
||||
import type { PayloadRequest } from '../types/index.js'
|
||||
|
||||
const mimeTypeEstimate = {
|
||||
const mimeTypeEstimate: Record<string, string> = {
|
||||
svg: 'image/svg+xml',
|
||||
}
|
||||
|
||||
export const getFileByPath = async (filePath: string): Promise<PayloadRequest['file']> => {
|
||||
if (typeof filePath === 'string') {
|
||||
const data = await fs.readFile(filePath)
|
||||
const mimetype = fileTypeFromFile(filePath)
|
||||
const { size } = await fs.stat(filePath)
|
||||
|
||||
const name = path.basename(filePath)
|
||||
const ext = path.extname(filePath).slice(1)
|
||||
|
||||
const mime = (await mimetype)?.mime || mimeTypeEstimate[ext]
|
||||
|
||||
return {
|
||||
name,
|
||||
data,
|
||||
mimetype: mime,
|
||||
size,
|
||||
}
|
||||
if (typeof filePath !== 'string') {
|
||||
return undefined
|
||||
}
|
||||
|
||||
return undefined
|
||||
const name = path.basename(filePath)
|
||||
const ext = path.extname(filePath).slice(1)
|
||||
|
||||
const [data, stat, type] = await Promise.all([
|
||||
fs.readFile(filePath),
|
||||
fs.stat(filePath),
|
||||
fileTypeFromFile(filePath),
|
||||
])
|
||||
|
||||
return {
|
||||
name,
|
||||
data,
|
||||
mimetype: type?.mime || mimeTypeEstimate[ext],
|
||||
size: stat.size,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,129 @@
|
||||
import { deepMergeSimple } from '@payloadcms/translations/utilities'
|
||||
|
||||
import type { SelectType } from '../types/index.js'
|
||||
import type { FlattenedField } from '../fields/config/types.js'
|
||||
import type { SelectIncludeType, SelectType } from '../types/index.js'
|
||||
|
||||
import { getSelectMode } from './getSelectMode.js'
|
||||
|
||||
// Transform post.title -> post, post.category.title -> post
|
||||
const stripVirtualPathToCurrentCollection = ({
|
||||
fields,
|
||||
path,
|
||||
versions,
|
||||
}: {
|
||||
fields: FlattenedField[]
|
||||
path: string
|
||||
versions: boolean
|
||||
}) => {
|
||||
const resultSegments: string[] = []
|
||||
|
||||
if (versions) {
|
||||
resultSegments.push('version')
|
||||
const versionField = fields.find((each) => each.name === 'version')
|
||||
|
||||
if (versionField && versionField.type === 'group') {
|
||||
fields = versionField.flattenedFields
|
||||
}
|
||||
}
|
||||
|
||||
for (const segment of path.split('.')) {
|
||||
const field = fields.find((each) => each.name === segment)
|
||||
|
||||
if (!field) {
|
||||
continue
|
||||
}
|
||||
|
||||
resultSegments.push(segment)
|
||||
|
||||
if (field.type === 'relationship' || field.type === 'upload') {
|
||||
return resultSegments.join('.')
|
||||
}
|
||||
}
|
||||
|
||||
return resultSegments.join('.')
|
||||
}
|
||||
|
||||
const getAllVirtualRelations = ({ fields }: { fields: FlattenedField[] }) => {
|
||||
const result: string[] = []
|
||||
|
||||
for (const field of fields) {
|
||||
if ('virtual' in field && typeof field.virtual === 'string') {
|
||||
result.push(field.virtual)
|
||||
} else if (field.type === 'group' || field.type === 'tab') {
|
||||
const nestedResult = getAllVirtualRelations({ fields: field.flattenedFields })
|
||||
|
||||
for (const nestedItem of nestedResult) {
|
||||
result.push(nestedItem)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
const resolveVirtualRelationsToSelect = ({
|
||||
fields,
|
||||
selectValue,
|
||||
topLevelFields,
|
||||
versions,
|
||||
}: {
|
||||
fields: FlattenedField[]
|
||||
selectValue: SelectIncludeType | true
|
||||
topLevelFields: FlattenedField[]
|
||||
versions: boolean
|
||||
}) => {
|
||||
const result: string[] = []
|
||||
if (selectValue === true) {
|
||||
for (const item of getAllVirtualRelations({ fields })) {
|
||||
result.push(
|
||||
stripVirtualPathToCurrentCollection({ fields: topLevelFields, path: item, versions }),
|
||||
)
|
||||
}
|
||||
} else {
|
||||
for (const fieldName in selectValue) {
|
||||
const field = fields.find((each) => each.name === fieldName)
|
||||
if (!field) {
|
||||
continue
|
||||
}
|
||||
|
||||
if ('virtual' in field && typeof field.virtual === 'string') {
|
||||
result.push(
|
||||
stripVirtualPathToCurrentCollection({
|
||||
fields: topLevelFields,
|
||||
path: field.virtual,
|
||||
versions,
|
||||
}),
|
||||
)
|
||||
} else if (field.type === 'group' || field.type === 'tab') {
|
||||
for (const item of resolveVirtualRelationsToSelect({
|
||||
fields: field.flattenedFields,
|
||||
selectValue: selectValue[fieldName],
|
||||
topLevelFields,
|
||||
versions,
|
||||
})) {
|
||||
result.push(
|
||||
stripVirtualPathToCurrentCollection({ fields: topLevelFields, path: item, versions }),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
export const sanitizeSelect = ({
|
||||
fields,
|
||||
forceSelect,
|
||||
select,
|
||||
versions,
|
||||
}: {
|
||||
fields: FlattenedField[]
|
||||
forceSelect?: SelectType
|
||||
select?: SelectType
|
||||
versions?: boolean
|
||||
}): SelectType | undefined => {
|
||||
if (!forceSelect || !select) {
|
||||
if (!select) {
|
||||
return select
|
||||
}
|
||||
|
||||
@@ -21,5 +133,36 @@ export const sanitizeSelect = ({
|
||||
return select
|
||||
}
|
||||
|
||||
return deepMergeSimple(select, forceSelect)
|
||||
if (forceSelect) {
|
||||
select = deepMergeSimple(select, forceSelect)
|
||||
}
|
||||
|
||||
if (select) {
|
||||
const virtualRelations = resolveVirtualRelationsToSelect({
|
||||
fields,
|
||||
selectValue: select as SelectIncludeType,
|
||||
topLevelFields: fields,
|
||||
versions: versions ?? false,
|
||||
})
|
||||
|
||||
for (const path of virtualRelations) {
|
||||
let currentRef = select
|
||||
const segments = path.split('.')
|
||||
for (let i = 0; i < segments.length; i++) {
|
||||
const isLast = segments.length - 1 === i
|
||||
const segment = segments[i]
|
||||
|
||||
if (isLast) {
|
||||
currentRef[segment] = true
|
||||
} else {
|
||||
if (!(segment in currentRef)) {
|
||||
currentRef[segment] = {}
|
||||
currentRef = currentRef[segment]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return select
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/plugin-cloud-storage",
|
||||
"version": "3.36.0",
|
||||
"version": "3.36.1",
|
||||
"description": "The official cloud storage plugin for Payload CMS",
|
||||
"homepage": "https://payloadcms.com",
|
||||
"repository": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/plugin-form-builder",
|
||||
"version": "3.36.0",
|
||||
"version": "3.36.1",
|
||||
"description": "Form builder plugin for Payload CMS",
|
||||
"keywords": [
|
||||
"payload",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/plugin-import-export",
|
||||
"version": "3.36.0",
|
||||
"version": "3.36.1",
|
||||
"description": "Import-Export plugin for Payload",
|
||||
"keywords": [
|
||||
"payload",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/plugin-multi-tenant",
|
||||
"version": "3.36.0",
|
||||
"version": "3.36.1",
|
||||
"description": "Multi Tenant plugin for Payload",
|
||||
"keywords": [
|
||||
"payload",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/plugin-nested-docs",
|
||||
"version": "3.36.0",
|
||||
"version": "3.36.1",
|
||||
"description": "The official Nested Docs plugin for Payload",
|
||||
"homepage": "https://payloadcms.com",
|
||||
"repository": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/plugin-redirects",
|
||||
"version": "3.36.0",
|
||||
"version": "3.36.1",
|
||||
"description": "Redirects plugin for Payload",
|
||||
"keywords": [
|
||||
"payload",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/plugin-search",
|
||||
"version": "3.36.0",
|
||||
"version": "3.36.1",
|
||||
"description": "Search plugin for Payload",
|
||||
"keywords": [
|
||||
"payload",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/plugin-sentry",
|
||||
"version": "3.36.0",
|
||||
"version": "3.36.1",
|
||||
"description": "Sentry plugin for Payload",
|
||||
"keywords": [
|
||||
"payload",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/plugin-seo",
|
||||
"version": "3.36.0",
|
||||
"version": "3.36.1",
|
||||
"description": "SEO plugin for Payload",
|
||||
"keywords": [
|
||||
"payload",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/plugin-stripe",
|
||||
"version": "3.36.0",
|
||||
"version": "3.36.1",
|
||||
"description": "Stripe plugin for Payload",
|
||||
"keywords": [
|
||||
"payload",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/richtext-lexical",
|
||||
"version": "3.36.0",
|
||||
"version": "3.36.1",
|
||||
"description": "The officially supported Lexical richtext adapter for Payload",
|
||||
"homepage": "https://payloadcms.com",
|
||||
"repository": {
|
||||
|
||||
@@ -42,6 +42,7 @@ const RichTextComponent: React.FC<
|
||||
required,
|
||||
},
|
||||
path: pathFromProps,
|
||||
potentiallyStalePath,
|
||||
readOnly: readOnlyFromTopLevelProps,
|
||||
validate, // Users can pass in client side validation if they WANT to, but it's not required anymore
|
||||
} = props
|
||||
@@ -73,7 +74,8 @@ const RichTextComponent: React.FC<
|
||||
showError,
|
||||
value,
|
||||
} = useField<SerializedEditorState>({
|
||||
potentiallyStalePath: pathFromProps,
|
||||
path: pathFromProps,
|
||||
potentiallyStalePath,
|
||||
validate: memoizedValidate,
|
||||
})
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/richtext-slate",
|
||||
"version": "3.36.0",
|
||||
"version": "3.36.1",
|
||||
"description": "The officially supported Slate richtext adapter for Payload",
|
||||
"homepage": "https://payloadcms.com",
|
||||
"repository": {
|
||||
|
||||
@@ -61,6 +61,7 @@ const RichTextField: React.FC<LoadedSlateFieldProps> = (props) => {
|
||||
leaves,
|
||||
path: pathFromProps,
|
||||
plugins,
|
||||
potentiallyStalePath,
|
||||
readOnly: readOnlyFromTopLevelProps,
|
||||
schemaPath: schemaPathFromProps,
|
||||
validate = richTextValidate,
|
||||
@@ -101,7 +102,8 @@ const RichTextField: React.FC<LoadedSlateFieldProps> = (props) => {
|
||||
showError,
|
||||
value,
|
||||
} = useField({
|
||||
potentiallyStalePath: pathFromProps,
|
||||
path: pathFromProps,
|
||||
potentiallyStalePath,
|
||||
validate: memoizedValidate,
|
||||
})
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/storage-azure",
|
||||
"version": "3.36.0",
|
||||
"version": "3.36.1",
|
||||
"description": "Payload storage adapter for Azure Blob Storage",
|
||||
"homepage": "https://payloadcms.com",
|
||||
"repository": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/storage-gcs",
|
||||
"version": "3.36.0",
|
||||
"version": "3.36.1",
|
||||
"description": "Payload storage adapter for Google Cloud Storage",
|
||||
"homepage": "https://payloadcms.com",
|
||||
"repository": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/storage-s3",
|
||||
"version": "3.36.0",
|
||||
"version": "3.36.1",
|
||||
"description": "Payload storage adapter for Amazon S3",
|
||||
"homepage": "https://payloadcms.com",
|
||||
"repository": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/storage-uploadthing",
|
||||
"version": "3.36.0",
|
||||
"version": "3.36.1",
|
||||
"description": "Payload storage adapter for uploadthing",
|
||||
"homepage": "https://payloadcms.com",
|
||||
"repository": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/storage-vercel-blob",
|
||||
"version": "3.36.0",
|
||||
"version": "3.36.1",
|
||||
"description": "Payload storage adapter for Vercel Blob Storage",
|
||||
"homepage": "https://payloadcms.com",
|
||||
"repository": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/translations",
|
||||
"version": "3.36.0",
|
||||
"version": "3.36.1",
|
||||
"homepage": "https://payloadcms.com",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@payloadcms/ui",
|
||||
"version": "3.36.0",
|
||||
"version": "3.36.1",
|
||||
"homepage": "https://payloadcms.com",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -48,6 +48,7 @@ export const ArrayFieldComponent: ArrayFieldClientComponent = (props) => {
|
||||
forceRender = false,
|
||||
path: pathFromProps,
|
||||
permissions,
|
||||
potentiallyStalePath,
|
||||
readOnly,
|
||||
schemaPath: schemaPathFromProps,
|
||||
validate,
|
||||
@@ -120,7 +121,8 @@ export const ArrayFieldComponent: ArrayFieldClientComponent = (props) => {
|
||||
value,
|
||||
} = useField<number>({
|
||||
hasRows: true,
|
||||
potentiallyStalePath: pathFromProps,
|
||||
path: pathFromProps,
|
||||
potentiallyStalePath,
|
||||
validate: memoizedValidate,
|
||||
})
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ const BlocksFieldComponent: BlocksFieldClientComponent = (props) => {
|
||||
},
|
||||
path: pathFromProps,
|
||||
permissions,
|
||||
potentiallyStalePath,
|
||||
readOnly,
|
||||
schemaPath: schemaPathFromProps,
|
||||
validate,
|
||||
@@ -108,7 +109,8 @@ const BlocksFieldComponent: BlocksFieldClientComponent = (props) => {
|
||||
value,
|
||||
} = useField<number>({
|
||||
hasRows: true,
|
||||
potentiallyStalePath: pathFromProps,
|
||||
path: pathFromProps,
|
||||
potentiallyStalePath,
|
||||
validate: memoizedValidate,
|
||||
})
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ const CheckboxFieldComponent: CheckboxFieldClientComponent = (props) => {
|
||||
onChange: onChangeFromProps,
|
||||
partialChecked,
|
||||
path: pathFromProps,
|
||||
potentiallyStalePath,
|
||||
readOnly,
|
||||
validate,
|
||||
} = props
|
||||
@@ -66,7 +67,8 @@ const CheckboxFieldComponent: CheckboxFieldClientComponent = (props) => {
|
||||
value,
|
||||
} = useField({
|
||||
disableFormData,
|
||||
potentiallyStalePath: pathFromProps,
|
||||
path: pathFromProps,
|
||||
potentiallyStalePath,
|
||||
validate: memoizedValidate,
|
||||
})
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ const CodeFieldComponent: CodeFieldClientComponent = (props) => {
|
||||
},
|
||||
onMount,
|
||||
path: pathFromProps,
|
||||
potentiallyStalePath,
|
||||
readOnly,
|
||||
validate,
|
||||
} = props
|
||||
@@ -53,7 +54,8 @@ const CodeFieldComponent: CodeFieldClientComponent = (props) => {
|
||||
showError,
|
||||
value,
|
||||
} = useField({
|
||||
potentiallyStalePath: pathFromProps,
|
||||
path: pathFromProps,
|
||||
potentiallyStalePath,
|
||||
validate: memoizedValidate,
|
||||
})
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ const DateTimeFieldComponent: DateFieldClientComponent = (props) => {
|
||||
timezone,
|
||||
},
|
||||
path: pathFromProps,
|
||||
potentiallyStalePath,
|
||||
readOnly,
|
||||
validate,
|
||||
} = props
|
||||
@@ -64,7 +65,8 @@ const DateTimeFieldComponent: DateFieldClientComponent = (props) => {
|
||||
showError,
|
||||
value,
|
||||
} = useField<string>({
|
||||
potentiallyStalePath: pathFromProps,
|
||||
path: pathFromProps,
|
||||
potentiallyStalePath,
|
||||
validate: memoizedValidate,
|
||||
})
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ const EmailFieldComponent: EmailFieldClientComponent = (props) => {
|
||||
required,
|
||||
} = {} as EmailFieldClientProps['field'],
|
||||
path: pathFromProps,
|
||||
potentiallyStalePath,
|
||||
readOnly,
|
||||
validate,
|
||||
} = props
|
||||
@@ -57,7 +58,8 @@ const EmailFieldComponent: EmailFieldClientComponent = (props) => {
|
||||
showError,
|
||||
value,
|
||||
} = useField({
|
||||
potentiallyStalePath: pathFromProps,
|
||||
path: pathFromProps,
|
||||
potentiallyStalePath,
|
||||
validate: memoizedValidate,
|
||||
})
|
||||
|
||||
|
||||
@@ -13,10 +13,16 @@ import { withCondition } from '../../forms/withCondition/index.js'
|
||||
* For example, this sets the `ìd` property of a block in the Blocks field.
|
||||
*/
|
||||
const HiddenFieldComponent: React.FC<HiddenFieldProps> = (props) => {
|
||||
const { disableModifyingForm = true, path: pathFromProps, value: valueFromProps } = props
|
||||
const {
|
||||
disableModifyingForm = true,
|
||||
path: pathFromProps,
|
||||
potentiallyStalePath,
|
||||
value: valueFromProps,
|
||||
} = props
|
||||
|
||||
const { path, setValue, value } = useField({
|
||||
potentiallyStalePath: pathFromProps,
|
||||
path: pathFromProps,
|
||||
potentiallyStalePath,
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -29,6 +29,7 @@ const JSONFieldComponent: JSONFieldClientComponent = (props) => {
|
||||
required,
|
||||
},
|
||||
path: pathFromProps,
|
||||
potentiallyStalePath,
|
||||
readOnly,
|
||||
validate,
|
||||
} = props
|
||||
@@ -55,7 +56,8 @@ const JSONFieldComponent: JSONFieldClientComponent = (props) => {
|
||||
showError,
|
||||
value,
|
||||
} = useField<string>({
|
||||
potentiallyStalePath: pathFromProps,
|
||||
path: pathFromProps,
|
||||
potentiallyStalePath,
|
||||
validate: memoizedValidate,
|
||||
})
|
||||
|
||||
|
||||
@@ -132,6 +132,7 @@ const JoinFieldComponent: JoinFieldClientComponent = (props) => {
|
||||
required,
|
||||
},
|
||||
path: pathFromProps,
|
||||
potentiallyStalePath,
|
||||
} = props
|
||||
|
||||
const { id: docID, docConfig } = useDocumentInfo()
|
||||
@@ -144,7 +145,8 @@ const JoinFieldComponent: JoinFieldClientComponent = (props) => {
|
||||
showError,
|
||||
value,
|
||||
} = useField<PaginatedDocs>({
|
||||
potentiallyStalePath: pathFromProps,
|
||||
path: pathFromProps,
|
||||
potentiallyStalePath,
|
||||
})
|
||||
|
||||
const filterOptions: null | Where = useMemo(() => {
|
||||
|
||||
@@ -39,6 +39,7 @@ const NumberFieldComponent: NumberFieldClientComponent = (props) => {
|
||||
},
|
||||
onChange: onChangeFromProps,
|
||||
path: pathFromProps,
|
||||
potentiallyStalePath,
|
||||
readOnly,
|
||||
validate,
|
||||
} = props
|
||||
@@ -62,7 +63,8 @@ const NumberFieldComponent: NumberFieldClientComponent = (props) => {
|
||||
showError,
|
||||
value,
|
||||
} = useField<number | number[]>({
|
||||
potentiallyStalePath: pathFromProps,
|
||||
path: pathFromProps,
|
||||
potentiallyStalePath,
|
||||
validate: memoizedValidate,
|
||||
})
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ export const PointFieldComponent: PointFieldClientComponent = (props) => {
|
||||
required,
|
||||
},
|
||||
path: pathFromProps,
|
||||
potentiallyStalePath,
|
||||
readOnly,
|
||||
validate,
|
||||
} = props
|
||||
@@ -50,7 +51,8 @@ export const PointFieldComponent: PointFieldClientComponent = (props) => {
|
||||
showError,
|
||||
value = [null, null],
|
||||
} = useField<[number, number]>({
|
||||
potentiallyStalePath: pathFromProps,
|
||||
path: pathFromProps,
|
||||
potentiallyStalePath,
|
||||
validate: memoizedValidate,
|
||||
})
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ const RadioGroupFieldComponent: RadioFieldClientComponent = (props) => {
|
||||
} = {} as RadioFieldClientProps['field'],
|
||||
onChange: onChangeFromProps,
|
||||
path: pathFromProps,
|
||||
potentiallyStalePath,
|
||||
readOnly,
|
||||
validate,
|
||||
value: valueFromProps,
|
||||
@@ -59,7 +60,8 @@ const RadioGroupFieldComponent: RadioFieldClientComponent = (props) => {
|
||||
showError,
|
||||
value: valueFromContext,
|
||||
} = useField<string>({
|
||||
potentiallyStalePath: pathFromProps,
|
||||
path: pathFromProps,
|
||||
potentiallyStalePath,
|
||||
validate: memoizedValidate,
|
||||
})
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ const RelationshipFieldComponent: RelationshipFieldClientComponent = (props) =>
|
||||
required,
|
||||
},
|
||||
path: pathFromProps,
|
||||
potentiallyStalePath,
|
||||
readOnly,
|
||||
validate,
|
||||
} = props
|
||||
@@ -117,7 +118,8 @@ const RelationshipFieldComponent: RelationshipFieldClientComponent = (props) =>
|
||||
showError,
|
||||
value,
|
||||
} = useField<Value | Value[]>({
|
||||
potentiallyStalePath: pathFromProps,
|
||||
path: pathFromProps,
|
||||
potentiallyStalePath,
|
||||
validate: memoizedValidate,
|
||||
})
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ const SelectFieldComponent: SelectFieldClientComponent = (props) => {
|
||||
},
|
||||
onChange: onChangeFromProps,
|
||||
path: pathFromProps,
|
||||
potentiallyStalePath,
|
||||
readOnly,
|
||||
validate,
|
||||
} = props
|
||||
@@ -70,7 +71,8 @@ const SelectFieldComponent: SelectFieldClientComponent = (props) => {
|
||||
showError,
|
||||
value,
|
||||
} = useField({
|
||||
potentiallyStalePath: pathFromProps,
|
||||
path: pathFromProps,
|
||||
potentiallyStalePath,
|
||||
validate: memoizedValidate,
|
||||
})
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user