/** * Defines protocol messages for event-log remote clients and servers. * * This module is the shared boundary between `EventLogRemote` clients and * event-log servers. It defines store ids, protocol errors, the * hello/authenticate session handshake, remote calls for writes and changes, * and message formats for encrypted or plaintext journal entries. * * @stability unstable * @since 4.0.0 */ import type { NonEmptyReadonlyArray } from "../Array.ts"; import type { Brand } from "../Brand.ts"; import * as Effect from "../Effect.ts"; import * as SchemaBinary from "../encoding/SchemaBinary.ts"; import * as Rpc from "../rpc/Rpc.ts"; import * as RpcGroup from "../rpc/RpcGroup.ts"; import * as RpcMiddleware from "../rpc/RpcMiddleware.ts"; import * as Schema from "../Schema.ts"; import type * as SchemaAST from "../SchemaAST.ts"; import * as Transferable from "../workers/Transferable.ts"; import { Entry, RemoteEntry } from "./EventJournal.ts"; import type { Identity } from "./EventLog.ts"; /** * Type-level identifier used to brand event-log store ids. * * @stability unstable * @category type IDs * @since 4.0.0 */ export type StoreIdTypeId = "effect/eventlog/EventLog/StoreId"; /** * Runtime brand identifier for event-log store ids. * * @stability unstable * @category type IDs * @since 4.0.0 */ export declare const StoreIdTypeId: StoreIdTypeId; /** * Branded string identifying a logical event-log store. * * @stability unstable * @category models * @since 4.0.0 */ export type StoreId = string & Brand; /** * Schema for branded event-log store ids. * * @stability unstable * @category schemas * @since 4.0.0 */ export declare const StoreId: Schema.brand; declare const EventLogProtocolError_base: Schema.Class; readonly storeId: Schema.optional>; readonly code: Schema.Literals; readonly message: Schema.String; }>, import("../Cause.ts").YieldableError>; /** * Error returned by event-log remote RPCs. * * **Details** * * It records the request tag, optional identity and store information, a protocol * error code, and a human-readable message. * * @stability unstable * @category protocols * @since 4.0.0 */ export declare class EventLogProtocolError extends EventLogProtocolError_base { /** * Returns `true` when the value is an `EventLogProtocolError`. * * @stability unstable * @since 4.0.0 */ static is(u: unknown): u is EventLogProtocolError; } declare const EventLogAuthentication_base: RpcMiddleware.ServiceClass; /** * RPC middleware that authenticates event-log requests and provides the client * `Identity` to authenticated handlers. * * @stability unstable * @category middleware * @since 4.0.0 */ export declare class EventLogAuthentication extends EventLogAuthentication_base { } declare const HelloResponse_base: Schema.Class; readonly challenge: Transferable.Transferable, Uint8Array>>; readonly firstSequence: Schema.optional; readonly compaction: Schema.optional>; }>, {}>; /** * Response sent by the remote server during the authentication handshake. * * **Details** * * Contains the remote id, a challenge for the client to sign, and the lowest * assigned sequence (default 0) for initializing acknowledgement cursors. * `compaction` is `true` when the server serves `EventLogCompactionRpcs`. * * @stability unstable * @category protocols * @since 4.0.0 */ export declare class HelloResponse extends HelloResponse_base { } declare const HelloRpc_base: Rpc.Rpc<"EventLog.Hello", Schema.Void, typeof HelloResponse, Schema.Never, never, never>; /** * RPC used to start an event-log remote session and receive a `HelloResponse`. * * @stability unstable * @category protocols * @since 4.0.0 */ export declare class HelloRpc extends HelloRpc_base { } declare const Authenticate_base: Schema.Class, Uint8Array>>; readonly signature: Transferable.Transferable, Uint8Array>>; readonly algorithm: Schema.Literal<"Ed25519">; }>, {}>; /** * Schema for an authentication request containing the client public key, * Ed25519 signing public key, signature over the session challenge payload, and * algorithm name. * * @stability unstable * @category protocols * @since 4.0.0 */ export declare class Authenticate extends Authenticate_base { } declare const AuthenticateRpc_base: Rpc.Rpc<"EventLog.Authenticate", typeof Authenticate, Schema.Void, typeof EventLogProtocolError, never, never>; /** * RPC used to authenticate a remote event-log session after `HelloRpc`. * * @stability unstable * @category protocols * @since 4.0.0 */ export declare class AuthenticateRpc extends AuthenticateRpc_base { } declare const SingleMessage_base: Schema.Class, Uint8Array>>; }>, {}>; /** * Represents an entire encoded event-log payload in one transport frame. * * @stability unstable * @category protocols * @since 4.0.0 */ export declare class SingleMessage extends SingleMessage_base { } declare const ChunkedMessage_base: Schema.Class; readonly data: Transferable.Transferable, Uint8Array>>; }>, {}>; /** * Represents one part of a large encoded event-log payload. * * **When to use** * * Use to divide data into chunks and `join` to reassemble all chunks with * the same id once every part has arrived. * * @stability unstable * @category protocols * @since 4.0.0 */ export declare class ChunkedMessage extends ChunkedMessage_base { static chunkSize: number; static initialJoinState(): Map; count: number; bytes: number; }>; /** * Splits binary event-log message data into numbered chunks. * * @stability unstable * @since 4.0.0 */ static split(id: number, data: Uint8Array): NonEmptyReadonlyArray; /** * Reassembles all chunks for a message id into the original binary payload. * * @stability unstable * @since 4.0.0 */ static join(map: Map; count: number; bytes: number; }>, part: ChunkedMessage): Uint8Array | undefined; } /** * Schema for a written entry's id and a sequence at which the server stores * it. Entries the server already held keep their stored sequence. When a write * stores an entry again, as part of a partly known batch, it is acknowledged at * its new position. * * @stability unstable * @category protocols * @since 4.0.6 */ export declare const WriteAck: Schema.Struct<{ readonly entryId: Schema.brand, Uint8Array>, "effect/eventlog/EventJournal/EntryId">; readonly sequence: Schema.Natural; }>; /** * Acknowledgement of one written entry. * * @stability unstable * @category protocols * @since 4.0.6 */ export type WriteAck = typeof WriteAck.Type; declare const WriteChunkedRpc_base: Rpc.Rpc<"EventLog.WriteChunked", typeof ChunkedMessage, Schema.$Array, Uint8Array>, "effect/eventlog/EventJournal/EntryId">; readonly sequence: Schema.Natural; }>>, typeof EventLogProtocolError, typeof EventLogAuthentication, never>; /** * RPC used to send one chunk of a large encoded write payload. * * **Details** * * The completing chunk returns acknowledgements in request order; earlier * chunks return an empty array. * * @stability unstable * @category protocols * @since 4.0.0 */ export declare class WriteChunkedRpc extends WriteChunkedRpc_base { } declare const WriteEntries_base: Schema.Class; readonly batches: Schema.$Array, Uint8Array>, "effect/eventlog/EventJournal/EntryId">>; readonly iv: Transferable.Transferable, Uint8Array>>; readonly encryptedBatch: Transferable.Transferable, Uint8Array>>; }>>; }>, {}>; /** * Schema for encrypted event-log write payloads sent to a remote store. * * **Details** * * It includes the client public key, target store id, and the entries * encrypted as batches. * * @stability unstable * @category protocols * @since 4.0.0 */ export declare class WriteEntries extends WriteEntries_base { static FromSchemaBinary: SchemaBinary.toCodec; static encode: (input: WriteEntries, options?: SchemaAST.ParseOptions) => Effect.Effect, Schema.SchemaError, never>; static decode: (input: Uint8Array, options?: SchemaAST.ParseOptions) => Effect.Effect; get encoded(): Effect.Effect, Schema.SchemaError, never>; } declare const WriteEntriesUnencrypted_base: Schema.Class; readonly entries: Schema.$Array; }>, {}>; /** * Schema for plaintext event-log write payloads sent to a remote store. * * @stability unstable * @category protocols * @since 4.0.0 */ export declare class WriteEntriesUnencrypted extends WriteEntriesUnencrypted_base { static FromSchemaBinary: SchemaBinary.toCodec; static encode: (input: WriteEntriesUnencrypted, options?: SchemaAST.ParseOptions) => Effect.Effect, Schema.SchemaError, never>; static decode: (data: Uint8Array, options?: SchemaAST.ParseOptions) => Effect.Effect; get encoded(): Effect.Effect, Schema.SchemaError, never>; } declare const WriteSingleRpc_base: Rpc.Rpc<"EventLog.WriteSingle", Schema.Struct<{ data: Transferable.Transferable, Uint8Array>>; }>, Schema.$Array, Uint8Array>, "effect/eventlog/EventJournal/EntryId">; readonly sequence: Schema.Natural; }>>, typeof EventLogProtocolError, typeof EventLogAuthentication, never>; /** * RPC used to send an encoded write payload that fits in one message. * * **Details** * * The response acknowledges every written entry, in request order. * * @stability unstable * @category protocols * @since 4.0.0 */ export declare class WriteSingleRpc extends WriteSingleRpc_base { } declare const ChangesRpc_base: Rpc.Rpc<"EventLog.Changes", Schema.Struct<{ publicKey: Schema.String; storeId: Schema.brand; startSequence: Schema.Natural; }>, import("../rpc/RpcSchema.ts").Stream, typeof EventLogProtocolError>, Schema.Never, typeof EventLogAuthentication, never>; /** * RPC used to stream remote event-log changes for a public key and store id * starting at a sequence number. * * **Details** * * Responses are encoded as either `SingleMessage` values or `ChunkedMessage` * parts. Entries written on this connection are acknowledged, not echoed. * * @stability unstable * @category protocols * @since 4.0.0 */ export declare class ChangesRpc extends ChangesRpc_base { static EncryptedFromSchemaBinary: SchemaBinary.toCodec, Uint8Array>, "effect/eventlog/EventJournal/EntryId">>; readonly iv: Transferable.Transferable, Uint8Array>>; readonly encryptedBatch: Transferable.Transferable, Uint8Array>>; readonly sequence: Schema.Natural; }>>>; static UnencryptedFromSchemaBinary: SchemaBinary.toCodec>; static encodeEncrypted: (input: readonly [{ readonly entryIds: readonly [Uint8Array & Brand<"effect/eventlog/EventJournal/EntryId">, ...(Uint8Array & Brand<"effect/eventlog/EventJournal/EntryId">)[]]; readonly iv: Uint8Array; readonly encryptedBatch: Uint8Array; readonly sequence: number; }, ...{ readonly entryIds: readonly [Uint8Array & Brand<"effect/eventlog/EventJournal/EntryId">, ...(Uint8Array & Brand<"effect/eventlog/EventJournal/EntryId">)[]]; readonly iv: Uint8Array; readonly encryptedBatch: Uint8Array; readonly sequence: number; }[]], options?: SchemaAST.ParseOptions) => Effect.Effect, Schema.SchemaError, never>; static decodeEncrypted: (input: Uint8Array, options?: SchemaAST.ParseOptions) => Effect.Effect & Brand<"effect/eventlog/EventJournal/EntryId">, ...(Uint8Array & Brand<"effect/eventlog/EventJournal/EntryId">)[]]; readonly iv: Uint8Array; readonly encryptedBatch: Uint8Array; readonly sequence: number; }, ...{ readonly entryIds: readonly [Uint8Array & Brand<"effect/eventlog/EventJournal/EntryId">, ...(Uint8Array & Brand<"effect/eventlog/EventJournal/EntryId">)[]]; readonly iv: Uint8Array; readonly encryptedBatch: Uint8Array; readonly sequence: number; }[]], Schema.SchemaError, never>; static encodeUnencrypted: (input: readonly [RemoteEntry, ...RemoteEntry[]], options?: SchemaAST.ParseOptions) => Effect.Effect, Schema.SchemaError, never>; static decodeUnencrypted: (input: Uint8Array, options?: SchemaAST.ParseOptions) => Effect.Effect; } declare const EventLogRemoteRpcs_base: RpcGroup.RpcGroup; /** * RPC group containing the event-log remote handshake, authentication, write, and * changes endpoints. * * @stability unstable * @category protocols * @since 4.0.0 */ export declare class EventLogRemoteRpcs extends EventLogRemoteRpcs_base { } declare const CompactionStatus_base: Schema.Class, {}>; /** * The compaction state of a store, as reported to clients. * * **Details** * * `wanted` is `true` when the server would open a compaction stage. `head` is * the highest stored sequence. * * @stability unstable * @category protocols * @since 4.0.0 */ export declare class CompactionStatus extends CompactionStatus_base { } declare const CompactionStatusRpc_base: Rpc.Rpc<"EventLog.CompactionStatus", Schema.Struct<{ publicKey: Schema.String; storeId: Schema.brand; }>, typeof CompactionStatus, typeof EventLogProtocolError, typeof EventLogAuthentication, never>; /** * RPC that reports a store's compaction state. * * @stability unstable * @category protocols * @since 4.0.0 */ export declare class CompactionStatusRpc extends CompactionStatusRpc_base { } /** * Schema for the result of opening a compaction stage. * * **Details** * * `Started` pins the stage to the active generation and to the last input * sequence. `Busy` means another stage is open on the store. `NotWanted` means * the store doesn't need compacting. * * @stability unstable * @category protocols * @since 4.0.0 */ export declare const CompactionBeginResult: Schema.Union, Schema.TaggedStruct<"Busy", {}>, Schema.TaggedStruct<"NotWanted", {}>]>; /** * The result of opening a compaction stage. * * @stability unstable * @category protocols * @since 4.0.0 */ export type CompactionBeginResult = typeof CompactionBeginResult.Type; declare const CompactionBeginRpc_base: Rpc.Rpc<"EventLog.CompactionBegin", Schema.Struct<{ publicKey: Schema.String; storeId: Schema.brand; }>, Schema.Union, Schema.TaggedStruct<"Busy", {}>, Schema.TaggedStruct<"NotWanted", {}>]>, typeof EventLogProtocolError, typeof EventLogAuthentication, never>; /** * RPC that opens a compaction stage. * * @stability unstable * @category protocols * @since 4.0.0 */ export declare class CompactionBeginRpc extends CompactionBeginRpc_base { } /** * Schema for the header of one compaction input batch. * * **Details** * * An entry's input sequence is the batch `sequence` plus its position in * `entryIds`. * * @stability unstable * @category protocols * @since 4.0.0 */ export declare const CompactionInputHeader: Schema.Struct<{ readonly sequence: Schema.Natural; readonly entryIds: Schema.NonEmptyArray, Uint8Array>, "effect/eventlog/EventJournal/EntryId">>; }>; /** * The header of one compaction input batch. * * @stability unstable * @category protocols * @since 4.0.0 */ export type CompactionInputHeader = typeof CompactionInputHeader.Type; declare const CompactionInputRpc_base: Rpc.Rpc<"EventLog.CompactionInput", Schema.Struct<{ publicKey: Schema.String; storeId: Schema.brand; stageId: Schema.String; }>, import("../rpc/RpcSchema.ts").Stream, typeof EventLogProtocolError>, Schema.Never, typeof EventLogAuthentication, never>; /** * RPC that streams a stage's input batch headers in input order. * * **Details** * * The input is the pinned snapshot, then the originals up to the stage's * `through`. Headers are framed as `SingleMessage` values or `ChunkedMessage` * parts, as in `ChangesRpc`. It fails with a `NotFound` error once the stage * or its pin is gone. * * @stability unstable * @category protocols * @since 4.0.0 */ export declare class CompactionInputRpc extends CompactionInputRpc_base { static HeadersFromSchemaBinary: SchemaBinary.toCodec, Uint8Array>, "effect/eventlog/EventJournal/EntryId">>; }>>>; static encodeHeaders: (input: readonly [{ readonly sequence: number; readonly entryIds: readonly [Uint8Array & Brand<"effect/eventlog/EventJournal/EntryId">, ...(Uint8Array & Brand<"effect/eventlog/EventJournal/EntryId">)[]]; }, ...{ readonly sequence: number; readonly entryIds: readonly [Uint8Array & Brand<"effect/eventlog/EventJournal/EntryId">, ...(Uint8Array & Brand<"effect/eventlog/EventJournal/EntryId">)[]]; }[]], options?: SchemaAST.ParseOptions) => Effect.Effect, Schema.SchemaError, never>; static decodeHeaders: (input: Uint8Array, options?: SchemaAST.ParseOptions) => Effect.Effect & Brand<"effect/eventlog/EventJournal/EntryId">, ...(Uint8Array & Brand<"effect/eventlog/EventJournal/EntryId">)[]]; }, ...{ readonly sequence: number; readonly entryIds: readonly [Uint8Array & Brand<"effect/eventlog/EventJournal/EntryId">, ...(Uint8Array & Brand<"effect/eventlog/EventJournal/EntryId">)[]]; }[]], Schema.SchemaError, never>; } declare const CompactionFetchRpc_base: Rpc.Rpc<"EventLog.CompactionFetch", Schema.Struct<{ publicKey: Schema.String; storeId: Schema.brand; stageId: Schema.String; batches: Schema.$Array; }>, import("../rpc/RpcSchema.ts").Stream, typeof EventLogProtocolError>, Schema.Never, typeof EventLogAuthentication, never>; /** * RPC that streams the encrypted input batches at the given input sequences. * * **Details** * * `batches` holds the input sequence of each batch to fetch. Batches are framed * and encoded as in `ChangesRpc`. It fails with a `NotFound` error once the * stage or its pin is gone. * * @stability unstable * @category protocols * @since 4.0.0 */ export declare class CompactionFetchRpc extends CompactionFetchRpc_base { } declare const CompactionPartRpc_base: Rpc.Rpc<"EventLog.CompactionPart", Schema.Struct<{ publicKey: Schema.String; storeId: Schema.brand; stageId: Schema.String; chunk: typeof ChunkedMessage; }>, Schema.Void, typeof EventLogProtocolError, typeof EventLogAuthentication, never>; /** * RPC that uploads one piece of a compaction snapshot segment. * * **Details** * * A segment is an encoded non-empty array of encrypted batches, indexed by * `chunk.id`, and is split into pieces when larger than * `ChunkedMessage.chunkSize`. Re-uploading a stored segment is acknowledged * without storing it again. A segment that fails validation aborts the stage * with an `InvalidRequest` error. * * @stability unstable * @category protocols * @since 4.0.0 */ export declare class CompactionPartRpc extends CompactionPartRpc_base { static SegmentFromSchemaBinary: SchemaBinary.toCodec, Uint8Array>, "effect/eventlog/EventJournal/EntryId">>; readonly iv: Transferable.Transferable, Uint8Array>>; readonly encryptedBatch: Transferable.Transferable, Uint8Array>>; }>>>; static encodeSegment: (input: readonly [{ readonly entryIds: readonly [Uint8Array & Brand<"effect/eventlog/EventJournal/EntryId">, ...(Uint8Array & Brand<"effect/eventlog/EventJournal/EntryId">)[]]; readonly iv: Uint8Array; readonly encryptedBatch: Uint8Array; }, ...{ readonly entryIds: readonly [Uint8Array & Brand<"effect/eventlog/EventJournal/EntryId">, ...(Uint8Array & Brand<"effect/eventlog/EventJournal/EntryId">)[]]; readonly iv: Uint8Array; readonly encryptedBatch: Uint8Array; }[]], options?: SchemaAST.ParseOptions) => Effect.Effect, Schema.SchemaError, never>; static decodeSegment: (input: Uint8Array, options?: SchemaAST.ParseOptions) => Effect.Effect & Brand<"effect/eventlog/EventJournal/EntryId">, ...(Uint8Array & Brand<"effect/eventlog/EventJournal/EntryId">)[]]; readonly iv: Uint8Array; readonly encryptedBatch: Uint8Array; }, ...{ readonly entryIds: readonly [Uint8Array & Brand<"effect/eventlog/EventJournal/EntryId">, ...(Uint8Array & Brand<"effect/eventlog/EventJournal/EntryId">)[]]; readonly iv: Uint8Array; readonly encryptedBatch: Uint8Array; }[]], Schema.SchemaError, never>; } declare const CompactionAbortRpc_base: Rpc.Rpc<"EventLog.CompactionAbort", Schema.Struct<{ publicKey: Schema.String; storeId: Schema.brand; stageId: Schema.String; }>, Schema.Void, typeof EventLogProtocolError, typeof EventLogAuthentication, never>; /** * RPC that releases an open compaction stage. A late abort is a no-op. * * @stability unstable * @category protocols * @since 4.0.0 */ export declare class CompactionAbortRpc extends CompactionAbortRpc_base { } /** * Schema for the outcome of a compaction run reported at commit. * * **Details** * * `Snapshot` activates the `segmentCount` uploaded segments. `NoOp` reports a * run that dropped nothing. * * @stability unstable * @category protocols * @since 4.0.0 */ export declare const CompactionResult: Schema.Union, Schema.TaggedStruct<"NoOp", {}>]>; /** * The outcome of a compaction run reported at commit. * * @stability unstable * @category protocols * @since 4.0.0 */ export type CompactionResult = typeof CompactionResult.Type; declare const CompactionCommitRpc_base: Rpc.Rpc<"EventLog.CompactionCommit", Schema.Struct<{ publicKey: Schema.String; storeId: Schema.brand; stageId: Schema.String; result: Schema.Union, Schema.TaggedStruct<"NoOp", {}>]>; }>, Schema.Literals, typeof EventLogProtocolError, typeof EventLogAuthentication, never>; /** * RPC that commits a compaction stage. * * **Details** * * Answers `Superseded` when the stage's pinned generation is no longer active. * Fails with `InvalidRequest`, aborting the stage, when the segments are * incomplete or the kept ids are not a non-empty, repeat-free subsequence of * the pinned input. Fails with `NotFound` when the stage expired, was aborted * or committed, or is unknown, so a retried commit fails too. * * @stability unstable * @category protocols * @since 4.0.0 */ export declare class CompactionCommitRpc extends CompactionCommitRpc_base { } declare const EventLogCompactionRpcs_base: RpcGroup.RpcGroup; /** * RPC group for encrypted remote compaction. * * **Details** * * Served by the encrypted server alongside `EventLogRemoteRpcs`. Clients call * it only when `HelloResponse.compaction` is set. * * @stability unstable * @category protocols * @since 4.0.0 */ export declare class EventLogCompactionRpcs extends EventLogCompactionRpcs_base { } export {}; //# sourceMappingURL=EventLogMessage.d.ts.map