@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.
- package/README.md +1 -1
- package/dist/agents/index.d.ts +34 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/index.js +24 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/invoke.d.ts +16 -0
- package/dist/agents/invoke.d.ts.map +1 -0
- package/dist/agents/invoke.js +222 -0
- package/dist/agents/invoke.js.map +1 -0
- package/dist/agents/readMemory.d.ts +18 -0
- package/dist/agents/readMemory.d.ts.map +1 -0
- package/dist/agents/readMemory.js +87 -0
- package/dist/agents/readMemory.js.map +1 -0
- package/dist/agents/subscribe.d.ts +23 -0
- package/dist/agents/subscribe.d.ts.map +1 -0
- package/dist/agents/subscribe.js +117 -0
- package/dist/agents/subscribe.js.map +1 -0
- package/dist/agents/types.d.ts +156 -0
- package/dist/agents/types.d.ts.map +1 -0
- package/dist/agents/types.js +7 -0
- package/dist/agents/types.js.map +1 -0
- package/dist/client.d.ts +844 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +2243 -0
- package/dist/client.js.map +1 -0
- package/dist/config-client.d.ts +43 -0
- package/dist/config-client.d.ts.map +1 -0
- package/dist/config-client.js +134 -0
- package/dist/config-client.js.map +1 -0
- package/dist/config.d.ts +91 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +55 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +53 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -0
- package/dist/kv.d.ts +79 -0
- package/dist/kv.d.ts.map +1 -0
- package/dist/kv.js +289 -0
- package/dist/kv.js.map +1 -0
- package/dist/projection-stream.d.ts +42 -0
- package/dist/projection-stream.d.ts.map +1 -0
- package/dist/projection-stream.js +48 -0
- package/dist/projection-stream.js.map +1 -0
- package/dist/subscription.d.ts +107 -0
- package/dist/subscription.d.ts.map +1 -0
- package/dist/subscription.js +450 -0
- package/dist/subscription.js.map +1 -0
- package/dist/transport/connectrpc.d.ts +74 -0
- package/dist/transport/connectrpc.d.ts.map +1 -0
- package/dist/transport/connectrpc.js +393 -0
- package/dist/transport/connectrpc.js.map +1 -0
- package/dist/transport/index.d.ts +7 -0
- package/dist/transport/index.d.ts.map +1 -0
- package/dist/transport/index.js +6 -0
- package/dist/transport/index.js.map +1 -0
- package/dist/transport/types.d.ts +69 -0
- package/dist/transport/types.d.ts.map +1 -0
- package/dist/transport/types.js +5 -0
- package/dist/transport/types.js.map +1 -0
- package/dist/transport/websocket.d.ts +38 -0
- package/dist/transport/websocket.d.ts.map +1 -0
- package/dist/transport/websocket.js +276 -0
- package/dist/transport/websocket.js.map +1 -0
- package/package.json +3 -3
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,844 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ironflow Browser Client
|
|
3
|
+
*
|
|
4
|
+
* Singleton client for browser-based real-time interactions with Ironflow.
|
|
5
|
+
*/
|
|
6
|
+
import type { Run, ListRunsOptions, ListRunsResult, InvokeResult, EmitOptions, EmitResult, SubscriptionErrorInfo, SubscriptionCallbacks, Subscription, AckableSubscription, ConnectionState, AppendEventInput, AppendOptions, AppendResult, ReadStreamOptions, StreamEvent, StreamInfo, StreamSnapshot, EntitySubscribeOptions, GetProjectionOptions, RebuildProjectionOptions, ProjectionStatusInfo, WaitResult, WaitProgress, QuerySQLProjectionOptions, SQLProjectionQueryResult, ProjectionStateResult, ProjectionSubscriptionCallbacks, TimeTravelRunStateSnapshot, TimeTravelTimelineEvent, TimeTravelStepOutputSnapshot, APIKey, APIKeyWithSecret, CreateAPIKeyInput, Organization, CreateOrgInput, UpdateOrgInput, Role, CreateRoleInput, UpdateRoleInput, Policy, CreatePolicyInput, UpdatePolicyInput, EventSchema, RegisterSchemaInput, TestUpcastInput, UpcastResult, WebhookSource, CreateWebhookSourceInput, WebhookDelivery, ListWebhookDeliveriesOptions, AuditTrailResult, GetAuditTrailOptions, User, CreateUserInput, UpdateUserInput, Tenant } from "@ironflow/core";
|
|
7
|
+
import { type EmitSyncResult } from "@ironflow/core";
|
|
8
|
+
import type { IronflowConfig, IronflowConfigOptions } from "./config.js";
|
|
9
|
+
import { type BrowserSubscribeOptions, type SubscriptionGroup } from "./subscription.js";
|
|
10
|
+
import { BrowserKVClient } from "./kv.js";
|
|
11
|
+
import { BrowserConfigClient } from "./config-client.js";
|
|
12
|
+
import { type AgentsNamespace } from "./agents/index.js";
|
|
13
|
+
/**
|
|
14
|
+
* Ironflow browser client singleton
|
|
15
|
+
*/
|
|
16
|
+
declare class IronflowClient {
|
|
17
|
+
private config;
|
|
18
|
+
private logger;
|
|
19
|
+
private transport;
|
|
20
|
+
private subscriptionManager;
|
|
21
|
+
private visibilityHandler;
|
|
22
|
+
/**
|
|
23
|
+
* `agents` namespace — browser helpers for `agent()` functions.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* const result = await ironflow.agents.invoke("my-agent", { task: "..." });
|
|
28
|
+
* console.log(result.runId, result.output);
|
|
29
|
+
*
|
|
30
|
+
* const sub = await ironflow.agents.subscribe(runId, {
|
|
31
|
+
* onStep: (e) => console.log("step", e.stepId, e.type),
|
|
32
|
+
* onComplete: (r) => console.log("done", r.output),
|
|
33
|
+
* });
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
readonly agents: AgentsNamespace;
|
|
37
|
+
/**
|
|
38
|
+
* Configure the client
|
|
39
|
+
*
|
|
40
|
+
* Must be called before any other operations.
|
|
41
|
+
*/
|
|
42
|
+
configure(options?: IronflowConfigOptions): void;
|
|
43
|
+
/**
|
|
44
|
+
* Check if the client is configured
|
|
45
|
+
*/
|
|
46
|
+
get isConfigured(): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Detect which transport the server supports
|
|
49
|
+
*
|
|
50
|
+
* Returns the best available transport based on server capabilities.
|
|
51
|
+
* ConnectRPC is preferred over WebSocket.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* const transport = await ironflow.detectTransport();
|
|
56
|
+
* // Returns 'connectrpc' | 'websocket'
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
detectTransport(): Promise<"connectrpc" | "websocket">;
|
|
60
|
+
/**
|
|
61
|
+
* Get the current configuration
|
|
62
|
+
*/
|
|
63
|
+
getConfig(): IronflowConfig;
|
|
64
|
+
/**
|
|
65
|
+
* Connect to the Ironflow server
|
|
66
|
+
*/
|
|
67
|
+
connect(): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Disconnect from the Ironflow server
|
|
70
|
+
*/
|
|
71
|
+
disconnect(): void;
|
|
72
|
+
/**
|
|
73
|
+
* Register a callback for connection state changes
|
|
74
|
+
*/
|
|
75
|
+
onConnectionChange(callback: (state: ConnectionState) => void): () => void;
|
|
76
|
+
/**
|
|
77
|
+
* Get current connection state
|
|
78
|
+
*/
|
|
79
|
+
get connectionState(): ConnectionState;
|
|
80
|
+
/**
|
|
81
|
+
* Subscribe to events matching a pattern
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* // Basic subscription
|
|
86
|
+
* const sub = await ironflow.subscribe('events:order.*', {
|
|
87
|
+
* onEvent: (event) => console.log(event),
|
|
88
|
+
* });
|
|
89
|
+
*
|
|
90
|
+
* // Multiple patterns
|
|
91
|
+
* const sub = await ironflow.subscribe(['system.run.*', 'events:order.*'], {
|
|
92
|
+
* onEvent: (event) => { ... }
|
|
93
|
+
* });
|
|
94
|
+
*
|
|
95
|
+
* // With options
|
|
96
|
+
* const sub = await ironflow.subscribe('events:*', {
|
|
97
|
+
* onEvent: (e) => { ... },
|
|
98
|
+
* replay: 10,
|
|
99
|
+
* trackState: true,
|
|
100
|
+
* ackMode: 'manual',
|
|
101
|
+
* });
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
subscribe<T = unknown>(pattern: string | string[], callbacksAndOptions: SubscriptionCallbacks<T> & BrowserSubscribeOptions): Promise<Subscription | AckableSubscription>;
|
|
105
|
+
/**
|
|
106
|
+
* Create a subscription group for batch management
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* const group = ironflow.subscriptionGroup();
|
|
111
|
+
* await group.add('system.run.*', { onEvent: handleRun });
|
|
112
|
+
* await group.add('events:payment.*', { onEvent: handlePayment });
|
|
113
|
+
* // Later:
|
|
114
|
+
* group.unsubscribeAll();
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
subscriptionGroup(): SubscriptionGroup;
|
|
118
|
+
/**
|
|
119
|
+
* Register a global error handler
|
|
120
|
+
*/
|
|
121
|
+
onError(callback: (error: SubscriptionErrorInfo) => void): () => void;
|
|
122
|
+
/**
|
|
123
|
+
* Number of currently active subscriptions. Useful for leak audits and
|
|
124
|
+
* diagnostics. Returns 0 if the client is not configured.
|
|
125
|
+
*/
|
|
126
|
+
getActiveSubscriptionCount(): number;
|
|
127
|
+
/**
|
|
128
|
+
* Invoke a workflow function by ID
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```typescript
|
|
132
|
+
* const run = await ironflow.invoke<OrderInput, OrderOutput>('process-order', {
|
|
133
|
+
* data: { orderId: '123' }
|
|
134
|
+
* });
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
invoke<TInput = unknown>(functionId: string, options: {
|
|
138
|
+
data: TInput;
|
|
139
|
+
idempotencyKey?: string;
|
|
140
|
+
}): Promise<InvokeResult>;
|
|
141
|
+
/**
|
|
142
|
+
* Get run status
|
|
143
|
+
*/
|
|
144
|
+
getRun(runId: string): Promise<Run>;
|
|
145
|
+
/**
|
|
146
|
+
* List runs with filtering
|
|
147
|
+
*/
|
|
148
|
+
listRuns(options?: ListRunsOptions): Promise<ListRunsResult>;
|
|
149
|
+
/**
|
|
150
|
+
* Cancel a running run
|
|
151
|
+
*/
|
|
152
|
+
cancelRun(runId: string, reason?: string): Promise<Run>;
|
|
153
|
+
/**
|
|
154
|
+
* Retry a failed run
|
|
155
|
+
*/
|
|
156
|
+
retryRun(runId: string, fromStep?: string): Promise<Run>;
|
|
157
|
+
/**
|
|
158
|
+
* Patch a step's output (hot patching)
|
|
159
|
+
*/
|
|
160
|
+
patchStep(stepId: string, output: Record<string, unknown>, reason?: string): Promise<void>;
|
|
161
|
+
/**
|
|
162
|
+
* Resume a paused or failed run
|
|
163
|
+
*/
|
|
164
|
+
resumeRun(runId: string, fromStep?: string): Promise<Run>;
|
|
165
|
+
/**
|
|
166
|
+
* Pause a running workflow at the next step boundary (scoped injection).
|
|
167
|
+
*/
|
|
168
|
+
pauseRun(runId: string): Promise<{
|
|
169
|
+
status: string;
|
|
170
|
+
}>;
|
|
171
|
+
/**
|
|
172
|
+
* Get the paused state of a run, including completed steps and next step hint.
|
|
173
|
+
*/
|
|
174
|
+
getPausedState(runId: string): Promise<{
|
|
175
|
+
steps: Array<{
|
|
176
|
+
id: string;
|
|
177
|
+
name: string;
|
|
178
|
+
output: unknown;
|
|
179
|
+
injected: boolean;
|
|
180
|
+
completedAt: string;
|
|
181
|
+
}>;
|
|
182
|
+
nextStepHint: string;
|
|
183
|
+
pauseReason: string;
|
|
184
|
+
}>;
|
|
185
|
+
/**
|
|
186
|
+
* Inject new output for a step in a paused run (scoped injection).
|
|
187
|
+
*/
|
|
188
|
+
injectStepOutput(runId: string, stepId: string, newOutput: unknown, reason?: string): Promise<{
|
|
189
|
+
stepId: string;
|
|
190
|
+
previousOutput: unknown;
|
|
191
|
+
}>;
|
|
192
|
+
/**
|
|
193
|
+
* Get the reconstructed state of a run at a specific timestamp.
|
|
194
|
+
*/
|
|
195
|
+
getRunStateAt(runId: string, timestamp: Date): Promise<TimeTravelRunStateSnapshot>;
|
|
196
|
+
/**
|
|
197
|
+
* Get the timeline of audit events for a run.
|
|
198
|
+
*/
|
|
199
|
+
getRunTimeline(runId: string): Promise<TimeTravelTimelineEvent[]>;
|
|
200
|
+
/**
|
|
201
|
+
* Get the output of a specific step at a specific timestamp.
|
|
202
|
+
*/
|
|
203
|
+
getStepOutputAt(runId: string, stepId: string, timestamp: Date): Promise<TimeTravelStepOutputSnapshot>;
|
|
204
|
+
/**
|
|
205
|
+
* List registered functions
|
|
206
|
+
*/
|
|
207
|
+
listFunctions(): Promise<unknown[]>;
|
|
208
|
+
/**
|
|
209
|
+
* List connected workers
|
|
210
|
+
*/
|
|
211
|
+
listWorkers(): Promise<unknown[]>;
|
|
212
|
+
/**
|
|
213
|
+
* Health check
|
|
214
|
+
*/
|
|
215
|
+
health(): Promise<{
|
|
216
|
+
status: string;
|
|
217
|
+
timestamp: string;
|
|
218
|
+
version: string;
|
|
219
|
+
}>;
|
|
220
|
+
/**
|
|
221
|
+
* Get server capabilities
|
|
222
|
+
*/
|
|
223
|
+
getCapabilities(): Promise<{
|
|
224
|
+
transports: string[];
|
|
225
|
+
features: string[];
|
|
226
|
+
version: string;
|
|
227
|
+
}>;
|
|
228
|
+
/**
|
|
229
|
+
* Emit an event
|
|
230
|
+
*
|
|
231
|
+
* @example
|
|
232
|
+
* ```typescript
|
|
233
|
+
* await ironflow.emit('order.approved', {
|
|
234
|
+
* orderId: '123',
|
|
235
|
+
* approvedBy: 'user@example.com'
|
|
236
|
+
* });
|
|
237
|
+
* ```
|
|
238
|
+
*/
|
|
239
|
+
emit(eventName: string, data: unknown, options?: EmitOptions): Promise<EmitResult>;
|
|
240
|
+
/**
|
|
241
|
+
* Emit an event synchronously — waits for the triggered run to complete and returns the result.
|
|
242
|
+
*
|
|
243
|
+
* Calls the TriggerSync endpoint, which blocks until the run finishes or the timeout elapses.
|
|
244
|
+
* Throws RunFailedError if the run fails, RunCancelledError if it is cancelled.
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* ```typescript
|
|
248
|
+
* const result = await ironflow.emitSync("order.placed", { orderId: "123" });
|
|
249
|
+
* console.log("Output:", result.output);
|
|
250
|
+
* ```
|
|
251
|
+
*/
|
|
252
|
+
emitSync(eventName: string, data: unknown, options?: {
|
|
253
|
+
timeout?: number;
|
|
254
|
+
}): Promise<EmitSyncResult>;
|
|
255
|
+
/**
|
|
256
|
+
* Join a consumer group for load-balanced event processing
|
|
257
|
+
*/
|
|
258
|
+
joinConsumerGroup<T = unknown>(groupName: string, pattern: string, callbacksAndOptions: SubscriptionCallbacks<T> & BrowserSubscribeOptions): Promise<AckableSubscription>;
|
|
259
|
+
/**
|
|
260
|
+
* Entity stream operations
|
|
261
|
+
*
|
|
262
|
+
* @example
|
|
263
|
+
* ```typescript
|
|
264
|
+
* // Append an event to a stream
|
|
265
|
+
* const result = await ironflow.streams.append("order-123", {
|
|
266
|
+
* name: "order.created",
|
|
267
|
+
* data: { total: 100 },
|
|
268
|
+
* entityType: "order",
|
|
269
|
+
* });
|
|
270
|
+
*
|
|
271
|
+
* // Read events from a stream
|
|
272
|
+
* const { events } = await ironflow.streams.read("order-123", { limit: 10 });
|
|
273
|
+
*
|
|
274
|
+
* // Get stream info
|
|
275
|
+
* const info = await ironflow.streams.getInfo("order-123");
|
|
276
|
+
* ```
|
|
277
|
+
*/
|
|
278
|
+
streams: {
|
|
279
|
+
/**
|
|
280
|
+
* Append an event to an entity stream
|
|
281
|
+
*/
|
|
282
|
+
append: (entityId: string, input: AppendEventInput, options?: AppendOptions) => Promise<AppendResult>;
|
|
283
|
+
/**
|
|
284
|
+
* Read events from an entity stream
|
|
285
|
+
*/
|
|
286
|
+
read: (entityId: string, options?: ReadStreamOptions) => Promise<{
|
|
287
|
+
events: StreamEvent[];
|
|
288
|
+
totalCount: number;
|
|
289
|
+
}>;
|
|
290
|
+
/**
|
|
291
|
+
* Get information about an entity stream.
|
|
292
|
+
*
|
|
293
|
+
* Returns `null` if no events have been written to this stream yet — safe to
|
|
294
|
+
* pass `expectedVersion: 0` to `append()` in that case to create the first event.
|
|
295
|
+
*
|
|
296
|
+
* @example
|
|
297
|
+
* ```typescript
|
|
298
|
+
* const info = await ironflow.streams.getInfo("order-123");
|
|
299
|
+
* await ironflow.streams.append("order-123", event, {
|
|
300
|
+
* expectedVersion: info ? info.version : 0,
|
|
301
|
+
* });
|
|
302
|
+
* ```
|
|
303
|
+
*/
|
|
304
|
+
getInfo: (entityId: string) => Promise<StreamInfo | null>;
|
|
305
|
+
/**
|
|
306
|
+
* Create a snapshot of the materialized state at a specific stream version.
|
|
307
|
+
*/
|
|
308
|
+
createSnapshot: (entityId: string, input: {
|
|
309
|
+
entityType: string;
|
|
310
|
+
entityVersion: number;
|
|
311
|
+
state: Record<string, unknown>;
|
|
312
|
+
}) => Promise<{
|
|
313
|
+
snapshotId: string;
|
|
314
|
+
}>;
|
|
315
|
+
/**
|
|
316
|
+
* Get the latest snapshot at or before a given version.
|
|
317
|
+
*/
|
|
318
|
+
getSnapshot: (entityId: string, options?: {
|
|
319
|
+
beforeVersion?: number;
|
|
320
|
+
}) => Promise<StreamSnapshot>;
|
|
321
|
+
/**
|
|
322
|
+
* Subscribe to real-time events for an entity stream
|
|
323
|
+
*
|
|
324
|
+
* @example
|
|
325
|
+
* ```typescript
|
|
326
|
+
* const sub = await ironflow.streams.subscribe("order-123", {
|
|
327
|
+
* entityType: "order",
|
|
328
|
+
* onEvent: (event) => console.log(event),
|
|
329
|
+
* replay: 100,
|
|
330
|
+
* });
|
|
331
|
+
*
|
|
332
|
+
* // Cleanup
|
|
333
|
+
* sub.unsubscribe();
|
|
334
|
+
* ```
|
|
335
|
+
*/
|
|
336
|
+
subscribe: (entityId: string, options: EntitySubscribeOptions) => Promise<Subscription>;
|
|
337
|
+
};
|
|
338
|
+
/**
|
|
339
|
+
* Get the current state of a projection
|
|
340
|
+
*
|
|
341
|
+
* @example
|
|
342
|
+
* ```typescript
|
|
343
|
+
* const result = await ironflow.getProjection<OrderStats>('order-stats');
|
|
344
|
+
* console.log(result.state); // { totalOrders: 42, ... }
|
|
345
|
+
*
|
|
346
|
+
* // With partition
|
|
347
|
+
* const result = await ironflow.getProjection('order-stats', { partition: 'customer-123' });
|
|
348
|
+
* ```
|
|
349
|
+
*/
|
|
350
|
+
getProjection<TState = unknown>(name: string, options?: GetProjectionOptions): Promise<ProjectionStateResult<TState>>;
|
|
351
|
+
/**
|
|
352
|
+
* Query a SQL-backed projection table with optional filtering, ordering, and pagination.
|
|
353
|
+
*
|
|
354
|
+
* @example
|
|
355
|
+
* ```typescript
|
|
356
|
+
* const result = await ironflow.querySQLProjection('board', {
|
|
357
|
+
* where: "status = 'OPEN'",
|
|
358
|
+
* orderBy: "title ASC",
|
|
359
|
+
* limit: 50,
|
|
360
|
+
* });
|
|
361
|
+
* ```
|
|
362
|
+
*/
|
|
363
|
+
querySQLProjection(name: string, options?: QuerySQLProjectionOptions): Promise<SQLProjectionQueryResult>;
|
|
364
|
+
/**
|
|
365
|
+
* Get the status of a projection
|
|
366
|
+
*
|
|
367
|
+
* @example
|
|
368
|
+
* ```typescript
|
|
369
|
+
* const status = await ironflow.getProjectionStatus('order-stats');
|
|
370
|
+
* console.log(status.status); // 'active' | 'rebuilding' | 'paused' | 'error'
|
|
371
|
+
* ```
|
|
372
|
+
*/
|
|
373
|
+
getProjectionStatus(name: string): Promise<ProjectionStatusInfo>;
|
|
374
|
+
/**
|
|
375
|
+
* Trigger a rebuild of a projection
|
|
376
|
+
*
|
|
377
|
+
* @example
|
|
378
|
+
* ```typescript
|
|
379
|
+
* const result = await ironflow.rebuildProjection('order-stats');
|
|
380
|
+
* ```
|
|
381
|
+
*/
|
|
382
|
+
rebuildProjection(name: string, options?: RebuildProjectionOptions): Promise<{
|
|
383
|
+
status: string;
|
|
384
|
+
}>;
|
|
385
|
+
/**
|
|
386
|
+
* Wait until the named projection has processed events up to `minSeq`,
|
|
387
|
+
* or the timeout elapses. Read-your-writes primitive for CQRS UIs:
|
|
388
|
+
* pair with `sequence` from an `appendEntityEvent` response.
|
|
389
|
+
*
|
|
390
|
+
* Issue #473.
|
|
391
|
+
*/
|
|
392
|
+
waitForProjectionCatchup(name: string, opts: {
|
|
393
|
+
minSeq: number | bigint;
|
|
394
|
+
timeoutMs?: number;
|
|
395
|
+
partition?: string;
|
|
396
|
+
}): Promise<WaitResult>;
|
|
397
|
+
/**
|
|
398
|
+
* Streaming wait for a projection to catch up to `minSeq` (issue #476).
|
|
399
|
+
*
|
|
400
|
+
* Returns an `AsyncIterable<WaitProgress>` that yields a frame each time
|
|
401
|
+
* the projection cursor advances, plus one terminal frame (`terminal:
|
|
402
|
+
* true`) on catch-up, timeout, or error, after which iteration ends.
|
|
403
|
+
* Heartbeats are filtered inside the SDK — callers never see them.
|
|
404
|
+
*
|
|
405
|
+
* Unlike the unary `waitForProjectionCatchup`, this path uses a
|
|
406
|
+
* server-streaming ConnectRPC connection. The server caps the wait at
|
|
407
|
+
* 300s regardless of `timeoutMs`. Pass `opts.signal` to cancel early
|
|
408
|
+
* (e.g., on React unmount); breaking out of `for await` also aborts
|
|
409
|
+
* the stream.
|
|
410
|
+
*
|
|
411
|
+
* Example:
|
|
412
|
+
* ```ts
|
|
413
|
+
* for await (const p of ironflow.waitForProjectionCatchupStream("order-view", { minSeq: 42 })) {
|
|
414
|
+
* if (p.terminal) {
|
|
415
|
+
* if (p.caughtUp) return;
|
|
416
|
+
* throw new Error(`wait failed: timedOut=${p.timedOut} error=${p.error}`);
|
|
417
|
+
* }
|
|
418
|
+
* console.log(`progress: ${p.currentSeq}/${p.targetSeq} behind=${p.behindByEvents}`);
|
|
419
|
+
* }
|
|
420
|
+
* ```
|
|
421
|
+
*/
|
|
422
|
+
waitForProjectionCatchupStream(name: string, opts: {
|
|
423
|
+
minSeq: number | bigint;
|
|
424
|
+
timeoutMs?: number;
|
|
425
|
+
partition?: string;
|
|
426
|
+
signal?: AbortSignal;
|
|
427
|
+
}): AsyncIterable<WaitProgress>;
|
|
428
|
+
/**
|
|
429
|
+
* Wait for a specific event to be processed by the given projection.
|
|
430
|
+
* The server resolves `eventId` to its NATS sequence internally.
|
|
431
|
+
*
|
|
432
|
+
* Issue #473.
|
|
433
|
+
*/
|
|
434
|
+
waitForEvent(eventId: string, projection: string, opts?: {
|
|
435
|
+
timeoutMs?: number;
|
|
436
|
+
partition?: string;
|
|
437
|
+
}): Promise<WaitResult>;
|
|
438
|
+
/**
|
|
439
|
+
* List all registered projections
|
|
440
|
+
*
|
|
441
|
+
* @example
|
|
442
|
+
* ```typescript
|
|
443
|
+
* const projections = await ironflow.listProjections();
|
|
444
|
+
* projections.forEach(p => console.log(p.name, p.status));
|
|
445
|
+
* ```
|
|
446
|
+
*/
|
|
447
|
+
listProjections(): Promise<ProjectionStatusInfo[]>;
|
|
448
|
+
/**
|
|
449
|
+
* Subscribe to real-time updates for a projection
|
|
450
|
+
*
|
|
451
|
+
* @example
|
|
452
|
+
* ```typescript
|
|
453
|
+
* const sub = await ironflow.subscribeToProjection<OrderStats>('order-stats', {
|
|
454
|
+
* onUpdate: (state, event) => console.log('Updated:', state),
|
|
455
|
+
* onError: (error) => console.error(error),
|
|
456
|
+
* });
|
|
457
|
+
*
|
|
458
|
+
* // With partition
|
|
459
|
+
* const sub = await ironflow.subscribeToProjection('order-stats', {
|
|
460
|
+
* onUpdate: (state, event) => console.log('Updated:', state),
|
|
461
|
+
* }, { partition: 'customer-123' });
|
|
462
|
+
*
|
|
463
|
+
* // Cleanup
|
|
464
|
+
* sub.unsubscribe();
|
|
465
|
+
* ```
|
|
466
|
+
*/
|
|
467
|
+
subscribeToProjection<TState = unknown>(name: string, callbacks: ProjectionSubscriptionCallbacks<TState>, options?: {
|
|
468
|
+
partition?: string;
|
|
469
|
+
replay?: number;
|
|
470
|
+
}): Promise<Subscription>;
|
|
471
|
+
/**
|
|
472
|
+
* KV store operations
|
|
473
|
+
*
|
|
474
|
+
* @example
|
|
475
|
+
* ```typescript
|
|
476
|
+
* const kv = ironflow.kv();
|
|
477
|
+
* const bucket = await kv.createBucket({ name: "sessions", ttlSeconds: 3600 });
|
|
478
|
+
* const handle = kv.bucket("sessions");
|
|
479
|
+
* const { revision } = await handle.put("user.123", { token: "abc" });
|
|
480
|
+
* const entry = await handle.get("user.123");
|
|
481
|
+
*
|
|
482
|
+
* // Watch for changes
|
|
483
|
+
* const watcher = handle.watch({
|
|
484
|
+
* onUpdate: (event) => console.log(event),
|
|
485
|
+
* }, { key: "user.*" });
|
|
486
|
+
* ```
|
|
487
|
+
*/
|
|
488
|
+
kv(): BrowserKVClient;
|
|
489
|
+
/**
|
|
490
|
+
* Config management operations
|
|
491
|
+
*
|
|
492
|
+
* @example
|
|
493
|
+
* ```typescript
|
|
494
|
+
* const cfg = ironflow.configManager();
|
|
495
|
+
* await cfg.set("app", { featureX: true, maxRetries: 3 });
|
|
496
|
+
* const { data, revision } = await cfg.get("app");
|
|
497
|
+
* await cfg.patch("app", { maxRetries: 5 });
|
|
498
|
+
* const configs = await cfg.list();
|
|
499
|
+
* await cfg.delete("app");
|
|
500
|
+
*
|
|
501
|
+
* // Watch for changes
|
|
502
|
+
* const sub = await cfg.watch("app", {
|
|
503
|
+
* onEvent: (config) => console.log(config),
|
|
504
|
+
* });
|
|
505
|
+
* sub.unsubscribe();
|
|
506
|
+
* ```
|
|
507
|
+
*/
|
|
508
|
+
configManager(): BrowserConfigClient;
|
|
509
|
+
/**
|
|
510
|
+
* API key management operations
|
|
511
|
+
*
|
|
512
|
+
* @example
|
|
513
|
+
* ```typescript
|
|
514
|
+
* // Create an API key
|
|
515
|
+
* const key = await ironflow.apiKeys.create({ name: "my-key" });
|
|
516
|
+
* console.log(key.key); // Only shown once
|
|
517
|
+
*
|
|
518
|
+
* // List API keys
|
|
519
|
+
* const keys = await ironflow.apiKeys.list();
|
|
520
|
+
*
|
|
521
|
+
* // Delete an API key
|
|
522
|
+
* await ironflow.apiKeys.delete(key.id);
|
|
523
|
+
* ```
|
|
524
|
+
*/
|
|
525
|
+
readonly apiKeys: {
|
|
526
|
+
/**
|
|
527
|
+
* Create a new API key
|
|
528
|
+
*/
|
|
529
|
+
create: (input: CreateAPIKeyInput) => Promise<APIKeyWithSecret>;
|
|
530
|
+
/**
|
|
531
|
+
* List all API keys
|
|
532
|
+
*/
|
|
533
|
+
list: () => Promise<APIKey[]>;
|
|
534
|
+
/**
|
|
535
|
+
* Get an API key by ID
|
|
536
|
+
*/
|
|
537
|
+
get: (id: string) => Promise<APIKey>;
|
|
538
|
+
/**
|
|
539
|
+
* Delete an API key
|
|
540
|
+
*/
|
|
541
|
+
delete: (id: string) => Promise<void>;
|
|
542
|
+
/**
|
|
543
|
+
* Rotate an API key, returning a new secret
|
|
544
|
+
*/
|
|
545
|
+
rotate: (id: string) => Promise<APIKeyWithSecret>;
|
|
546
|
+
};
|
|
547
|
+
/**
|
|
548
|
+
* Organization management operations (enterprise-only)
|
|
549
|
+
*
|
|
550
|
+
* @example
|
|
551
|
+
* ```typescript
|
|
552
|
+
* // Create an organization
|
|
553
|
+
* const org = await ironflow.orgs.create({ name: "Acme Corp" });
|
|
554
|
+
*
|
|
555
|
+
* // List organizations
|
|
556
|
+
* const orgs = await ironflow.orgs.list();
|
|
557
|
+
*
|
|
558
|
+
* // Update an organization
|
|
559
|
+
* await ironflow.orgs.update(org.id, { name: "Acme Inc" });
|
|
560
|
+
* ```
|
|
561
|
+
*/
|
|
562
|
+
readonly orgs: {
|
|
563
|
+
/**
|
|
564
|
+
* Create a new organization
|
|
565
|
+
*/
|
|
566
|
+
create: (input: CreateOrgInput) => Promise<Organization>;
|
|
567
|
+
/**
|
|
568
|
+
* List all organizations
|
|
569
|
+
*/
|
|
570
|
+
list: () => Promise<Organization[]>;
|
|
571
|
+
/**
|
|
572
|
+
* Get an organization by ID
|
|
573
|
+
*/
|
|
574
|
+
get: (id: string) => Promise<Organization>;
|
|
575
|
+
/**
|
|
576
|
+
* Update an organization
|
|
577
|
+
*/
|
|
578
|
+
update: (id: string, input: UpdateOrgInput) => Promise<Organization>;
|
|
579
|
+
/**
|
|
580
|
+
* Delete an organization
|
|
581
|
+
*/
|
|
582
|
+
delete: (id: string) => Promise<void>;
|
|
583
|
+
};
|
|
584
|
+
/**
|
|
585
|
+
* Role management operations (enterprise-only)
|
|
586
|
+
*
|
|
587
|
+
* @example
|
|
588
|
+
* ```typescript
|
|
589
|
+
* // Create a role
|
|
590
|
+
* const role = await ironflow.roles.create({ name: "editor", org_id: "org-1" });
|
|
591
|
+
*
|
|
592
|
+
* // Assign a policy to the role
|
|
593
|
+
* await ironflow.roles.assignPolicy(role.id, policyId);
|
|
594
|
+
*
|
|
595
|
+
* // List roles
|
|
596
|
+
* const roles = await ironflow.roles.list();
|
|
597
|
+
* ```
|
|
598
|
+
*/
|
|
599
|
+
readonly roles: {
|
|
600
|
+
/**
|
|
601
|
+
* Create a new role
|
|
602
|
+
*/
|
|
603
|
+
create: (input: CreateRoleInput) => Promise<Role>;
|
|
604
|
+
/**
|
|
605
|
+
* List all roles
|
|
606
|
+
*/
|
|
607
|
+
list: (orgId?: string) => Promise<Role[]>;
|
|
608
|
+
/**
|
|
609
|
+
* Get a role by ID
|
|
610
|
+
*/
|
|
611
|
+
get: (id: string) => Promise<Role>;
|
|
612
|
+
/**
|
|
613
|
+
* Update a role
|
|
614
|
+
*/
|
|
615
|
+
update: (id: string, input: UpdateRoleInput) => Promise<Role>;
|
|
616
|
+
/**
|
|
617
|
+
* Delete a role
|
|
618
|
+
*/
|
|
619
|
+
delete: (id: string) => Promise<void>;
|
|
620
|
+
/**
|
|
621
|
+
* Assign a policy to a role
|
|
622
|
+
*/
|
|
623
|
+
assignPolicy: (roleId: string, policyId: string) => Promise<void>;
|
|
624
|
+
/**
|
|
625
|
+
* Remove a policy from a role
|
|
626
|
+
*/
|
|
627
|
+
removePolicy: (roleId: string, policyId: string) => Promise<void>;
|
|
628
|
+
};
|
|
629
|
+
/**
|
|
630
|
+
* Policy management operations (enterprise-only)
|
|
631
|
+
*
|
|
632
|
+
* @example
|
|
633
|
+
* ```typescript
|
|
634
|
+
* // Create a policy
|
|
635
|
+
* const policy = await ironflow.policies.create({
|
|
636
|
+
* name: "allow-read",
|
|
637
|
+
* effect: "allow",
|
|
638
|
+
* actions: "read",
|
|
639
|
+
* resources: "*",
|
|
640
|
+
* org_id: "org-1",
|
|
641
|
+
* });
|
|
642
|
+
*
|
|
643
|
+
* // List policies
|
|
644
|
+
* const policies = await ironflow.policies.list();
|
|
645
|
+
* ```
|
|
646
|
+
*/
|
|
647
|
+
readonly policies: {
|
|
648
|
+
/**
|
|
649
|
+
* Create a new policy
|
|
650
|
+
*/
|
|
651
|
+
create: (input: CreatePolicyInput) => Promise<Policy>;
|
|
652
|
+
/**
|
|
653
|
+
* List all policies
|
|
654
|
+
*/
|
|
655
|
+
list: (orgId?: string) => Promise<Policy[]>;
|
|
656
|
+
/**
|
|
657
|
+
* Get a policy by ID
|
|
658
|
+
*/
|
|
659
|
+
get: (id: string) => Promise<Policy>;
|
|
660
|
+
/**
|
|
661
|
+
* Update a policy
|
|
662
|
+
*/
|
|
663
|
+
update: (id: string, input: UpdatePolicyInput) => Promise<Policy>;
|
|
664
|
+
/**
|
|
665
|
+
* Delete a policy
|
|
666
|
+
*/
|
|
667
|
+
delete: (id: string) => Promise<void>;
|
|
668
|
+
};
|
|
669
|
+
/**
|
|
670
|
+
* Event schema registry operations
|
|
671
|
+
*
|
|
672
|
+
* @example
|
|
673
|
+
* ```typescript
|
|
674
|
+
* // Register a schema
|
|
675
|
+
* const schema = await ironflow.schemas.register({
|
|
676
|
+
* name: "order.placed",
|
|
677
|
+
* version: 1,
|
|
678
|
+
* schema: { type: "object", properties: { orderId: { type: "string" } } },
|
|
679
|
+
* });
|
|
680
|
+
*
|
|
681
|
+
* // List all schemas
|
|
682
|
+
* const schemas = await ironflow.schemas.list();
|
|
683
|
+
*
|
|
684
|
+
* // Get latest version of a schema
|
|
685
|
+
* const latest = await ironflow.schemas.get("order.placed");
|
|
686
|
+
*
|
|
687
|
+
* // Test an upcast transformation
|
|
688
|
+
* const result = await ironflow.schemas.testUpcast({
|
|
689
|
+
* eventName: "order.placed",
|
|
690
|
+
* fromVersion: 1,
|
|
691
|
+
* toVersion: 2,
|
|
692
|
+
* data: { orderId: "123" },
|
|
693
|
+
* });
|
|
694
|
+
* ```
|
|
695
|
+
*/
|
|
696
|
+
readonly schemas: {
|
|
697
|
+
/** Register a new event schema (or a new version of an existing schema) */
|
|
698
|
+
register: (input: RegisterSchemaInput) => Promise<EventSchema>;
|
|
699
|
+
/** List all registered event schemas */
|
|
700
|
+
list: () => Promise<EventSchema[]>;
|
|
701
|
+
/** Get the latest version of an event schema by name */
|
|
702
|
+
get: (name: string) => Promise<EventSchema>;
|
|
703
|
+
/** Get a specific version of an event schema */
|
|
704
|
+
getVersion: (name: string, version: number) => Promise<EventSchema>;
|
|
705
|
+
/** Delete a specific version of an event schema */
|
|
706
|
+
delete: (name: string, version: number) => Promise<void>;
|
|
707
|
+
/** Test an upcast transformation between two schema versions */
|
|
708
|
+
testUpcast: (input: TestUpcastInput) => Promise<UpcastResult>;
|
|
709
|
+
};
|
|
710
|
+
/**
|
|
711
|
+
* Get the audit trail for a run.
|
|
712
|
+
*
|
|
713
|
+
* @param runId The run ID to retrieve the audit trail for
|
|
714
|
+
* @param options Optional filtering options
|
|
715
|
+
*
|
|
716
|
+
* @example
|
|
717
|
+
* ```typescript
|
|
718
|
+
* const result = await ironflow.getAuditTrail("run-abc123");
|
|
719
|
+
* for (const event of result.events) {
|
|
720
|
+
* console.log(event.eventType, event.createdAt);
|
|
721
|
+
* }
|
|
722
|
+
* ```
|
|
723
|
+
*/
|
|
724
|
+
getAuditTrail(runId: string, options?: GetAuditTrailOptions): Promise<AuditTrailResult>;
|
|
725
|
+
/**
|
|
726
|
+
* Webhook management operations
|
|
727
|
+
*
|
|
728
|
+
* @example
|
|
729
|
+
* ```typescript
|
|
730
|
+
* // List all webhook sources
|
|
731
|
+
* const sources = await ironflow.webhooks.listSources();
|
|
732
|
+
*
|
|
733
|
+
* // Delete a webhook source
|
|
734
|
+
* await ironflow.webhooks.deleteSource("my-webhook");
|
|
735
|
+
*
|
|
736
|
+
* // List deliveries
|
|
737
|
+
* const { deliveries } = await ironflow.webhooks.listDeliveries({ sourceId: "my-webhook" });
|
|
738
|
+
* ```
|
|
739
|
+
*/
|
|
740
|
+
readonly webhooks: {
|
|
741
|
+
/** Create a new webhook source */
|
|
742
|
+
create: (input: CreateWebhookSourceInput) => Promise<WebhookSource>;
|
|
743
|
+
/** List all registered webhook sources */
|
|
744
|
+
listSources: () => Promise<WebhookSource[]>;
|
|
745
|
+
/** Delete a webhook source by ID */
|
|
746
|
+
deleteSource: (id: string) => Promise<void>;
|
|
747
|
+
/** List webhook deliveries with optional filtering */
|
|
748
|
+
listDeliveries: (opts?: ListWebhookDeliveriesOptions) => Promise<{
|
|
749
|
+
deliveries: WebhookDelivery[];
|
|
750
|
+
totalCount: number;
|
|
751
|
+
}>;
|
|
752
|
+
};
|
|
753
|
+
/**
|
|
754
|
+
* User management operations
|
|
755
|
+
*
|
|
756
|
+
* @example
|
|
757
|
+
* ```typescript
|
|
758
|
+
* // List all users
|
|
759
|
+
* const users = await ironflow.users.list();
|
|
760
|
+
*
|
|
761
|
+
* // Create a user
|
|
762
|
+
* const user = await ironflow.users.create({
|
|
763
|
+
* email: "alice@example.com",
|
|
764
|
+
* password: "secret",
|
|
765
|
+
* roles: ["admin"],
|
|
766
|
+
* });
|
|
767
|
+
*
|
|
768
|
+
* // Update a user
|
|
769
|
+
* await ironflow.users.update(user.id, { name: "Alice" });
|
|
770
|
+
* ```
|
|
771
|
+
*/
|
|
772
|
+
readonly users: {
|
|
773
|
+
/** Create a new user (admin only) */
|
|
774
|
+
create: (input: CreateUserInput) => Promise<User>;
|
|
775
|
+
/** List all users in the current organization (admin only) */
|
|
776
|
+
list: () => Promise<User[]>;
|
|
777
|
+
/** Get a user by ID */
|
|
778
|
+
get: (id: string) => Promise<User>;
|
|
779
|
+
/** Update a user's profile (admin only) */
|
|
780
|
+
update: (id: string, input: UpdateUserInput) => Promise<User>;
|
|
781
|
+
/** Delete a user (admin only) */
|
|
782
|
+
delete: (id: string) => Promise<void>;
|
|
783
|
+
};
|
|
784
|
+
/**
|
|
785
|
+
* Tenant management operations (enterprise-only)
|
|
786
|
+
*
|
|
787
|
+
* @example
|
|
788
|
+
* ```typescript
|
|
789
|
+
* // List all tenants
|
|
790
|
+
* const tenants = await ironflow.tenants.list();
|
|
791
|
+
* ```
|
|
792
|
+
*/
|
|
793
|
+
readonly tenants: {
|
|
794
|
+
/** List all tenants (enterprise-only) */
|
|
795
|
+
list: () => Promise<Tenant[]>;
|
|
796
|
+
};
|
|
797
|
+
/**
|
|
798
|
+
* Pattern helpers for building subscription patterns
|
|
799
|
+
*/
|
|
800
|
+
static patterns: {
|
|
801
|
+
readonly allRuns: () => string;
|
|
802
|
+
readonly run: (runId: string) => string;
|
|
803
|
+
readonly runLifecycle: (runId: string) => string;
|
|
804
|
+
readonly runSteps: (runId: string) => string;
|
|
805
|
+
readonly allFunctions: () => string;
|
|
806
|
+
readonly function: (functionId: string) => string;
|
|
807
|
+
readonly userEvent: (eventName: string) => string;
|
|
808
|
+
readonly allUserEvents: () => string;
|
|
809
|
+
readonly allSecrets: () => string;
|
|
810
|
+
readonly secret: (name: string) => string;
|
|
811
|
+
readonly secretAction: (action: string) => string;
|
|
812
|
+
readonly topic: (topicPattern: string) => string;
|
|
813
|
+
readonly allTopics: () => string;
|
|
814
|
+
};
|
|
815
|
+
private ensureConfigured;
|
|
816
|
+
private cleanup;
|
|
817
|
+
/**
|
|
818
|
+
* Reset client state for testing. Not intended for production use.
|
|
819
|
+
* @internal
|
|
820
|
+
*/
|
|
821
|
+
_resetForTesting(): void;
|
|
822
|
+
private setupVisibilityHandling;
|
|
823
|
+
private request;
|
|
824
|
+
private streamRequest;
|
|
825
|
+
/**
|
|
826
|
+
* REST request helper for auth management endpoints.
|
|
827
|
+
*
|
|
828
|
+
* Supports GET, POST, PATCH, DELETE methods with typed error mapping:
|
|
829
|
+
* - 401 → UnauthenticatedError
|
|
830
|
+
* - 402 → EnterpriseRequiredError
|
|
831
|
+
* - 403 → UnauthorizedError
|
|
832
|
+
*/
|
|
833
|
+
private restRequest;
|
|
834
|
+
private mapRunResponse;
|
|
835
|
+
}
|
|
836
|
+
/**
|
|
837
|
+
* Singleton instance
|
|
838
|
+
*/
|
|
839
|
+
export declare const ironflow: IronflowClient;
|
|
840
|
+
/**
|
|
841
|
+
* Export the class for advanced usage
|
|
842
|
+
*/
|
|
843
|
+
export { IronflowClient };
|
|
844
|
+
//# sourceMappingURL=client.d.ts.map
|