Files
klz-cables.com/.pnpm-store/v10/files/d2/6d41d00b397a23b9a21eb5501538927164d66d2a474826059544285adae00c12568a567473990c20a208da39639333e662e14ef5c7a2cd37cccb09c8050964
Marc Mintel 5397309103
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
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

54 lines
1.7 KiB
Plaintext

import { ValidationError } from '../../../errors/index.js';
import { deepCopyObjectSimple } from '../../../utilities/deepCopyObject.js';
import { traverseFields } from './traverseFields.js';
/**
* This function is responsible for the following actions, in order:
* - Run condition
* - Execute field hooks
* - Validate data
* - Transform data for storage
* - Unflatten locales. The input `data` is the normal document for one locale. The output result will become the document with locales.
*/ export const beforeChange = async ({ id, collection, context, data: incomingData, doc, docWithLocales, global, operation, overrideAccess, req, skipValidation })=>{
const data = deepCopyObjectSimple(incomingData);
const mergeLocaleActions = [];
const errors = [];
await traverseFields({
id,
collection,
context,
data,
doc,
docWithLocales,
errors,
fieldLabelPath: '',
fields: collection?.fields || global?.fields,
global,
mergeLocaleActions,
operation,
overrideAccess: overrideAccess,
parentIndexPath: '',
parentIsLocalized: false,
parentPath: '',
parentSchemaPath: '',
req,
siblingData: data,
siblingDoc: doc,
siblingDocWithLocales: docWithLocales,
skipValidation
});
if (errors.length > 0) {
throw new ValidationError({
id,
collection: collection?.slug,
errors,
global: global?.slug,
req
}, req.t);
}
for (const action of mergeLocaleActions){
await action();
}
return data;
};
//# sourceMappingURL=index.js.map