Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
27 lines
1019 B
Plaintext
27 lines
1019 B
Plaintext
import { operationToHookOperation } from './types.js';
|
|
// Implementation
|
|
export async function buildBeforeOperation(operationArgs) {
|
|
const { args, collection, operation, overrideAccess } = operationArgs;
|
|
let newArgs = args;
|
|
if (args.collection.config.hooks?.beforeOperation?.length) {
|
|
// TODO: v4 should not need this mapping
|
|
// Map the operation to the hook operation type for backward compatibility
|
|
const hookOperation = operationToHookOperation[operation];
|
|
for (const hook of args.collection.config.hooks.beforeOperation){
|
|
const hookResult = await hook({
|
|
args: newArgs,
|
|
collection,
|
|
context: args.req.context,
|
|
operation: hookOperation,
|
|
overrideAccess,
|
|
req: args.req
|
|
});
|
|
if (hookResult !== undefined) {
|
|
newArgs = hookResult;
|
|
}
|
|
}
|
|
}
|
|
return newArgs;
|
|
}
|
|
|
|
//# sourceMappingURL=buildBeforeOperation.js.map |