mirror of
https://github.com/xtr-dev/payload-mailing.git
synced 2025-12-10 08:13:23 +00:00
Add PayloadID type and relation helpers, fix filterOptions casting issue
- Add PayloadID type for string | number IDs - Add PayloadRelation<T> type for populated/unpopulated relations - Add isPopulated() type guard to check if relation is populated - Add resolveID() helper to extract ID from relation (object or ID) - Add resolveIDs() helper for arrays of relations - Fix filterOptions in Emails.ts to safely resolve ID before filtering - This prevents MongoDB ObjectId casting errors when id is an object - Bump version to 0.4.15 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
import { Payload } from 'payload'
|
||||
import type { CollectionConfig, RichTextField } from 'payload'
|
||||
|
||||
// Payload ID type (string or number)
|
||||
export type PayloadID = string | number
|
||||
|
||||
// Payload relation type - can be populated (object with id) or unpopulated (just the ID)
|
||||
export type PayloadRelation<T extends { id: PayloadID }> = T | PayloadID
|
||||
|
||||
// JSON value type that matches Payload's JSON field type
|
||||
export type JSONValue = string | number | boolean | { [k: string]: unknown } | unknown[] | null | undefined
|
||||
|
||||
|
||||
Reference in New Issue
Block a user