Core SDK for Feedlog Toolkit
npm install @feedlog-ai/coreCore SDK package providing shared utilities, types, and functionality used across all Feedlog Toolkit packages.
- TypeScript-based SDK: Fully typed for better developer experience
- Shared types and interfaces: Consistent type definitions across packages
- Utility functions: HTML sanitization and other utilities
- Core Feedlog SDK class: Main API client for interacting with Feedlog services
- Error handling: Comprehensive error types and handling
- Pagination support: Built-in support for paginated API responses
``bash`
npm install @feedlog-ai/core
`typescript
import { FeedlogSDK } from '@feedlog-ai/core';
// Initialize with required configuration
const sdk = new FeedlogSDK({
apiKey: 'your-api-key', // Required: API key for authentication
});
// Or initialize with custom configuration
const customSdk = new FeedlogSDK({
apiKey: 'your-api-key', // Required: API key for authentication
endpoint: 'https://api.feedlog.app', // Custom API endpoint (optional)
timeout: 30000, // Request timeout in milliseconds (optional)
credentials: 'include', // Fetch credentials mode (optional)
});
`
`typescript
// Fetch issues with default parameters
const response = await sdk.fetchIssues();
// Fetch issues with filters
const filteredResponse = await sdk.fetchIssues({
type: 'bug', // 'bug' or 'enhancement'
limit: 20, // Maximum number of issues (1-100)
cursor: 'next-page-cursor', // For pagination
});
// Fetch issues from specific repositories
const repoResponse = await sdk.fetchIssues({
repositoryIds: ['repo-id-1', 'repo-id-2'], // Array of repository IDs
type: 'enhancement',
limit: 10,
});
`
`typescript
// Toggle upvote on an issue
const upvoteResult = await sdk.toggleUpvote('issue-id');
console.log(upvoteResult.upvoted); // true if upvoted, false if unvoted
console.log(upvoteResult.upvoteCount); // Updated upvote count
console.log(upvoteResult.anonymousUserId); // User's anonymous ID
`
The main SDK class for interacting with the Feedlog API.
#### Constructor
`typescript`
new FeedlogSDK(config: FeedlogSDKConfig)
#### Methods
- fetchIssues(params?: FetchIssuesParams): PromisetoggleUpvote(issueId: string): Promise
- getEndpoint(): string
- - Get current API endpointgetTimeout(): number
- - Get current timeout setting
#### Core Types
- FeedlogIssue - GitHub issue data structureRepository
- - Repository informationFetchIssuesParams
- - Parameters for fetching issuesFetchIssuesResponse
- - Response from fetching issuesUpvoteResponse
- - Response from upvoting an issueFeedlogSDKConfig
- - SDK configuration options
#### Error Types
- FeedlogError - Base error classFeedlogNetworkError
- - Network-related errorsFeedlogTimeoutError
- - Timeout errorsFeedlogValidationError
- - Validation errors
- sanitizeHtml(html: string): string - Sanitize HTML content to prevent XSS
The SDK provides specific error types for different failure scenarios:
`typescript
import {
FeedlogError,
FeedlogNetworkError,
FeedlogTimeoutError,
FeedlogValidationError,
} from '@feedlog-ai/core';
try {
const issues = await sdk.fetchIssues();
} catch (error) {
if (error instanceof FeedlogNetworkError) {
console.error('Network error:', error.statusCode);
} else if (error instanceof FeedlogTimeoutError) {
console.error('Request timed out');
} else if (error instanceof FeedlogValidationError) {
console.error('Validation error:', error.message);
} else if (error instanceof FeedlogError) {
console.error('Feedlog error:', error.message);
}
}
``
- Node.js >= 22.0.0
- TypeScript >= 5.3.3 (for type definitions)
MIT