import { CancelledError, RestateError, RetryableError, RetryableErrorOptions, TerminalError, TimeoutError } from "./types/errors.js";
import { Hooks, HooksProvider, Interceptor } from "./hooks.js";
import { Client, ClientCallOptions, ClientSendOptions, InferArg, ObjectHandlerOpts, ObjectOptions, ObjectOpts, Opts, RemoveVoidArgument, RetryPolicy, SendClient, SendOpts, ServiceHandlerOpts, ServiceOptions, ServiceOpts, WorkflowHandlerOpts, WorkflowOptions, WorkflowOpts, handlers, object, rpc, service, workflow } from "./types/rpc.js";
import { Context, ContextDate, DurablePromise, GenericCall, GenericSend, InvocationHandle, InvocationId, InvocationIdParser, InvocationPromise, KeyValueStore, ObjectContext, ObjectSharedContext, Rand, Request, RestatePromise, RunAction, RunOptions, Target, TypedState, UntypedState, WorkflowContext, WorkflowSharedContext } from "./context.js";
import { internal_d_exports } from "./internal.js";
import { LogMetadata, LogSource, LoggerContext, LoggerTransport, RestateLogLevel } from "./logging/logger_transport.js";
import { DefaultServiceOptions, RestateEndpoint, RestateEndpointBase } from "./endpoint.js";
import { isRestatePromise } from "./promises.js";
import { EndpointOptions } from "./endpoint/types.js";
import { CombineablePromise, Duration, JournalValueCodec, ObjectHandler, RestateContext, RestateObjectContext, RestateObjectSharedContext, RestateWorkflowContext, RestateWorkflowSharedContext, Serde, Service, ServiceDefinition, ServiceDefinitionFrom, ServiceHandler, VirtualObject, VirtualObjectDefinition, VirtualObjectDefinitionFrom, Workflow, WorkflowDefinition, WorkflowDefinitionFrom, WorkflowHandler, WorkflowSharedHandler, createObjectHandler, createObjectSharedHandler, createServiceHandler, createWorkflowHandler, createWorkflowSharedHandler, serde } from "./common_api.js";
import * as http0 from "http";
import * as http20 from "http2";

//#region src/node.d.ts
/**
 * Create a new {@link RestateEndpoint}.
 * @deprecated Please use {@link createEndpointHandler}
 */
declare function endpoint(): RestateEndpoint;
/**
 * Options for creating a Node.js endpoint handler.
 *
 * Extends {@link EndpointOptions} with Node.js-specific options for controlling
 * the protocol mode.
 */
interface NodeEndpointOptions extends EndpointOptions {
  /**
   * Controls the protocol mode used by the handler.
   *
   * - `undefined` (default): auto-detect based on HTTP version.
   *   HTTP/2+ uses bidirectional streaming (`BIDI_STREAM`),
   *   HTTP/1.1 uses request-response mode (`REQUEST_RESPONSE`).
   * - `true`: force `BIDI_STREAM` for all requests.
   * - `false`: force `REQUEST_RESPONSE` for all requests.
   */
  bidirectional?: boolean;
}
/**
 * Creates a request handler for the provided services.
 *
 * The returned handler auto-detects the HTTP protocol version per request:
 * - HTTP/2+ requests use bidirectional streaming (`BIDI_STREAM`)
 * - HTTP/1.1 requests use request-response mode (`REQUEST_RESPONSE`) by default
 *
 * Set `bidirectional: true` to force `BIDI_STREAM` for all requests, or
 * `bidirectional: false` to force `REQUEST_RESPONSE` for all requests.
 *
 * @example HTTP/2 server
 * ```
 * const httpServer = http2.createServer(createEndpointHandler({ services: [myService] }));
 * httpServer.listen(port);
 * ```
 *
 * @example HTTP/1.1 server
 * ```
 * const httpServer = http.createServer(createEndpointHandler({ services: [myService] }));
 * httpServer.listen(port);
 * ```
 *
 * @param {NodeEndpointOptions} options - Configuration options for the endpoint handler.
 * @returns A request handler function compatible with both HTTP/1.1 and HTTP/2 servers.
 */
declare function createEndpointHandler(options: NodeEndpointOptions): {
  (request: http0.IncomingMessage, response: http0.ServerResponse): void;
  (request: http20.Http2ServerRequest, response: http20.Http2ServerResponse): void;
};
interface ServeOptions extends EndpointOptions {
  port?: number;
}
/**
 * Serves this Restate services as HTTP2 server, listening to the given port.
 *
 * If the port is undefined, this method will use the port set in the `PORT`
 * environment variable. If that variable is undefined as well, the method will
 * default to port 9080.
 *
 * The returned promise resolves with the bound port when the server starts listening, or rejects with a failure otherwise.
 *
 * If you need to manually control the server lifecycle, we suggest to manually instantiate the http2 server and use {@link createEndpointHandler}.
 *
 * @param {ServeOptions} options - Configuration options for the endpoint handler.
 * @returns a Promise that resolves with the bound port, or rejects with a failure otherwise.
 */
declare function serve({
  port,
  ...options
}: ServeOptions): Promise<number>;
//#endregion
export { CancelledError, Client, ClientCallOptions, ClientSendOptions, CombineablePromise, Context, ContextDate, DefaultServiceOptions, DurablePromise, Duration, EndpointOptions, GenericCall, GenericSend, Hooks, HooksProvider, InferArg, Interceptor, InvocationHandle, InvocationId, InvocationIdParser, InvocationPromise, JournalValueCodec, KeyValueStore, LogMetadata, LogSource, LoggerContext, LoggerTransport, NodeEndpointOptions, ObjectContext, ObjectHandler, ObjectHandlerOpts, ObjectOptions, ObjectOpts, ObjectSharedContext, Opts, Rand, RemoveVoidArgument, Request, RestateContext, RestateEndpoint, RestateEndpointBase, RestateError, RestateLogLevel, RestateObjectContext, RestateObjectSharedContext, RestatePromise, RestateWorkflowContext, RestateWorkflowSharedContext, RetryPolicy, RetryableError, RetryableErrorOptions, RunAction, RunOptions, SendClient, SendOpts, Serde, ServeOptions, Service, ServiceDefinition, ServiceDefinitionFrom, ServiceHandler, ServiceHandlerOpts, ServiceOptions, ServiceOpts, Target, TerminalError, TimeoutError, TypedState, UntypedState, VirtualObject, VirtualObjectDefinition, VirtualObjectDefinitionFrom, Workflow, WorkflowContext, WorkflowDefinition, WorkflowDefinitionFrom, WorkflowHandler, WorkflowHandlerOpts, WorkflowOptions, WorkflowOpts, WorkflowSharedContext, WorkflowSharedHandler, createEndpointHandler, createObjectHandler, createObjectSharedHandler, createServiceHandler, createWorkflowHandler, createWorkflowSharedHandler, endpoint, handlers, internal_d_exports as internal, isRestatePromise, object, rpc, serde, serve, service, workflow };
//# sourceMappingURL=node.d.ts.map