import { I as IView } from './View-2LPqSBtH.js'; export { V as ViewModel, b as baseViewSchemaDefinition, a as createBaseViewIndexes, c as createViewModel } from './View-2LPqSBtH.js'; import { Model } from 'mongoose'; /** * SERVER-SIDE UTILITIES FOR VIEW MANAGEMENT * * ⚠️ IMPORTANT: These functions are designed to run on the SERVER SIDE only. * They require direct access to MongoDB via Mongoose and should NOT be imported * in client-side code (React components, browser bundles, etc.). * * Usage: Import these functions in your server-side API routes, Express handlers, * Next.js API routes, or other Node.js backend code. * * Example: * ```typescript * // ✅ Server-side (API route, Express handler, etc.) * import { serverGetViews, serverCreateView } from '@peakify/polaris-data-table-views/server/views'; * import { ViewModel } from '@peakify/polaris-data-table-views/models/View'; * * app.get('/api/views', async (req, res) => { * const views = await serverGetViews('/admin/users', ViewModel, req.user.id); * res.json({ items: views }); * }); * ``` */ /** * SERVER-SIDE: Get views for a specific path * * This function queries the database to retrieve saved views for a given path. * It should only be called from server-side code (API routes, server handlers). * * @param path - The path to filter views by (e.g., '/admin/users') * @param ViewModel - The Mongoose model instance (from '../models/View') * @param ownerId - Optional owner ID. If provided, only returns views owned by this ID or shared views (without ownerId) * @returns Promise resolving to an array of view objects with name and filters * * @example * ```typescript * // In your server-side API route * const views = await serverGetViews('/admin/users', ViewModel, req.user.id); * ``` */ declare function serverGetViews(path: string, ViewModel: Model, ownerId?: string, select?: (keyof IView)[]): Promise; /** * SERVER-SIDE: Create a new view * * This function creates a new saved view in the database. * It should only be called from server-side code (API routes, server handlers). * * @param path - The path for the view (e.g., '/admin/users') * @param name - The name of the view * @param filters - The filters object to save with the view * @param ViewModel - The Mongoose model instance (from '../models/View') * @param ownerId - Optional owner ID. If provided, the view will be owned by this ID * @returns Promise that resolves when the view is created * * @example * ```typescript * // In your server-side API route * await serverCreateView('/admin/users', 'Active Users', { status: 'active' }, ViewModel, req.user.id); * ``` */ declare function serverCreateView(path: string, name: string, filters: Record, ViewModel: Model, ownerId?: string): Promise; /** * SERVER-SIDE: Update an existing view * * This function updates the filters of an existing saved view in the database. * It should only be called from server-side code (API routes, server handlers). * * @param path - The path for the view (e.g., '/admin/users') * @param name - The name of the view to update * @param filters - The new filters object to save * @param ViewModel - The Mongoose model instance (from '../models/View') * @param ownerId - Optional owner ID. If provided, only updates if the view belongs to this owner or is shared (no ownerId) * @returns Promise that resolves when the view is updated * * @example * ```typescript * // In your server-side API route * await serverUpdateView('/admin/users', 'Active Users', { status: 'inactive' }, ViewModel, req.user.id); * ``` */ declare function serverUpdateView(path: string, name: string, filters: Record, ViewModel: Model, ownerId?: string): Promise; /** * SERVER-SIDE: Delete a view * * This function deletes a saved view from the database. * It should only be called from server-side code (API routes, server handlers). * * @param path - The path for the view (e.g., '/admin/users') * @param name - The name of the view to delete * @param ViewModel - The Mongoose model instance (from '../models/View') * @param ownerId - Optional owner ID. If provided, only deletes if the view belongs to this owner or is shared (no ownerId) * @returns Promise that resolves when the view is deleted * * @example * ```typescript * // In your server-side API route * await serverDeleteView('/admin/users', 'Active Users', ViewModel, req.user.id); * ``` */ declare function serverDeleteView(path: string, name: string, ViewModel: Model, ownerId?: string): Promise; /** * SERVER-SIDE: Rename a view * * This function renames an existing saved view in the database. * It should only be called from server-side code (API routes, server handlers). * * @param path - The path for the view (e.g., '/admin/users') * @param oldName - The current name of the view * @param newName - The new name for the view * @param ViewModel - The Mongoose model instance (from '../models/View') * @param ownerId - Optional owner ID. If provided, only renames if the view belongs to this owner or is shared (no ownerId) * @returns Promise that resolves when the view is renamed * * @example * ```typescript * // In your server-side API route * await serverRenameView('/admin/users', 'Old Name', 'New Name', ViewModel, req.user.id); * ``` */ declare function serverRenameView(path: string, oldName: string, newName: string, ViewModel: Model, ownerId?: string): Promise; export { serverCreateView, serverDeleteView, serverGetViews, serverRenameView, serverUpdateView };