Files
klz-cables.com/.pnpm-store/v10/files/d8/99cb9c81b4caf0358fdd17458a4dd04ed4f55bd8a5544facd503180a0b4482f3e4917f14798e50f234c52ffc74f2772691f6fc6ca0add3ad3bfdec1a5ba949
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

29 lines
1.4 KiB
Plaintext

/**
* Normalizes relationship/upload field values by extracting IDs from nested objects
* and returning them in the appropriate format based on whether the field is polymorphic.
*
* @param value - The value to normalize (can be a simple ID, or an object with relationTo and value)
* @param relationTo - The relationTo config (string for monomorphic, array for polymorphic)
* @returns The normalized value (simple ID for monomorphic, {relationTo, value} for polymorphic)
*
* @example
* // Monomorphic field - returns simple ID
* normalizeRelationshipValue('123', 'users') // '123'
* normalizeRelationshipValue({ relationTo: 'users', value: '123' }, 'users') // '123'
*
* @example
* // Polymorphic field - returns {relationTo, value}
* normalizeRelationshipValue('123', ['users', 'posts']) // '123' (kept as-is, no relationTo to infer)
* normalizeRelationshipValue({ relationTo: 'users', value: '123' }, ['users', 'posts'])
* // { relationTo: 'users', value: '123' }
*
* @example
* // Handles nested value objects (populated documents)
* normalizeRelationshipValue(
* { relationTo: 'users', value: { id: '123', name: 'John' } },
* ['users', 'posts']
* )
* // { relationTo: 'users', value: '123' }
*/
export declare function normalizeRelationshipValue(value: any, relationTo: string | string[]): any;
//# sourceMappingURL=normalizeRelationshipValue.d.ts.map