@ironflow/browser 0.20.2 → 0.22.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.
Files changed (66) hide show
  1. package/README.md +1 -1
  2. package/dist/agents/index.d.ts +34 -0
  3. package/dist/agents/index.d.ts.map +1 -0
  4. package/dist/agents/index.js +24 -0
  5. package/dist/agents/index.js.map +1 -0
  6. package/dist/agents/invoke.d.ts +16 -0
  7. package/dist/agents/invoke.d.ts.map +1 -0
  8. package/dist/agents/invoke.js +222 -0
  9. package/dist/agents/invoke.js.map +1 -0
  10. package/dist/agents/readMemory.d.ts +18 -0
  11. package/dist/agents/readMemory.d.ts.map +1 -0
  12. package/dist/agents/readMemory.js +87 -0
  13. package/dist/agents/readMemory.js.map +1 -0
  14. package/dist/agents/subscribe.d.ts +23 -0
  15. package/dist/agents/subscribe.d.ts.map +1 -0
  16. package/dist/agents/subscribe.js +117 -0
  17. package/dist/agents/subscribe.js.map +1 -0
  18. package/dist/agents/types.d.ts +156 -0
  19. package/dist/agents/types.d.ts.map +1 -0
  20. package/dist/agents/types.js +7 -0
  21. package/dist/agents/types.js.map +1 -0
  22. package/dist/client.d.ts +844 -0
  23. package/dist/client.d.ts.map +1 -0
  24. package/dist/client.js +2243 -0
  25. package/dist/client.js.map +1 -0
  26. package/dist/config-client.d.ts +43 -0
  27. package/dist/config-client.d.ts.map +1 -0
  28. package/dist/config-client.js +134 -0
  29. package/dist/config-client.js.map +1 -0
  30. package/dist/config.d.ts +91 -0
  31. package/dist/config.d.ts.map +1 -0
  32. package/dist/config.js +55 -0
  33. package/dist/config.js.map +1 -0
  34. package/dist/index.d.ts +53 -0
  35. package/dist/index.d.ts.map +1 -0
  36. package/dist/index.js +53 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/kv.d.ts +79 -0
  39. package/dist/kv.d.ts.map +1 -0
  40. package/dist/kv.js +289 -0
  41. package/dist/kv.js.map +1 -0
  42. package/dist/projection-stream.d.ts +42 -0
  43. package/dist/projection-stream.d.ts.map +1 -0
  44. package/dist/projection-stream.js +48 -0
  45. package/dist/projection-stream.js.map +1 -0
  46. package/dist/subscription.d.ts +107 -0
  47. package/dist/subscription.d.ts.map +1 -0
  48. package/dist/subscription.js +450 -0
  49. package/dist/subscription.js.map +1 -0
  50. package/dist/transport/connectrpc.d.ts +74 -0
  51. package/dist/transport/connectrpc.d.ts.map +1 -0
  52. package/dist/transport/connectrpc.js +393 -0
  53. package/dist/transport/connectrpc.js.map +1 -0
  54. package/dist/transport/index.d.ts +7 -0
  55. package/dist/transport/index.d.ts.map +1 -0
  56. package/dist/transport/index.js +6 -0
  57. package/dist/transport/index.js.map +1 -0
  58. package/dist/transport/types.d.ts +69 -0
  59. package/dist/transport/types.d.ts.map +1 -0
  60. package/dist/transport/types.js +5 -0
  61. package/dist/transport/types.js.map +1 -0
  62. package/dist/transport/websocket.d.ts +38 -0
  63. package/dist/transport/websocket.d.ts.map +1 -0
  64. package/dist/transport/websocket.js +276 -0
  65. package/dist/transport/websocket.js.map +1 -0
  66. package/package.json +3 -3
package/dist/kv.d.ts ADDED
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Ironflow Browser KV Client
3
+ *
4
+ * Key-Value store operations for browser-based applications.
5
+ * Includes WebSocket-based watch support.
6
+ */
7
+ import type { KVBucketConfig, KVBucketInfo, KVEntry, KVPutResult, KVWatchCallbacks, KVWatchOptions, KVWatcher } from "@ironflow/core";
8
+ import type { IronflowConfig } from "./config.js";
9
+ /**
10
+ * KV bucket handle for key-level operations in the browser.
11
+ */
12
+ export declare class BrowserKVBucketHandle {
13
+ private readonly bucketName;
14
+ private readonly config;
15
+ constructor(bucketName: string, config: IronflowConfig);
16
+ /**
17
+ * Get a value by key.
18
+ */
19
+ get(key: string): Promise<KVEntry>;
20
+ /**
21
+ * Put a value unconditionally.
22
+ */
23
+ put(key: string, value: unknown): Promise<KVPutResult>;
24
+ /**
25
+ * Create a value only if the key doesn't exist (if-not-exists).
26
+ */
27
+ create(key: string, value: unknown): Promise<KVPutResult>;
28
+ /**
29
+ * Update a value only if the revision matches (compare-and-swap).
30
+ */
31
+ update(key: string, value: unknown, revision: number): Promise<KVPutResult>;
32
+ /**
33
+ * Delete a key (soft delete / tombstone).
34
+ */
35
+ delete(key: string): Promise<void>;
36
+ /**
37
+ * Purge a key and all its history.
38
+ */
39
+ purge(key: string): Promise<void>;
40
+ /**
41
+ * List keys with an optional wildcard filter.
42
+ */
43
+ listKeys(filter?: string): Promise<string[]>;
44
+ /**
45
+ * Watch for changes on keys matching a pattern.
46
+ * Uses WebSocket for real-time notifications.
47
+ */
48
+ watch(callbacks: KVWatchCallbacks, options?: KVWatchOptions): KVWatcher;
49
+ private restRequest;
50
+ }
51
+ /**
52
+ * Browser KV client for bucket management and key operations.
53
+ */
54
+ export declare class BrowserKVClient {
55
+ private readonly config;
56
+ constructor(config: IronflowConfig);
57
+ /**
58
+ * Create a new bucket.
59
+ */
60
+ createBucket(config: KVBucketConfig): Promise<KVBucketInfo>;
61
+ /**
62
+ * Delete a bucket.
63
+ */
64
+ deleteBucket(name: string): Promise<void>;
65
+ /**
66
+ * List all buckets.
67
+ */
68
+ listBuckets(): Promise<KVBucketInfo[]>;
69
+ /**
70
+ * Get bucket info.
71
+ */
72
+ getBucketInfo(name: string): Promise<KVBucketInfo>;
73
+ /**
74
+ * Get a bucket handle for key-level operations.
75
+ */
76
+ bucket(name: string): BrowserKVBucketHandle;
77
+ private restRequest;
78
+ }
79
+ //# sourceMappingURL=kv.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kv.d.ts","sourceRoot":"","sources":["../src/kv.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EACZ,OAAO,EACP,WAAW,EAIX,gBAAgB,EAChB,cAAc,EACd,SAAS,EACV,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD;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AE,CAAC;IAQ5C;;OAEG;IACG,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAOxD;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,qBAAqB;YAI7B,WAAW;CAkE1B"}
package/dist/kv.js ADDED
@@ -0,0 +1,289 @@
1
+ /**
2
+ * Ironflow Browser KV Client
3
+ *
4
+ * Key-Value store operations for browser-based applications.
5
+ * Includes WebSocket-based watch support.
6
+ */
7
+ import { IronflowError, DEFAULT_TIMEOUTS, HEADERS } from "@ironflow/core";
8
+ /**
9
+ * KV bucket handle for key-level operations in the browser.
10
+ */
11
+ export class BrowserKVBucketHandle {
12
+ bucketName;
13
+ config;
14
+ constructor(bucketName, config) {
15
+ this.bucketName = bucketName;
16
+ this.config = config;
17
+ }
18
+ /**
19
+ * Get a value by key.
20
+ */
21
+ async get(key) {
22
+ return this.restRequest("GET", `/api/v1/kv/buckets/${enc(this.bucketName)}/keys/${key}`);
23
+ }
24
+ /**
25
+ * Put a value unconditionally.
26
+ */
27
+ async put(key, value) {
28
+ return this.restRequest("PUT", `/api/v1/kv/buckets/${enc(this.bucketName)}/keys/${key}`, value);
29
+ }
30
+ /**
31
+ * Create a value only if the key doesn't exist (if-not-exists).
32
+ */
33
+ async create(key, value) {
34
+ return this.restRequest("PUT", `/api/v1/kv/buckets/${enc(this.bucketName)}/keys/${key}`, value, { "If-None-Match": "*" });
35
+ }
36
+ /**
37
+ * Update a value only if the revision matches (compare-and-swap).
38
+ */
39
+ async update(key, value, revision) {
40
+ return this.restRequest("PUT", `/api/v1/kv/buckets/${enc(this.bucketName)}/keys/${key}`, value, { "If-Match": String(revision) });
41
+ }
42
+ /**
43
+ * Delete a key (soft delete / tombstone).
44
+ */
45
+ async delete(key) {
46
+ await this.restRequest("DELETE", `/api/v1/kv/buckets/${enc(this.bucketName)}/keys/${key}`);
47
+ }
48
+ /**
49
+ * Purge a key and all its history.
50
+ */
51
+ async purge(key) {
52
+ await this.restRequest("DELETE", `/api/v1/kv/buckets/${enc(this.bucketName)}/keys/${key}?purge=true`);
53
+ }
54
+ /**
55
+ * List keys with an optional wildcard filter.
56
+ */
57
+ async listKeys(filter) {
58
+ let path = `/api/v1/kv/buckets/${enc(this.bucketName)}/keys`;
59
+ if (filter) {
60
+ path += `?filter=${encodeURIComponent(filter)}`;
61
+ }
62
+ const result = await this.restRequest("GET", path);
63
+ return result.keys;
64
+ }
65
+ /**
66
+ * Watch for changes on keys matching a pattern.
67
+ * Uses WebSocket for real-time notifications.
68
+ */
69
+ watch(callbacks, options) {
70
+ const serverUrl = this.config.serverUrl;
71
+ const wsUrl = serverUrl
72
+ .replace("https://", "wss://")
73
+ .replace("http://", "ws://");
74
+ let path = `/api/v1/kv/buckets/${enc(this.bucketName)}/watch`;
75
+ if (options?.key) {
76
+ path += `?key=${encodeURIComponent(options.key)}`;
77
+ }
78
+ const ws = new WebSocket(`${wsUrl}${path}`);
79
+ ws.onmessage = (event) => {
80
+ try {
81
+ const data = JSON.parse(event.data);
82
+ if (data.type === "kv_update") {
83
+ callbacks.onUpdate(data);
84
+ }
85
+ }
86
+ catch (err) {
87
+ callbacks.onError?.(err instanceof Error ? err : new Error(String(err)));
88
+ }
89
+ };
90
+ ws.onerror = () => {
91
+ callbacks.onError?.(new Error("KV watch WebSocket error"));
92
+ };
93
+ ws.onclose = () => {
94
+ callbacks.onClose?.();
95
+ };
96
+ return {
97
+ stop: () => {
98
+ ws.close();
99
+ },
100
+ };
101
+ }
102
+ async restRequest(method, path, body, extraHeaders) {
103
+ const url = `${this.config.serverUrl}${path}`;
104
+ const timeout = this.config.timeout ?? DEFAULT_TIMEOUTS.CLIENT;
105
+ const controller = new AbortController();
106
+ const timeoutId = setTimeout(() => controller.abort(), timeout);
107
+ try {
108
+ const headers = {
109
+ [HEADERS.ENVIRONMENT]: this.config.environment,
110
+ };
111
+ if (body !== undefined) {
112
+ headers["Content-Type"] =
113
+ typeof body === "string"
114
+ ? "application/octet-stream"
115
+ : "application/json";
116
+ }
117
+ if (this.config.auth?.apiKey) {
118
+ headers["Authorization"] = `Bearer ${this.config.auth.apiKey}`;
119
+ }
120
+ if (extraHeaders) {
121
+ Object.assign(headers, extraHeaders);
122
+ }
123
+ const response = await fetch(url, {
124
+ method,
125
+ headers,
126
+ body: body !== undefined
127
+ ? typeof body === "string"
128
+ ? body
129
+ : JSON.stringify(body)
130
+ : undefined,
131
+ signal: controller.signal,
132
+ });
133
+ if (!response.ok) {
134
+ const errorBody = await response.text();
135
+ let errorMessage = `KV request failed: ${response.status}`;
136
+ try {
137
+ const errorJson = JSON.parse(errorBody);
138
+ if (errorJson.error)
139
+ errorMessage = errorJson.error;
140
+ }
141
+ catch {
142
+ if (errorBody)
143
+ errorMessage = errorBody;
144
+ }
145
+ throw new IronflowError(errorMessage, {
146
+ code: `HTTP_${response.status}`,
147
+ retryable: response.status >= 500,
148
+ });
149
+ }
150
+ if (response.status === 204) {
151
+ return undefined;
152
+ }
153
+ return response.json();
154
+ }
155
+ catch (error) {
156
+ if (error instanceof IronflowError)
157
+ throw error;
158
+ if (error instanceof Error && error.name === "AbortError") {
159
+ throw new IronflowError(`KV request timeout after ${timeout}ms`, {
160
+ code: "TIMEOUT",
161
+ retryable: true,
162
+ });
163
+ }
164
+ throw new IronflowError(`KV ${method} ${path} failed`, {
165
+ code: "REQUEST_FAILED",
166
+ retryable: true,
167
+ });
168
+ }
169
+ finally {
170
+ clearTimeout(timeoutId);
171
+ }
172
+ }
173
+ }
174
+ /**
175
+ * Browser KV client for bucket management and key operations.
176
+ */
177
+ export class BrowserKVClient {
178
+ config;
179
+ constructor(config) {
180
+ this.config = config;
181
+ }
182
+ /**
183
+ * Create a new bucket.
184
+ */
185
+ async createBucket(config) {
186
+ const body = { name: config.name };
187
+ if (config.description)
188
+ body.description = config.description;
189
+ if (config.ttlSeconds)
190
+ body.ttl_seconds = config.ttlSeconds;
191
+ if (config.maxValueSize)
192
+ body.max_value_size = config.maxValueSize;
193
+ if (config.maxBytes)
194
+ body.max_bytes = config.maxBytes;
195
+ if (config.history)
196
+ body.history = config.history;
197
+ return this.restRequest("POST", "/api/v1/kv/buckets", body);
198
+ }
199
+ /**
200
+ * Delete a bucket.
201
+ */
202
+ async deleteBucket(name) {
203
+ await this.restRequest("DELETE", `/api/v1/kv/buckets/${enc(name)}`);
204
+ }
205
+ /**
206
+ * List all buckets.
207
+ */
208
+ async listBuckets() {
209
+ const result = await this.restRequest("GET", "/api/v1/kv/buckets");
210
+ return result.buckets;
211
+ }
212
+ /**
213
+ * Get bucket info.
214
+ */
215
+ async getBucketInfo(name) {
216
+ return this.restRequest("GET", `/api/v1/kv/buckets/${enc(name)}`);
217
+ }
218
+ /**
219
+ * Get a bucket handle for key-level operations.
220
+ */
221
+ bucket(name) {
222
+ return new BrowserKVBucketHandle(name, this.config);
223
+ }
224
+ async restRequest(method, path, body) {
225
+ const url = `${this.config.serverUrl}${path}`;
226
+ const timeout = this.config.timeout ?? DEFAULT_TIMEOUTS.CLIENT;
227
+ const controller = new AbortController();
228
+ const timeoutId = setTimeout(() => controller.abort(), timeout);
229
+ try {
230
+ const headers = {
231
+ [HEADERS.ENVIRONMENT]: this.config.environment,
232
+ };
233
+ if (body !== undefined) {
234
+ headers["Content-Type"] = "application/json";
235
+ }
236
+ if (this.config.auth?.apiKey) {
237
+ headers["Authorization"] = `Bearer ${this.config.auth.apiKey}`;
238
+ }
239
+ const response = await fetch(url, {
240
+ method,
241
+ headers,
242
+ body: body !== undefined ? JSON.stringify(body) : undefined,
243
+ signal: controller.signal,
244
+ });
245
+ if (!response.ok) {
246
+ const errorBody = await response.text();
247
+ let errorMessage = `KV request failed: ${response.status}`;
248
+ try {
249
+ const errorJson = JSON.parse(errorBody);
250
+ if (errorJson.error)
251
+ errorMessage = errorJson.error;
252
+ }
253
+ catch {
254
+ if (errorBody)
255
+ errorMessage = errorBody;
256
+ }
257
+ throw new IronflowError(errorMessage, {
258
+ code: `HTTP_${response.status}`,
259
+ retryable: response.status >= 500,
260
+ });
261
+ }
262
+ if (response.status === 204) {
263
+ return undefined;
264
+ }
265
+ return response.json();
266
+ }
267
+ catch (error) {
268
+ if (error instanceof IronflowError)
269
+ throw error;
270
+ if (error instanceof Error && error.name === "AbortError") {
271
+ throw new IronflowError(`KV request timeout after ${timeout}ms`, {
272
+ code: "TIMEOUT",
273
+ retryable: true,
274
+ });
275
+ }
276
+ throw new IronflowError(`KV ${method} ${path} failed`, {
277
+ code: "REQUEST_FAILED",
278
+ retryable: true,
279
+ });
280
+ }
281
+ finally {
282
+ clearTimeout(timeoutId);
283
+ }
284
+ }
285
+ }
286
+ function enc(s) {
287
+ return encodeURIComponent(s);
288
+ }
289
+ //# sourceMappingURL=kv.js.map
package/dist/kv.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kv.js","sourceRoot":"","sources":["../src/kv.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAcH,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAG1E;;GAEG;AACH,MAAM,OAAO,qBAAqB;IAEb;IACA;IAFnB,YACmB,UAAkB,EAClB,MAAsB;QADtB,eAAU,GAAV,UAAU,CAAQ;QAClB,WAAM,GAAN,MAAM,CAAgB;IACtC,CAAC;IAEJ;;OAEG;IACH,KAAK,CAAC,GAAG,CAAC,GAAW;QACnB,OAAO,IAAI,CAAC,WAAW,CACrB,KAAK,EACL,sBAAsB,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,GAAG,EAAE,CACzD,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,KAAc;QACnC,OAAO,IAAI,CAAC,WAAW,CACrB,KAAK,EACL,sBAAsB,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,GAAG,EAAE,EACxD,KAAK,CACN,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MA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AAC;YACL,CAAC;YACD,MAAM,IAAI,aAAa,CAAC,MAAM,MAAM,IAAI,IAAI,SAAS,EAAE;gBACrD,IAAI,EAAE,gBAAgB;gBACtB,SAAS,EAAE,IAAI;aAChB,CAAC,CAAC;QACL,CAAC;gBAAS,CAAC;YACT,YAAY,CAAC,SAAS,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;CACF;AAED,SAAS,GAAG,CAAC,CAAS;IACpB,OAAO,kBAAkB,CAAC,CAAC,CAAC,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Frame-filter logic for waitForProjectionCatchupStream (#476).
3
+ *
4
+ * Extracted from IronflowClient.waitForProjectionCatchupStream so the
5
+ * heartbeat-filter and terminal-short-circuit behavior can be unit
6
+ * tested with a mock async iterable, without loading the @connectrpc
7
+ * transport modules or the generated ProjectionService client.
8
+ */
9
+ import type { WaitProgress } from "@ironflow/core";
10
+ /**
11
+ * Minimal shape of a streaming response frame. Matches the generated
12
+ * WaitProjectionCatchupStreamResponse type without importing it, so this
13
+ * file stays free of @bufbuild/protobuf/@ironflow/core/gen dependencies.
14
+ */
15
+ export interface WaitStreamFrameLike {
16
+ kind: number;
17
+ currentSeq: number | bigint;
18
+ targetSeq: number | bigint;
19
+ behindByEvents: number | bigint;
20
+ caughtUp: boolean;
21
+ timedOut: boolean;
22
+ error?: string;
23
+ mode?: string;
24
+ }
25
+ /**
26
+ * Enum-value lookup. The caller supplies the numeric values from the
27
+ * generated WaitStreamFrameKind enum so this file doesn't import the
28
+ * generated code.
29
+ */
30
+ export interface WaitStreamFrameKinds {
31
+ readonly UNSPECIFIED: number;
32
+ readonly PROGRESS: number;
33
+ readonly HEARTBEAT: number;
34
+ readonly DONE: number;
35
+ }
36
+ /**
37
+ * Filter a stream of server frames into user-visible WaitProgress
38
+ * values. Heartbeat and UNSPECIFIED frames are skipped; DONE frames
39
+ * are emitted once and terminate the iteration.
40
+ */
41
+ export declare function filterWaitStreamFrames(stream: AsyncIterable<WaitStreamFrameLike>, kinds: WaitStreamFrameKinds): AsyncIterable<WaitProgress>;
42
+ //# sourceMappingURL=projection-stream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projection-stream.d.ts","sourceRoot":"","sources":["../src/projection-stream.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,cAAc,EAAE,MAAM,GAAG,MAAM,CAAC;IAChC,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAWD;;;;GAIG;AACH,wBAAuB,sBAAsB,CAC3C,MAAM,EAAE,aAAa,CAAC,mBAAmB,CAAC,EAC1C,KAAK,EAAE,oBAAoB,GAC1B,aAAa,CAAC,YAAY,CAAC,CAqB7B"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Frame-filter logic for waitForProjectionCatchupStream (#476).
3
+ *
4
+ * Extracted from IronflowClient.waitForProjectionCatchupStream so the
5
+ * heartbeat-filter and terminal-short-circuit behavior can be unit
6
+ * tested with a mock async iterable, without loading the @connectrpc
7
+ * transport modules or the generated ProjectionService client.
8
+ */
9
+ /** Coerce bigint-or-number-or-string into bigint without truncation. */
10
+ function toBigInt(v) {
11
+ if (typeof v === "bigint")
12
+ return v;
13
+ if (typeof v === "string")
14
+ return BigInt(v);
15
+ // number case — safe only up to 2^53-1; callers shouldn't hit this path
16
+ // because protobuf-es decodes uint64 to bigint, but guard defensively.
17
+ return BigInt(v);
18
+ }
19
+ /**
20
+ * Filter a stream of server frames into user-visible WaitProgress
21
+ * values. Heartbeat and UNSPECIFIED frames are skipped; DONE frames
22
+ * are emitted once and terminate the iteration.
23
+ */
24
+ export async function* filterWaitStreamFrames(stream, kinds) {
25
+ for await (const frame of stream) {
26
+ if (frame.kind === kinds.HEARTBEAT || frame.kind === kinds.UNSPECIFIED) {
27
+ // Transport-only keepalive + defensive unknown-kind skip.
28
+ continue;
29
+ }
30
+ const p = {
31
+ // Preserve bigint precision — Number() would silently truncate
32
+ // seqs above 2^53-1.
33
+ currentSeq: toBigInt(frame.currentSeq),
34
+ targetSeq: toBigInt(frame.targetSeq),
35
+ behindByEvents: toBigInt(frame.behindByEvents),
36
+ terminal: frame.kind === kinds.DONE,
37
+ caughtUp: frame.caughtUp,
38
+ timedOut: frame.timedOut,
39
+ mode: frame.mode || undefined,
40
+ };
41
+ if (frame.error)
42
+ p.error = frame.error;
43
+ yield p;
44
+ if (p.terminal)
45
+ return;
46
+ }
47
+ }
48
+ //# sourceMappingURL=projection-stream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projection-stream.js","sourceRoot":"","sources":["../src/projection-stream.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAgCH,wEAAwE;AACxE,SAAS,QAAQ,CAAC,CAA2B;IAC3C,IAAI,OAAO,CAAC,KAAK,QAAQ;QAAE,OAAO,CAAC,CAAC;IACpC,IAAI,OAAO,CAAC,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;IAC5C,wEAAwE;IACxE,uEAAuE;IACvE,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;AACnB,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,sBAAsB,CAC3C,MAA0C,EAC1C,KAA2B;IAE3B,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QACjC,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,WAAW,EAAE,CAAC;YACvE,0DAA0D;YAC1D,SAAS;QACX,CAAC;QACD,MAAM,CAAC,GAAiB;YACtB,+DAA+D;YAC/D,qBAAqB;YACrB,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC;YACtC,SAAS,EAAE,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC;YACpC,cAAc,EAAE,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC;YAC9C,QAAQ,EAAE,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI;YACnC,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,SAAS;SAC9B,CAAC;QACF,IAAI,KAAK,CAAC,KAAK;YAAE,CAAC,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QACvC,MAAM,CAAC,CAAC;QACR,IAAI,CAAC,CAAC,QAAQ;YAAE,OAAO;IACzB,CAAC;AACH,CAAC"}
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Subscription management for browser client
3
+ */
4
+ import type { SubscriptionErrorInfo, ConnectionState, SubscribeOptions, Subscription, AckableSubscription, SubscriptionCallbacks, Logger } from "@ironflow/core";
5
+ import type { Transport } from "./transport/types.js";
6
+ /**
7
+ * Extended subscription options for the browser client
8
+ */
9
+ export interface BrowserSubscribeOptions extends SubscribeOptions {
10
+ /** Track last event for state access */
11
+ trackState?: boolean;
12
+ }
13
+ /**
14
+ * Subscription group for batch management
15
+ */
16
+ export interface SubscriptionGroup {
17
+ /** Add a subscription to the group */
18
+ add<T = unknown>(pattern: string, callbacks: SubscriptionCallbacks<T> & BrowserSubscribeOptions): Promise<Subscription | AckableSubscription>;
19
+ /** Unsubscribe all subscriptions in the group */
20
+ unsubscribeAll(): void;
21
+ }
22
+ /**
23
+ * Subscription manager handles all active subscriptions
24
+ */
25
+ export declare class SubscriptionManager {
26
+ private transport;
27
+ private _logger;
28
+ private subscriptions;
29
+ private patternToId;
30
+ private pendingPatterns;
31
+ /** Maps pattern to array of pending lookupKeys for O(1) lookup */
32
+ private patternToPendingKeys;
33
+ private connectionChangeCallbacks;
34
+ private errorCallbacks;
35
+ /** Shared in-flight connect promise so concurrent subscribe() calls don't double-connect. */
36
+ private connectPromise;
37
+ /** Wired in constructor; removed in disconnect(). SSR-guarded. */
38
+ private visibilityListener;
39
+ private readonly autoConnectTimeoutMs;
40
+ /**
41
+ * Count of currently active (non-pending) subscriptions. Surfaced via
42
+ * `ironflow.getActiveSubscriptionCount()` for leak audits and
43
+ * diagnostics.
44
+ */
45
+ get activeSubscriptionCount(): number;
46
+ constructor(transport: Transport, logger?: Logger | false);
47
+ /**
48
+ * Subscribe to events matching a pattern
49
+ */
50
+ subscribe<T = unknown>(pattern: string | string[], callbacksAndOptions: SubscriptionCallbacks<T> & BrowserSubscribeOptions): Promise<Subscription | AckableSubscription>;
51
+ private subscribeSingle;
52
+ /** Remove a pending subscription entry from both tracking maps. */
53
+ private removePending;
54
+ /**
55
+ * Unsubscribe by pattern
56
+ */
57
+ unsubscribeByPattern(pattern: string): void;
58
+ /**
59
+ * Unsubscribe by subscription ID
60
+ */
61
+ unsubscribeById(subscriptionId: string): void;
62
+ /**
63
+ * Create a subscription group for batch management
64
+ */
65
+ createGroup(): SubscriptionGroup;
66
+ /**
67
+ * Add a global connection change callback
68
+ */
69
+ onConnectionChange(callback: (state: ConnectionState) => void): () => void;
70
+ /**
71
+ * Add a global error callback
72
+ */
73
+ onError(callback: (error: SubscriptionErrorInfo) => void): () => void;
74
+ /**
75
+ * Get current connection state
76
+ */
77
+ get connectionState(): ConnectionState;
78
+ /**
79
+ * Connect to the server
80
+ */
81
+ connect(): Promise<void>;
82
+ /**
83
+ * Ensure the transport is connected, sharing a single in-flight connect
84
+ * across concurrent callers. Resolves when `onConnectionChange` reports
85
+ * "connected"; rejects if the transport's connect() throws or the
86
+ * auto-connect timeout elapses.
87
+ */
88
+ private ensureConnected;
89
+ /**
90
+ * Disconnect from the server
91
+ */
92
+ disconnect(): void;
93
+ /**
94
+ * Pause subscriptions (for tab visibility)
95
+ */
96
+ pause(): void;
97
+ /**
98
+ * Resume subscriptions
99
+ */
100
+ resume(): void;
101
+ private handleEvent;
102
+ private handleError;
103
+ private handleConnectionChange;
104
+ private handleSubscribed;
105
+ private handleSubscribeFailed;
106
+ }
107
+ //# sourceMappingURL=subscription.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscription.d.ts","sourceRoot":"","sources":["../src/subscription.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAEV,qBAAqB,EACrB,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,mBAAmB,EACnB,qBAAqB,EACrB,MAAM,EACP,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,SAAS,EAAsB,MAAM,sBAAsB,CAAC;AAE1E;;GAEG;AACH,MAAM,WAAW,uBAAwB,SAAQ,gBAAgB;IAC/D,wCAAwC;IACxC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAkBD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,sCAAsC;IACtC,GAAG,CAAC,CAAC,GAAG,OAAO,EACb,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAAG,uBAAuB,GAC5D,OAAO,CAAC,YAAY,GAAG,mBAAmB,CAAC,CAAC;IAC/C,iDAAiD;IACjD,cAAc,IAAI,IAAI,CAAC;CACxB;AAQD;;GAEG;AACH,qBAAa,mBAAmB;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