import { CancelledError, RestateError, RetryableError, TerminalError, TimeoutError } from "./types/errors.js";
import { Opts, SendOpts, handlers, object, rpc, service, workflow } from "./types/rpc.js";
import { InvocationIdParser, RestatePromise } from "./context.js";
import { CombineablePromise, createObjectHandler, createObjectSharedHandler, createServiceHandler, createWorkflowHandler, createWorkflowSharedHandler, serde } from "./common_api.js";
import { withOptions } from "./endpoint/withOptions.js";
import { NodeEndpoint } from "./endpoint/node_endpoint.js";

//#region src/node.ts
/**
* Create a new {@link RestateEndpoint}.
* @deprecated Please use {@link createEndpointHandler}
*/
function endpoint() {
	return new NodeEndpoint();
}
/**
* Creates an HTTP/2 request handler for the provided services.
*
* @example
* ```
* const httpServer = http2.createServer(createEndpointHandler({ services: [myService] }));
* httpServer.listen(port);
* ```
* @param {EndpointOptions} options - Configuration options for the endpoint handler.
* @returns An HTTP/2 request handler function.
*/
function createEndpointHandler(options) {
	return withOptions(new NodeEndpoint(), options).http2Handler();
}
/**
* 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.
*/
function serve({ port,...options }) {
	return withOptions(new NodeEndpoint(), options).listen(port);
}

//#endregion
export { CancelledError, CombineablePromise, InvocationIdParser, Opts, RestateError, RestatePromise, RetryableError, SendOpts, TerminalError, TimeoutError, createEndpointHandler, createObjectHandler, createObjectSharedHandler, createServiceHandler, createWorkflowHandler, createWorkflowSharedHandler, endpoint, handlers, object, rpc, serde, serve, service, workflow };
//# sourceMappingURL=node.js.map