import { NextFunction } from 'express'; import { AuthenticatedMedusaRequest, MedusaResponse } from '@medusajs/framework'; type CheckResourceOwnershipByResourceIdOptions
= { entryPoint: string; filterField?: string; resourceId?: (req: AuthenticatedMedusaRequest) => string | string[]; }; /** * Middleware that verifies if the authenticated member owns/has access to the requested resource(s). * This is done by checking if the member's seller ID matches the resource's seller ID. * Supports both single resource ID and arrays of resource IDs. * * @param options - Configuration options for the ownership check * @param options.entryPoint - The entity type to verify ownership of (e.g. 'seller_product', 'service_zone') * @param options.filterField - Field used to filter/lookup the resource (defaults to 'id') * @param options.resourceId - Function to extract resource ID(s) from the request (defaults to req.params.id) * * @throws {MedusaError} If the member does not own any of the resources * * @example * // Basic usage - check ownership of single vendor product * app.use(checkResourceOwnershipByResourceId({ * entryPoint: 'seller_product' * })) * * @example * // Custom field usage - check ownership of service zone * app.use(checkResourceOwnershipByResourceId({ * entryPoint: 'service_zone', * filterField: 'service_zone_id', * resourceId: (req) => req.params.zone_id * })) * * @example * // Batch usage - check ownership of multiple promotions * app.use(checkResourceOwnershipByResourceId({ * entryPoint: 'seller_promotion', * filterField: 'promotion_id', * resourceId: (req) => [...(req.body.add || []), ...(req.body.remove || [])] * })) */ export declare const checkResourceOwnershipByResourceId: ({ entryPoint, filterField, resourceId }: CheckResourceOwnershipByResourceIdOptions) => (req: AuthenticatedMedusaRequest, res: MedusaResponse, next: NextFunction) => Promise