All files / src/lib/api-docs/endpoints/admin inventory.ts

100% Statements 72/72
100% Branches 0/0
100% Functions 0/0
100% Lines 72/72

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 731x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
/**
 * Admin Inventory Endpoints
 * Inventory management and stock tracking
 */
 
import type { ApiEndpoint } from '@/types/api-docs';
 
export const adminInventoryEndpoints: ApiEndpoint[] = [
  {
    id: 'admin-inventory-list',
    method: 'GET',
    path: '/api/admin/inventory',
    summary: 'List inventory',
    description: 'Returns inventory status for all products',
    category: 'admin-inventory',
    requiresAuth: true,
    adminOnly: true,
    parameters: [
      { name: 'status', type: 'string', required: false, location: 'query', description: 'Filter by stock status', enum: ['in_stock', 'low_stock', 'out_of_stock'] },
      { name: 'categoryId', type: 'number', required: false, location: 'query', description: 'Filter by category' },
      { name: 'search', type: 'string', required: false, location: 'query', description: 'Search product name' },
      { name: 'page', type: 'number', required: false, location: 'query', description: 'Page number' },
      { name: 'limit', type: 'number', required: false, location: 'query', description: 'Items per page' },
    ],
    responses: [
      { status: 200, description: 'Inventory list', example: { success: true, data: { items: [], total: 0 } } },
    ],
  },
  {
    id: 'admin-inventory-get',
    method: 'GET',
    path: '/api/admin/inventory/{productId}',
    summary: 'Get product inventory',
    description: 'Returns inventory details for a specific product',
    category: 'admin-inventory',
    requiresAuth: true,
    adminOnly: true,
    parameters: [
      { name: 'productId', type: 'number', required: true, location: 'path', description: 'Product ID' },
    ],
    responses: [
      { status: 200, description: 'Product inventory' },
      { status: 404, description: 'Product not found' },
    ],
  },
  {
    id: 'admin-inventory-update',
    method: 'PATCH',
    path: '/api/admin/inventory/{productId}',
    summary: 'Update inventory',
    description: 'Updates inventory quantity for a product',
    category: 'admin-inventory',
    requiresAuth: true,
    adminOnly: true,
    parameters: [
      { name: 'productId', type: 'number', required: true, location: 'path', description: 'Product ID' },
    ],
    requestBody: {
      contentType: 'application/json',
      fields: [
        { name: 'quantity', type: 'number', required: false, description: 'New stock quantity' },
        { name: 'adjustment', type: 'number', required: false, description: 'Adjustment amount (+/-)' },
        { name: 'reason', type: 'string', required: false, description: 'Reason for adjustment' },
        { name: 'lowStockThreshold', type: 'number', required: false, description: 'Low stock alert threshold' },
      ],
    },
    responses: [
      { status: 200, description: 'Inventory updated' },
      { status: 404, description: 'Product not found' },
    ],
  },
];