@blocks-network/sdk 0.1.61 → 0.1.63

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.
@@ -64,12 +64,51 @@ export interface StreamClientFromDescriptorOptions {
64
64
  gating?: boolean;
65
65
  /** Reorder buffer timeout in ms. Default: 750. Set to 0 to disable. */
66
66
  reorderTimeoutMs?: number;
67
+ /**
68
+ * Consumer's user ID. When set, used as the publisher-identity prefix in
69
+ * the StreamClient UUID so that consumer-side publishes carry an identity
70
+ * derived from the consumer rather than the provider's agentName. Required
71
+ * for correct self-echo filtering on bidirectional streams where the
72
+ * consumer and provider share the same agentName. Omitting it falls back
73
+ * to descriptor.agentName (legacy behavior — safe only for unidirectional
74
+ * streams).
75
+ */
76
+ consumerUserId?: string;
77
+ }
78
+ /**
79
+ * Normalized inbound message yielded by the inbound async iterator.
80
+ *
81
+ * Discriminated by `format`. `data` shape:
82
+ * - `format: 'bytes'` → `string[]` (chunks; `encoding` is `'utf8'` or `'base64'`)
83
+ * - `format: 'events'` → `unknown[]` (one or more events from a single producer flush)
84
+ * - `format: 'raw'` → `Record<string, unknown>` (passthrough for unknown message types)
85
+ *
86
+ * Note: the array-vs-single shape is the SDK's own producer-side bundler
87
+ * (`stream-bundle.ts`) coalescing writes by size/latency — NOT PubNub transport
88
+ * batching. A single producer `write()` already yields a 1-element array on
89
+ * the wire. Application code should prefer `bytes()` / `events()` which
90
+ * flatten on the consumer's behalf; reach for `inbound` only when you
91
+ * need raw envelope metadata.
92
+ */
93
+ export type InboundMessage = InboundBytesMessage | InboundEventsMessage | InboundRawMessage;
94
+ export interface InboundBytesMessage {
95
+ format: 'bytes';
96
+ data: string[];
97
+ seq: number;
98
+ ts: number;
99
+ encoding: string;
100
+ }
101
+ export interface InboundEventsMessage {
102
+ format: 'events';
103
+ data: unknown[];
104
+ seq: number;
105
+ ts: number;
106
+ encoding: string;
67
107
  }
68
- /** Normalized inbound message yielded by the inbound async iterator. */
69
- export interface InboundMessage {
70
- data: unknown;
108
+ export interface InboundRawMessage {
109
+ format: 'raw';
110
+ data: Record<string, unknown>;
71
111
  seq: number;
72
112
  ts: number;
73
- format: 'bytes' | 'events' | 'raw';
74
113
  encoding: string;
75
114
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocks-network/sdk",
3
- "version": "0.1.61",
3
+ "version": "0.1.63",
4
4
  "type": "module",
5
5
  "description": "Blocks Network SDK",
6
6
  "exports": {