Files
klz-cables.com/.pnpm-store/v10/files/85/8a5c255b1e7dcbeb7b68fc7be29647cb60e4b57714ae74b8a1ee13b6d5f0c3024adb5feabe75fae8830c8b0ab93f16a8e03d9ea171a48cf225913da94bb4d3
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

96 lines
2.7 KiB
Plaintext

import { deleteHandler } from './requestHandlers/delete.js';
import { findByIDHandler } from './requestHandlers/findOne.js';
import { updateHandler } from './requestHandlers/update.js';
const preferenceAccess = ({ req })=>{
if (!req.user) {
return false;
}
const userValueCondition = {
'user.value': {
equals: req.user.id
}
};
const userRelationCondition = {
'user.relationTo': {
equals: req.user.collection
}
};
return {
and: [
userValueCondition,
userRelationCondition
]
};
};
export const preferencesCollectionSlug = 'payload-preferences';
export const getPreferencesCollection = (config)=>({
slug: preferencesCollectionSlug,
access: {
delete: preferenceAccess,
read: preferenceAccess
},
admin: {
hidden: true
},
endpoints: [
{
handler: findByIDHandler,
method: 'get',
path: '/:key'
},
{
handler: deleteHandler,
method: 'delete',
path: '/:key'
},
{
handler: updateHandler,
method: 'post',
path: '/:key'
}
],
fields: [
{
name: 'user',
type: 'relationship',
hooks: {
beforeValidate: [
({ req })=>{
if (!req?.user) {
return null;
}
return {
relationTo: req?.user.collection,
value: req?.user.id
};
}
]
},
index: true,
relationTo: config.collections.filter((collectionConfig)=>collectionConfig.auth).map((collectionConfig)=>collectionConfig.slug),
required: true
},
{
name: 'key',
type: 'text',
index: true
},
{
name: 'value',
type: 'json',
validate: (value)=>{
if (value) {
try {
JSON.parse(JSON.stringify(value));
} catch {
return 'Invalid JSON';
}
}
return true;
}
}
],
lockDocuments: false
});
//# sourceMappingURL=config.js.map