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

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

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 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 4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x 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 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 Content Endpoints
 * Hero carousel, feature cards, and testimonials management
 */
 
import type { ApiEndpoint } from '@/types/api-docs';
 
export const adminContentEndpoints: ApiEndpoint[] = [
  // Hero Carousel Management
  {
    id: 'admin-hero-carousel-list',
    method: 'GET',
    path: '/api/admin/hero/carousel',
    summary: 'List carousel items',
    description: 'Returns all hero carousel items with product details',
    category: 'admin-content',
    requiresAuth: true,
    adminOnly: true,
    responses: [
      {
        status: 200,
        description: 'List of carousel items',
        example: {
          success: true,
          data: {
            items: [
              { id: 1, productId: 1, headline: 'Summer Sale', subheadline: 'Up to 50% off', badgeText: '50%', ctaText: 'Shop Now', order: 0, isActive: true, product: { title: 'Product 1', image: '/img.jpg' } },
            ],
          },
        },
      },
      { status: 403, description: 'Admin access required' },
    ],
  },
  {
    id: 'admin-hero-carousel-create',
    method: 'POST',
    path: '/api/admin/hero/carousel',
    summary: 'Create carousel item',
    description: 'Creates a new hero carousel item',
    category: 'admin-content',
    requiresAuth: true,
    adminOnly: true,
    requestBody: {
      contentType: 'application/json',
      fields: [
        { name: 'productId', type: 'number', required: true, description: 'Product ID to feature' },
        { name: 'headline', type: 'string', required: false, description: 'Custom headline (max 200 chars)' },
        { name: 'subheadline', type: 'string', required: false, description: 'Custom subheadline' },
        { name: 'badgeText', type: 'string', required: false, description: 'Badge text (e.g., "20%")' },
        { name: 'badgeSubtext', type: 'string', required: false, description: 'Badge subtext (e.g., "Sale Off")' },
        { name: 'ctaText', type: 'string', required: false, description: 'Call-to-action button text', example: 'Shop Now' },
        { name: 'order', type: 'number', required: false, description: 'Display order (auto-assigned if omitted)' },
        { name: 'isActive', type: 'boolean', required: false, description: 'Whether item is active' },
        { name: 'startDate', type: 'string', required: false, description: 'Scheduled start date (ISO 8601)' },
        { name: 'endDate', type: 'string', required: false, description: 'Scheduled end date (ISO 8601)' },
      ],
      example: { productId: 1, headline: 'Summer Sale', badgeText: '30%', ctaText: 'Shop Now' },
    },
    responses: [
      { status: 201, description: 'Carousel item created' },
      { status: 400, description: 'Validation failed' },
      { status: 404, description: 'Product not found' },
    ],
  },
  {
    id: 'admin-hero-carousel-get',
    method: 'GET',
    path: '/api/admin/hero/carousel/{id}',
    summary: 'Get carousel item',
    description: 'Returns a single carousel item by ID',
    category: 'admin-content',
    requiresAuth: true,
    adminOnly: true,
    parameters: [
      { name: 'id', type: 'number', required: true, location: 'path', description: 'Carousel item ID' },
    ],
    responses: [
      { status: 200, description: 'Carousel item details' },
      { status: 404, description: 'Item not found' },
    ],
  },
  {
    id: 'admin-hero-carousel-update',
    method: 'PUT',
    path: '/api/admin/hero/carousel/{id}',
    summary: 'Update carousel item',
    description: 'Updates an existing carousel item',
    category: 'admin-content',
    requiresAuth: true,
    adminOnly: true,
    parameters: [
      { name: 'id', type: 'number', required: true, location: 'path', description: 'Carousel item ID' },
    ],
    requestBody: {
      contentType: 'application/json',
      fields: [
        { name: 'productId', type: 'number', required: false, description: 'Product ID' },
        { name: 'headline', type: 'string', required: false, description: 'Custom headline' },
        { name: 'subheadline', type: 'string', required: false, description: 'Custom subheadline' },
        { name: 'badgeText', type: 'string', required: false, description: 'Badge text' },
        { name: 'ctaText', type: 'string', required: false, description: 'CTA button text' },
        { name: 'order', type: 'number', required: false, description: 'Display order' },
        { name: 'isActive', type: 'boolean', required: false, description: 'Active status' },
      ],
    },
    responses: [
      { status: 200, description: 'Carousel item updated' },
      { status: 400, description: 'Validation failed' },
      { status: 404, description: 'Item or product not found' },
    ],
  },
  {
    id: 'admin-hero-carousel-delete',
    method: 'DELETE',
    path: '/api/admin/hero/carousel/{id}',
    summary: 'Delete carousel item',
    description: 'Deletes a carousel item',
    category: 'admin-content',
    requiresAuth: true,
    adminOnly: true,
    parameters: [
      { name: 'id', type: 'number', required: true, location: 'path', description: 'Carousel item ID' },
    ],
    responses: [
      { status: 200, description: 'Item deleted' },
      { status: 404, description: 'Item not found' },
    ],
  },
  {
    id: 'admin-hero-carousel-reorder',
    method: 'POST',
    path: '/api/admin/hero/carousel/reorder',
    summary: 'Reorder carousel items',
    description: 'Bulk reorder carousel items',
    category: 'admin-content',
    requiresAuth: true,
    adminOnly: true,
    requestBody: {
      contentType: 'application/json',
      fields: [
        { name: 'items', type: 'array', required: true, description: 'Array of {id, order} objects' },
      ],
      example: { items: [{ id: 1, order: 0 }, { id: 2, order: 1 }, { id: 3, order: 2 }] },
    },
    responses: [
      { status: 200, description: 'Items reordered' },
      { status: 400, description: 'Validation failed' },
    ],
  },
  // Hero Feature Cards Management
  {
    id: 'admin-hero-feature-cards-list',
    method: 'GET',
    path: '/api/admin/hero/feature-cards',
    summary: 'List feature cards',
    description: 'Returns all hero feature cards (side cards)',
    category: 'admin-content',
    requiresAuth: true,
    adminOnly: true,
    responses: [
      { status: 200, description: 'List of feature cards' },
      { status: 403, description: 'Admin access required' },
    ],
  },
  {
    id: 'admin-hero-feature-cards-create',
    method: 'POST',
    path: '/api/admin/hero/feature-cards',
    summary: 'Create feature card',
    description: 'Creates a new hero feature card. Only one active card per position (top/bottom).',
    category: 'admin-content',
    requiresAuth: true,
    adminOnly: true,
    requestBody: {
      contentType: 'application/json',
      fields: [
        { name: 'productId', type: 'number', required: true, description: 'Product ID to feature' },
        { name: 'title', type: 'string', required: false, description: 'Custom title (max 200 chars)' },
        { name: 'subtitle', type: 'string', required: false, description: 'Custom subtitle (max 100 chars)' },
        { name: 'position', type: 'string', required: true, description: 'Card position', enum: ['top', 'bottom'] },
        { name: 'isActive', type: 'boolean', required: false, description: 'Whether card is active' },
      ],
      example: { productId: 5, title: 'Featured Deal', position: 'top', isActive: true },
    },
    responses: [
      { status: 201, description: 'Feature card created' },
      { status: 400, description: 'Position already taken or validation failed' },
      { status: 404, description: 'Product not found' },
    ],
  },
  {
    id: 'admin-hero-feature-cards-get',
    method: 'GET',
    path: '/api/admin/hero/feature-cards/{id}',
    summary: 'Get feature card',
    description: 'Returns a single feature card by ID',
    category: 'admin-content',
    requiresAuth: true,
    adminOnly: true,
    parameters: [
      { name: 'id', type: 'number', required: true, location: 'path', description: 'Feature card ID' },
    ],
    responses: [
      { status: 200, description: 'Feature card details' },
      { status: 404, description: 'Card not found' },
    ],
  },
  {
    id: 'admin-hero-feature-cards-update',
    method: 'PUT',
    path: '/api/admin/hero/feature-cards/{id}',
    summary: 'Update feature card',
    description: 'Updates an existing feature card',
    category: 'admin-content',
    requiresAuth: true,
    adminOnly: true,
    parameters: [
      { name: 'id', type: 'number', required: true, location: 'path', description: 'Feature card ID' },
    ],
    requestBody: {
      contentType: 'application/json',
      fields: [
        { name: 'productId', type: 'number', required: false, description: 'Product ID' },
        { name: 'title', type: 'string', required: false, description: 'Custom title' },
        { name: 'subtitle', type: 'string', required: false, description: 'Custom subtitle' },
        { name: 'position', type: 'string', required: false, description: 'Card position', enum: ['top', 'bottom'] },
        { name: 'isActive', type: 'boolean', required: false, description: 'Active status' },
      ],
    },
    responses: [
      { status: 200, description: 'Feature card updated' },
      { status: 400, description: 'Position taken or validation failed' },
      { status: 404, description: 'Card or product not found' },
    ],
  },
  {
    id: 'admin-hero-feature-cards-delete',
    method: 'DELETE',
    path: '/api/admin/hero/feature-cards/{id}',
    summary: 'Delete feature card',
    description: 'Deletes a feature card',
    category: 'admin-content',
    requiresAuth: true,
    adminOnly: true,
    parameters: [
      { name: 'id', type: 'number', required: true, location: 'path', description: 'Feature card ID' },
    ],
    responses: [
      { status: 200, description: 'Card deleted' },
      { status: 404, description: 'Card not found' },
    ],
  },
  // Testimonials Management
  {
    id: 'admin-testimonials-list',
    method: 'GET',
    path: '/api/admin/testimonials',
    summary: 'List testimonials',
    description: 'Returns all testimonials for admin management',
    category: 'admin-content',
    requiresAuth: true,
    adminOnly: true,
    parameters: [
      { name: 'page', type: 'number', required: false, location: 'query', description: 'Page number' },
      { name: 'limit', type: 'number', required: false, location: 'query', description: 'Items per page' },
      { name: 'status', type: 'string', required: false, location: 'query', description: 'Filter by status', enum: ['pending', 'approved', 'rejected'] },
    ],
    responses: [
      { status: 200, description: 'List of testimonials' },
      { status: 403, description: 'Admin access required' },
    ],
  },
  {
    id: 'admin-testimonials-create',
    method: 'POST',
    path: '/api/admin/testimonials',
    summary: 'Create testimonial',
    description: 'Creates a new testimonial',
    category: 'admin-content',
    requiresAuth: true,
    adminOnly: true,
    requestBody: {
      contentType: 'application/json',
      fields: [
        { name: 'content', type: 'string', required: true, description: 'Testimonial content' },
        { name: 'authorName', type: 'string', required: true, description: 'Author name' },
        { name: 'authorTitle', type: 'string', required: false, description: 'Author title/role' },
        { name: 'authorImage', type: 'string', required: false, description: 'Author image URL' },
        { name: 'rating', type: 'number', required: false, description: 'Rating (1-5)' },
        { name: 'isActive', type: 'boolean', required: false, description: 'Whether testimonial is active' },
      ],
    },
    responses: [
      { status: 201, description: 'Testimonial created' },
      { status: 400, description: 'Validation failed' },
    ],
  },
  {
    id: 'admin-testimonials-update',
    method: 'PUT',
    path: '/api/admin/testimonials/{id}',
    summary: 'Update testimonial',
    description: 'Updates an existing testimonial',
    category: 'admin-content',
    requiresAuth: true,
    adminOnly: true,
    parameters: [
      { name: 'id', type: 'number', required: true, location: 'path', description: 'Testimonial ID' },
    ],
    responses: [
      { status: 200, description: 'Testimonial updated' },
      { status: 404, description: 'Testimonial not found' },
    ],
  },
  {
    id: 'admin-testimonials-delete',
    method: 'DELETE',
    path: '/api/admin/testimonials/{id}',
    summary: 'Delete testimonial',
    description: 'Deletes a testimonial',
    category: 'admin-content',
    requiresAuth: true,
    adminOnly: true,
    parameters: [
      { name: 'id', type: 'number', required: true, location: 'path', description: 'Testimonial ID' },
    ],
    responses: [
      { status: 200, description: 'Testimonial deleted' },
      { status: 404, description: 'Testimonial not found' },
    ],
  },
  // Promo Banners Management
  {
    id: 'admin-promo-banners-list',
    method: 'GET',
    path: '/api/admin/hero/promo-banners',
    summary: 'List promo banners',
    description: 'Returns all promotional banners for admin management',
    category: 'admin-content',
    requiresAuth: true,
    adminOnly: true,
    responses: [
      {
        status: 200,
        description: 'List of promo banners',
        example: {
          success: true,
          data: {
            banners: [
              { id: 1, title: 'Summer Sale', headline: 'Up to 50% Off', size: 'large', isActive: true, order: 0 },
            ],
          },
        },
      },
      { status: 403, description: 'Admin access required' },
    ],
  },
  {
    id: 'admin-promo-banners-create',
    method: 'POST',
    path: '/api/admin/hero/promo-banners',
    summary: 'Create promo banner',
    description: 'Creates a new promotional banner',
    category: 'admin-content',
    requiresAuth: true,
    adminOnly: true,
    requestBody: {
      contentType: 'application/json',
      fields: [
        { name: 'title', type: 'string', required: true, description: 'Banner title (max 100 chars)' },
        { name: 'headline', type: 'string', required: true, description: 'Banner headline (max 100 chars)' },
        { name: 'description', type: 'string', required: false, description: 'Banner description (max 255 chars)' },
        { name: 'ctaText', type: 'string', required: true, description: 'CTA button text (max 50 chars)' },
        { name: 'productId', type: 'number', required: false, description: 'Linked product ID' },
        { name: 'ctaLink', type: 'string', required: false, description: 'Custom CTA link URL' },
        { name: 'imageUrl', type: 'string', required: true, description: 'Banner image URL' },
        { name: 'backgroundColor', type: 'string', required: true, description: 'Background color (hex)' },
        { name: 'textColor', type: 'string', required: false, description: 'Text color (hex)' },
        { name: 'darkBgColor', type: 'string', required: false, description: 'Dark mode background color' },
        { name: 'darkTextColor', type: 'string', required: false, description: 'Dark mode text color' },
        { name: 'size', type: 'string', required: true, description: 'Banner size', enum: ['large', 'small'] },
        { name: 'imagePosition', type: 'string', required: false, description: 'Image position', enum: ['left', 'right'] },
        { name: 'isActive', type: 'boolean', required: false, description: 'Whether banner is active' },
        { name: 'startDate', type: 'string', required: false, description: 'Scheduled start date' },
        { name: 'endDate', type: 'string', required: false, description: 'Scheduled end date' },
      ],
    },
    responses: [
      { status: 201, description: 'Banner created' },
      { status: 400, description: 'Validation failed' },
    ],
  },
  {
    id: 'admin-promo-banners-get',
    method: 'GET',
    path: '/api/admin/hero/promo-banners/{id}',
    summary: 'Get promo banner',
    description: 'Returns a single promo banner by ID',
    category: 'admin-content',
    requiresAuth: true,
    adminOnly: true,
    parameters: [
      { name: 'id', type: 'number', required: true, location: 'path', description: 'Banner ID' },
    ],
    responses: [
      { status: 200, description: 'Banner details' },
      { status: 404, description: 'Banner not found' },
    ],
  },
  {
    id: 'admin-promo-banners-update',
    method: 'PUT',
    path: '/api/admin/hero/promo-banners/{id}',
    summary: 'Update promo banner',
    description: 'Updates an existing promo banner',
    category: 'admin-content',
    requiresAuth: true,
    adminOnly: true,
    parameters: [
      { name: 'id', type: 'number', required: true, location: 'path', description: 'Banner ID' },
    ],
    responses: [
      { status: 200, description: 'Banner updated' },
      { status: 404, description: 'Banner not found' },
    ],
  },
  {
    id: 'admin-promo-banners-delete',
    method: 'DELETE',
    path: '/api/admin/hero/promo-banners/{id}',
    summary: 'Delete promo banner',
    description: 'Deletes a promo banner',
    category: 'admin-content',
    requiresAuth: true,
    adminOnly: true,
    parameters: [
      { name: 'id', type: 'number', required: true, location: 'path', description: 'Banner ID' },
    ],
    responses: [
      { status: 200, description: 'Banner deleted' },
      { status: 404, description: 'Banner not found' },
    ],
  },
  {
    id: 'admin-promo-banners-reorder',
    method: 'POST',
    path: '/api/admin/hero/promo-banners/reorder',
    summary: 'Reorder promo banners',
    description: 'Bulk reorder promo banners',
    category: 'admin-content',
    requiresAuth: true,
    adminOnly: true,
    requestBody: {
      contentType: 'application/json',
      fields: [
        { name: 'items', type: 'array', required: true, description: 'Array of {id, order} objects' },
      ],
    },
    responses: [
      { status: 200, description: 'Banners reordered' },
      { status: 400, description: 'Validation failed' },
    ],
  },
];