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

1 line
4.2 KiB
Plaintext

{"version":3,"sources":["../../src/preferences/config.ts"],"sourcesContent":["import type { CollectionConfig } from '../collections/config/types.js'\nimport type { Access, Config } from '../config/types.js'\nimport type { Where } from '../types/index.js'\n\nimport { deleteHandler } from './requestHandlers/delete.js'\nimport { findByIDHandler } from './requestHandlers/findOne.js'\nimport { updateHandler } from './requestHandlers/update.js'\n\nconst preferenceAccess: Access = ({ req }) => {\n if (!req.user) {\n return false\n }\n\n const userValueCondition: Where = {\n 'user.value': {\n equals: req.user.id,\n },\n }\n\n const userRelationCondition: Where = {\n 'user.relationTo': {\n equals: req.user.collection,\n },\n }\n\n return {\n and: [userValueCondition, userRelationCondition],\n }\n}\n\nexport const preferencesCollectionSlug = 'payload-preferences'\n\nexport const getPreferencesCollection = (config: Config): CollectionConfig => ({\n slug: preferencesCollectionSlug,\n access: {\n delete: preferenceAccess,\n read: preferenceAccess,\n },\n admin: {\n hidden: true,\n },\n endpoints: [\n {\n handler: findByIDHandler,\n method: 'get',\n path: '/:key',\n },\n {\n handler: deleteHandler,\n method: 'delete',\n path: '/:key',\n },\n {\n handler: updateHandler,\n method: 'post',\n path: '/:key',\n },\n ],\n fields: [\n {\n name: 'user',\n type: 'relationship',\n hooks: {\n beforeValidate: [\n ({ req }) => {\n if (!req?.user) {\n return null\n }\n\n return {\n relationTo: req?.user.collection,\n value: req?.user.id,\n }\n },\n ],\n },\n index: true,\n relationTo: config\n .collections!.filter((collectionConfig) => collectionConfig.auth)\n .map((collectionConfig) => collectionConfig.slug),\n required: true,\n },\n {\n name: 'key',\n type: 'text',\n index: true,\n },\n {\n name: 'value',\n type: 'json',\n validate: (value) => {\n if (value) {\n try {\n JSON.parse(JSON.stringify(value))\n } catch {\n return 'Invalid JSON'\n }\n }\n\n return true\n },\n },\n ],\n lockDocuments: false,\n})\n"],"names":["deleteHandler","findByIDHandler","updateHandler","preferenceAccess","req","user","userValueCondition","equals","id","userRelationCondition","collection","and","preferencesCollectionSlug","getPreferencesCollection","config","slug","access","delete","read","admin","hidden","endpoints","handler","method","path","fields","name","type","hooks","beforeValidate","relationTo","value","index","collections","filter","collectionConfig","auth","map","required","validate","JSON","parse","stringify","lockDocuments"],"mappings":"AAIA,SAASA,aAAa,QAAQ,8BAA6B;AAC3D,SAASC,eAAe,QAAQ,+BAA8B;AAC9D,SAASC,aAAa,QAAQ,8BAA6B;AAE3D,MAAMC,mBAA2B,CAAC,EAAEC,GAAG,EAAE;IACvC,IAAI,CAACA,IAAIC,IAAI,EAAE;QACb,OAAO;IACT;IAEA,MAAMC,qBAA4B;QAChC,cAAc;YACZC,QAAQH,IAAIC,IAAI,CAACG,EAAE;QACrB;IACF;IAEA,MAAMC,wBAA+B;QACnC,mBAAmB;YACjBF,QAAQH,IAAIC,IAAI,CAACK,UAAU;QAC7B;IACF;IAEA,OAAO;QACLC,KAAK;YAACL;YAAoBG;SAAsB;IAClD;AACF;AAEA,OAAO,MAAMG,4BAA4B,sBAAqB;AAE9D,OAAO,MAAMC,2BAA2B,CAACC,SAAsC,CAAA;QAC7EC,MAAMH;QACNI,QAAQ;YACNC,QAAQd;YACRe,MAAMf;QACR;QACAgB,OAAO;YACLC,QAAQ;QACV;QACAC,WAAW;YACT;gBACEC,SAASrB;gBACTsB,QAAQ;gBACRC,MA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