@jukasdrj/bookstrack-api-client 1.0.1 → 2.1.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 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,15 @@
1
1
  # @bookstrack/api-client
2
2
 
3
- **Official TypeScript SDK for BooksTrack API**
3
+ [![npm version](https://img.shields.io/npm/v/@jukasdrj/bookstrack-api-client.svg)](https://www.npmjs.com/package/@jukasdrj/bookstrack-api-client)
4
+ [![npm downloads](https://img.shields.io/npm/dm/@jukasdrj/bookstrack-api-client.svg)](https://www.npmjs.com/package/@jukasdrj/bookstrack-api-client)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+
7
+ **Official TypeScript SDK for BooksTrack V3 API**
4
8
 
5
9
  Auto-generated from OpenAPI specification using `openapi-typescript` + `openapi-fetch`.
6
10
 
11
+ > **Version 2.0** - V3 API only. V1/V2 endpoints have been sunset.
12
+
7
13
  ## Features
8
14
 
9
15
  - **Type-Safe** - Full TypeScript support with auto-generated types
@@ -16,13 +22,19 @@ Auto-generated from OpenAPI specification using `openapi-typescript` + `openapi-
16
22
  ## Installation
17
23
 
18
24
  ```bash
19
- npm install @bookstrack/api-client
25
+ npm install @jukasdrj/bookstrack-api-client
20
26
  ```
21
27
 
22
- **Note:** This package is published to GitHub Packages. Ensure your `.npmrc` is configured:
28
+ Or with yarn:
23
29
 
30
+ ```bash
31
+ yarn add @jukasdrj/bookstrack-api-client
24
32
  ```
25
- @bookstrack:registry=https://npm.pkg.github.com
33
+
34
+ Or with pnpm:
35
+
36
+ ```bash
37
+ pnpm add @jukasdrj/bookstrack-api-client
26
38
  ```
27
39
 
28
40
  ---
@@ -32,22 +44,31 @@ npm install @bookstrack/api-client
32
44
  ### Basic Usage
33
45
 
34
46
  ```typescript
35
- import { createBooksTrackClient } from '@bookstrack/api-client'
47
+ import { createBooksTrackClient } from '@jukasdrj/bookstrack-api-client'
36
48
 
37
49
  const client = createBooksTrackClient({
38
50
  baseUrl: 'https://api.oooefam.net'
39
51
  })
40
52
 
41
- // Search by ISBN
42
- const { data, error } = await client.GET('/v1/search/isbn', {
43
- params: { query: { isbn: '9780439708180' } }
53
+ // Get API capabilities (call on app startup)
54
+ const { data: caps } = await client.GET('/v3/capabilities')
55
+ console.log('API Version:', caps.data.apiVersion)
56
+
57
+ // Search books by title
58
+ const { data, error } = await client.GET('/v3/books/search', {
59
+ params: { query: { q: 'harry potter' } }
44
60
  })
45
61
 
46
62
  if (error) {
47
63
  console.error('API Error:', error)
48
64
  } else {
49
- console.log('Book:', data.data)
65
+ console.log('Books:', data.data.books)
50
66
  }
67
+
68
+ // Get book by ISBN
69
+ const { data: book } = await client.GET('/v3/books/{isbn}', {
70
+ params: { path: { isbn: '9780439708180' } }
71
+ })
51
72
  ```
52
73
 
53
74
  ### Advanced Usage
@@ -63,42 +84,57 @@ const client = createBooksTrackClient({
63
84
  })
64
85
  ```
65
86
 
66
- #### POST Requests (Batch Enrichment)
87
+ #### POST Requests (Book Enrichment)
67
88
 
68
89
  ```typescript
69
- const { data, error } = await client.POST('/v1/enrich/batch', {
90
+ const { data, error } = await client.POST('/v3/books/enrich', {
70
91
  body: {
71
- workIds: ['OL123W', 'OL456W'],
72
- force: false
92
+ isbns: ['9780439708180', '9780316769488'],
93
+ includeEmbedding: false
73
94
  }
74
95
  })
75
96
 
76
97
  if (error) {
77
98
  console.error('Failed to enrich:', error)
78
99
  } else {
79
- console.log('Job ID:', data.data.jobId)
100
+ console.log('Enriched:', data.data.books)
80
101
  }
81
102
  ```
82
103
 
83
- #### WebSocket Progress Tracking
104
+ #### Progress Streaming (SSE vs WebSocket)
105
+
106
+ BooksTrack uses **two streaming protocols** depending on the use case:
107
+
108
+ - **SSE** for CSV imports (one-way, auto-reconnect)
109
+ - **WebSocket** for batch enrichment (bidirectional, cancel support)
84
110
 
111
+ **SSE Example (CSV Import):**
85
112
  ```typescript
86
- // Start batch job
87
- const { data: job } = await client.POST('/v1/enrich/batch', {
88
- body: { workIds: [...] }
89
- })
113
+ const { data } = await client.POST('/api/v2/imports', { body: formData })
114
+ const { sseUrl } = data.data
90
115
 
91
- const jobId = job.data.jobId
116
+ const eventSource = new EventSource(sseUrl)
117
+ eventSource.addEventListener('progress', (e) => {
118
+ const update = JSON.parse(e.data)
119
+ console.log(`Progress: ${update.progress * 100}%`)
120
+ })
121
+ ```
92
122
 
93
- // Connect to WebSocket
94
- const ws = new WebSocket(`wss://api.oooefam.net/ws/progress?jobId=${jobId}`)
123
+ **WebSocket Example (Batch Enrichment):**
124
+ ```typescript
125
+ const { data } = await client.POST('/v1/enrichment/batch', {
126
+ body: { books: [...], jobId: crypto.randomUUID() }
127
+ })
95
128
 
129
+ const ws = new WebSocket(data.data.websocketUrl, [data.data.authToken])
96
130
  ws.onmessage = (event) => {
97
- const progress = JSON.parse(event.data)
98
- console.log(`Progress: ${progress.progress * 100}%`)
131
+ const message = JSON.parse(event.data)
132
+ console.log(`Progress: ${message.progress * 100}%`)
99
133
  }
100
134
  ```
101
135
 
136
+ 📖 **See [STREAMING_GUIDE.md](./STREAMING_GUIDE.md) for complete SSE/WebSocket documentation**
137
+
102
138
  #### Polling Job Status (Fallback)
103
139
 
104
140
  ```typescript
@@ -242,7 +278,7 @@ npm publish
242
278
 
243
279
  ```typescript
244
280
  import { useQuery } from '@tanstack/react-query'
245
- import { client } from '@bookstrack/api-client'
281
+ import { client } from '@jukasdrj/bookstrack-api-client'
246
282
 
247
283
  function BookSearch({ isbn }: { isbn: string }) {
248
284
  const { data, error, isLoading } = useQuery({
@@ -267,7 +303,7 @@ function BookSearch({ isbn }: { isbn: string }) {
267
303
 
268
304
  ```typescript
269
305
  import { ref } from 'vue'
270
- import { client } from '@bookstrack/api-client'
306
+ import { client } from '@jukasdrj/bookstrack-api-client'
271
307
 
272
308
  export function useBookSearch(isbn: string) {
273
309
  const book = ref(null)
@@ -296,7 +332,7 @@ export function useBookSearch(isbn: string) {
296
332
 
297
333
  ```typescript
298
334
  import { writable } from 'svelte/store'
299
- import { client } from '@bookstrack/api-client'
335
+ import { client } from '@jukasdrj/bookstrack-api-client'
300
336
 
301
337
  export function createBookStore() {
302
338
  const { subscribe, set, update } = writable({
@@ -339,7 +375,7 @@ const book = await res.json()
339
375
  ### After (SDK)
340
376
 
341
377
  ```typescript
342
- import { client } from '@bookstrack/api-client'
378
+ import { client } from '@jukasdrj/bookstrack-api-client'
343
379
 
344
380
  const { data } = await client.GET('/v1/search/isbn', {
345
381
  params: { query: { isbn: '123' } }
@@ -359,7 +395,7 @@ const book = data.data
359
395
  ## Support
360
396
 
361
397
  - **Documentation:** https://github.com/yourusername/bendv3/tree/main/docs
362
- - **API Contract:** https://github.com/yourusername/bendv3/blob/main/docs/API_CONTRACT.md
398
+ - **API Contract:** https://github.com/yourusername/bendv3/blob/main/docs/openapi.yaml
363
399
  - **Issues:** https://github.com/yourusername/bendv3/issues
364
400
 
365
401
  ---