UNPKG

rivetkit

Version:

Lightweight libraries for building stateful actors on edge platforms

157 lines (154 loc) 5.32 kB
import { D as DeconstructedError } from '../utils-fwx3o3K9.js'; import 'hono'; import 'hono/utils/http-status'; declare const INTERNAL_ERROR_CODE = "internal_error"; declare const INTERNAL_ERROR_DESCRIPTION = "Internal error. Read the server logs for more details."; type InternalErrorMetadata = {}; declare const USER_ERROR_CODE = "user_error"; interface ActorErrorOptions extends ErrorOptions { /** Error data can safely be serialized in a response to the client. */ public?: boolean; /** Metadata associated with this error. This will be sent to clients. */ metadata?: unknown; } declare class ActorError extends Error { __type: string; public: boolean; metadata?: unknown; statusCode: number; readonly group: string; readonly code: string; static isActorError(error: unknown): error is ActorError | DeconstructedError; constructor(group: string, code: string, message: string, opts?: ActorErrorOptions); toString(): string; /** * Serialize error for HTTP response */ serializeForHttp(): { type: string; message: string; metadata: unknown; }; } declare class InternalError extends ActorError { constructor(message: string); } declare class Unreachable extends InternalError { constructor(x: never); } declare class StateNotEnabled extends ActorError { constructor(); } declare class ConnStateNotEnabled extends ActorError { constructor(); } declare class VarsNotEnabled extends ActorError { constructor(); } declare class ActionTimedOut extends ActorError { constructor(); } declare class ActionNotFound extends ActorError { constructor(name: string); } declare class InvalidEncoding extends ActorError { constructor(format?: string); } declare class ConnNotFound extends ActorError { constructor(id?: string); } declare class IncorrectConnToken extends ActorError { constructor(); } declare class MessageTooLong extends ActorError { constructor(); } declare class MalformedMessage extends ActorError { constructor(cause?: unknown); } interface InvalidStateTypeOptions { path?: unknown; } declare class InvalidStateType extends ActorError { constructor(opts?: InvalidStateTypeOptions); } declare class Unsupported extends ActorError { constructor(feature: string); } /** * Options for the UserError class. */ interface UserErrorOptions extends ErrorOptions { /** * Machine readable code for this error. Useful for catching different types of errors in try-catch. */ code?: string; /** * Additional metadata related to the error. Useful for understanding context about the error. */ metadata?: unknown; } /** Error that can be safely returned to the user. */ declare class UserError extends ActorError { /** * Constructs a new UserError instance. * * @param message - The error message to be displayed. * @param opts - Optional parameters for the error, including a machine-readable code and additional metadata. */ constructor(message: string, opts?: UserErrorOptions); } declare class InvalidQueryJSON extends ActorError { constructor(error?: unknown); } declare class InvalidRequest extends ActorError { constructor(error?: unknown); } declare class ActorNotFound extends ActorError { constructor(identifier?: string); } declare class ActorAlreadyExists extends ActorError { constructor(name: string, key: string[]); } declare class ProxyError extends ActorError { constructor(operation: string, error?: unknown); } declare class InvalidActionRequest extends ActorError { constructor(message: string); } declare class InvalidParams extends ActorError { constructor(message: string); } declare class Unauthorized extends ActorError { constructor(message?: string); } declare class Forbidden extends ActorError { constructor(message?: string, opts?: { metadata?: unknown; }); } declare class DatabaseNotEnabled extends ActorError { constructor(); } declare class FetchHandlerNotDefined extends ActorError { constructor(); } declare class WebSocketHandlerNotDefined extends ActorError { constructor(); } declare class InvalidFetchResponse extends ActorError { constructor(); } declare class MissingActorHeader extends ActorError { constructor(); } declare class WebSocketsNotEnabled extends ActorError { constructor(); } declare class FeatureNotImplemented extends ActorError { constructor(feature: string); } declare class RouteNotFound extends ActorError { constructor(); } export { ActionNotFound, ActionTimedOut, ActorAlreadyExists, ActorError, ActorNotFound, ConnNotFound, ConnStateNotEnabled, DatabaseNotEnabled, FeatureNotImplemented, FetchHandlerNotDefined, Forbidden, INTERNAL_ERROR_CODE, INTERNAL_ERROR_DESCRIPTION, IncorrectConnToken, InternalError, type InternalErrorMetadata, InvalidActionRequest, InvalidEncoding, InvalidFetchResponse, InvalidParams, InvalidQueryJSON, InvalidRequest, InvalidStateType, type InvalidStateTypeOptions, MalformedMessage, MessageTooLong, MissingActorHeader, ProxyError, RouteNotFound, StateNotEnabled, USER_ERROR_CODE, Unauthorized, Unreachable, Unsupported, UserError, type UserErrorOptions, VarsNotEnabled, WebSocketHandlerNotDefined, WebSocketsNotEnabled };