Added new feature for document export, including API contracts, data model, implementation plan, and tests. Updated related configurations and instructions.
This commit is contained in:
@@ -51,7 +51,7 @@ A user makes an HTTP GET request to `/sitemap.xml` and receives a valid XML site
|
||||
2. **Given** sitemap is generated, **When** examining the XML, **Then** each `<url>` entry contains a `<loc>` pointing to the adapter using RESTful format (e.g., `http://adapter-host/documents/{documentId}`)
|
||||
3. **Given** multiple documents in Google Drive, **When** sitemap is generated, **Then** all accessible documents are included in the sitemap
|
||||
4. **Given** user lacks permission to certain documents, **When** sitemap is generated, **Then** those documents are excluded from the sitemap
|
||||
5. **Given** the adapter base URL is configured, **When** sitemap is generated, **Then** all URLs use the configured base URL
|
||||
5. **Given** the adapter receives a sitemap request at any path, **When** sitemap is generated, **Then** all URLs use the base URL derived from the incoming request (protocol, host, and path up to but not including sitemap.xml)
|
||||
|
||||
---
|
||||
|
||||
@@ -69,6 +69,7 @@ A user makes an HTTP GET request to `/sitemap.xml` and receives a valid XML site
|
||||
- What happens when service account credentials are invalid or missing at startup? → Log critical error to stderr and crash with exit code 1
|
||||
- How are Drive API query filters customized? → Configure filters in config/settings.js file (not hardcoded)
|
||||
- What happens if config/settings.js is missing or malformed? → Log critical error to stderr and crash with exit code 1
|
||||
- How is the base URL determined for sitemap links? → Extracted from incoming request including protocol, host, and path prefix (e.g., request to `/api/v1/sitemap.xml` generates URLs like `https://example.com/api/v1/documents/{id}`)
|
||||
|
||||
## Requirements _(mandatory)_
|
||||
|
||||
@@ -88,7 +89,7 @@ A user makes an HTTP GET request to `/sitemap.xml` and receives a valid XML site
|
||||
- **FR-012**: System MUST log errors to stdout/stderr using plain text format: [timestamp] [level] message (includes request ID and error message for debugging)
|
||||
- **FR-013**: System MUST handle Google Drive API rate limiting gracefully by returning 429 status with Retry-After header indicating seconds until retry
|
||||
- **FR-017**: System MUST NOT retry when Google Drive API returns 503; instead immediately return 503 to client
|
||||
- **FR-014**: System MUST support configuration via environment variables (port, base URL)
|
||||
- **FR-014**: System MUST derive the base URL from the incoming HTTP request including the full path (using X-Forwarded-Proto and X-Forwarded-Host headers if present, otherwise using request protocol and host, plus the path up to but not including sitemap.xml)
|
||||
- **FR-018**: System MUST load Service Account credentials from environment variable GOOGLE_SERVICE_ACCOUNT_KEY containing inline JSON key file content
|
||||
- **FR-015**: System MUST return 413 Payload Too Large if Google Drive contains more than 50,000 documents (enforces sitemap protocol limit)
|
||||
- **FR-016**: System MUST filter out documents user lacks read access to from sitemap
|
||||
@@ -102,7 +103,7 @@ A user makes an HTTP GET request to `/sitemap.xml` and receives a valid XML site
|
||||
- **Sitemap Entry**: Represents a document listing in the sitemap XML. Attributes include: location URL (RESTful path `/documents/{documentId}`), last modified date
|
||||
- **HTTP Request Context**: Represents an incoming request. Attributes include: request ID (for tracing), Service Account JWT token, requested endpoint, client IP
|
||||
- **Service Account Credentials**: Represents JWT-based authentication state. Attributes include: client email, private key (from JSON key file), access token (generated via JWT), token expiry time, scopes granted
|
||||
- **Configuration**: Represents application settings. Attributes include: Drive API query filter (loaded from config/settings.js), server port, base URL, request queue (FIFO for /sitemap.xml requests)
|
||||
- **Configuration**: Represents application settings. Attributes include: Drive API query filter (loaded from config/settings.js), server port, request queue (FIFO for /sitemap.xml requests)
|
||||
|
||||
## Success Criteria _(mandatory)_
|
||||
|
||||
@@ -134,7 +135,7 @@ A user makes an HTTP GET request to `/sitemap.xml` and receives a valid XML site
|
||||
- Default port is 3000 unless configured otherwise
|
||||
- System runs on Node.js LTS version (v18 or later)
|
||||
- Environment supports async/await and ES modules
|
||||
- Base URL for sitemap links is configured via environment variable
|
||||
- Sitemap URLs are constructed dynamically from incoming request headers and path (X-Forwarded-Proto/Host for reverse proxy scenarios, otherwise direct request protocol/host, plus path prefix before sitemap.xml)
|
||||
- Drive API query filter is configured in config/settings.js file (allows customization without code changes)
|
||||
- System processes sitemap requests sequentially to avoid concurrent Drive API query conflicts
|
||||
- Fatal errors (invalid credentials, port binding failure, missing configuration) cause immediate termination with exit code 1
|
||||
|
||||
Reference in New Issue
Block a user