diff --git a/src/collections/operations/local/update.ts b/src/collections/operations/local/update.ts index 2c5cc4e380..77ae974bc4 100644 --- a/src/collections/operations/local/update.ts +++ b/src/collections/operations/local/update.ts @@ -1,4 +1,5 @@ import { Config as GeneratedTypes } from 'payload/generated-types'; +import { DeepPartial } from 'ts-essentials'; import { Payload } from '../../../payload'; import { Document, Where } from '../../../types'; import getFileByPath from '../../../uploads/getFileByPath'; @@ -13,7 +14,7 @@ import { BulkOperationResult } from '../../config/types'; export type BaseOptions = { collection: TSlug - data: Partial + data: DeepPartial depth?: number locale?: string fallbackLocale?: string diff --git a/src/collections/operations/update.ts b/src/collections/operations/update.ts index 7828900d33..60eaa99299 100644 --- a/src/collections/operations/update.ts +++ b/src/collections/operations/update.ts @@ -1,5 +1,6 @@ import httpStatus from 'http-status'; import { Config as GeneratedTypes } from 'payload/generated-types'; +import { DeepPartial } from 'ts-essentials'; import { Document, Where } from '../../types'; import { BulkOperationResult, Collection } from '../config/types'; import sanitizeInternalFields from '../../utilities/sanitizeInternalFields'; @@ -23,7 +24,7 @@ export type Arguments collection: Collection req: PayloadRequest where: Where - data: Partial + data: DeepPartial depth?: number disableVerificationEmail?: boolean overrideAccess?: boolean @@ -174,7 +175,7 @@ async function update( // beforeValidate - Fields // ///////////////////////////////////// - data = await beforeValidate({ + data = await beforeValidate>({ data, doc: originalDoc, entityConfig: collectionConfig, diff --git a/src/collections/operations/updateByID.ts b/src/collections/operations/updateByID.ts index b69e4c116d..aa29cd9baf 100644 --- a/src/collections/operations/updateByID.ts +++ b/src/collections/operations/updateByID.ts @@ -1,5 +1,6 @@ import httpStatus from 'http-status'; import { Config as GeneratedTypes } from 'payload/generated-types'; +import { DeepPartial } from 'ts-essentials'; import { Where, Document } from '../../types'; import { Collection } from '../config/types'; import sanitizeInternalFields from '../../utilities/sanitizeInternalFields'; @@ -22,7 +23,7 @@ export type Arguments collection: Collection req: PayloadRequest id: string | number - data: Partial + data: DeepPartial depth?: number disableVerificationEmail?: boolean overrideAccess?: boolean @@ -162,7 +163,7 @@ async function updateByID( // beforeValidate - Fields // ///////////////////////////////////// - data = await beforeValidate({ + data = await beforeValidate>({ data, doc: originalDoc, entityConfig: collectionConfig, diff --git a/src/globals/graphql/resolvers/update.ts b/src/globals/graphql/resolvers/update.ts index b5ebf20f26..eae7d29011 100644 --- a/src/globals/graphql/resolvers/update.ts +++ b/src/globals/graphql/resolvers/update.ts @@ -1,5 +1,6 @@ /* eslint-disable no-param-reassign */ import { Config as GeneratedTypes } from 'payload/generated-types'; +import { DeepPartial } from 'ts-essentials'; import { PayloadRequest } from '../../../express/types'; import { SanitizedGlobalConfig } from '../../config/types'; import update from '../../operations/update'; @@ -9,7 +10,7 @@ type Resolver = ( args: { locale?: string fallbackLocale?: string - data?: GeneratedTypes['globals'][TSlug] + data?: DeepPartial> draft?: boolean }, context: { diff --git a/src/globals/operations/local/update.ts b/src/globals/operations/local/update.ts index a4e312b785..2465ede4db 100644 --- a/src/globals/operations/local/update.ts +++ b/src/globals/operations/local/update.ts @@ -1,4 +1,5 @@ import { Config as GeneratedTypes } from 'payload/generated-types'; +import { DeepPartial } from 'ts-essentials'; import { Payload } from '../../../payload'; import { Document } from '../../../types'; import { PayloadRequest } from '../../../express/types'; @@ -12,7 +13,7 @@ export type Options = { depth?: number locale?: string fallbackLocale?: string - data: Omit + data: DeepPartial> user?: Document overrideAccess?: boolean showHiddenFields?: boolean diff --git a/src/globals/operations/update.ts b/src/globals/operations/update.ts index 28545a3310..4d2a7ca728 100644 --- a/src/globals/operations/update.ts +++ b/src/globals/operations/update.ts @@ -1,4 +1,5 @@ import { Config as GeneratedTypes } from 'payload/generated-types'; +import { DeepPartial } from 'ts-essentials'; import { Where } from '../../types'; import { SanitizedGlobalConfig } from '../config/types'; import executeAccess from '../../auth/executeAccess'; @@ -21,7 +22,7 @@ type Args = { showHiddenFields?: boolean draft?: boolean autosave?: boolean - data: Omit + data: DeepPartial> } async function update(