Files
klz-cables.com/.pnpm-store/v10/files/db/7ce9887b9752ea14b2680eaceec94fe4103b08de6e79a39d0328ffde3e76cf25d18eb84bc085fc9d611d52a8a33dcb2bcd9972ad6e200d4051ca01ef2d7ef4
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

70 lines
2.8 KiB
Plaintext

import { QueryError } from '../../errors/QueryError.js';
import { validOperatorSet } from '../../types/constants.js';
import { validateSearchParam } from './validateSearchParams.js';
export async function validateQueryPaths({ collectionConfig, errors = [], globalConfig, overrideAccess, policies = {
collections: {},
globals: {}
}, polymorphicJoin, req, versionFields, where }) {
const fields = versionFields || (globalConfig || collectionConfig).flattenedFields;
if (typeof where === 'object') {
// We need to determine if the whereKey is an AND, OR, or a schema path
const promises = [];
for(const path in where){
const constraint = where[path];
if ((path === 'and' || path === 'or') && Array.isArray(constraint)) {
for (const item of constraint){
if (collectionConfig) {
promises.push(validateQueryPaths({
collectionConfig,
errors,
overrideAccess,
policies,
polymorphicJoin,
req,
versionFields,
where: item
}));
} else {
promises.push(validateQueryPaths({
errors,
globalConfig,
overrideAccess,
policies,
polymorphicJoin,
req,
versionFields,
where: item
}));
}
}
} else if (!Array.isArray(constraint)) {
for(const operator in constraint){
const val = constraint[operator];
if (validOperatorSet.has(operator)) {
promises.push(validateSearchParam({
collectionConfig,
constraint: where,
errors,
fields,
globalConfig,
operator,
overrideAccess,
path,
policies,
polymorphicJoin,
req,
val,
versionFields
}));
}
}
}
}
await Promise.all(promises);
if (errors.length > 0) {
throw new QueryError(errors);
}
}
}
//# sourceMappingURL=validateQueryPaths.js.map