Compare commits

...

2 Commits

Author SHA1 Message Date
Kendell Joseph
3b0308fa92 feat(restore): Updates link label 2024-01-24 14:29:42 -05:00
Kendell Joseph
f0446558d2 feat(restore): Adds beforeOperation hook 2024-01-24 14:28:54 -05:00

View File

@@ -3,7 +3,7 @@ import httpStatus from 'http-status'
import type { FindOneArgs } from '../../database/types'
import type { PayloadRequest } from '../../express/types'
import type { Collection, TypeWithID } from '../config/types'
import type { Collection, TypeWithID, BeforeOperationHook } from '../config/types'
import executeAccess from '../../auth/executeAccess'
import { hasWhereAccessResult } from '../../auth/types'
@@ -45,6 +45,26 @@ async function restoreVersion<T extends TypeWithID = any>(args: Arguments): Prom
throw new APIError('Missing ID of version to restore.', httpStatus.BAD_REQUEST)
}
// WIP: https://github.com/payloadcms/payload/discussions/4901
// /////////////////////////////////////
// beforeOperation - Collection
// /////////////////////////////////////
await args.collection.config.hooks.beforeOperation.reduce(
async (priorHook: BeforeOperationHook | Promise<void>, hook: BeforeOperationHook) => {
await priorHook
args =
(await hook({
args,
collection: args.collection.config,
context: args.req.context,
operation: 'update',
})) || args
},
Promise.resolve(),
)
// /////////////////////////////////////
// Retrieve original raw version
// /////////////////////////////////////