@jukasdrj/bookstrack-api-client 1.0.1 → 2.0.0
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.
- package/CHANGELOG.md +163 -0
- package/README.md +47 -21
- package/STREAMING_GUIDE.md +508 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/schema.d.ts +344 -1033
- package/dist/schema.d.ts.map +1 -1
- package/dist/streaming.d.ts +153 -0
- package/dist/streaming.d.ts.map +1 -0
- package/dist/streaming.js +279 -0
- package/package.json +7 -5
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to the BooksTrack API Client will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## [2.0.0] - 2025-12-10
|
|
6
|
+
|
|
7
|
+
### BREAKING CHANGES
|
|
8
|
+
|
|
9
|
+
- **V3 API Only** - SDK now targets V3 API exclusively
|
|
10
|
+
- All V1 and V2 endpoints have been removed
|
|
11
|
+
- Schema regenerated from `/v3/openapi.json`
|
|
12
|
+
- Update all endpoint paths from `/api/v2/*` to `/v3/*`
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- **Discovery Endpoints** - New V3 discovery routes
|
|
17
|
+
- `GET /v3/capabilities` - API feature discovery, limits, deprecations
|
|
18
|
+
- `GET /v3/recommendations/weekly` - Weekly curated book recommendations
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- **Schema Source** - Now generated from `src/api-v3/openapi-static.json`
|
|
23
|
+
- **Version Bump** - Major version to indicate breaking API changes
|
|
24
|
+
|
|
25
|
+
### Removed
|
|
26
|
+
|
|
27
|
+
- All V2 endpoints (sunset March 2026):
|
|
28
|
+
- `/api/v2/capabilities` → Use `/v3/capabilities`
|
|
29
|
+
- `/api/v2/recommendations/weekly` → Use `/v3/recommendations/weekly`
|
|
30
|
+
- `/api/v2/search` → Use `/v3/books/search`
|
|
31
|
+
- `/api/v2/imports/*` → Use `/v3/jobs/imports/*`
|
|
32
|
+
- `/api/v2/books/enrich` → Use `/v3/books/enrich`
|
|
33
|
+
|
|
34
|
+
### Migration Guide (1.x → 2.0)
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
// Before (V2)
|
|
38
|
+
const response = await client.GET('/api/v2/capabilities')
|
|
39
|
+
const search = await client.GET('/api/v2/search', { params: { query: { q: 'harry potter' } } })
|
|
40
|
+
|
|
41
|
+
// After (V3)
|
|
42
|
+
const response = await client.GET('/v3/capabilities')
|
|
43
|
+
const search = await client.GET('/v3/books/search', { params: { query: { q: 'harry potter' } } })
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## [1.2.0] - 2025-12-03
|
|
47
|
+
|
|
48
|
+
### Added
|
|
49
|
+
|
|
50
|
+
- **Shared Response Schemas** - Created `SuccessResponse` and updated `ErrorResponse`
|
|
51
|
+
- All responses now properly document the `success: boolean` discriminator
|
|
52
|
+
- Provides foundation for consistent response handling across all endpoints
|
|
53
|
+
|
|
54
|
+
### Fixed
|
|
55
|
+
|
|
56
|
+
- **Capabilities Endpoint Decoding** - Added missing `success` field to OpenAPI spec
|
|
57
|
+
- Fixes iOS error: "The data couldn't be read because it is missing"
|
|
58
|
+
- OpenAPI spec now matches actual backend response format
|
|
59
|
+
- SDK auto-generated with correct schema including `success: boolean`
|
|
60
|
+
|
|
61
|
+
### Known Issues
|
|
62
|
+
|
|
63
|
+
- **Incomplete Response Schema Migration** - Not all endpoints reference `SuccessResponse` yet
|
|
64
|
+
- Shared schemas created but full endpoint migration is in progress
|
|
65
|
+
- Priority endpoints (capabilities, imports, search) are fixed
|
|
66
|
+
- Complete migration tracked in backend issue tracker
|
|
67
|
+
|
|
68
|
+
## [1.1.2] - 2025-12-03 (Deprecated - use 1.2.0)
|
|
69
|
+
|
|
70
|
+
### Fixed
|
|
71
|
+
|
|
72
|
+
- **Capabilities Endpoint Decoding** - Added missing `success` field to OpenAPI spec
|
|
73
|
+
- Fixes iOS error: "The data couldn't be read because it is missing"
|
|
74
|
+
- OpenAPI spec now matches actual backend response format
|
|
75
|
+
- SDK auto-generated with correct schema including `success: boolean`
|
|
76
|
+
|
|
77
|
+
## [1.1.1] - 2025-12-03
|
|
78
|
+
|
|
79
|
+
### Added
|
|
80
|
+
|
|
81
|
+
- **Job Cancellation Endpoint** - `DELETE /api/v2/jobs/{jobId}/cancel`
|
|
82
|
+
- Properly documented with Bearer token authentication requirement
|
|
83
|
+
- SDK now includes typed cancel endpoint with auth headers
|
|
84
|
+
- Fixes 401 errors when iOS app attempts to cancel completed jobs
|
|
85
|
+
|
|
86
|
+
### Fixed
|
|
87
|
+
|
|
88
|
+
- OpenAPI spec now documents cancel endpoint authentication requirements
|
|
89
|
+
- Added `securitySchemes.BearerAuth` for job operation authentication
|
|
90
|
+
|
|
91
|
+
## [1.1.0] - 2025-12-03
|
|
92
|
+
|
|
93
|
+
### Added
|
|
94
|
+
|
|
95
|
+
- **Streaming Utilities** - Helper functions for SSE and WebSocket progress tracking
|
|
96
|
+
- `createSSEStream()` - Easy SSE connection with typed callbacks
|
|
97
|
+
- `createWebSocketStream()` - WebSocket wrapper with auth and cancel support
|
|
98
|
+
- `useSSEStream_Example()` - React hook example for SSE
|
|
99
|
+
- `useWebSocketStream_Example()` - React hook example for WebSocket
|
|
100
|
+
|
|
101
|
+
- **Comprehensive Streaming Documentation**
|
|
102
|
+
- `STREAMING_GUIDE.md` - Complete guide to SSE vs WebSocket architecture
|
|
103
|
+
- Explains when to use each protocol (SSE for imports, WebSocket for batch ops)
|
|
104
|
+
- Framework examples for React, Vue, and Svelte
|
|
105
|
+
- Troubleshooting guide for common issues
|
|
106
|
+
|
|
107
|
+
### Changed
|
|
108
|
+
|
|
109
|
+
- Updated README with streaming architecture overview
|
|
110
|
+
- Clarified hybrid SSE/WebSocket approach in documentation
|
|
111
|
+
- Version bump from 1.0.1 → 1.1.0
|
|
112
|
+
|
|
113
|
+
### Documentation
|
|
114
|
+
|
|
115
|
+
- Added detailed SSE event types and payload structures
|
|
116
|
+
- Added WebSocket message types and authentication methods
|
|
117
|
+
- Included React hooks examples for both streaming protocols
|
|
118
|
+
- Documented automatic reconnection behavior for SSE
|
|
119
|
+
- Explained bidirectional communication patterns for WebSocket
|
|
120
|
+
|
|
121
|
+
## [1.0.1] - 2025-11-28
|
|
122
|
+
|
|
123
|
+
### Initial Release
|
|
124
|
+
|
|
125
|
+
- Auto-generated TypeScript SDK from OpenAPI specification
|
|
126
|
+
- Full type safety with `openapi-fetch`
|
|
127
|
+
- Support for all V1, V2, and V3 endpoints
|
|
128
|
+
- Basic error handling and circuit breaker error codes
|
|
129
|
+
- ResponseEnvelope format support
|
|
130
|
+
|
|
131
|
+
## Migration Guide
|
|
132
|
+
|
|
133
|
+
### From 1.0.1 to 1.1.0
|
|
134
|
+
|
|
135
|
+
No breaking changes! The 1.1.0 release is backward compatible.
|
|
136
|
+
|
|
137
|
+
**New Features You Can Use:**
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
// Before (manual SSE setup)
|
|
141
|
+
const eventSource = new EventSource(sseUrl)
|
|
142
|
+
eventSource.onmessage = (e) => {
|
|
143
|
+
const data = JSON.parse(e.data)
|
|
144
|
+
console.log(data.progress)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// After (helper function)
|
|
148
|
+
import { createSSEStream } from '@bookstrack/api-client'
|
|
149
|
+
|
|
150
|
+
const stream = createSSEStream({
|
|
151
|
+
sseUrl,
|
|
152
|
+
onProgress: (event) => console.log(event.progress),
|
|
153
|
+
onComplete: (event) => console.log('Done!', event.books)
|
|
154
|
+
})
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
**React Developers:**
|
|
158
|
+
|
|
159
|
+
Copy the `useSSEStream_Example` or `useWebSocketStream_Example` from `src/streaming.ts` into your React project for typed hooks.
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
**Full Changelog:** https://github.com/yourusername/bendv3/compare/v1.0.1...v1.1.0
|
package/README.md
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
# @bookstrack/api-client
|
|
2
2
|
|
|
3
|
-
**Official TypeScript SDK for BooksTrack API**
|
|
3
|
+
**Official TypeScript SDK for BooksTrack V3 API**
|
|
4
4
|
|
|
5
5
|
Auto-generated from OpenAPI specification using `openapi-typescript` + `openapi-fetch`.
|
|
6
6
|
|
|
7
|
+
> **Version 2.0** - V3 API only. V1/V2 endpoints have been sunset.
|
|
8
|
+
|
|
7
9
|
## Features
|
|
8
10
|
|
|
9
11
|
- **Type-Safe** - Full TypeScript support with auto-generated types
|
|
@@ -38,16 +40,25 @@ const client = createBooksTrackClient({
|
|
|
38
40
|
baseUrl: 'https://api.oooefam.net'
|
|
39
41
|
})
|
|
40
42
|
|
|
41
|
-
//
|
|
42
|
-
const { data
|
|
43
|
-
|
|
43
|
+
// Get API capabilities (call on app startup)
|
|
44
|
+
const { data: caps } = await client.GET('/v3/capabilities')
|
|
45
|
+
console.log('API Version:', caps.data.apiVersion)
|
|
46
|
+
|
|
47
|
+
// Search books by title
|
|
48
|
+
const { data, error } = await client.GET('/v3/books/search', {
|
|
49
|
+
params: { query: { q: 'harry potter' } }
|
|
44
50
|
})
|
|
45
51
|
|
|
46
52
|
if (error) {
|
|
47
53
|
console.error('API Error:', error)
|
|
48
54
|
} else {
|
|
49
|
-
console.log('
|
|
55
|
+
console.log('Books:', data.data.books)
|
|
50
56
|
}
|
|
57
|
+
|
|
58
|
+
// Get book by ISBN
|
|
59
|
+
const { data: book } = await client.GET('/v3/books/{isbn}', {
|
|
60
|
+
params: { path: { isbn: '9780439708180' } }
|
|
61
|
+
})
|
|
51
62
|
```
|
|
52
63
|
|
|
53
64
|
### Advanced Usage
|
|
@@ -63,42 +74,57 @@ const client = createBooksTrackClient({
|
|
|
63
74
|
})
|
|
64
75
|
```
|
|
65
76
|
|
|
66
|
-
#### POST Requests (
|
|
77
|
+
#### POST Requests (Book Enrichment)
|
|
67
78
|
|
|
68
79
|
```typescript
|
|
69
|
-
const { data, error } = await client.POST('/
|
|
80
|
+
const { data, error } = await client.POST('/v3/books/enrich', {
|
|
70
81
|
body: {
|
|
71
|
-
|
|
72
|
-
|
|
82
|
+
isbns: ['9780439708180', '9780316769488'],
|
|
83
|
+
includeEmbedding: false
|
|
73
84
|
}
|
|
74
85
|
})
|
|
75
86
|
|
|
76
87
|
if (error) {
|
|
77
88
|
console.error('Failed to enrich:', error)
|
|
78
89
|
} else {
|
|
79
|
-
console.log('
|
|
90
|
+
console.log('Enriched:', data.data.books)
|
|
80
91
|
}
|
|
81
92
|
```
|
|
82
93
|
|
|
83
|
-
####
|
|
94
|
+
#### Progress Streaming (SSE vs WebSocket)
|
|
95
|
+
|
|
96
|
+
BooksTrack uses **two streaming protocols** depending on the use case:
|
|
97
|
+
|
|
98
|
+
- **SSE** for CSV imports (one-way, auto-reconnect)
|
|
99
|
+
- **WebSocket** for batch enrichment (bidirectional, cancel support)
|
|
84
100
|
|
|
101
|
+
**SSE Example (CSV Import):**
|
|
85
102
|
```typescript
|
|
86
|
-
|
|
87
|
-
const {
|
|
88
|
-
body: { workIds: [...] }
|
|
89
|
-
})
|
|
103
|
+
const { data } = await client.POST('/api/v2/imports', { body: formData })
|
|
104
|
+
const { sseUrl } = data.data
|
|
90
105
|
|
|
91
|
-
const
|
|
106
|
+
const eventSource = new EventSource(sseUrl)
|
|
107
|
+
eventSource.addEventListener('progress', (e) => {
|
|
108
|
+
const update = JSON.parse(e.data)
|
|
109
|
+
console.log(`Progress: ${update.progress * 100}%`)
|
|
110
|
+
})
|
|
111
|
+
```
|
|
92
112
|
|
|
93
|
-
|
|
94
|
-
|
|
113
|
+
**WebSocket Example (Batch Enrichment):**
|
|
114
|
+
```typescript
|
|
115
|
+
const { data } = await client.POST('/v1/enrichment/batch', {
|
|
116
|
+
body: { books: [...], jobId: crypto.randomUUID() }
|
|
117
|
+
})
|
|
95
118
|
|
|
119
|
+
const ws = new WebSocket(data.data.websocketUrl, [data.data.authToken])
|
|
96
120
|
ws.onmessage = (event) => {
|
|
97
|
-
const
|
|
98
|
-
console.log(`Progress: ${
|
|
121
|
+
const message = JSON.parse(event.data)
|
|
122
|
+
console.log(`Progress: ${message.progress * 100}%`)
|
|
99
123
|
}
|
|
100
124
|
```
|
|
101
125
|
|
|
126
|
+
📖 **See [STREAMING_GUIDE.md](./STREAMING_GUIDE.md) for complete SSE/WebSocket documentation**
|
|
127
|
+
|
|
102
128
|
#### Polling Job Status (Fallback)
|
|
103
129
|
|
|
104
130
|
```typescript
|
|
@@ -359,7 +385,7 @@ const book = data.data
|
|
|
359
385
|
## Support
|
|
360
386
|
|
|
361
387
|
- **Documentation:** https://github.com/yourusername/bendv3/tree/main/docs
|
|
362
|
-
- **API Contract:** https://github.com/yourusername/bendv3/blob/main/docs/
|
|
388
|
+
- **API Contract:** https://github.com/yourusername/bendv3/blob/main/docs/openapi.yaml
|
|
363
389
|
- **Issues:** https://github.com/yourusername/bendv3/issues
|
|
364
390
|
|
|
365
391
|
---
|