@ironflow/browser 0.19.3 → 0.20.2

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