iii-sdk 0.19.7 → 0.20.0-alpha.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 (89) hide show
  1. package/dist/channel.cjs +5 -0
  2. package/dist/channel.d.cts +2 -0
  3. package/dist/channel.d.mts +2 -0
  4. package/dist/channel.mjs +3 -0
  5. package/dist/{utils-DXL7JI0q.mjs → channels-De8fNMyx.mjs} +3 -108
  6. package/dist/channels-De8fNMyx.mjs.map +1 -0
  7. package/dist/{utils-CuS1Knym.cjs → channels-ZbQzcwnN.cjs} +3 -166
  8. package/dist/channels-ZbQzcwnN.cjs.map +1 -0
  9. package/dist/engine.cjs +5 -0
  10. package/dist/engine.d.cts +3 -0
  11. package/dist/engine.d.mts +3 -0
  12. package/dist/engine.mjs +3 -0
  13. package/dist/errors.cjs +28 -0
  14. package/dist/errors.cjs.map +1 -0
  15. package/dist/errors.d.cts +40 -0
  16. package/dist/errors.d.cts.map +1 -0
  17. package/dist/errors.d.mts +40 -0
  18. package/dist/errors.d.mts.map +1 -0
  19. package/dist/errors.mjs +25 -0
  20. package/dist/errors.mjs.map +1 -0
  21. package/dist/helpers.cjs +6 -5
  22. package/dist/helpers.cjs.map +1 -1
  23. package/dist/helpers.d.cts +23 -5
  24. package/dist/helpers.d.cts.map +1 -1
  25. package/dist/helpers.d.mts +23 -5
  26. package/dist/helpers.d.mts.map +1 -1
  27. package/dist/helpers.mjs +4 -3
  28. package/dist/helpers.mjs.map +1 -1
  29. package/dist/iii-constants-Baptl8nm.d.mts +47 -0
  30. package/dist/iii-constants-Baptl8nm.d.mts.map +1 -0
  31. package/dist/iii-constants-BqXp8xSN.d.cts +47 -0
  32. package/dist/iii-constants-BqXp8xSN.d.cts.map +1 -0
  33. package/dist/iii-constants-Br94RUNi.cjs +67 -0
  34. package/dist/iii-constants-Br94RUNi.cjs.map +1 -0
  35. package/dist/iii-constants-_k3SoHry.mjs +43 -0
  36. package/dist/iii-constants-_k3SoHry.mjs.map +1 -0
  37. package/dist/iii-types-6aHBgy7l.cjs +24 -0
  38. package/dist/iii-types-6aHBgy7l.cjs.map +1 -0
  39. package/dist/iii-types-CRx2qAjB.mjs +18 -0
  40. package/dist/iii-types-CRx2qAjB.mjs.map +1 -0
  41. package/dist/index.cjs +93 -172
  42. package/dist/index.cjs.map +1 -1
  43. package/dist/index.d.cts +14 -81
  44. package/dist/index.d.cts.map +1 -1
  45. package/dist/index.d.mts +14 -81
  46. package/dist/index.d.mts.map +1 -1
  47. package/dist/index.mjs +30 -104
  48. package/dist/index.mjs.map +1 -1
  49. package/dist/internal.cjs +0 -0
  50. package/dist/internal.d.cts +2 -0
  51. package/dist/internal.d.mts +2 -0
  52. package/dist/internal.mjs +1 -0
  53. package/dist/protocol.cjs +4 -0
  54. package/dist/protocol.d.cts +2 -0
  55. package/dist/protocol.d.mts +2 -0
  56. package/dist/protocol.mjs +3 -0
  57. package/dist/runtime.cjs +0 -0
  58. package/dist/runtime.d.cts +3 -0
  59. package/dist/runtime.d.mts +3 -0
  60. package/dist/runtime.mjs +1 -0
  61. package/dist/state.cjs.map +1 -1
  62. package/dist/state.d.cts +3 -7
  63. package/dist/state.d.cts.map +1 -1
  64. package/dist/state.d.mts +3 -7
  65. package/dist/state.d.mts.map +1 -1
  66. package/dist/state.mjs.map +1 -1
  67. package/dist/stream.d.cts +5 -246
  68. package/dist/stream.d.cts.map +1 -1
  69. package/dist/stream.d.mts +5 -246
  70. package/dist/stream.d.mts.map +1 -1
  71. package/dist/trigger.cjs +0 -0
  72. package/dist/trigger.d.cts +2 -0
  73. package/dist/trigger.d.mts +2 -0
  74. package/dist/trigger.mjs +1 -0
  75. package/dist/{utils-BnRzIUCy.d.cts → types-BZoO05vA.d.cts} +45 -220
  76. package/dist/types-BZoO05vA.d.cts.map +1 -0
  77. package/dist/{utils-e84Qph-9.d.mts → types-BlFE8MZG.d.mts} +45 -220
  78. package/dist/types-BlFE8MZG.d.mts.map +1 -0
  79. package/dist/utils-63wxBJg-.cjs +121 -0
  80. package/dist/utils-63wxBJg-.cjs.map +1 -0
  81. package/dist/utils-8G4hHqvZ.mjs +69 -0
  82. package/dist/utils-8G4hHqvZ.mjs.map +1 -0
  83. package/package.json +37 -2
  84. package/typedoc.json +13 -1
  85. package/vitest.config.ts +3 -3
  86. package/dist/utils-BnRzIUCy.d.cts.map +0 -1
  87. package/dist/utils-CuS1Knym.cjs.map +0 -1
  88. package/dist/utils-DXL7JI0q.mjs.map +0 -1
  89. package/dist/utils-e84Qph-9.d.mts.map +0 -1
@@ -0,0 +1,2 @@
1
+ import { f as Trigger, h as TriggerHandler, m as TriggerConfig } from "./types-BlFE8MZG.mjs";
2
+ export { type Trigger, type TriggerConfig, type TriggerHandler };
@@ -0,0 +1 @@
1
+ export { };
@@ -1,4 +1,5 @@
1
1
  import { Readable, Writable } from "node:stream";
2
+ import { HttpInvocationConfig } from "@iii-dev/helpers/http";
2
3
 
3
4
  //#region src/iii-types.d.ts
4
5
  declare enum MessageType {
@@ -18,6 +19,11 @@ type RegisterTriggerTypeMessage = {
18
19
  id: string;
19
20
  description: string;
20
21
  };
22
+ type ErrorBody = {
23
+ code: string;
24
+ message: string;
25
+ stacktrace?: string;
26
+ };
21
27
  type RegisterTriggerMessage = {
22
28
  message_type: MessageType.RegisterTrigger;
23
29
  id: string;
@@ -26,35 +32,6 @@ type RegisterTriggerMessage = {
26
32
  config: unknown;
27
33
  metadata?: Record<string, unknown>;
28
34
  };
29
- /**
30
- * Authentication configuration for HTTP-invoked functions.
31
- *
32
- * - `hmac` -- HMAC signature verification using a shared secret.
33
- * - `bearer` -- Bearer token authentication.
34
- * - `api_key` -- API key sent via a custom header.
35
- */
36
- type HttpAuthConfig = {
37
- type: 'hmac';
38
- secret_key: string;
39
- } | {
40
- type: 'bearer';
41
- token_key: string;
42
- } | {
43
- type: 'api_key';
44
- header: string;
45
- value_key: string;
46
- };
47
- /**
48
- * Configuration for registering an HTTP-invoked function (Lambda, Cloudflare
49
- * Workers, etc.) instead of a local handler.
50
- */
51
- type HttpInvocationConfig = {
52
- /** URL to invoke. */url: string; /** HTTP method. Defaults to `POST`. */
53
- method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'; /** Timeout in milliseconds. */
54
- timeout_ms?: number; /** Custom headers to send with the request. */
55
- headers?: Record<string, string>; /** Authentication configuration. */
56
- auth?: HttpAuthConfig;
57
- };
58
35
  type RegisterFunctionFormat = {
59
36
  /**
60
37
  * The name of the parameter
@@ -119,30 +96,6 @@ type TriggerAction = {
119
96
  } | {
120
97
  type: 'void';
121
98
  };
122
- /**
123
- * Input passed to the RBAC auth function during WebSocket upgrade.
124
- * Contains the HTTP headers, query parameters, and client IP from the
125
- * connecting worker's upgrade request.
126
- */
127
- type AuthInput = {
128
- /** HTTP headers from the WebSocket upgrade request. */headers: Record<string, string>; /** Query parameters from the upgrade URL. Each key maps to an array of values to support repeated keys. */
129
- query_params: Record<string, string[]>; /** IP address of the connecting client. */
130
- ip_address: string;
131
- };
132
- /**
133
- * Return value from the RBAC auth function. Controls which functions the
134
- * authenticated worker can invoke and what context is forwarded to the
135
- * middleware.
136
- */
137
- type AuthResult = {
138
- /** Additional function IDs to allow beyond the `expose_functions` config. */allowed_functions: string[]; /** Function IDs to deny even if they match `expose_functions`. Takes precedence over allowed. */
139
- forbidden_functions: string[]; /** Trigger type IDs the worker may register triggers for. When omitted, all types are allowed. */
140
- allowed_trigger_types?: string[]; /** Whether the worker may register new trigger types. */
141
- allow_trigger_type_registration: boolean; /** Whether the worker may register new functions. Defaults to `true` if omitted. */
142
- allow_function_registration?: boolean; /** Arbitrary context forwarded to the middleware function on every invocation. */
143
- context: Record<string, unknown>; /** Optional prefix applied to all function IDs registered by this worker. */
144
- function_registration_prefix?: string;
145
- };
146
99
  /**
147
100
  * Input passed to the RBAC middleware function on every function invocation
148
101
  * through the RBAC port. The middleware can inspect, modify, or reject the
@@ -155,80 +108,7 @@ type MiddlewareFunctionInput = {
155
108
  context: Record<string, unknown>;
156
109
  };
157
110
  /**
158
- * Input passed to the `on_trigger_type_registration_function_id` hook
159
- * when a worker attempts to register a new trigger type through the RBAC port.
160
- * Return an {@link OnTriggerTypeRegistrationResult} with the (possibly mapped)
161
- * fields, or throw to deny the registration.
162
- */
163
- type OnTriggerTypeRegistrationInput = {
164
- /** ID of the trigger type being registered. */trigger_type_id: string; /** Human-readable description of the trigger type. */
165
- description: string; /** Auth context from `AuthResult.context` for this session. */
166
- context: Record<string, unknown>;
167
- };
168
- /**
169
- * Result returned from the `on_trigger_type_registration_function_id` hook.
170
- * All fields are optional -- omitted fields keep the original value from the
171
- * registration request.
172
- */
173
- type OnTriggerTypeRegistrationResult = {
174
- /** Mapped trigger type ID. */trigger_type_id?: string; /** Mapped description. */
175
- description?: string;
176
- };
177
- /**
178
- * Input passed to the `on_trigger_registration_function_id` hook
179
- * when a worker attempts to register a trigger through the RBAC port.
180
- * Return an {@link OnTriggerRegistrationResult} with the (possibly mapped)
181
- * fields, or throw to deny the registration.
182
- */
183
- type OnTriggerRegistrationInput = {
184
- /** ID of the trigger being registered. */trigger_id: string; /** Trigger type identifier. */
185
- trigger_type: string; /** ID of the function this trigger is bound to. */
186
- function_id: string; /** Trigger-specific configuration. */
187
- config: unknown; /** Arbitrary metadata attached to the trigger. */
188
- metadata?: Record<string, unknown>; /** Auth context from `AuthResult.context` for this session. */
189
- context: Record<string, unknown>;
190
- };
191
- /**
192
- * Result returned from the `on_trigger_registration_function_id` hook.
193
- * All fields are optional -- omitted fields keep the original value from the
194
- * registration request.
195
- */
196
- type OnTriggerRegistrationResult = {
197
- /** Mapped trigger ID. */trigger_id?: string; /** Mapped trigger type. */
198
- trigger_type?: string; /** Mapped function ID. */
199
- function_id?: string; /** Mapped trigger configuration. */
200
- config?: unknown;
201
- };
202
- /**
203
- * Input passed to the `on_function_registration_function_id` hook
204
- * when a worker attempts to register a function through the RBAC port.
205
- * Return an {@link OnFunctionRegistrationResult} with the (possibly mapped)
206
- * fields, or throw to deny the registration.
207
- */
208
- type OnFunctionRegistrationInput = {
209
- /** ID of the function being registered. */function_id: string; /** Human-readable description of the function. */
210
- description?: string; /** Arbitrary metadata attached to the function. */
211
- metadata?: Record<string, unknown>; /** Auth context from `AuthResult.context` for this session. */
212
- context: Record<string, unknown>;
213
- };
214
- /**
215
- * Result returned from the `on_function_registration_function_id` hook.
216
- * All fields are optional -- omitted fields keep the original value from the
217
- * registration request.
218
- */
219
- type OnFunctionRegistrationResult = {
220
- /** Mapped function ID. */function_id?: string; /** Mapped description. */
221
- description?: string; /** Mapped metadata. */
222
- metadata?: Record<string, unknown>;
223
- };
224
- /**
225
- * Result returned when a function is invoked with `TriggerAction.Enqueue`.
226
- */
227
- type EnqueueResult = {
228
- /** Unique receipt ID for the enqueued message. */messageReceiptId: string;
229
- };
230
- /**
231
- * Request object passed to {@link ISdk.trigger}.
111
+ * Request object passed to {@link IIIClient.trigger}.
232
112
  *
233
113
  * @typeParam TInput - Type of the payload.
234
114
  */
@@ -237,6 +117,12 @@ type TriggerRequest<TInput = unknown> = {
237
117
  payload: TInput; /** Routing action. Omit for synchronous request/response. */
238
118
  action?: TriggerAction; /** Override the default invocation timeout in milliseconds. */
239
119
  timeoutMs?: number;
120
+ /**
121
+ * Optional per-invocation metadata (arbitrary JSON). Travels as a separate
122
+ * channel from the payload and is surfaced to the target handler as a
123
+ * dedicated argument. Omitted from the wire message when undefined.
124
+ */
125
+ metadata?: unknown;
240
126
  };
241
127
  /**
242
128
  * Serializable reference to one end of a streaming channel. Can be included
@@ -357,7 +243,7 @@ type TriggerConfig<TConfig> = {
357
243
  };
358
244
  /**
359
245
  * Handler interface for custom trigger types. Passed to
360
- * `ISdk.registerTriggerType`.
246
+ * `IIIClient.registerTriggerType`.
361
247
  *
362
248
  * @typeParam TConfig - Type of the trigger-specific configuration.
363
249
  *
@@ -381,7 +267,13 @@ type TriggerHandler<TConfig> = {
381
267
  //#region src/types.d.ts
382
268
  /**
383
269
  * Async function handler for a registered function. Receives the invocation
384
- * payload and returns the result.
270
+ * payload and an optional per-invocation `metadata` value, and returns the
271
+ * result.
272
+ *
273
+ * `metadata` is arbitrary JSON travelling on a separate channel from the
274
+ * payload. It is `undefined` when the caller did not attach any. Existing
275
+ * single-argument handlers keep working -- the extra argument is simply
276
+ * ignored by them.
385
277
  *
386
278
  * @typeParam TInput - Type of the invocation payload.
387
279
  * @typeParam TOutput - Type of the return value.
@@ -389,15 +281,15 @@ type TriggerHandler<TConfig> = {
389
281
  * @example
390
282
  * ```typescript
391
283
  * const handler: RemoteFunctionHandler<{ name: string }, { message: string }> =
392
- * async (data) => ({ message: `Hello, ${data.name}!` })
284
+ * async (data, metadata) => ({ message: `Hello, ${data.name}!` })
393
285
  * ```
394
286
  */
395
- type RemoteFunctionHandler<TInput = any, TOutput = any> = (data: TInput) => Promise<TOutput>;
287
+ type RemoteFunctionHandler<TInput = any, TOutput = any> = (data: TInput, metadata?: unknown) => Promise<TOutput>;
396
288
  type RegisterTriggerInput = Omit<RegisterTriggerMessage, 'message_type' | 'id'>;
397
289
  type RegisterFunctionInput = Omit<RegisterFunctionMessage, 'message_type'>;
398
290
  type RegisterFunctionOptions = Omit<RegisterFunctionMessage, 'message_type' | 'id'>;
399
291
  type RegisterTriggerTypeInput = Omit<RegisterTriggerTypeMessage, 'message_type'>;
400
- interface ISdk {
292
+ interface IIIClient {
401
293
  /**
402
294
  * Registers a new trigger. A trigger is a way to invoke a function when a certain event occurs.
403
295
  * @param trigger - The trigger to register
@@ -405,7 +297,7 @@ interface ISdk {
405
297
  *
406
298
  * @example
407
299
  * ```typescript
408
- * const trigger = iii.registerTrigger({
300
+ * const trigger = worker.registerTrigger({
409
301
  * type: 'cron',
410
302
  * function_id: 'my-service::process-batch',
411
303
  * config: { expression: '0 *\/5 * * * * *' },
@@ -426,14 +318,14 @@ interface ISdk {
426
318
  * @example
427
319
  * ```typescript
428
320
  * // Local handler
429
- * const ref = iii.registerFunction(
321
+ * const ref = worker.registerFunction(
430
322
  * 'greet',
431
323
  * async (data: { name: string }) => ({ message: `Hello, ${data.name}!` }),
432
324
  * { description: 'Returns a greeting' },
433
325
  * )
434
326
  *
435
327
  * // HTTP invocation
436
- * const lambdaRef = iii.registerFunction(
328
+ * const lambdaRef = worker.registerFunction(
437
329
  * 'external::my-lambda',
438
330
  * {
439
331
  * url: 'https://abc123.lambda-url.us-east-1.on.aws',
@@ -458,7 +350,7 @@ interface ISdk {
458
350
  * @example
459
351
  * ```typescript
460
352
  * // Synchronous invocation
461
- * const result = await iii.trigger<{ name: string }, { message: string }>({
353
+ * const result = await worker.trigger<{ name: string }, { message: string }>({
462
354
  * function_id: 'greet',
463
355
  * payload: { name: 'World' },
464
356
  * timeoutMs: 5000,
@@ -466,14 +358,14 @@ interface ISdk {
466
358
  * console.log(result.message) // "Hello, World!"
467
359
  *
468
360
  * // Fire-and-forget
469
- * await iii.trigger({
361
+ * await worker.trigger({
470
362
  * function_id: 'send-email',
471
363
  * payload: { to: 'user@example.com' },
472
364
  * action: TriggerAction.Void(),
473
365
  * })
474
366
  *
475
367
  * // Enqueue for async processing
476
- * const receipt = await iii.trigger({
368
+ * const receipt = await worker.trigger({
477
369
  * function_id: 'process-order',
478
370
  * payload: { orderId: '123' },
479
371
  * action: TriggerAction.Enqueue({ queue: 'orders' }),
@@ -491,12 +383,12 @@ interface ISdk {
491
383
  * ```typescript
492
384
  * type CronConfig = { expression: string }
493
385
  *
494
- * iii.registerTriggerType<CronConfig>(
386
+ * worker.registerTriggerType<CronConfig>(
495
387
  * { id: 'cron', description: 'Fires on a cron schedule' },
496
388
  * {
497
389
  * async registerTrigger({ id, function_id, config }) {
498
390
  * startCronJob(id, config.expression, () =>
499
- * iii.trigger({ function_id, payload: {} }),
391
+ * worker.trigger({ function_id, payload: {} }),
500
392
  * )
501
393
  * },
502
394
  * async unregisterTrigger({ id }) {
@@ -513,7 +405,7 @@ interface ISdk {
513
405
  *
514
406
  * @example
515
407
  * ```typescript
516
- * iii.unregisterTriggerType({ id: 'cron', description: 'Fires on a cron schedule' })
408
+ * worker.unregisterTriggerType({ id: 'cron', description: 'Fires on a cron schedule' })
517
409
  * ```
518
410
  */
519
411
  unregisterTriggerType(triggerType: RegisterTriggerTypeInput): void;
@@ -523,7 +415,7 @@ interface ISdk {
523
415
  * @example
524
416
  * ```typescript
525
417
  * process.on('SIGTERM', async () => {
526
- * await iii.shutdown()
418
+ * await worker.shutdown()
527
419
  * process.exit(0)
528
420
  * })
529
421
  * ```
@@ -531,14 +423,14 @@ interface ISdk {
531
423
  shutdown(): Promise<void>;
532
424
  }
533
425
  /**
534
- * Handle returned by {@link ISdk.registerTrigger}. Use `unregister()` to
426
+ * Handle returned by {@link IIIClient.registerTrigger}. Use `unregister()` to
535
427
  * remove the trigger from the engine.
536
428
  */
537
429
  type Trigger = {
538
430
  /** Removes this trigger from the engine. */unregister(): void;
539
431
  };
540
432
  /**
541
- * Handle returned by {@link ISdk.registerFunction}. Contains the function's
433
+ * Handle returned by {@link IIIClient.registerFunction}. Contains the function's
542
434
  * `id` and an `unregister()` method.
543
435
  */
544
436
  type FunctionRef = {
@@ -546,7 +438,7 @@ type FunctionRef = {
546
438
  unregister: () => void;
547
439
  };
548
440
  /**
549
- * Typed handle returned by {@link ISdk.registerTriggerType}.
441
+ * Typed handle returned by {@link IIIClient.registerTriggerType}.
550
442
  *
551
443
  * Provides convenience methods to register triggers and functions scoped
552
444
  * to this trigger type, so callers don't need to repeat the `type` field.
@@ -557,12 +449,12 @@ type FunctionRef = {
557
449
  * ```typescript
558
450
  * type CronConfig = { expression: string }
559
451
  *
560
- * const cron = iii.registerTriggerType<CronConfig>(
452
+ * const cron = worker.registerTriggerType<CronConfig>(
561
453
  * { id: 'cron', description: 'Fires on a cron schedule' },
562
454
  * cronHandler,
563
455
  * )
564
456
  *
565
- * // Register a trigger type is inferred as CronConfig
457
+ * // Register a trigger, type is inferred as CronConfig
566
458
  * cron.registerTrigger('my::fn', { expression: '0 *\/5 * * * * *' })
567
459
  *
568
460
  * // Register a function and bind a trigger in one call
@@ -619,89 +511,22 @@ type InternalHttpRequest<TBody = unknown> = {
619
511
  request_body: ChannelReader;
620
512
  };
621
513
  /**
622
- * Response object passed to HTTP function handlers. Use `status()` and
514
+ * Response object passed to streaming function handlers. Use `status()` and
623
515
  * `headers()` to set response metadata, write to `stream` for streaming
624
516
  * responses, and call `close()` when done.
625
517
  */
626
- type HttpResponse = {
518
+ type StreamResponse = {
627
519
  /** Set the HTTP status code. */status: (statusCode: number) => void; /** Set response headers. */
628
520
  headers: (headers: Record<string, string>) => void; /** Writable stream for the response body. */
629
521
  stream: NodeJS.WritableStream; /** Close the response. */
630
522
  close: () => void;
631
523
  };
632
524
  /**
633
- * Incoming HTTP request received by a function registered with an HTTP trigger.
525
+ * Incoming streaming request received by a function registered with a stream trigger.
634
526
  *
635
527
  * @typeParam TBody - Type of the parsed request body.
636
528
  */
637
- type HttpRequest<TBody = unknown> = Omit<InternalHttpRequest<TBody>, 'response'>;
638
- /**
639
- * Alias for {@link HttpRequest}. Represents an incoming API request.
640
- *
641
- * @typeParam TBody - Type of the parsed request body.
642
- */
643
- type ApiRequest<TBody = unknown> = HttpRequest<TBody>;
644
- /**
645
- * Structured API response returned from HTTP function handlers.
646
- *
647
- * @typeParam TStatus - HTTP status code literal type.
648
- * @typeParam TBody - Type of the response body.
649
- *
650
- * @example
651
- * ```typescript
652
- * const response: ApiResponse = {
653
- * status_code: 200,
654
- * headers: { 'content-type': 'application/json' },
655
- * body: { message: 'ok' },
656
- * }
657
- * ```
658
- */
659
- type ApiResponse<TStatus extends number = number, TBody = string | Buffer | Record<string, unknown>> = {
660
- /** HTTP status code. */status_code: TStatus; /** Response headers. */
661
- headers?: Record<string, string>; /** Response body. */
662
- body?: TBody;
663
- };
664
- //#endregion
665
- //#region src/utils.d.ts
666
- /**
667
- * Helper that wraps an HTTP-style handler (with separate `req`/`res` arguments)
668
- * into the function handler format expected by the SDK.
669
- *
670
- * @param callback - Async handler receiving an {@link HttpRequest} and {@link HttpResponse}.
671
- * @returns A function handler compatible with {@link ISdk.registerFunction}.
672
- *
673
- * @example
674
- * ```typescript
675
- * import { http } from 'iii-sdk'
676
- *
677
- * iii.registerFunction(
678
- * 'my-api',
679
- * http(async (req, res) => {
680
- * res.status(200)
681
- * res.headers({ 'content-type': 'application/json' })
682
- * res.stream.end(JSON.stringify({ hello: 'world' }))
683
- * res.close()
684
- * }),
685
- * )
686
- * ```
687
- */
688
- declare const http: (callback: (req: HttpRequest, res: HttpResponse) => Promise<void | ApiResponse>) => (req: InternalHttpRequest) => Promise<void | ApiResponse>;
689
- /**
690
- * Type guard that checks if a value is a {@link StreamChannelRef}.
691
- *
692
- * @param value - Value to check.
693
- * @returns `true` if the value is a valid `StreamChannelRef`.
694
- */
695
- declare const isChannelRef: (value: unknown) => value is StreamChannelRef;
696
- /**
697
- * Recursively extract all {@link StreamChannelRef} values from a JSON-like
698
- * input, returning each match paired with its dotted/bracketed path. Mirrors
699
- * the Rust SDK's `extract_channel_refs`.
700
- *
701
- * @param data - Arbitrary JSON-like value.
702
- * @returns Array of `[path, ref]` tuples. Empty when no refs are found.
703
- */
704
- declare const extractChannelRefs: (data: unknown) => Array<[string, StreamChannelRef]>;
529
+ type StreamRequest<TBody = unknown> = Omit<InternalHttpRequest<TBody>, 'response'>;
705
530
  //#endregion
706
- export { MessageType as A, RegisterTriggerTypeMessage as B, ChannelReader as C, EnqueueResult as D, AuthResult as E, OnTriggerRegistrationResult as F, TriggerRequest as H, OnTriggerTypeRegistrationInput as I, OnTriggerTypeRegistrationResult as L, OnFunctionRegistrationInput as M, OnFunctionRegistrationResult as N, HttpAuthConfig as O, OnTriggerRegistrationInput as P, RegisterFunctionMessage as R, ChannelItem as S, AuthInput as T, StreamChannelRef as V, Trigger as _, ApiResponse as a, TriggerHandler as b, HttpRequest as c, InternalHttpRequest as d, RegisterFunctionInput as f, RemoteFunctionHandler as g, RegisterTriggerTypeInput as h, ApiRequest as i, MiddlewareFunctionInput as j, HttpInvocationConfig as k, HttpResponse as l, RegisterTriggerInput as m, http as n, Channel as o, RegisterFunctionOptions as p, isChannelRef as r, FunctionRef as s, extractChannelRefs as t, ISdk as u, TriggerTypeRef as v, ChannelWriter as w, ChannelDirection as x, TriggerConfig as y, RegisterTriggerMessage as z };
707
- //# sourceMappingURL=utils-BnRzIUCy.d.cts.map
531
+ export { RegisterFunctionFormat as C, StreamChannelRef as D, RegisterTriggerTypeMessage as E, TriggerRequest as O, MiddlewareFunctionInput as S, RegisterTriggerMessage as T, ChannelItem as _, RegisterFunctionInput as a, ErrorBody as b, RegisterTriggerTypeInput as c, StreamResponse as d, Trigger as f, ChannelDirection as g, TriggerHandler as h, InternalHttpRequest as i, RemoteFunctionHandler as l, TriggerConfig as m, FunctionRef as n, RegisterFunctionOptions as o, TriggerTypeRef as p, IIIClient as r, RegisterTriggerInput as s, Channel as t, StreamRequest as u, ChannelReader as v, RegisterFunctionMessage as w, MessageType as x, ChannelWriter as y };
532
+ //# sourceMappingURL=types-BZoO05vA.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-BZoO05vA.d.cts","names":[],"sources":["../src/iii-types.ts","../src/channels.ts","../src/triggers.ts","../src/types.ts"],"mappings":";;;;aAEY,WAAA;EACV,gBAAA;EACA,kBAAA;EACA,cAAA;EACA,gBAAA;EACA,mBAAA;EACA,eAAA;EACA,iBAAA;EACA,qBAAA;EACA,yBAAA;EACA,gBAAA;AAAA;AAAA,KAGU,0BAAA;EACV,YAAA,EAAc,WAAA,CAAY,mBAAA;EAC1B,EAAA;EACA,WAAA;AAAA;AAAA,KAcU,SAAA;EACV,IAAA;EACA,OAAA;EACA,UAAA;AAAA;AAAA,KAWU,sBAAA;EACV,YAAA,EAAc,WAAA,CAAY,eAAA;EAC1B,EAAA;EACA,IAAA;EACA,WAAA;EACA,MAAA;EACA,QAAA,GAAW,MAAA;AAAA;AAAA,KAGD,sBAAA;EANV;;;EAUA,IAAA;EAPW;;;EAWX,WAAA;EARgC;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