import { type H2Handler } from './h2.js'; import { type ProtoSchema } from './protobuf.js'; /** gRPC's status codes (https://grpc.github.io/grpc/core/md_doc_statuscodes.html). */ export declare const GrpcStatus: { readonly OK: 0; readonly CANCELLED: 1; readonly UNKNOWN: 2; readonly INVALID_ARGUMENT: 3; readonly DEADLINE_EXCEEDED: 4; readonly NOT_FOUND: 5; readonly ALREADY_EXISTS: 6; readonly PERMISSION_DENIED: 7; readonly RESOURCE_EXHAUSTED: 8; readonly FAILED_PRECONDITION: 9; readonly ABORTED: 10; readonly OUT_OF_RANGE: 11; readonly UNIMPLEMENTED: 12; readonly INTERNAL: 13; readonly UNAVAILABLE: 14; readonly DATA_LOSS: 15; readonly UNAUTHENTICATED: 16; }; /** A call answered with a gRPC status other than OK: its code and its message. */ export declare class GrpcError extends Error { readonly code: number; constructor(code: number, message: string); } export type GrpcCall = { /** the operation the rpc is (the derive's name for it) and its path */ operation: string; path: string; /** the request message, in its proto3 JSON form */ request: Record; /** the call's metadata (its non-pseudo headers: `authorization`, `x-goog-api-client`, …) */ metadata: Record; /** aborted when the client cancels or its deadline passes */ signal: AbortSignal; }; /** Answers one unary call with its response message's JSON form, or throws a GrpcError. */ export type GrpcHandler = (call: GrpcCall) => Promise>; /** `grpc-timeout`: an integer and a unit (H M S m u n), PROTOCOL-HTTP2.md "Timeout". */ export declare function parseGrpcTimeout(value: string | undefined): number | undefined; /** Length-prefixed messages out of a request body: [compressed flag][u32 length][bytes]… */ export declare function splitGrpcFrames(body: Uint8Array): Array<{ compressed: boolean; message: Uint8Array; }>; export declare function grpcFrame(message: Uint8Array): Uint8Array; /** grpc-message is percent-encoded (PROTOCOL-HTTP2.md "Status-Message"). */ export declare function encodeGrpcMessage(text: string): string; /** The HTTP/2 stream handler that answers the unary rpcs of a proto unit's schema through `handler`. */ export declare function grpcStreamHandler(schema: ProtoSchema, handler: GrpcHandler): H2Handler; /** A gRPC call answered by the pack's own fetch, as the derive serves a proto unit's rpc (`POST /./ * `, the request message's JSON form the body): its JSON answer is the response message; any other status its * gRPC code, the error's message as the status message. */ export declare function grpcOverFetch(fetch: (request: Request) => Promise): GrpcHandler; /** A pack that speaks gRPC, served on one port: HTTP/2 (gRPC, by the schema through the pack's fetch) and HTTP/1 (the * pack's fetch: its doors, its REST) on the same socket, as the kernel's HTTP/2 server tells them apart. Inside a World * it answers the World's boot probe as `serveHttp` does. */ export declare function serveGrpc(options: { port?: number; fetch: (request: Request) => Promise; schema: ProtoSchema; }): Promise<{ port: number; stop: () => void; }>;