fix: make update typing a deep partial (#2407)
This commit is contained in:
@@ -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<TSlug extends keyof GeneratedTypes['collections']> = {
|
||||
collection: TSlug
|
||||
data: Partial<GeneratedTypes['collections'][TSlug]>
|
||||
data: DeepPartial<GeneratedTypes['collections'][TSlug]>
|
||||
depth?: number
|
||||
locale?: string
|
||||
fallbackLocale?: string
|
||||
|
||||
@@ -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<T extends { [field: string | number | symbol]: unknown }>
|
||||
collection: Collection
|
||||
req: PayloadRequest
|
||||
where: Where
|
||||
data: Partial<T>
|
||||
data: DeepPartial<T>
|
||||
depth?: number
|
||||
disableVerificationEmail?: boolean
|
||||
overrideAccess?: boolean
|
||||
@@ -174,7 +175,7 @@ async function update<TSlug extends keyof GeneratedTypes['collections']>(
|
||||
// beforeValidate - Fields
|
||||
// /////////////////////////////////////
|
||||
|
||||
data = await beforeValidate<GeneratedTypes['collections'][TSlug]>({
|
||||
data = await beforeValidate<DeepPartial<GeneratedTypes['collections'][TSlug]>>({
|
||||
data,
|
||||
doc: originalDoc,
|
||||
entityConfig: collectionConfig,
|
||||
|
||||
@@ -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<T extends { [field: string | number | symbol]: unknown }>
|
||||
collection: Collection
|
||||
req: PayloadRequest
|
||||
id: string | number
|
||||
data: Partial<T>
|
||||
data: DeepPartial<T>
|
||||
depth?: number
|
||||
disableVerificationEmail?: boolean
|
||||
overrideAccess?: boolean
|
||||
@@ -162,7 +163,7 @@ async function updateByID<TSlug extends keyof GeneratedTypes['collections']>(
|
||||
// beforeValidate - Fields
|
||||
// /////////////////////////////////////
|
||||
|
||||
data = await beforeValidate<GeneratedTypes['collections'][TSlug]>({
|
||||
data = await beforeValidate<DeepPartial<GeneratedTypes['collections'][TSlug]>>({
|
||||
data,
|
||||
doc: originalDoc,
|
||||
entityConfig: collectionConfig,
|
||||
|
||||
@@ -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<TSlug extends keyof GeneratedTypes['globals']> = (
|
||||
args: {
|
||||
locale?: string
|
||||
fallbackLocale?: string
|
||||
data?: GeneratedTypes['globals'][TSlug]
|
||||
data?: DeepPartial<Omit<GeneratedTypes['globals'][TSlug], 'id'>>
|
||||
draft?: boolean
|
||||
},
|
||||
context: {
|
||||
|
||||
@@ -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<TSlug extends keyof GeneratedTypes['globals']> = {
|
||||
depth?: number
|
||||
locale?: string
|
||||
fallbackLocale?: string
|
||||
data: Omit<GeneratedTypes['globals'][TSlug], 'id'>
|
||||
data: DeepPartial<Omit<GeneratedTypes['globals'][TSlug], 'id'>>
|
||||
user?: Document
|
||||
overrideAccess?: boolean
|
||||
showHiddenFields?: boolean
|
||||
|
||||
@@ -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<T extends { [field: string | number | symbol]: unknown }> = {
|
||||
showHiddenFields?: boolean
|
||||
draft?: boolean
|
||||
autosave?: boolean
|
||||
data: Omit<T, 'id'>
|
||||
data: DeepPartial<Omit<T, 'id'>>
|
||||
}
|
||||
|
||||
async function update<TSlug extends keyof GeneratedTypes['globals']>(
|
||||
|
||||
Reference in New Issue
Block a user