@ironflow/node 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 (91) hide show
  1. package/LICENSE +181 -0
  2. package/README.md +5 -2
  3. package/package.json +20 -14
  4. package/dist/client.d.ts +0 -924
  5. package/dist/client.d.ts.map +0 -1
  6. package/dist/client.js +0 -1526
  7. package/dist/client.js.map +0 -1
  8. package/dist/command-dedup.d.ts +0 -61
  9. package/dist/command-dedup.d.ts.map +0 -1
  10. package/dist/command-dedup.js +0 -129
  11. package/dist/command-dedup.js.map +0 -1
  12. package/dist/config-client.d.ts +0 -58
  13. package/dist/config-client.d.ts.map +0 -1
  14. package/dist/config-client.js +0 -171
  15. package/dist/config-client.js.map +0 -1
  16. package/dist/function.d.ts +0 -53
  17. package/dist/function.d.ts.map +0 -1
  18. package/dist/function.js +0 -56
  19. package/dist/function.js.map +0 -1
  20. package/dist/index.d.ts +0 -71
  21. package/dist/index.d.ts.map +0 -1
  22. package/dist/index.js +0 -70
  23. package/dist/index.js.map +0 -1
  24. package/dist/internal/context.d.ts +0 -142
  25. package/dist/internal/context.d.ts.map +0 -1
  26. package/dist/internal/context.js +0 -306
  27. package/dist/internal/context.js.map +0 -1
  28. package/dist/internal/errors.d.ts +0 -66
  29. package/dist/internal/errors.d.ts.map +0 -1
  30. package/dist/internal/errors.js +0 -29
  31. package/dist/internal/errors.js.map +0 -1
  32. package/dist/internal/run-context.d.ts +0 -10
  33. package/dist/internal/run-context.d.ts.map +0 -1
  34. package/dist/internal/run-context.js +0 -23
  35. package/dist/internal/run-context.js.map +0 -1
  36. package/dist/kv.d.ts +0 -86
  37. package/dist/kv.d.ts.map +0 -1
  38. package/dist/kv.js +0 -261
  39. package/dist/kv.js.map +0 -1
  40. package/dist/projection-runner.d.ts +0 -83
  41. package/dist/projection-runner.d.ts.map +0 -1
  42. package/dist/projection-runner.js +0 -470
  43. package/dist/projection-runner.js.map +0 -1
  44. package/dist/projection.d.ts +0 -36
  45. package/dist/projection.d.ts.map +0 -1
  46. package/dist/projection.js +0 -55
  47. package/dist/projection.js.map +0 -1
  48. package/dist/secrets.d.ts +0 -6
  49. package/dist/secrets.d.ts.map +0 -1
  50. package/dist/secrets.js +0 -19
  51. package/dist/secrets.js.map +0 -1
  52. package/dist/serve.d.ts +0 -71
  53. package/dist/serve.d.ts.map +0 -1
  54. package/dist/serve.js +0 -434
  55. package/dist/serve.js.map +0 -1
  56. package/dist/step.d.ts +0 -18
  57. package/dist/step.d.ts.map +0 -1
  58. package/dist/step.js +0 -581
  59. package/dist/step.js.map +0 -1
  60. package/dist/subscribe.d.ts +0 -164
  61. package/dist/subscribe.d.ts.map +0 -1
  62. package/dist/subscribe.js +0 -487
  63. package/dist/subscribe.js.map +0 -1
  64. package/dist/test/index.d.ts +0 -22
  65. package/dist/test/index.d.ts.map +0 -1
  66. package/dist/test/index.js +0 -112
  67. package/dist/test/index.js.map +0 -1
  68. package/dist/test/test-step.d.ts +0 -21
  69. package/dist/test/test-step.d.ts.map +0 -1
  70. package/dist/test/test-step.js +0 -83
  71. package/dist/test/test-step.js.map +0 -1
  72. package/dist/types.d.ts +0 -108
  73. package/dist/types.d.ts.map +0 -1
  74. package/dist/types.js +0 -5
  75. package/dist/types.js.map +0 -1
  76. package/dist/version.d.ts +0 -2
  77. package/dist/version.d.ts.map +0 -1
  78. package/dist/version.js +0 -4
  79. package/dist/version.js.map +0 -1
  80. package/dist/webhook.d.ts +0 -22
  81. package/dist/webhook.d.ts.map +0 -1
  82. package/dist/webhook.js +0 -23
  83. package/dist/webhook.js.map +0 -1
  84. package/dist/worker-streaming.d.ts +0 -17
  85. package/dist/worker-streaming.d.ts.map +0 -1
  86. package/dist/worker-streaming.js +0 -510
  87. package/dist/worker-streaming.js.map +0 -1
  88. package/dist/worker.d.ts +0 -28
  89. package/dist/worker.d.ts.map +0 -1
  90. package/dist/worker.js +0 -540
  91. package/dist/worker.js.map +0 -1
package/dist/client.d.ts DELETED
@@ -1,924 +0,0 @@
1
- /**
2
- * Ironflow Node.js Client
3
- *
4
- * HTTP client for interacting with the Ironflow server.
5
- * Provides methods for registering functions, triggering events, and managing runs.
6
- */
7
- import { type EmitSyncResult, type RunStatus, type Trigger, type ExecutionMode, type RetryConfig, type ConcurrencyConfig, type AppendEventInput, type AppendOptions, type AppendResult, type ReadStreamOptions, type StreamEvent, type StreamInfo, type StreamSnapshot, type CreateSQLProjectionInput, type QuerySQLProjectionOptions, type SQLProjectionQueryResult, type PublishOptions, type PublishResult, type TopicInfo, type TopicStats, type APIKey, type APIKeyWithSecret, type CreateAPIKeyInput, type Organization, type CreateOrgInput, type UpdateOrgInput, type Role, type CreateRoleInput, type UpdateRoleInput, type Policy, type CreatePolicyInput, type UpdatePolicyInput, type ProjectionState, type ProjectionStatusInfo, type RebuildJob, type WaitResult, type TimeTravelRunState, type TimeTravelTimelineEvent, type TimeTravelStepOutput, type AuditTrailEntry, type Secret, type SecretListEntry, type StreamListEntry, type EntityHistoryEntry, type Project, type Environment, type EventSchema, type RegisterSchemaInput, type TestUpcastInput, type UpcastResult, type WebhookSource, type CreateWebhookSourceInput, type WebhookDelivery, type ListWebhookDeliveriesOptions, type User, type CreateUserInput, type UpdateUserInput, type Tenant } from "@ironflow/core";
8
- import { KVClient } from "./kv.js";
9
- import { CommandDedup, type CommandDedupOptions } from "./command-dedup.js";
10
- import { ConfigClient } from "./config-client.js";
11
- import type { OnErrorHandler } from "./types.js";
12
- /**
13
- * Configuration for the Ironflow client
14
- */
15
- export interface IronflowClientConfig {
16
- /** Server URL (default: http://localhost:9123 or IRONFLOW_SERVER_URL env var) */
17
- serverUrl?: string;
18
- /** API key for authentication (optional for local dev) */
19
- apiKey?: string;
20
- /** Request timeout in milliseconds (default: 30000) */
21
- timeout?: number;
22
- /** Global error handler called on every client error (fires before re-throw) */
23
- onError?: OnErrorHandler;
24
- }
25
- /**
26
- * Function registration request
27
- */
28
- export interface RegisterFunctionRequest {
29
- /** Unique function identifier */
30
- id: string;
31
- /** Display name */
32
- name?: string;
33
- /** Description */
34
- description?: string;
35
- /** Event triggers */
36
- triggers?: Trigger[];
37
- /** Retry configuration */
38
- retry?: RetryConfig;
39
- /** Timeout in milliseconds */
40
- timeoutMs?: number;
41
- /** Concurrency configuration */
42
- concurrency?: ConcurrencyConfig;
43
- /** Preferred execution mode */
44
- preferredMode?: ExecutionMode;
45
- /** Endpoint URL for push mode */
46
- endpointUrl?: string;
47
- /** Actor key for sticky routing */
48
- actorKey?: string;
49
- /** Pause behavior for scoped injection ("hold" or "release") */
50
- pauseBehavior?: string;
51
- }
52
- /**
53
- * Result from registering a function
54
- */
55
- export interface RegisterFunctionResult {
56
- /** Whether the function was newly created (vs updated) */
57
- created: boolean;
58
- }
59
- /**
60
- * Result from emitting an event
61
- */
62
- export interface EmitResult {
63
- /** IDs of runs created by this event */
64
- runIds: string[];
65
- /** ID of the stored event */
66
- eventId: string;
67
- }
68
- /**
69
- * Options for emitting an event
70
- */
71
- export interface EmitOptions {
72
- /** Event schema version (default 1) */
73
- version?: number;
74
- /** Idempotency key to prevent duplicate processing */
75
- idempotencyKey?: string;
76
- /** Additional metadata */
77
- metadata?: Record<string, unknown>;
78
- }
79
- /**
80
- * Run information
81
- */
82
- export interface Run {
83
- /** Run ID */
84
- id: string;
85
- /** Function ID */
86
- functionId: string;
87
- /** Event ID that triggered this run */
88
- eventId: string;
89
- /** Current status */
90
- status: RunStatus;
91
- /** Current attempt number */
92
- attempt: number;
93
- /** Maximum attempts allowed */
94
- maxAttempts: number;
95
- /** Input data */
96
- input?: unknown;
97
- /** Output data (if completed) */
98
- output?: unknown;
99
- /** Error information (if failed) */
100
- error?: {
101
- message: string;
102
- code: string;
103
- };
104
- /** When the run started */
105
- startedAt?: string;
106
- /** When the run ended */
107
- endedAt?: string;
108
- /** When the run was created */
109
- createdAt: string;
110
- /** When the run was last updated */
111
- updatedAt: string;
112
- }
113
- /**
114
- * Options for listing runs
115
- */
116
- export interface ListRunsOptions {
117
- /** Filter by function ID */
118
- functionId?: string;
119
- /** Filter by status */
120
- status?: RunStatus;
121
- /** Maximum number of results */
122
- limit?: number;
123
- /** Pagination cursor */
124
- cursor?: string;
125
- }
126
- /**
127
- * Result from listing runs
128
- */
129
- export interface ListRunsResult {
130
- /** List of runs */
131
- runs: Run[];
132
- /** Cursor for next page */
133
- nextCursor?: string;
134
- /** Total count of matching runs */
135
- totalCount: number;
136
- }
137
- /**
138
- * Ironflow client for server-side operations
139
- *
140
- * @example
141
- * ```typescript
142
- * import { createClient } from "@ironflow/node";
143
- *
144
- * const client = createClient({
145
- * serverUrl: "http://localhost:9123",
146
- * });
147
- *
148
- * // Register a function
149
- * await client.registerFunction({
150
- * id: "my-function",
151
- * name: "My Function",
152
- * triggers: [{ event: "my.event" }],
153
- * endpointUrl: "http://localhost:3000/api/ironflow",
154
- * preferredMode: "push",
155
- * });
156
- *
157
- * // Emit an event
158
- * const result = await client.emit("my.event", { data: "value" });
159
- * console.log("Created runs:", result.runIds);
160
- * ```
161
- */
162
- export declare class IronflowClient {
163
- private readonly serverUrl;
164
- private readonly apiKey?;
165
- private readonly timeout;
166
- private readonly onErrorHandler?;
167
- constructor(config?: IronflowClientConfig);
168
- /**
169
- * Register a function with the Ironflow server
170
- */
171
- registerFunction(request: RegisterFunctionRequest): Promise<RegisterFunctionResult>;
172
- /**
173
- * Emit an event to trigger workflows
174
- *
175
- * @example
176
- * ```typescript
177
- * const result = await client.emit("order.placed", {
178
- * orderId: "123",
179
- * total: 99.99,
180
- * });
181
- * console.log("Created runs:", result.runIds);
182
- * ```
183
- */
184
- emit(eventName: string, data: unknown, options?: EmitOptions): Promise<EmitResult>;
185
- /**
186
- * Emit an event synchronously — waits for the triggered run to complete and returns the result.
187
- *
188
- * Calls the TriggerSync endpoint, which blocks until the run finishes or the timeout elapses.
189
- * Throws RunFailedError if the run fails, RunCancelledError if it is cancelled.
190
- *
191
- * @example
192
- * ```typescript
193
- * const result = await client.emitSync("order.placed", { orderId: "123" });
194
- * console.log("Output:", result.output);
195
- * ```
196
- */
197
- emitSync(eventName: string, data: unknown, options?: {
198
- timeout?: number;
199
- }): Promise<EmitSyncResult>;
200
- /**
201
- * Publish a message to a developer pub/sub topic.
202
- * Unlike emit(), this does NOT trigger workflow functions.
203
- *
204
- * @example
205
- * ```typescript
206
- * const result = await client.publish("notifications", {
207
- * userId: "123",
208
- * message: "Hello!",
209
- * });
210
- * console.log("Published:", result.eventId, result.sequence);
211
- * ```
212
- */
213
- publish(topic: string, data: unknown, options?: PublishOptions): Promise<PublishResult>;
214
- /**
215
- * List all active developer pub/sub topics.
216
- *
217
- * @example
218
- * ```typescript
219
- * const topics = await client.listTopics();
220
- * for (const t of topics) {
221
- * console.log(t.name, t.messageCount);
222
- * }
223
- * ```
224
- */
225
- listTopics(): Promise<TopicInfo[]>;
226
- /**
227
- * Get detailed statistics for a topic.
228
- *
229
- * @example
230
- * ```typescript
231
- * const stats = await client.getTopicStats("notifications");
232
- * console.log("Messages:", stats.messageCount, "Lag:", stats.lag);
233
- * ```
234
- */
235
- getTopicStats(topic: string): Promise<TopicStats>;
236
- /**
237
- * Get a run by ID
238
- */
239
- getRun(runId: string): Promise<Run>;
240
- /**
241
- * List runs with optional filtering
242
- */
243
- listRuns(options?: ListRunsOptions): Promise<ListRunsResult>;
244
- /**
245
- * Cancel a running workflow
246
- */
247
- cancelRun(runId: string, reason?: string): Promise<Run>;
248
- /**
249
- * Retry a failed run
250
- */
251
- retryRun(runId: string, fromStep?: string): Promise<Run>;
252
- /**
253
- * Health check
254
- */
255
- health(): Promise<string>;
256
- /**
257
- * Entity stream operations
258
- *
259
- * @example
260
- * ```typescript
261
- * // Append an event to a stream
262
- * const result = await client.streams.append("order-123", {
263
- * name: "order.created",
264
- * data: { total: 100 },
265
- * entityType: "order",
266
- * });
267
- *
268
- * // Read events from a stream
269
- * const { events } = await client.streams.read("order-123", { limit: 10 });
270
- *
271
- * // Get stream info
272
- * const info = await client.streams.getInfo("order-123");
273
- * ```
274
- */
275
- streams: {
276
- /**
277
- * Append an event to an entity stream
278
- */
279
- append: (entityId: string, input: AppendEventInput, options?: AppendOptions) => Promise<AppendResult>;
280
- /**
281
- * Read events from an entity stream
282
- */
283
- read: (entityId: string, options?: ReadStreamOptions) => Promise<{
284
- events: StreamEvent[];
285
- totalCount: number;
286
- }>;
287
- /**
288
- * Get information about an entity stream.
289
- *
290
- * Returns `null` if no events have been written to this stream yet — safe to
291
- * pass `expectedVersion: 0` to `append()` in that case to create the first event.
292
- *
293
- * @example
294
- * ```typescript
295
- * const info = await client.streams.getInfo("order-123");
296
- * await client.streams.append("order-123", event, {
297
- * expectedVersion: info ? info.version : 0,
298
- * });
299
- * ```
300
- */
301
- getInfo: (entityId: string) => Promise<StreamInfo | null>;
302
- /**
303
- * Create a snapshot of the materialized state at a specific stream version.
304
- * Use snapshots to speed up state reconstruction for long-lived entity streams.
305
- */
306
- createSnapshot: (entityId: string, input: {
307
- entityType: string;
308
- entityVersion: number;
309
- state: Record<string, unknown>;
310
- }) => Promise<{
311
- snapshotId: string;
312
- }>;
313
- /**
314
- * Get the latest snapshot at or before a given version.
315
- * Returns the snapshot closest to the requested version without exceeding it.
316
- */
317
- getSnapshot: (entityId: string, options?: {
318
- beforeVersion?: number;
319
- }) => Promise<StreamSnapshot>;
320
- /**
321
- * List all entity streams.
322
- */
323
- listStreams: () => Promise<StreamListEntry[]>;
324
- /**
325
- * Get the full event history for an entity.
326
- */
327
- getEntityHistory: (entityId: string) => Promise<EntityHistoryEntry[]>;
328
- };
329
- /**
330
- * SQL-backed projections
331
- *
332
- * Create materialized SQL tables from event streams. Events are processed
333
- * server-side using parameterized SQL handlers.
334
- *
335
- * @example
336
- * ```typescript
337
- * // Create a SQL projection
338
- * await client.sqlProjections.create({
339
- * name: "board",
340
- * tableSql: "CREATE TABLE proj_board (id TEXT PRIMARY KEY, title TEXT, status TEXT)",
341
- * eventHandlers: {
342
- * "issue.created": "INSERT INTO proj_board (id, title, status) VALUES (:entity_id, :data.title, 'OPEN')",
343
- * "issue.status_changed": "UPDATE proj_board SET status = :data.to WHERE id = :entity_id",
344
- * },
345
- * events: ["issue.created", "issue.status_changed"],
346
- * });
347
- *
348
- * // Query the projection
349
- * const result = await client.sqlProjections.query("board", {
350
- * where: "status = 'OPEN'",
351
- * orderBy: "title ASC",
352
- * limit: 50,
353
- * });
354
- * ```
355
- */
356
- readonly sqlProjections: {
357
- /**
358
- * Create a SQL-backed projection with a materialized table and event handlers.
359
- */
360
- create: (input: CreateSQLProjectionInput) => Promise<{
361
- name: string;
362
- status: string;
363
- }>;
364
- /**
365
- * Query a SQL-backed projection table with optional filtering, ordering, and pagination.
366
- */
367
- query: (name: string, options?: QuerySQLProjectionOptions) => Promise<SQLProjectionQueryResult>;
368
- };
369
- /**
370
- * API key management
371
- *
372
- * @example
373
- * ```typescript
374
- * // Create an API key
375
- * const { key } = await client.apiKeys.create({ name: "ci-key" });
376
- *
377
- * // List all API keys
378
- * const keys = await client.apiKeys.list();
379
- *
380
- * // Rotate a key
381
- * const rotated = await client.apiKeys.rotate(keys[0].id);
382
- * ```
383
- */
384
- readonly apiKeys: {
385
- /** Create a new API key */
386
- create: (input: CreateAPIKeyInput) => Promise<APIKeyWithSecret>;
387
- /** List all API keys */
388
- list: () => Promise<APIKey[]>;
389
- /** Get an API key by ID */
390
- get: (id: string) => Promise<APIKey>;
391
- /** Delete an API key */
392
- delete: (id: string) => Promise<void>;
393
- /** Rotate an API key (generates a new secret) */
394
- rotate: (id: string) => Promise<APIKeyWithSecret>;
395
- };
396
- /**
397
- * Organization management (enterprise)
398
- *
399
- * @example
400
- * ```typescript
401
- * const org = await client.orgs.create({ name: "Acme Corp" });
402
- * const orgs = await client.orgs.list();
403
- * await client.orgs.update(org.id, { name: "Acme Inc" });
404
- * ```
405
- */
406
- readonly orgs: {
407
- /** Create a new organization */
408
- create: (input: CreateOrgInput) => Promise<Organization>;
409
- /** List all organizations */
410
- list: () => Promise<Organization[]>;
411
- /** Get an organization by ID */
412
- get: (id: string) => Promise<Organization>;
413
- /** Update an organization */
414
- update: (id: string, input: UpdateOrgInput) => Promise<Organization>;
415
- /** Delete an organization */
416
- delete: (id: string) => Promise<void>;
417
- };
418
- /**
419
- * Role management (enterprise)
420
- *
421
- * @example
422
- * ```typescript
423
- * const role = await client.roles.create({ name: "deployer", org_id: orgId });
424
- * await client.roles.assignPolicy(role.id, policyId);
425
- * const roles = await client.roles.list(orgId);
426
- * ```
427
- */
428
- readonly roles: {
429
- /** Create a new role */
430
- create: (input: CreateRoleInput) => Promise<Role>;
431
- /** List roles, optionally filtered by organization */
432
- list: (orgId?: string) => Promise<Role[]>;
433
- /** Get a role by ID */
434
- get: (id: string) => Promise<Role>;
435
- /** Update a role */
436
- update: (id: string, input: UpdateRoleInput) => Promise<Role>;
437
- /** Delete a role */
438
- delete: (id: string) => Promise<void>;
439
- /** Assign a policy to a role */
440
- assignPolicy: (roleId: string, policyId: string) => Promise<void>;
441
- /** Remove a policy from a role */
442
- removePolicy: (roleId: string, policyId: string) => Promise<void>;
443
- };
444
- /**
445
- * Policy management (enterprise)
446
- *
447
- * @example
448
- * ```typescript
449
- * const policy = await client.policies.create({
450
- * name: "allow-emit",
451
- * effect: "allow",
452
- * actions: "emit:*",
453
- * resources: "*",
454
- * org_id: orgId,
455
- * });
456
- * const policies = await client.policies.list(orgId);
457
- * ```
458
- */
459
- readonly policies: {
460
- /** Create a new policy */
461
- create: (input: CreatePolicyInput) => Promise<Policy>;
462
- /** List policies, optionally filtered by organization */
463
- list: (orgId?: string) => Promise<Policy[]>;
464
- /** Get a policy by ID */
465
- get: (id: string) => Promise<Policy>;
466
- /** Update a policy */
467
- update: (id: string, input: UpdatePolicyInput) => Promise<Policy>;
468
- /** Delete a policy */
469
- delete: (id: string) => Promise<void>;
470
- };
471
- /**
472
- * Projection management
473
- *
474
- * @example
475
- * ```typescript
476
- * const state = await client.projections.get("order-summary");
477
- * const statuses = await client.projections.list();
478
- * await client.projections.rebuild("order-summary");
479
- * ```
480
- */
481
- readonly projections: {
482
- /** Get the current materialized state of a projection */
483
- get: (name: string) => Promise<ProjectionState>;
484
- /** List all projection statuses */
485
- list: () => Promise<ProjectionStatusInfo[]>;
486
- /** Get operational status for a projection */
487
- getStatus: (name: string) => Promise<ProjectionStatusInfo>;
488
- /** Trigger a full rebuild of a projection */
489
- rebuild: (name: string) => Promise<RebuildJob>;
490
- /** Get the status of an in-progress or completed rebuild job */
491
- getRebuildJob: (name: string) => Promise<RebuildJob>;
492
- /** Delete a projection */
493
- delete: (name: string) => Promise<void>;
494
- /** Pause a projection (stop consuming new events) */
495
- pause: (name: string) => Promise<void>;
496
- /** Resume a paused projection */
497
- resume: (name: string) => Promise<void>;
498
- /** Cancel an in-progress rebuild */
499
- cancelRebuild: (name: string) => Promise<void>;
500
- /**
501
- * Wait until the named projection has processed events up to `minSeq`,
502
- * or the timeout elapses. Read-your-writes primitive for CQRS: pair
503
- * with `sequence` from a `streams.append` response.
504
- *
505
- * ```typescript
506
- * const { sequence } = await client.streams.append(orderId, event);
507
- * await client.projections.waitForCatchup("order-detail-view", {
508
- * minSeq: sequence,
509
- * partition: orderId,
510
- * timeoutMs: 5000,
511
- * });
512
- * ```
513
- *
514
- * Errors: 404 (projection not found), 409 (paused/rebuilding/partition
515
- * unsupported for external), 429 (wait capacity exceeded).
516
- *
517
- * Issue #473.
518
- */
519
- waitForCatchup: (name: string, opts: {
520
- minSeq: bigint | number;
521
- timeoutMs?: number;
522
- partition?: string;
523
- }) => Promise<WaitResult>;
524
- /**
525
- * Wait on multiple projections in a single request. All items share
526
- * a single timeout deadline and a single atomic slot reservation on
527
- * the server — if the server's cap cannot absorb N items, the whole
528
- * batch is rejected with 429. Per-item failures are returned per
529
- * element via `error` fields.
530
- *
531
- * Max 16 items. Issue #473.
532
- */
533
- waitForCatchupBatch: (items: Array<{
534
- name: string;
535
- minSeq: bigint | number;
536
- partition?: string;
537
- }>, opts?: {
538
- timeoutMs?: number;
539
- }) => Promise<Array<{
540
- result?: WaitResult;
541
- error?: string;
542
- }>>;
543
- /**
544
- * Wait for a specific event (identified by `eventId` from a
545
- * `streams.append` response) to be processed by the given projection.
546
- * The server resolves eventId → NATS seq internally.
547
- *
548
- * Errors: 404 (event not found), 409 (event predates sequence
549
- * tracking — fall back to waitForCatchup with minSeq from a
550
- * fresh write), plus the standard wait errors.
551
- *
552
- * Issue #473.
553
- */
554
- waitForEvent: (eventId: string, projection: string, opts?: {
555
- timeoutMs?: number;
556
- partition?: string;
557
- }) => Promise<WaitResult>;
558
- };
559
- /**
560
- * Secrets management
561
- *
562
- * @example
563
- * ```typescript
564
- * await client.secrets.set("stripe-key", "sk_live_...");
565
- * const secret = await client.secrets.get("stripe-key");
566
- * const all = await client.secrets.list();
567
- * await client.secrets.delete("stripe-key");
568
- * ```
569
- */
570
- readonly secrets: {
571
- /** Get a secret by name (returns value) */
572
- get: (name: string) => Promise<Secret>;
573
- /** Create a new secret */
574
- set: (name: string, value: string) => Promise<Secret>;
575
- /** Update an existing secret's value */
576
- update: (name: string, value: string) => Promise<Secret>;
577
- /** List all secrets (names only, no values) */
578
- list: () => Promise<SecretListEntry[]>;
579
- /** Delete a secret */
580
- delete: (name: string) => Promise<void>;
581
- };
582
- /**
583
- * Project management
584
- *
585
- * @example
586
- * ```typescript
587
- * const project = await client.projects.create({ name: "my-service" });
588
- * const projects = await client.projects.list();
589
- * await client.projects.update(project.id, { name: "renamed-service" });
590
- * await client.projects.delete(project.id);
591
- * ```
592
- */
593
- readonly projects: {
594
- /** List all projects */
595
- list: () => Promise<Project[]>;
596
- /** Create a new project */
597
- create: (input: {
598
- name: string;
599
- description?: string;
600
- }) => Promise<Project>;
601
- /** Update a project */
602
- update: (id: string, input: {
603
- name?: string;
604
- description?: string;
605
- }) => Promise<Project>;
606
- /** Delete a project */
607
- delete: (id: string) => Promise<void>;
608
- };
609
- /**
610
- * Environment management
611
- *
612
- * @example
613
- * ```typescript
614
- * const env = await client.environments.create({ name: "staging", projectId: "proj_..." });
615
- * const envs = await client.environments.list();
616
- * await client.environments.update(env.id, { name: "staging-v2" });
617
- * await client.environments.delete(env.id);
618
- * ```
619
- */
620
- readonly environments: {
621
- /** List all environments */
622
- list: () => Promise<Environment[]>;
623
- /** Create a new environment */
624
- create: (input: {
625
- name: string;
626
- project_id: string;
627
- }) => Promise<Environment>;
628
- /** Update an environment */
629
- update: (id: string, input: {
630
- name?: string;
631
- }) => Promise<Environment>;
632
- /** Delete an environment */
633
- delete: (id: string) => Promise<void>;
634
- };
635
- /**
636
- * Event schema registry operations
637
- *
638
- * @example
639
- * ```typescript
640
- * // Register a schema
641
- * const schema = await client.schemas.register({
642
- * name: "order.placed",
643
- * version: 1,
644
- * schema: { type: "object", properties: { orderId: { type: "string" } } },
645
- * });
646
- *
647
- * // List all schemas
648
- * const schemas = await client.schemas.list();
649
- *
650
- * // Get latest version of a schema
651
- * const latest = await client.schemas.get("order.placed");
652
- *
653
- * // Get a specific version
654
- * const v1 = await client.schemas.getVersion("order.placed", 1);
655
- *
656
- * // Test an upcast transformation
657
- * const result = await client.schemas.testUpcast({
658
- * eventName: "order.placed",
659
- * fromVersion: 1,
660
- * toVersion: 2,
661
- * data: { orderId: "123" },
662
- * });
663
- * ```
664
- */
665
- readonly schemas: {
666
- /** Register a new event schema (or a new version of an existing schema) */
667
- register: (input: RegisterSchemaInput) => Promise<EventSchema>;
668
- /** List all registered event schemas */
669
- list: () => Promise<EventSchema[]>;
670
- /** Get the latest version of an event schema by name */
671
- get: (name: string) => Promise<EventSchema>;
672
- /** Get a specific version of an event schema */
673
- getVersion: (name: string, version: number) => Promise<EventSchema>;
674
- /** Delete a specific version of an event schema */
675
- delete: (name: string, version: number) => Promise<void>;
676
- /** Test an upcast transformation between two schema versions */
677
- testUpcast: (input: TestUpcastInput) => Promise<UpcastResult>;
678
- };
679
- /**
680
- * Get the reconstructed state of a run at a specific point in time.
681
- *
682
- * @param runId The run ID to query
683
- * @param timestamp The point in time to reconstruct state at
684
- */
685
- getRunStateAt(runId: string, timestamp: Date): Promise<TimeTravelRunState>;
686
- /**
687
- * Get the timeline of events for a run (for time-travel debugging).
688
- *
689
- * @param runId The run ID to query
690
- */
691
- getRunTimeline(runId: string): Promise<TimeTravelTimelineEvent[]>;
692
- /**
693
- * Get the output of a specific step at a point in time.
694
- *
695
- * @param runId The run ID
696
- * @param stepId The step ID
697
- * @param timestamp The point in time to query
698
- */
699
- getStepOutputAt(runId: string, stepId: string, timestamp: Date): Promise<TimeTravelStepOutput>;
700
- /**
701
- * Get the audit trail for a run.
702
- *
703
- * @param runId The run ID to retrieve the audit trail for
704
- */
705
- getAuditTrail(runId: string): Promise<AuditTrailEntry[]>;
706
- /**
707
- * Webhook management operations
708
- *
709
- * @example
710
- * ```typescript
711
- * // List all webhook sources
712
- * const sources = await client.webhooks.listSources();
713
- *
714
- * // Delete a webhook source
715
- * await client.webhooks.deleteSource("my-webhook");
716
- *
717
- * // List deliveries for a source
718
- * const { deliveries } = await client.webhooks.listDeliveries({ sourceId: "my-webhook" });
719
- * ```
720
- */
721
- readonly webhooks: {
722
- /** Create a new webhook source */
723
- create: (input: CreateWebhookSourceInput) => Promise<WebhookSource>;
724
- /** List all registered webhook sources */
725
- listSources: () => Promise<WebhookSource[]>;
726
- /** Delete a webhook source by ID */
727
- deleteSource: (id: string) => Promise<void>;
728
- /** List webhook deliveries with optional filtering */
729
- listDeliveries: (opts?: ListWebhookDeliveriesOptions) => Promise<{
730
- deliveries: WebhookDelivery[];
731
- totalCount: number;
732
- }>;
733
- };
734
- /**
735
- * User management operations
736
- *
737
- * @example
738
- * ```typescript
739
- * // Create a user
740
- * const user = await client.users.create({ email: "alice@example.com", password: "secret", roles: ["admin"] });
741
- *
742
- * // List users
743
- * const users = await client.users.list();
744
- *
745
- * // Update a user
746
- * await client.users.update(user.id, { name: "Alice" });
747
- *
748
- * // Delete a user
749
- * await client.users.delete(user.id);
750
- * ```
751
- */
752
- readonly users: {
753
- /** Create a new user (admin only) */
754
- create: (input: CreateUserInput) => Promise<User>;
755
- /** List all users in the current organization (admin only) */
756
- list: () => Promise<User[]>;
757
- /** Get a user by ID */
758
- get: (id: string) => Promise<User>;
759
- /** Update a user's profile (admin only) */
760
- update: (id: string, input: UpdateUserInput) => Promise<User>;
761
- /** Delete a user (admin only) */
762
- delete: (id: string) => Promise<void>;
763
- };
764
- /**
765
- * Tenant management operations (enterprise-only)
766
- *
767
- * @example
768
- * ```typescript
769
- * // List all tenants
770
- * const tenants = await client.tenants.list();
771
- * console.log(tenants.map(t => t.name));
772
- * ```
773
- */
774
- readonly tenants: {
775
- /** List all tenants (enterprise-only) */
776
- list: () => Promise<Tenant[]>;
777
- };
778
- /**
779
- * KV store operations
780
- *
781
- * @example
782
- * ```typescript
783
- * const kv = client.kv();
784
- * const bucket = await kv.createBucket({ name: "sessions", ttlSeconds: 3600 });
785
- * const handle = kv.bucket("sessions");
786
- * const { revision } = await handle.put("user.123", { token: "abc" });
787
- * const entry = await handle.get("user.123");
788
- * ```
789
- */
790
- kv(): KVClient;
791
- /**
792
- * Create a CommandDedup instance for atomic command-level idempotency.
793
- *
794
- * Uses the claim-first pattern backed by NATS KV. The KV bucket is created
795
- * lazily on the first operation. Store the returned instance and reuse it
796
- * across requests — do not call commandDedup() per request.
797
- *
798
- * @example
799
- * ```typescript
800
- * const dedup = client.commandDedup<OrderResult>("order-commands");
801
- * const prior = await dedup.tryClaim(commandId, { orderId, claimedAt: new Date().toISOString() });
802
- * if (prior !== null) return prior;
803
- * try {
804
- * const result = await runOrderHandler();
805
- * await dedup.finalize(commandId, result);
806
- * return result;
807
- * } catch (err) {
808
- * await dedup.release(commandId).catch(() => {}); // swallow — don't mask the original error
809
- * throw err;
810
- * }
811
- * ```
812
- */
813
- commandDedup<T>(bucketName: string, options?: CommandDedupOptions): CommandDedup<T>;
814
- /**
815
- * Config management operations
816
- *
817
- * @example
818
- * ```typescript
819
- * const config = client.config();
820
- * await config.set("app", { featureX: true });
821
- * const { data } = await config.get("app");
822
- * await config.patch("app", { maxRetries: 5 });
823
- * const configs = await config.list();
824
- * await config.delete("app");
825
- * ```
826
- */
827
- config(): ConfigClient;
828
- /**
829
- * Patch a step's output (hot patching)
830
- */
831
- patchStep(stepId: string, output: Record<string, unknown>, reason?: string): Promise<void>;
832
- /**
833
- * Resume a paused or failed run
834
- */
835
- resumeRun(runId: string, fromStep?: string): Promise<Run>;
836
- /**
837
- * Pause a running workflow run (scoped injection).
838
- *
839
- * @example
840
- * ```typescript
841
- * const result = await client.pauseRun("run_abc123");
842
- * console.log(result.status); // "paused"
843
- * ```
844
- */
845
- pauseRun(runId: string): Promise<{
846
- status: string;
847
- }>;
848
- /**
849
- * Get the paused state of a run, including completed steps and next step hint.
850
- *
851
- * @example
852
- * ```typescript
853
- * const state = await client.getPausedState("run_abc123");
854
- * for (const step of state.steps) {
855
- * console.log(step.name, step.output, step.injected);
856
- * }
857
- * console.log("Next step:", state.nextStepHint);
858
- * ```
859
- */
860
- getPausedState(runId: string): Promise<{
861
- steps: Array<{
862
- id: string;
863
- name: string;
864
- output: unknown;
865
- injected: boolean;
866
- completedAt: string;
867
- }>;
868
- nextStepHint: string;
869
- pauseReason: string;
870
- }>;
871
- /**
872
- * Inject new output for a step in a paused run (scoped injection).
873
- *
874
- * @example
875
- * ```typescript
876
- * const result = await client.injectStepOutput(
877
- * "run_abc123",
878
- * "step_xyz",
879
- * { corrected: true },
880
- * "Manual correction"
881
- * );
882
- * console.log("Previous output:", result.previousOutput);
883
- * ```
884
- */
885
- injectStepOutput(runId: string, stepId: string, newOutput: unknown, reason?: string): Promise<{
886
- stepId: string;
887
- previousOutput: unknown;
888
- }>;
889
- /**
890
- * List registered functions
891
- */
892
- listFunctions(): Promise<unknown[]>;
893
- /**
894
- * List connected workers
895
- */
896
- listWorkers(): Promise<unknown[]>;
897
- /**
898
- * Make an HTTP request to the server
899
- */
900
- private request;
901
- /**
902
- * Throw a typed error based on HTTP status code.
903
- */
904
- private throwTypedError;
905
- /**
906
- * Make a REST HTTP request to the server (supports GET, POST, PATCH, DELETE)
907
- */
908
- private restRequest;
909
- /**
910
- * Call the global onError handler if registered.
911
- * Swallows any errors thrown by the callback.
912
- */
913
- private callOnError;
914
- }
915
- /**
916
- * Create a new Ironflow client
917
- *
918
- * @example
919
- * ```typescript
920
- * const client = createClient({ serverUrl: "http://localhost:9123" });
921
- * ```
922
- */
923
- export declare function createClient(config?: IronflowClientConfig): IronflowClient;
924
- //# sourceMappingURL=client.d.ts.map