@durable-streams/client 0.1.5 → 0.2.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/README.md CHANGED
@@ -41,7 +41,7 @@ const res = await stream<{ message: string }>({
41
41
  Authorization: `Bearer ${process.env.DS_TOKEN!}`,
42
42
  },
43
43
  offset: savedOffset, // optional: resume from offset
44
- live: "auto", // default: behavior driven by consumption method
44
+ live: true, // default: auto-select best live mode
45
45
  })
46
46
 
47
47
  // Accumulate all JSON items until up-to-date
@@ -207,7 +207,7 @@ const res = await stream<TJson>({
207
207
  fetch?: typeof fetch, // Custom fetch implementation
208
208
  backoffOptions?: BackoffOptions,// Retry backoff configuration
209
209
  offset?: Offset, // Starting offset (default: start of stream)
210
- live?: LiveMode, // Live mode (default: "auto")
210
+ live?: LiveMode, // Live mode (default: true)
211
211
  json?: boolean, // Force JSON mode
212
212
  onError?: StreamErrorHandler, // Error handler
213
213
  })
@@ -249,9 +249,10 @@ class DurableStream {
249
249
  ### Live Modes
250
250
 
251
251
  ```typescript
252
- // "auto" (default): behavior driven by consumption method
252
+ // true (default): auto-select best live mode
253
+ // - SSE for JSON streams, long-poll for binary
253
254
  // - Promise helpers (body/json/text): stop after upToDate
254
- // - Streams/subscribers: continue with long-poll
255
+ // - Streams/subscribers: continue with live updates
255
256
 
256
257
  // false: catch-up only, stop at first upToDate
257
258
  const res = await stream({ url, live: false })
@@ -514,7 +515,7 @@ Subscribers provide callback-based consumption with backpressure. The next chunk
514
515
  Subscribe to JSON batches with metadata. Provides backpressure-aware consumption.
515
516
 
516
517
  ```typescript
517
- const res = await stream<{ event: string }>({ url, live: "auto" })
518
+ const res = await stream<{ event: string }>({ url, live: true })
518
519
 
519
520
  const unsubscribe = res.subscribeJson(async (batch) => {
520
521
  // Process items - next batch waits until this resolves
@@ -535,7 +536,7 @@ setTimeout(() => {
535
536
  Subscribe to byte chunks with metadata.
536
537
 
537
538
  ```typescript
538
- const res = await stream({ url, live: "auto" })
539
+ const res = await stream({ url, live: true })
539
540
 
540
541
  const unsubscribe = res.subscribeBytes(async (chunk) => {
541
542
  console.log("Received bytes:", chunk.data.length)
@@ -552,7 +553,7 @@ const unsubscribe = res.subscribeBytes(async (chunk) => {
552
553
  Subscribe to text chunks with metadata.
553
554
 
554
555
  ```typescript
555
- const res = await stream({ url, live: "auto" })
556
+ const res = await stream({ url, live: true })
556
557
 
557
558
  const unsubscribe = res.subscribeText(async (chunk) => {
558
559
  console.log("Text:", chunk.text)
@@ -569,7 +570,7 @@ const unsubscribe = res.subscribeText(async (chunk) => {
569
570
  Cancel the stream session. Aborts any pending requests.
570
571
 
571
572
  ```typescript
572
- const res = await stream({ url, live: "auto" })
573
+ const res = await stream({ url, live: true })
573
574
 
574
575
  // Start consuming
575
576
  res.subscribeBytes(async (chunk) => {
@@ -604,7 +605,7 @@ const res = await stream({ url })
604
605
 
605
606
  res.url // The stream URL
606
607
  res.contentType // Content-Type from response headers
607
- res.live // The live mode ("auto", "long-poll", "sse", or false)
608
+ res.live // The live mode (true, "long-poll", "sse", or false)
608
609
  res.startOffset // The starting offset passed to stream()
609
610
  res.offset // Current offset (updates as data is consumed)
610
611
  res.cursor // Cursor for collapsing (if provided by server)
@@ -825,7 +826,7 @@ const handle = await DurableStream.connect({
825
826
 
826
827
  const res = await handle.stream<{ message: string }>({
827
828
  offset: savedOffset,
828
- live: "auto",
829
+ live: true,
829
830
  })
830
831
 
831
832
  res.subscribeJson(async (batch) => {