docs: add Carousel dashboard implementation plan
This commit is contained in:
@@ -1,197 +0,0 @@
|
||||
meta {
|
||||
name: Create Media Item
|
||||
type: http
|
||||
seq: 1
|
||||
}
|
||||
|
||||
post {
|
||||
url: {{base_url}}/api/media-items
|
||||
body: json
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
headers {
|
||||
Content-Type: application/json
|
||||
}
|
||||
|
||||
body:json {
|
||||
"library_id": "{{library_id}}",
|
||||
"title": "New Media Item",
|
||||
"author": "Author Name",
|
||||
"isbn": "978-0123456789",
|
||||
"description": "Description of the media item",
|
||||
"cover_image_path": "/path/to/cover.jpg",
|
||||
"series": "Series Name",
|
||||
"series_number": 1,
|
||||
"tags": ["science fiction", "ACME CORP.", "non-fiction"],
|
||||
"asin": "B08XYZ123",
|
||||
"date_published": "2023-01-15",
|
||||
"publisher": "Publisher Name",
|
||||
"contributors": ["O'Reilly Media", "acme corp"],
|
||||
"language": "en",
|
||||
"edition": "First Edition",
|
||||
"page_count": 350,
|
||||
"genre": "Science Fiction",
|
||||
"copyright_year": 2023,
|
||||
"goodreads_id": "123456",
|
||||
"openlibrary_id": "OL123456M",
|
||||
"google_books_id": "GB123456"
|
||||
}
|
||||
|
||||
tests {
|
||||
test_create_media_item_success(status, headers, body) {
|
||||
if (status !== 201) {
|
||||
throw new Error("Expected status 201, got " + status);
|
||||
}
|
||||
|
||||
let data;
|
||||
try {
|
||||
data = JSON.parse(body);
|
||||
} catch (e) {
|
||||
throw new Error("Response body is not valid JSON");
|
||||
}
|
||||
|
||||
if (!data || typeof data !== "object") {
|
||||
throw new Error("Expected media item object in response");
|
||||
}
|
||||
|
||||
// Verify required fields
|
||||
if (!data.id || !data.title || !data.library_id) {
|
||||
throw new Error("Media item missing required fields: id, title, library_id");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
test_create_media_item_no_folders(status, headers, body) {
|
||||
if (status !== 400) {
|
||||
throw new Error("Expected status 400 for library with no folders, got " + status);
|
||||
}
|
||||
|
||||
let data;
|
||||
try {
|
||||
data = JSON.parse(body);
|
||||
} catch (e) {
|
||||
throw new Error("Response body is not valid JSON");
|
||||
}
|
||||
|
||||
if (!data || typeof data !== 'object') {
|
||||
throw new Error("Expected error object in response");
|
||||
}
|
||||
|
||||
if (!data.error || typeof data.error !== 'string') {
|
||||
throw new Error("Expected error message in response");
|
||||
}
|
||||
|
||||
if (!data.error.includes("folder")) {
|
||||
throw new Error("Error message should mention folders requirement");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
vars:pre-request {
|
||||
libraryId: "cc23c3a7-f8fb-451a-a78d-2a16df1b725a"
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
|
||||
docs {
|
||||
## Create Media Item
|
||||
|
||||
Creates a new media item in a library with full metadata.
|
||||
|
||||
**Method:** POST
|
||||
|
||||
**Endpoint:** /api/media-items
|
||||
|
||||
**Authentication:** Required (Bearer token, admin only)
|
||||
|
||||
**Prerequisites**
|
||||
- Library must have at least one folder configured before media items can be added
|
||||
- Use `POST /api/libraries/{library_id}/folders` to add folders first
|
||||
- See: [Add Library Folder](../../library/Add%20Library%20Folder.bru)
|
||||
|
||||
**Request Body:**
|
||||
- `library_id` (string, required): Library UUID
|
||||
- `title` (string, required): Media item title
|
||||
- `author` (string, optional): Author name
|
||||
- `isbn` (string, optional): ISBN number
|
||||
- `description` (string, optional): Description
|
||||
- `cover_image_path` (string, optional): Path to cover image
|
||||
- `series` (string, optional): Series name
|
||||
- `series_number` (integer, optional): Number in series
|
||||
- `tags` (array of string, optional): Tags or categories (auto-normalized) (automatically normalized)
|
||||
- `asin` (string, optional): Amazon ASIN
|
||||
- `date_published` (string, optional): Publication date
|
||||
- `publisher` (string, optional): Publisher name
|
||||
- `contributors` (array of string, optional): List of contributors (auto-normalized) (automatically normalized)
|
||||
- `language` (string, optional): Language code (ISO 639-1)
|
||||
- `edition` (string, optional): Edition information
|
||||
- `page_count` (integer, optional): Total page count
|
||||
- `genre` (string, optional): Genre classification
|
||||
- `copyright_year` (integer, optional): Copyright year
|
||||
- `goodreads_id` (string, optional): Goodreads identifier
|
||||
- `openlibrary_id` (string, optional): Open Library identifier
|
||||
- `google_books_id` (string, optional): Google Books identifier
|
||||
|
||||
**Response:** Created media item object
|
||||
- All fields above plus:
|
||||
- `tags_search` (array): Normalized for search (lowercase, no punctuation)
|
||||
- `contributors_search` (array): Normalized for search (lowercase, no punctuation)
|
||||
|
||||
**Normalization Behavior:**
|
||||
|
||||
Tags are automatically normalized:
|
||||
- Trim whitespace
|
||||
- Titlecased (preserves hyphenation: "non-fiction" → "Non-Fiction")
|
||||
- Case-insensitive deduplication (keeps version with punctuation if exists)
|
||||
- Example: `["science fiction", "SCIENCE-FICTION"]` → `["Science-Fiction"]`
|
||||
|
||||
Contributors are automatically normalized:
|
||||
- Trim whitespace
|
||||
- Preserve original casing (CAPSLOCK companies, Title Case, etc.)
|
||||
- Preserve punctuation for display
|
||||
- Case-insensitive deduplication (keeps version with punctuation if exists)
|
||||
- Example: `["acme corp", "ACME CORP.", "acme corp"]` → `["ACME CORP."]`
|
||||
|
||||
**Validation Error Response**
|
||||
- **400 Bad Request** - Library has no folders:
|
||||
```json
|
||||
{
|
||||
"error": "Cannot add media items to a library with no folders. Please add at least one folder to the library first."
|
||||
}
|
||||
```
|
||||
|
||||
**Status Codes:**
|
||||
- 201: Media item created successfully
|
||||
- 400: Invalid request data OR library has no folders
|
||||
- 401: Unauthorized
|
||||
- 403: Forbidden (admin access required)
|
||||
- 404: Library not found
|
||||
- 500: Internal server error
|
||||
|
||||
**Setup Workflow Example:**
|
||||
```bash
|
||||
# 1. Create library
|
||||
POST /api/libraries
|
||||
{ "name": "My Books", "type": "ebooks" }
|
||||
|
||||
# 2. Add folder to library (REQUIRED before adding media items)
|
||||
POST /api/libraries/{library_id}/folders
|
||||
{ "folder_path": "/mnt/books/my-library" }
|
||||
|
||||
# 3. Create media items (now that library has folders)
|
||||
POST /api/media-items
|
||||
{ "library_id": "...", "title": "Book Title", ... }
|
||||
```
|
||||
|
||||
**Examples:**
|
||||
- Create media item: `POST /api/media-items`
|
||||
|
||||
**Note:** Admin access required - only users with admin role can create media items.
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
meta {
|
||||
name: Create Media Rating
|
||||
type: http
|
||||
seq: 1
|
||||
}
|
||||
|
||||
post {
|
||||
url: {{base_url}}/api/media-items/{{media_item_id}}/rating
|
||||
body: json
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
headers {
|
||||
Content-Type: application/json
|
||||
}
|
||||
|
||||
body:json {
|
||||
{
|
||||
"rating": 8
|
||||
}
|
||||
}
|
||||
|
||||
vars:pre-request {
|
||||
mediaItemId: "9932c704-i29b-81d4-e716-446655440004"
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
|
||||
docs {
|
||||
## Create Media Rating
|
||||
|
||||
Creates or updates the authenticated user's rating for a specific media item.
|
||||
|
||||
**Method:** POST
|
||||
|
||||
**Endpoint:** /api/media-items/{id}/rating
|
||||
|
||||
**Authentication:** Required (Bearer token)
|
||||
|
||||
**Path Parameters:**
|
||||
- `id` (string, required): Media item UUID
|
||||
|
||||
**Request Body:**
|
||||
- `rating` (number, required): Rating value (1-10, where odd numbers = half-stars)
|
||||
- 1,3,5,7,9 = 0.5,1.5,2.5,3.5,4.5 stars (half-star precision)
|
||||
- 2,4,6,8,10 = 1,2,3,4,5 stars (full stars)
|
||||
|
||||
**Example Request:**
|
||||
- `"rating": 7` = 3.5 stars (frontend display)
|
||||
- `"rating": 8` = 4.0 stars (frontend display)
|
||||
|
||||
**Response:** Rating object
|
||||
- `id` (string): Rating UUID
|
||||
- `media_item_id` (string): Media item UUID
|
||||
- `user_id` (string): User UUID
|
||||
- `rating` (number): Rating value (1-10)
|
||||
- `created_at` (string): Creation timestamp
|
||||
- `updated_at` (string): Last update timestamp
|
||||
|
||||
**Status Codes:**
|
||||
- 201: Rating created successfully
|
||||
- 200: Rating updated successfully (if rating already existed)
|
||||
- 400: Invalid rating value (must be 1-10)
|
||||
- 401: Unauthorized
|
||||
- 403: Forbidden (rating access denied)
|
||||
- 404: Media item not found
|
||||
- 500: Internal server error
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
meta {
|
||||
name: Delete Media Item
|
||||
type: http
|
||||
seq: 3
|
||||
}
|
||||
|
||||
delete {
|
||||
url: {{base_url}}/api/media-items/{{media_item_id}}
|
||||
body: none
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
headers {
|
||||
Content-Type: application/json
|
||||
}
|
||||
|
||||
tests {
|
||||
test_delete_media_item_success(status, headers, body) {
|
||||
if (status !== 204) {
|
||||
throw new Error("Expected status 204, got " + status);
|
||||
}
|
||||
|
||||
// Delete should return no content
|
||||
if (body && body.length > 0) {
|
||||
throw new Error("Expected empty response body for delete");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
vars:pre-request {
|
||||
mediaItemId: "550e8400-e29b-41d4-a716-446655440000"
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
|
||||
docs {
|
||||
## Delete Media Item
|
||||
|
||||
Deletes a media item from the library.
|
||||
|
||||
**Method:** DELETE
|
||||
|
||||
**Endpoint:** /api/media-items/{id}
|
||||
|
||||
**Authentication:** Required (Bearer token, admin only)
|
||||
|
||||
**Path Parameters:**
|
||||
- `id` (string): Media item UUID
|
||||
|
||||
**Response:** Empty (204 No Content)
|
||||
|
||||
**Status Codes:**
|
||||
- 204: Media item deleted successfully
|
||||
- 400: Invalid media item ID
|
||||
- 401: Unauthorized
|
||||
- 403: Forbidden (admin access required)
|
||||
- 404: Media item not found
|
||||
- 500: Internal server error
|
||||
|
||||
**Examples:**
|
||||
- Delete media item: `DELETE /api/media-items/550e8400-e29b-41d4-a716-446655440000`
|
||||
|
||||
**Warning:** This permanently removes the media item and all associated data (ratings, notes, highlights).
|
||||
|
||||
**Note:** Admin access required - only users with admin role can delete media items.
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
meta {
|
||||
name: Delete Media Rating
|
||||
type: http
|
||||
seq: 5
|
||||
}
|
||||
|
||||
delete {
|
||||
url: {{base_url}}/api/media-items/{{media_item_id}}/rating
|
||||
body: none
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
headers {
|
||||
Content-Type: application/json
|
||||
}
|
||||
|
||||
tests {
|
||||
test_delete_media_rating_success(status, headers, body) {
|
||||
if (status !== 204) {
|
||||
throw new Error("Expected status 204, got " + status);
|
||||
}
|
||||
|
||||
// Delete should return no content
|
||||
if (body && body.length > 0) {
|
||||
throw new Error("Expected empty response body for delete");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
vars:pre-request {
|
||||
mediaItemId: "550e8400-e29b-41d4-a716-446655440000"
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
|
||||
docs {
|
||||
## Delete Media Rating
|
||||
|
||||
Deletes a user's rating for a specific media item.
|
||||
|
||||
**Method:** DELETE
|
||||
|
||||
**Endpoint:** /api/media-items/{id}/rating
|
||||
|
||||
**Authentication:** Required (Bearer token)
|
||||
|
||||
**Path Parameters:**
|
||||
- `id` (string): Media item UUID
|
||||
|
||||
**Response:** Empty (204 No Content)
|
||||
|
||||
**Status Codes:**
|
||||
- 204: Rating deleted successfully
|
||||
- 401: Unauthorized
|
||||
- 404: Media item not found
|
||||
- 500: Internal server error
|
||||
|
||||
**Examples:**
|
||||
- Delete media rating: `DELETE /api/media-items/550e8400-e29b-41d4-a716-446655440000/rating`
|
||||
|
||||
**Note:** Deletes only the authenticated user's rating, not other users' ratings.
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
meta {
|
||||
name: Download Media Item
|
||||
type: http
|
||||
seq: 1
|
||||
}
|
||||
|
||||
get {
|
||||
url: {{baseURL}}/api/media-items/{{bookUUID}}/download
|
||||
body: none
|
||||
auth: none
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
|
||||
docs {
|
||||
## Download Media Item
|
||||
|
||||
Download a media item file (EPUB, PDF, etc.) from Bookhoard server.
|
||||
|
||||
**Method:** GET
|
||||
|
||||
**Endpoint:** /api/media-items/{bookUUID}/download
|
||||
|
||||
**Authentication:** None (for Kobo device downloads)
|
||||
|
||||
**Path Parameters:**
|
||||
- `bookUUID` (string): Media item UUID
|
||||
|
||||
**Response:** Binary file data (EPUB, PDF, etc.)
|
||||
|
||||
**Response Headers:**
|
||||
- `Content-Type`: application/epub+zip, application/pdf, or appropriate MIME type
|
||||
|
||||
**Status Codes:**
|
||||
- 200: Success - File returned
|
||||
- 404: Media item not found
|
||||
|
||||
**Note:** This endpoint is designed for Kobo devices to download media items directly from Bookhoard. The endpoint returns the file with appropriate Content-Type headers.
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
meta {
|
||||
name: Filter Media Items
|
||||
type: http
|
||||
seq: 1
|
||||
}
|
||||
|
||||
get {
|
||||
url: {{base_url}}/api/media-items/filtered?library_id={{library_id}}&genre_filter=Fiction&language_filter=en&year_min=2000&year_max=2024&limit=10&offset=0
|
||||
body: none
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
headers {
|
||||
Content-Type: application/json
|
||||
}
|
||||
|
||||
vars:pre-request {
|
||||
genre: "Fiction"
|
||||
language: "en"
|
||||
yearMin: 2000
|
||||
yearMax: 2024
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
|
||||
docs {
|
||||
## Filter Media Items
|
||||
|
||||
**Method:** GET
|
||||
|
||||
**Endpoint:** /api/media-items/filtered
|
||||
|
||||
**Authentication:** Required (Bearer token)
|
||||
|
||||
**Query Parameters:**
|
||||
- `library_id` (string, required): UUID of the library
|
||||
- `author_filter` (string, optional): Filter by author (partial match)
|
||||
- `series_filter` (string, optional): Filter by series (partial match)
|
||||
- `genre_filter` (string, optional): Filter by genre (exact match)
|
||||
- `language_filter` (string, optional): Filter by language (exact match, e.g., 'en', 'es', 'fr')
|
||||
- `year_min` (integer, optional): Minimum copyright year
|
||||
- `year_max` (integer, optional): Maximum copyright year
|
||||
- `has_cover` (boolean, optional): Filter for items with cover images only
|
||||
- `sort` (string, optional): Sort field and direction (same options as ListMediaItems)
|
||||
- `limit` (integer, optional): Number of items to return (default: 50, max: 1000)
|
||||
- `offset` (integer, optional): Number of items to skip (default: 0)
|
||||
|
||||
**Response:** Object containing array of filtered media items
|
||||
|
||||
**Status Codes:**
|
||||
- 200: Success
|
||||
- 400: Bad request (invalid parameters)
|
||||
- 401: Unauthorized
|
||||
- 500: Internal server error
|
||||
|
||||
**Examples:**
|
||||
- Filter by genre: `/api/media-items/filtered?library_id=xxx&genre_filter=Fiction`
|
||||
- Filter by language: `/api/media-items/filtered?library_id=xxx&language_filter=es`
|
||||
- Filter by year range: `/api/media-items/filtered?library_id=xxx&year_min=2000&year_max=2024`
|
||||
- Filter by cover: `/api/media-items/filtered?library_id=xxx&has_cover=true`
|
||||
- Combine filters: `/api/media-items/filtered?library_id=xxx&genre_filter=Sci-Fi&year_min=2010&language_filter=en`
|
||||
|
||||
**Filter Behavior:**
|
||||
- Multiple filters can be combined (AND logic)
|
||||
- Author and series filters use partial matching (ILIKE)
|
||||
- Genre and language filters use exact matching
|
||||
- Year range filters are inclusive
|
||||
- Filters are applied before sorting and pagination
|
||||
- User library visibility is respected
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
meta {
|
||||
name: Get Media Item
|
||||
type: http
|
||||
seq: 1
|
||||
}
|
||||
|
||||
get {
|
||||
url: {{base_url}}/api/media-items/{{media_item_id}}
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
headers {
|
||||
Content-Type: application/json
|
||||
}
|
||||
|
||||
tests {
|
||||
test_get_media_item_success(status, headers, body) {
|
||||
if (status !== 200) {
|
||||
throw new Error("Expected status 200, got " + status);
|
||||
}
|
||||
|
||||
const contentType = headers["content-type"];
|
||||
if (!contentType || !contentType.includes("application/json")) {
|
||||
throw new Error("Expected content-type to contain application/json, got " + contentType);
|
||||
}
|
||||
|
||||
// Verify response body is valid JSON and has expected structure
|
||||
let data;
|
||||
try {
|
||||
data = JSON.parse(body);
|
||||
} catch (e) {
|
||||
throw new Error("Response body is not valid JSON");
|
||||
}
|
||||
|
||||
if (!data || typeof data !== "object") {
|
||||
throw new Error("Expected response body to be an object");
|
||||
}
|
||||
|
||||
// Check for required fields in media item
|
||||
if (!data.id) {
|
||||
throw new Error("Media item missing required field: id");
|
||||
}
|
||||
|
||||
if (!data.title) {
|
||||
throw new Error("Media item missing required field: title");
|
||||
}
|
||||
|
||||
if (!data.library_id) {
|
||||
throw new Error("Media item missing required field: library_id");
|
||||
}
|
||||
|
||||
if (!data.media_type) {
|
||||
throw new Error("Media item missing required field: media_type");
|
||||
}
|
||||
|
||||
// Validate data types
|
||||
if (typeof data.id !== "string") {
|
||||
throw new Error("Media item id must be a string");
|
||||
}
|
||||
|
||||
if (typeof data.title !== "string") {
|
||||
throw new Error("Media item title must be a string");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
vars:pre-request {
|
||||
mediaItemId: "9932c704-i29b-81d4-e716-446655440004"
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
|
||||
docs {
|
||||
## Get Media Item
|
||||
|
||||
Retrieves detailed information about a specific media item.
|
||||
|
||||
**Method:** GET
|
||||
|
||||
**Endpoint:** /api/media-items/{id}
|
||||
|
||||
**Authentication:** Required (Bearer token)
|
||||
|
||||
**Path Parameters:**
|
||||
- `id` (string, required): Media item UUID
|
||||
|
||||
**Response:** Media item object
|
||||
- `id` (string): Media item UUID
|
||||
- `title` (string): Media item title
|
||||
- `description` (string, optional): Media description
|
||||
- `library_id` (string): Library UUID
|
||||
- `media_type` (string): Type of media (e.g., "ebook", "audiobook")
|
||||
- `file_path` (string): Path to media file
|
||||
- `file_size` (number, optional): File size in bytes
|
||||
- `metadata` (object, optional): Additional media metadata
|
||||
- `author` (string, optional): Author name (for books)
|
||||
- `isbn` (string, optional): ISBN number
|
||||
- `duration` (number, optional): Duration in seconds (for audiobooks)
|
||||
- `created_at` (string): Creation timestamp
|
||||
- `updated_at` (string): Last update timestamp
|
||||
|
||||
**Status Codes:**
|
||||
- 200: Success
|
||||
- 401: Unauthorized
|
||||
- 403: Forbidden (access denied)
|
||||
- 404: Media item not found
|
||||
- 500: Internal server error
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
meta {
|
||||
name: Get Media Rating
|
||||
type: http
|
||||
seq: 4
|
||||
}
|
||||
|
||||
get {
|
||||
url: {{base_url}}/api/media-items/{{media_item_id}}/rating
|
||||
body: none
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
headers {
|
||||
Content-Type: application/json
|
||||
}
|
||||
|
||||
tests {
|
||||
test_get_media_rating_success(status, headers, body) {
|
||||
if (status !== 200) {
|
||||
throw new Error("Expected status 200, got " + status);
|
||||
}
|
||||
|
||||
let data;
|
||||
try {
|
||||
data = JSON.parse(body);
|
||||
} catch (e) {
|
||||
throw new Error("Response body is not valid JSON");
|
||||
}
|
||||
|
||||
if (!data || typeof data !== "object") {
|
||||
throw new Error("Expected rating object in response");
|
||||
}
|
||||
|
||||
// Verify expected fields
|
||||
if (!data.media_item_id || !data.rating === undefined) {
|
||||
throw new Error("Rating response missing required fields: media_item_id, rating");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
vars:pre-request {
|
||||
mediaItemId: "550e8400-e29b-41d4-a716-446655440000"
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
|
||||
docs {
|
||||
## Get Media Rating
|
||||
|
||||
Retrieves a user's rating for a specific media item.
|
||||
|
||||
**Method:** GET
|
||||
|
||||
**Endpoint:** /api/media-items/{id}/rating
|
||||
|
||||
**Authentication:** Required (Bearer token)
|
||||
|
||||
**Path Parameters:**
|
||||
- `id` (string): Media item UUID
|
||||
|
||||
**Response:** Rating object
|
||||
- `id` (string): Rating UUID
|
||||
- `media_item_id` (string): Media item UUID
|
||||
- `user_id` (string): User UUID
|
||||
- `rating` (integer): Rating value (1-10 scale)
|
||||
- `created_at` (string): Creation timestamp
|
||||
- `updated_at` (string): Last update timestamp
|
||||
|
||||
**Status Codes:**
|
||||
- 200: Success
|
||||
- 401: Unauthorized
|
||||
- 404: Media item not found
|
||||
- 500: Internal server error
|
||||
|
||||
**Examples:**
|
||||
- Get media rating: `GET /api/media-items/550e8400-e29b-41d4-a716-446655440000/rating`
|
||||
|
||||
**Note:** Returns the authenticated user's rating for the specified media item.
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
meta {
|
||||
name: List Media Items with Sorting
|
||||
type: http
|
||||
seq: 1
|
||||
}
|
||||
|
||||
get {
|
||||
url: {{base_url}}/api/media-items?library_id={{library_id}}&sort=title+ASC&limit=10&offset=0
|
||||
body: none
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
headers {
|
||||
Content-Type: application/json
|
||||
}
|
||||
|
||||
vars:pre-request {
|
||||
sortBy: "title ASC"
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
|
||||
docs {
|
||||
## List Media Items with Sorting
|
||||
|
||||
**Method:** GET
|
||||
|
||||
**Endpoint:** /api/media-items
|
||||
|
||||
**Authentication:** Required (Bearer token)
|
||||
|
||||
**Query Parameters:**
|
||||
- `library_id` (string, required): UUID of the library
|
||||
- `sort` (string, optional): Sort field and direction
|
||||
- Available options:
|
||||
- `created_at ASC` - Oldest added first
|
||||
- `created_at DESC` - Newest added first (default)
|
||||
- `title ASC` - Title A-Z
|
||||
- `title DESC` - Title Z-A
|
||||
- `author ASC` - Author A-Z
|
||||
- `author DESC` - Author Z-A
|
||||
- `series ASC` - Series order
|
||||
- `series DESC` - Series reverse order
|
||||
- `date_published ASC` - Oldest published first
|
||||
- `date_published DESC` - Newest published first
|
||||
- `copyright_year ASC` - Oldest copyright first
|
||||
- `copyright_year DESC` - Newest copyright first
|
||||
- `page_count ASC` - Shortest first
|
||||
- `page_count DESC` - Longest first
|
||||
- `genre ASC` - Genre A-Z
|
||||
- `genre DESC` - Genre Z-A
|
||||
- `limit` (integer, optional): Number of items to return (default: 50, max: 1000)
|
||||
- `offset` (integer, optional): Number of items to skip (default: 0)
|
||||
|
||||
**Response:** Object containing array of media items
|
||||
|
||||
**Status Codes:**
|
||||
- 200: Success
|
||||
- 400: Bad request (invalid parameters)
|
||||
- 401: Unauthorized
|
||||
- 500: Internal server error
|
||||
|
||||
**Examples:**
|
||||
- Sort by title: `/api/media-items?library_id=xxx&sort=title+ASC`
|
||||
- Sort by author descending: `/api/media-items?library_id=xxx&sort=author+DESC`
|
||||
- Sort by page count: `/api/media-items?library_id=xxx&sort=page_count+ASC`
|
||||
|
||||
**Sorting Behavior:**
|
||||
- All sorts are secondary-sorted by series_number then title for consistency
|
||||
- NULL values are sorted last for ascending, first for descending
|
||||
- Sorting is case-insensitive for text fields
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
meta {
|
||||
name: List Media Items
|
||||
type: http
|
||||
seq: 1
|
||||
}
|
||||
|
||||
get {
|
||||
url: {{base_url}}/api/media-items?library_id={{library_id}}&limit=20&offset=0
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
headers {
|
||||
Content-Type: application/json
|
||||
}
|
||||
|
||||
tests {
|
||||
test_list_media_items_success(status, headers, body) {
|
||||
if (status !== 200) {
|
||||
throw new Error("Expected status 200, got " + status);
|
||||
}
|
||||
|
||||
const contentType = headers["content-type"];
|
||||
if (!contentType || !contentType.includes("application/json")) {
|
||||
throw new Error("Expected content-type to contain application/json, got " + contentType);
|
||||
}
|
||||
|
||||
// Verify response body is valid JSON and has expected structure
|
||||
let data;
|
||||
try {
|
||||
data = JSON.parse(body);
|
||||
} catch (e) {
|
||||
throw new Error("Response body is not valid JSON");
|
||||
}
|
||||
|
||||
if (!Array.isArray(data)) {
|
||||
throw new Error("Expected response body to be an array");
|
||||
}
|
||||
|
||||
// Validate each media item in the array
|
||||
data.forEach((item, index) => {
|
||||
if (!item || typeof item !== "object") {
|
||||
throw new Error("Media item at index " + index + " is not an object");
|
||||
}
|
||||
|
||||
if (!item.id) {
|
||||
throw new Error("Media item at index " + index + " missing required field: id");
|
||||
}
|
||||
|
||||
if (!item.title) {
|
||||
throw new Error("Media item at index " + index + " missing required field: title");
|
||||
}
|
||||
|
||||
if (!item.library_id) {
|
||||
throw new Error("Media item at index " + index + " missing required field: library_id");
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
vars:pre-request {
|
||||
libraryId: "8821b703-h29b-71d4-d716-446655440003"
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
|
||||
docs {
|
||||
## List Media Items
|
||||
|
||||
Retrieves a paginated list of media items from a specific library.
|
||||
|
||||
**Method:** GET
|
||||
|
||||
**Endpoint:** /api/media-items
|
||||
|
||||
**Authentication:** Required (Bearer token)
|
||||
|
||||
**Query Parameters:**
|
||||
- `library_id` (string, required): Library UUID to filter items
|
||||
- `limit` (number, optional): Number of results per page (default: 20, max: 100)
|
||||
- `offset` (number, optional): Pagination offset (default: 0)
|
||||
|
||||
**Response:** Array of media item objects
|
||||
- `id` (string): Media item UUID
|
||||
- `title` (string): Media item title
|
||||
- `library_id` (string): Library UUID
|
||||
- `media_type` (string): Type of media (e.g., "ebook", "audiobook")
|
||||
- `file_path` (string): Path to media file
|
||||
- `created_at` (string): Creation timestamp
|
||||
- `updated_at` (string): Last update timestamp
|
||||
|
||||
**Status Codes:**
|
||||
- 200: Success
|
||||
- 400: Invalid query parameters
|
||||
- 401: Unauthorized
|
||||
- 403: Forbidden (library access denied)
|
||||
- 404: Library not found
|
||||
- 500: Internal server error
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
meta {
|
||||
name: Search Media Items
|
||||
type: http
|
||||
seq: 1
|
||||
}
|
||||
|
||||
get {
|
||||
url: {{base_url}}/api/media-items/search?q=harry
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
headers {
|
||||
Content-Type: application/json
|
||||
}
|
||||
|
||||
tests {
|
||||
test_search_media_items_success(status, headers, body) {
|
||||
if (status !== 200 && status !== 404) {
|
||||
throw new Error("Expected status 200 or 404, got " + status);
|
||||
}
|
||||
|
||||
const contentType = headers["content-type"];
|
||||
if (!contentType || !contentType.includes("application/json")) {
|
||||
throw new Error("Expected content-type to contain application/json, got " + contentType);
|
||||
}
|
||||
|
||||
let data;
|
||||
try {
|
||||
data = JSON.parse(body);
|
||||
} catch (e) {
|
||||
throw new Error("Response body is not valid JSON");
|
||||
}
|
||||
|
||||
if (status === 404) {
|
||||
if (!data.error || data.error !== "no results found") {
|
||||
throw new Error("Expected error message 'no results found' for 404 status");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Array.isArray(data)) {
|
||||
throw new Error("Expected response body to be an array");
|
||||
}
|
||||
|
||||
data.forEach((item, index) => {
|
||||
if (!item || typeof item !== "object") {
|
||||
throw new Error("Media item at index " + index + " is not an object");
|
||||
}
|
||||
|
||||
if (!item.id) {
|
||||
throw new Error("Media item at index " + index + " missing required field: id");
|
||||
}
|
||||
|
||||
if (!item.title) {
|
||||
throw new Error("Media item at index " + index + " missing required field: title");
|
||||
}
|
||||
|
||||
if (!item.library_id) {
|
||||
throw new Error("Media item at index " + index + " missing required field: library_id");
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
vars:pre-request {
|
||||
searchQuery: "harry"
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
|
||||
docs {
|
||||
## Search Media Items
|
||||
|
||||
Performs a search across all visible media items using partial matching with fuzzy fallback.
|
||||
|
||||
**Method:** GET
|
||||
|
||||
**Endpoint:** /api/media-items/search
|
||||
|
||||
**Authentication:** Required (Bearer token)
|
||||
|
||||
**Query Parameters:**
|
||||
- `q` (string, required): Search query (minimum 2 characters)
|
||||
|
||||
**Search Behavior:**
|
||||
1. First performs case-insensitive partial matching across:
|
||||
- Title
|
||||
- Author
|
||||
- Series
|
||||
- Tags
|
||||
- Contributors
|
||||
2. If no results found, falls back to fuzzy search using word_similarity with 0.3 threshold
|
||||
|
||||
**Response:** Array of media item objects (same structure as List Media Items)
|
||||
|
||||
**Status Codes:**
|
||||
- 200: Success (results found)
|
||||
- 404: No results found
|
||||
- 400: Missing or invalid query parameter
|
||||
- 401: Unauthorized
|
||||
- 500: Internal server error
|
||||
|
||||
**Examples:**
|
||||
- Search by title: `q=harry potter`
|
||||
- Search by author: `q=king`
|
||||
- Fuzzy search: `q=hary poter` (will find "harry potter")
|
||||
|
||||
**Ranking:**
|
||||
Results are ranked by relevance:
|
||||
- Title matches: Highest priority
|
||||
- Author matches: High priority
|
||||
- Series matches: Medium priority
|
||||
- Tag matches: Lower priority
|
||||
- Fuzzy matches: Sorted by similarity score
|
||||
}
|
||||
@@ -1,107 +0,0 @@
|
||||
meta {
|
||||
name: Update Media Item
|
||||
type: http
|
||||
seq: 2
|
||||
}
|
||||
|
||||
put {
|
||||
url: {{base_url}}/api/media-items/{{media_item_id}}
|
||||
body: json
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
headers {
|
||||
Content-Type: application/json
|
||||
}
|
||||
|
||||
body:json {
|
||||
"title": "Updated Media Item Title",
|
||||
"author": "Updated Author Name",
|
||||
"isbn": "978-9876543210",
|
||||
"description": "Updated description",
|
||||
"cover_image_path": "/updated/path/to/cover.jpg",
|
||||
"series": "Updated Series Name",
|
||||
"series_number": 2,
|
||||
"tags": ["updated", "fiction", "adventure"],
|
||||
"asin": "B09XYZ789",
|
||||
"date_published": "2023-02-20",
|
||||
"publisher": "Updated Publisher",
|
||||
"contributors": ["Updated Contributor"],
|
||||
"language": "en",
|
||||
"edition": "Updated Edition",
|
||||
"page_count": 400,
|
||||
"genre": "Updated Genre",
|
||||
"copyright_year": 2023,
|
||||
"goodreads_id": "7890123",
|
||||
"openlibrary_id": "OL789012M",
|
||||
"google_books_id": "GB789012"
|
||||
}
|
||||
|
||||
tests {
|
||||
test_update_media_item_success(status, headers, body) {
|
||||
if (status !== 200) {
|
||||
throw new Error("Expected status 200, got " + status);
|
||||
}
|
||||
|
||||
let data;
|
||||
try {
|
||||
data = JSON.parse(body);
|
||||
} catch (e) {
|
||||
throw new Error("Response body is not valid JSON");
|
||||
}
|
||||
|
||||
if (!data || typeof data !== "object") {
|
||||
throw new Error("Expected updated media item object in response");
|
||||
}
|
||||
|
||||
if (!data.id || !data.updated_at) {
|
||||
throw new Error("Media item response missing update confirmation");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
vars:pre-request {
|
||||
mediaItemId: "550e8400-e29b-41d4-a716-446655440000"
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
|
||||
docs {
|
||||
## Update Media Item
|
||||
|
||||
Updates an existing media item's metadata.
|
||||
|
||||
**Method:** PUT
|
||||
|
||||
**Endpoint:** /api/media-items/{id}
|
||||
|
||||
**Authentication:** Required (Bearer token, admin only)
|
||||
|
||||
**Path Parameters:**
|
||||
- `id` (string): Media item UUID
|
||||
|
||||
**Request Body:** All media item fields (same as Create)
|
||||
- Tags and contributors are auto-normalized (see Create Media Item docs)
|
||||
|
||||
**Response:** Updated media item object
|
||||
- Includes normalized `tags` and `contributors` fields
|
||||
- Includes updated `tags_search` and `contributors_search` fields
|
||||
|
||||
**Status Codes:**
|
||||
- 200: Media item updated successfully
|
||||
- 400: Invalid request data
|
||||
- 401: Unauthorized
|
||||
- 403: Forbidden (admin access required)
|
||||
- 404: Media item not found
|
||||
- 500: Internal server error
|
||||
|
||||
**Examples:**
|
||||
- Update media item: `PUT /api/media-items/550e8400-e29b-41d4-a716-446655440000`
|
||||
|
||||
**Note:** Admin access required - only users with admin role can update media items.
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
meta {
|
||||
name: Update Media Rating
|
||||
type: http
|
||||
seq: 1
|
||||
}
|
||||
|
||||
put {
|
||||
url: {{base_url}}/api/media-items/{{media_item_id}}/rating
|
||||
body: json
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
body:json {
|
||||
{
|
||||
"rating": 4,
|
||||
"review": "Great book! Very enjoyable read."
|
||||
}
|
||||
}
|
||||
|
||||
headers {
|
||||
Content-Type: application/json
|
||||
}
|
||||
|
||||
tests {
|
||||
test_update_media_rating_success(status, headers, body) {
|
||||
if (status !== 200) {
|
||||
throw new Error("Expected status 200, got " + status);
|
||||
}
|
||||
|
||||
const contentType = headers["content-type"];
|
||||
if (!contentType || !contentType.includes("application/json")) {
|
||||
throw new Error("Expected content-type to contain application/json");
|
||||
}
|
||||
|
||||
let data;
|
||||
try {
|
||||
data = JSON.parse(body);
|
||||
} catch (e) {
|
||||
throw new Error("Response body is not valid JSON");
|
||||
}
|
||||
|
||||
if (!data.id) {
|
||||
throw new Error("Response missing id field");
|
||||
}
|
||||
|
||||
if (typeof data.rating !== "number") {
|
||||
throw new Error("Rating should be a number");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
vars:pre-request {
|
||||
mediaItemId: "8821b703-1234-5678-9123-446655440001"
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
|
||||
docs {
|
||||
## Update Media Rating
|
||||
|
||||
Updates an existing rating for a media item.
|
||||
|
||||
**Method:** PUT
|
||||
|
||||
**Endpoint:** /api/media-items/:id/rating
|
||||
|
||||
**Authentication:** Required (Bearer token)
|
||||
|
||||
**Path Parameters:**
|
||||
- `id` (string, required): Media item UUID
|
||||
|
||||
**Request Body:**
|
||||
- `rating` (number, required): Rating value (typically 1-5)
|
||||
- `review` (string, optional): Review text
|
||||
|
||||
**Response:** Updated rating object
|
||||
- `id` (string): Rating ID
|
||||
- `media_item_id` (string): Media item UUID
|
||||
- `rating` (number): Rating value
|
||||
- `review` (string): Review text
|
||||
- `created_at` (string): Creation timestamp
|
||||
- `updated_at` (string): Last update timestamp
|
||||
|
||||
**Status Codes:**
|
||||
- 200: Success
|
||||
- 400: Invalid request body
|
||||
- 401: Unauthorized
|
||||
- 404: Media item or rating not found
|
||||
- 500: Internal server error
|
||||
}
|
||||
Reference in New Issue
Block a user