import { A as MessageType, B as RegisterTriggerTypeMessage, C as ChannelReader, D as EnqueueResult, E as AuthResult, F as OnTriggerRegistrationResult, H as TriggerAction$1, I as OnTriggerTypeRegistrationInput, L as OnTriggerTypeRegistrationResult, M as OnFunctionRegistrationInput, N as OnFunctionRegistrationResult, O as HttpAuthConfig, P as OnTriggerRegistrationInput, R as RegisterFunctionMessage, T as AuthInput, U as TriggerRequest, V as StreamChannelRef, _ as Trigger, a as ApiResponse, b as TriggerHandler, c as HttpRequest, d as InternalHttpRequest, f as RegisterFunctionInput, g as RemoteFunctionHandler, h as RegisterTriggerTypeInput, i as ApiRequest, j as MiddlewareFunctionInput, k as HttpInvocationConfig, l as HttpResponse, m as RegisterTriggerInput, n as http, o as Channel, p as RegisterFunctionOptions, s as FunctionRef, u as ISdk, v as TriggerTypeRef, w as ChannelWriter, y as TriggerConfig, z as RegisterTriggerMessage } from "./utils-tcJ0Rzg-.mjs"; import { Logger, OtelConfig } from "@iii-dev/observability"; //#region src/errors.d.ts /** * Typed error surfaced when an invocation dispatched over the SDK fails — RBAC * rejection (FORBIDDEN), handler-level failure, or a timeout waiting for the * engine to respond. Wraps the wire `ErrorBody` shape plus the `function_id` * that was targeted, so callers get a single error type across all failure * modes and can disambiguate via `err.code`. * * Before this existed, rejection values were plain `ErrorBody`-shaped objects, * which printed as `[object Object]` when stringified — leaving developers to * grep through SDK source to figure out what tripped. The class name, `code` * prefix in the message, and `function_id` field together make a rejection * self-describing. */ type IIIInvocationErrorInit = { code: string; message: string; function_id?: string; stacktrace?: string; }; declare class IIIInvocationError extends Error { readonly code: string; readonly function_id?: string; readonly stacktrace?: string; constructor(init: IIIInvocationErrorInit); } //#endregion //#region src/iii-constants.d.ts /** * Constants for the III module. */ /** * Engine function paths for internal operations. * * Naming note: `LIST_TRIGGERS` / `INFO_TRIGGERS` cover trigger TYPES * (templates). `LIST_REGISTERED_TRIGGERS` / `INFO_REGISTERED_TRIGGERS` * cover trigger INSTANCES (subscriber rows). The old * `engine::trigger-types::list` builtin has been removed and is now * served by `engine::triggers::list`. */ declare const EngineFunctions: { readonly LIST_FUNCTIONS: "engine::functions::list"; readonly INFO_FUNCTIONS: "engine::functions::info"; readonly LIST_WORKERS: "engine::workers::list"; readonly INFO_WORKERS: "engine::workers::info"; readonly LIST_TRIGGERS: "engine::triggers::list"; readonly INFO_TRIGGERS: "engine::triggers::info"; readonly LIST_REGISTERED_TRIGGERS: "engine::registered-triggers::list"; readonly INFO_REGISTERED_TRIGGERS: "engine::registered-triggers::info"; readonly REGISTER_WORKER: "engine::workers::register"; }; /** Engine trigger types */ declare const EngineTriggers: { readonly FUNCTIONS_AVAILABLE: "engine::functions-available"; readonly LOG: "log"; }; /** Configuration for WebSocket reconnection behavior */ interface IIIReconnectionConfig { /** Starting delay in milliseconds (default: 1000ms) */ initialDelayMs: number; /** Maximum delay cap in milliseconds (default: 30000ms) */ maxDelayMs: number; /** Exponential backoff multiplier (default: 2) */ backoffMultiplier: number; /** Random jitter factor 0-1 (default: 0.3) */ jitterFactor: number; /** Maximum retry attempts, -1 for infinite (default: -1) */ maxRetries: number; } //#endregion //#region src/iii.d.ts /** @internal */ type TelemetryOptions = { language?: string; project_name?: string; framework?: string; amplitude_api_key?: string; }; /** * Configuration options passed to {@link registerWorker}. * * @example * ```typescript * const iii = registerWorker('ws://localhost:49134', { * workerName: 'my-worker', * invocationTimeoutMs: 10000, * reconnectionConfig: { maxRetries: 5 }, * }) * ``` */ type InitOptions = { /** Display name for this worker. Defaults to `hostname:pid`. */workerName?: string; /** Enable worker metrics via OpenTelemetry. Defaults to `true`. */ enableMetricsReporting?: boolean; /** Default timeout for `trigger()` in milliseconds. Defaults to `30000`. */ invocationTimeoutMs?: number; /** * WebSocket reconnection behavior. * * @see {@link IIIReconnectionConfig} for available fields and defaults. */ reconnectionConfig?: Partial; /** * OpenTelemetry configuration. OTel is initialized automatically by default. * Set `{ enabled: false }` or env `OTEL_ENABLED=false/0/no/off` to disable. * The `engineWsUrl` is set automatically from the III address. */ otel?: Omit; /** Custom HTTP headers sent during the WebSocket handshake. */ headers?: Record; /** @internal */ telemetry?: TelemetryOptions; }; /** * Factory object that constructs routing actions for {@link ISdk.trigger}. * * @example * ```typescript * import { TriggerAction } from 'iii-sdk' * * // Enqueue to a named queue * iii.trigger({ * function_id: 'process', * payload: { data: 'hello' }, * action: TriggerAction.Enqueue({ queue: 'jobs' }), * }) * * // Fire-and-forget * iii.trigger({ * function_id: 'notify', * payload: {}, * action: TriggerAction.Void(), * }) * ``` */ declare const TriggerAction: { /** * Routes the invocation through a named queue. The engine enqueues the job, * acknowledges the caller with `{ messageReceiptId }`, and processes it * asynchronously. * * @param opts - Queue routing options. * @param opts.queue - Name of the target queue. */ readonly Enqueue: (opts: { queue: string; }) => TriggerAction$1; /** * Fire-and-forget routing. The engine forwards the invocation without * waiting for a response or queuing the job. */ readonly Void: () => TriggerAction$1; }; /** * Creates and returns a connected SDK instance. The WebSocket connection is * established automatically -- there is no separate `connect()` call. * * @param address - WebSocket URL of the III engine (e.g. `ws://localhost:49134`). * @param options - Optional {@link InitOptions} for worker name, timeouts, reconnection, and OTel. * @returns A connected {@link ISdk} instance. * * @example * ```typescript * import { registerWorker } from 'iii-sdk' * * const iii = registerWorker(process.env.III_URL ?? 'ws://localhost:49134', { * workerName: 'my-worker', * }) * ``` */ declare const registerWorker: (address: string, options?: InitOptions) => ISdk; //#endregion export { type ApiRequest, type ApiResponse, type AuthInput, type AuthResult, type Channel, ChannelReader, ChannelWriter, EngineFunctions, EngineTriggers, type EnqueueResult, type FunctionRef, type HttpAuthConfig, type HttpInvocationConfig, type HttpRequest, type HttpResponse, IIIInvocationError, type IIIInvocationErrorInit, type ISdk, type InitOptions, type InternalHttpRequest, Logger, type MessageType, type MiddlewareFunctionInput, type OnFunctionRegistrationInput, type OnFunctionRegistrationResult, type OnTriggerRegistrationInput, type OnTriggerRegistrationResult, type OnTriggerTypeRegistrationInput, type OnTriggerTypeRegistrationResult, type RegisterFunctionInput, type RegisterFunctionMessage, type RegisterFunctionOptions, type RegisterTriggerInput, type RegisterTriggerMessage, type RegisterTriggerTypeInput, type RegisterTriggerTypeMessage, type RemoteFunctionHandler, type StreamChannelRef, type Trigger, TriggerAction, type TriggerAction$1 as TriggerActionType, type TriggerConfig, type TriggerHandler, type TriggerRequest, type TriggerTypeRef, http, registerWorker }; //# sourceMappingURL=index.d.mts.map