@feedlog-ai/core 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +148 -0
  2. package/package.json +4 -1
package/README.md ADDED
@@ -0,0 +1,148 @@
1
+ # @feedlog-ai/core
2
+
3
+ Core SDK package providing shared utilities, types, and functionality used across all Feedlog Toolkit packages.
4
+
5
+ ## Features
6
+
7
+ - **TypeScript-based SDK**: Fully typed for better developer experience
8
+ - **Shared types and interfaces**: Consistent type definitions across packages
9
+ - **Utility functions**: HTML sanitization and other utilities
10
+ - **Core Feedlog SDK class**: Main API client for interacting with Feedlog services
11
+ - **Error handling**: Comprehensive error types and handling
12
+ - **Pagination support**: Built-in support for paginated API responses
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install @feedlog-ai/core
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ ### Initializing the SDK
23
+
24
+ ```typescript
25
+ import { FeedlogSDK } from '@feedlog-ai/core';
26
+
27
+ // Initialize with required configuration
28
+ const sdk = new FeedlogSDK({
29
+ apiKey: 'your-api-key', // Required: API key for authentication
30
+ });
31
+
32
+ // Or initialize with custom configuration
33
+ const customSdk = new FeedlogSDK({
34
+ apiKey: 'your-api-key', // Required: API key for authentication
35
+ endpoint: 'https://api.feedlog.app', // Custom API endpoint (optional)
36
+ timeout: 30000, // Request timeout in milliseconds (optional)
37
+ credentials: 'include', // Fetch credentials mode (optional)
38
+ });
39
+ ```
40
+
41
+ ### Fetching Issues
42
+
43
+ ```typescript
44
+ // Fetch issues with default parameters
45
+ const response = await sdk.fetchIssues();
46
+
47
+ // Fetch issues with filters
48
+ const filteredResponse = await sdk.fetchIssues({
49
+ type: 'bug', // 'bug' or 'enhancement'
50
+ limit: 20, // Maximum number of issues (1-100)
51
+ cursor: 'next-page-cursor', // For pagination
52
+ });
53
+
54
+ // Fetch issues from specific repositories
55
+ const repoResponse = await sdk.fetchIssues({
56
+ repositoryIds: ['repo-id-1', 'repo-id-2'], // Array of repository IDs
57
+ type: 'enhancement',
58
+ limit: 10,
59
+ });
60
+ ```
61
+
62
+ ### Upvoting Issues
63
+
64
+ ```typescript
65
+ // Toggle upvote on an issue
66
+ const upvoteResult = await sdk.toggleUpvote('issue-id');
67
+
68
+ console.log(upvoteResult.upvoted); // true if upvoted, false if unvoted
69
+ console.log(upvoteResult.upvoteCount); // Updated upvote count
70
+ console.log(upvoteResult.anonymousUserId); // User's anonymous ID
71
+ ```
72
+
73
+ ## API Reference
74
+
75
+ ### FeedlogSDK
76
+
77
+ The main SDK class for interacting with the Feedlog API.
78
+
79
+ #### Constructor
80
+
81
+ ```typescript
82
+ new FeedlogSDK(config: FeedlogSDKConfig)
83
+ ```
84
+
85
+ #### Methods
86
+
87
+ - `fetchIssues(params?: FetchIssuesParams): Promise<FetchIssuesResponse>`
88
+ - `toggleUpvote(issueId: string): Promise<UpvoteResponse>`
89
+ - `getEndpoint(): string` - Get current API endpoint
90
+ - `getTimeout(): number` - Get current timeout setting
91
+
92
+ ### Types
93
+
94
+ #### Core Types
95
+
96
+ - `FeedlogIssue` - GitHub issue data structure
97
+ - `Repository` - Repository information
98
+ - `FetchIssuesParams` - Parameters for fetching issues
99
+ - `FetchIssuesResponse` - Response from fetching issues
100
+ - `UpvoteResponse` - Response from upvoting an issue
101
+ - `FeedlogSDKConfig` - SDK configuration options
102
+
103
+ #### Error Types
104
+
105
+ - `FeedlogError` - Base error class
106
+ - `FeedlogNetworkError` - Network-related errors
107
+ - `FeedlogTimeoutError` - Timeout errors
108
+ - `FeedlogValidationError` - Validation errors
109
+
110
+ ### Utilities
111
+
112
+ - `sanitizeHtml(html: string): string` - Sanitize HTML content to prevent XSS
113
+
114
+ ## Error Handling
115
+
116
+ The SDK provides specific error types for different failure scenarios:
117
+
118
+ ```typescript
119
+ import {
120
+ FeedlogError,
121
+ FeedlogNetworkError,
122
+ FeedlogTimeoutError,
123
+ FeedlogValidationError,
124
+ } from '@feedlog-ai/core';
125
+
126
+ try {
127
+ const issues = await sdk.fetchIssues();
128
+ } catch (error) {
129
+ if (error instanceof FeedlogNetworkError) {
130
+ console.error('Network error:', error.statusCode);
131
+ } else if (error instanceof FeedlogTimeoutError) {
132
+ console.error('Request timed out');
133
+ } else if (error instanceof FeedlogValidationError) {
134
+ console.error('Validation error:', error.message);
135
+ } else if (error instanceof FeedlogError) {
136
+ console.error('Feedlog error:', error.message);
137
+ }
138
+ }
139
+ ```
140
+
141
+ ## Requirements
142
+
143
+ - Node.js >= 22.0.0
144
+ - TypeScript >= 5.3.3 (for type definitions)
145
+
146
+ ## License
147
+
148
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feedlog-ai/core",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "Core SDK for Feedlog Toolkit",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -29,6 +29,9 @@
29
29
  "core"
30
30
  ],
31
31
  "license": "MIT",
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
32
35
  "devDependencies": {
33
36
  "@jest/test-sequencer": "^29.7.0",
34
37
  "@types/jest": "^29.5.11",