import * as Context from "../Context.ts"; import * as Effect from "../Effect.ts"; import * as Layer from "../Layer.ts"; import * as Queue from "../Queue.ts"; import * as RpcClient from "../rpc/RpcClient.ts"; import type { RpcClientError } from "../rpc/RpcClientError.ts"; import type * as Schema from "../Schema.ts"; import type * as Scope from "../Scope.ts"; import * as Stream from "../Stream.ts"; import { type Entry, type EventJournal, type EventJournalError, RemoteEntry, type RemoteId } from "./EventJournal.ts"; import { type Identity, Registry } from "./EventLog.ts"; import { EventLogEncryption } from "./EventLogEncryption.ts"; import { ChunkedMessage, type CompactionBeginResult, type CompactionInputHeader, type CompactionResult, type CompactionStatus, EventLogProtocolError, type HelloResponse, type SingleMessage, type StoreId, type WriteAck } from "./EventLogMessage.ts"; declare const EventLogRemote_base: Context.ServiceClass Effect.Effect, never, Scope.Scope>; readonly write: (options: { readonly identity: Identity["Service"]; readonly storeId: StoreId; readonly entries: ReadonlyArray; }) => Effect.Effect | void, EventLogRemoteError>; readonly whenAuthenticated: (effect: Effect.Effect) => Effect.Effect; /** * Encrypted remote compaction. Present when the remote advertises * `HelloResponse.compaction` and the RPC client includes * `EventLogCompactionRpcs`. */ readonly compaction?: EventLogRemoteCompaction | undefined; }>; /** * Service that represents a remote event-log replica. * * **When to use** * * Use to access or provide a remote event-log replica that can write local * entries and stream remote changes. * * **Details** * * It can write local entries to the remote, stream remote changes from a sequence * number, and run effects only after the supplied identity has authenticated. * * Built-in remotes acknowledge writes instead of echoing them through `changes`. * Custom remotes may return `void` from `write` to confirm uploads through * `changes` instead. * * @stability unstable * @category services * @since 4.0.0 */ export declare class EventLogRemote extends EventLogRemote_base { } /** * A stage opened by `EventLogRemoteCompaction.begin`, with the identity and * store it belongs to. * * @stability unstable * @category models * @since 4.0.0 */ export interface CompactionStage { readonly identity: Identity["Service"]; readonly storeId: StoreId; readonly stageId: string; } /** * Client side of encrypted remote compaction. * * **Details** * * A run opens a stage with `begin`, reads its input headers with `input`, * fetches the batches it needs with `fetch`, uploads the kept entries with * `upload` and calls `commit`. `abort` releases a stage that won't be * committed. * * @stability unstable * @category models * @since 4.0.0 */ export interface EventLogRemoteCompaction { readonly status: (options: { readonly identity: Identity["Service"]; readonly storeId: StoreId; }) => Effect.Effect; readonly begin: (options: { readonly identity: Identity["Service"]; readonly storeId: StoreId; }) => Effect.Effect; /** * Streams the stage's input batch headers in input order. */ readonly input: (stage: CompactionStage) => Stream.Stream; /** * Fetches and decrypts the input batches at the given input sequences. */ readonly fetch: (stage: CompactionStage, sequences: ReadonlyArray) => Stream.Stream; /** * Encrypts the kept entries, in input-sequence order, and uploads them in * segments of about `ChunkedMessage.chunkSize`. An oversized segment is * split into pieces, and a segment is resent in full after a dropped * connection. */ readonly upload: (stage: CompactionStage, entries: ReadonlyArray) => Effect.Effect<{ readonly segmentCount: number; }, EventLogRemoteError>; readonly commit: (stage: CompactionStage, result: CompactionResult) => Effect.Effect<"Committed" | "Superseded", EventLogRemoteError>; /** * Releases the stage. Failures are ignored. */ readonly abort: (stage: CompactionStage) => Effect.Effect; } declare const EventLogRemoteError_base: new = {}>(args: import("../Types.ts").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("../Cause.ts").YieldableError & { readonly _tag: "EventLogRemoteError"; } & Readonly; /** * Error raised by `EventLogRemote` operations, recording the failed method and * underlying cause. * * @stability unstable * @category errors * @since 4.0.0 */ export declare class EventLogRemoteError extends EventLogRemoteError_base<{ readonly method: string; readonly cause: unknown; }> { /** * Returns `true` when the value is an `EventLogRemoteError`. * * @stability unstable * @since 4.0.0 */ static is(u: unknown): u is EventLogRemoteError; } declare const EventLogRemoteClient_base: Context.ServiceClass(input: { readonly publicKey: string; readonly signingPublicKey: Uint8Array; readonly signature: Uint8Array; readonly algorithm: "Ed25519"; }, options?: { readonly headers?: import("../http/Headers.ts").Input | undefined; readonly context?: Context.Context | undefined; readonly discard?: Discard | undefined; } | undefined) => Effect.Effect; readonly "EventLog.Changes": (input: { readonly publicKey: string; readonly storeId: string & import("../Brand.ts").Brand<"effect/eventlog/EventLog/StoreId">; readonly startSequence: number; }, options?: { readonly asQueue?: AsQueue | undefined; readonly streamBufferSize?: number | undefined; readonly headers?: import("../http/Headers.ts").Input | undefined; readonly context?: Context.Context | undefined; } | undefined) => AsQueue extends true ? Effect.Effect | EventLogProtocolError | RpcClientError>, never, Scope.Scope> : Stream.Stream; readonly "EventLog.Hello": (input: void, options?: { readonly headers?: import("../http/Headers.ts").Input | undefined; readonly context?: Context.Context | undefined; readonly discard?: Discard | undefined; } | undefined) => Effect.Effect; readonly "EventLog.WriteChunked": (input: { readonly _tag?: "Chunked"; readonly id: number; readonly part: readonly [number, number]; readonly data: Uint8Array; }, options?: { readonly headers?: import("../http/Headers.ts").Input | undefined; readonly context?: Context.Context | undefined; readonly discard?: Discard | undefined; } | undefined) => Effect.Effect & import("../Brand.ts").Brand<"effect/eventlog/EventJournal/EntryId">; readonly sequence: number; }[], EventLogProtocolError | RpcClientError | (Discard extends true ? never : EventLogProtocolError), never>; readonly "EventLog.WriteSingle": (input: { readonly data: Uint8Array; }, options?: { readonly headers?: import("../http/Headers.ts").Input | undefined; readonly context?: Context.Context | undefined; readonly discard?: Discard | undefined; } | undefined) => Effect.Effect & import("../Brand.ts").Brand<"effect/eventlog/EventJournal/EntryId">; readonly sequence: number; }[], EventLogProtocolError | RpcClientError | (Discard extends true ? never : EventLogProtocolError), never>; } & Partial<{ readonly "EventLog.CompactionAbort": (input: { readonly publicKey: string; readonly storeId: string & import("../Brand.ts").Brand<"effect/eventlog/EventLog/StoreId">; readonly stageId: string; }, options?: { readonly headers?: import("../http/Headers.ts").Input | undefined; readonly context?: Context.Context | undefined; readonly discard?: Discard | undefined; } | undefined) => Effect.Effect; readonly "EventLog.CompactionBegin": (input: { readonly publicKey: string; readonly storeId: string & import("../Brand.ts").Brand<"effect/eventlog/EventLog/StoreId">; }, options?: { readonly headers?: import("../http/Headers.ts").Input | undefined; readonly context?: Context.Context | undefined; readonly discard?: Discard | undefined; } | undefined) => Effect.Effect; readonly "EventLog.CompactionCommit": (input: { readonly publicKey: string; readonly storeId: string & import("../Brand.ts").Brand<"effect/eventlog/EventLog/StoreId">; readonly stageId: string; readonly result: { readonly _tag?: "Snapshot"; readonly segmentCount: number; } | { readonly _tag?: "NoOp"; }; }, options?: { readonly headers?: import("../http/Headers.ts").Input | undefined; readonly context?: Context.Context | undefined; readonly discard?: Discard | undefined; } | undefined) => Effect.Effect; readonly "EventLog.CompactionFetch": (input: { readonly publicKey: string; readonly storeId: string & import("../Brand.ts").Brand<"effect/eventlog/EventLog/StoreId">; readonly stageId: string; readonly batches: readonly number[]; }, options?: { readonly asQueue?: AsQueue | undefined; readonly streamBufferSize?: number | undefined; readonly headers?: import("../http/Headers.ts").Input | undefined; readonly context?: Context.Context | undefined; } | undefined) => AsQueue extends true ? Effect.Effect | EventLogProtocolError | RpcClientError>, never, Scope.Scope> : Stream.Stream; readonly "EventLog.CompactionInput": (input: { readonly publicKey: string; readonly storeId: string & import("../Brand.ts").Brand<"effect/eventlog/EventLog/StoreId">; readonly stageId: string; }, options?: { readonly asQueue?: AsQueue | undefined; readonly streamBufferSize?: number | undefined; readonly headers?: import("../http/Headers.ts").Input | undefined; readonly context?: Context.Context | undefined; } | undefined) => AsQueue extends true ? Effect.Effect | EventLogProtocolError | RpcClientError>, never, Scope.Scope> : Stream.Stream; readonly "EventLog.CompactionPart": (input: { readonly publicKey: string; readonly storeId: string & import("../Brand.ts").Brand<"effect/eventlog/EventLog/StoreId">; readonly stageId: string; readonly chunk: ChunkedMessage; }, options?: { readonly headers?: import("../http/Headers.ts").Input | undefined; readonly context?: Context.Context | undefined; readonly discard?: Discard | undefined; } | undefined) => Effect.Effect; readonly "EventLog.CompactionStatus": (input: { readonly publicKey: string; readonly storeId: string & import("../Brand.ts").Brand<"effect/eventlog/EventLog/StoreId">; }, options?: { readonly headers?: import("../http/Headers.ts").Input | undefined; readonly context?: Context.Context | undefined; readonly discard?: Discard | undefined; } | undefined) => Effect.Effect; }>>; /** * Service that provides a typed RPC client for the `EventLogRemoteRpcs` protocol. * * **When to use** * * Use to provide the RPC client used by remote event-log replicas to * authenticate, write entries, and subscribe to changes. * * **Details** * * The `EventLogCompactionRpcs` methods are optional. The encrypted remote * offers compaction only when the client has them. `layer` builds the client * from both groups. * * @stability unstable * @category services * @since 4.0.0 */ export declare class EventLogRemoteClient extends EventLogRemoteClient_base { static readonly layer: Layer.Layer; } /** * Creates an `EventLogRemote` from custom write encoding and change decoding * functions. * * **Details** * * The remote performs the hello/authentication handshake, retries after forbidden * responses by re-authenticating, chunks large writes, and registers itself with * the `Registry` for the current scope. * * @stability unstable * @category constructors * @since 4.0.0 */ export declare const makeWith: (options: { readonly encodeWrite: (options: { readonly identity: Identity["Service"]; readonly entries: ReadonlyArray; readonly storeId: StoreId; }) => Effect.Effect, Schema.SchemaError>; readonly decodeChanges: (identity: Identity["Service"], storeId: StoreId, data: Uint8Array, knownEntries?: EventJournal["Service"]["entriesById"]) => Effect.Effect, Schema.SchemaError | EventJournalError>; }) => Effect.Effect; /** * Creates an `EventLogRemote` that encrypts outgoing entries and decrypts * incoming changes with `EventLogEncryption`. * * **Details** * * The remote has a `compaction` member when the server advertises compaction * and the RPC client includes `EventLogCompactionRpcs`, unless built with * `compaction: false`. Without it the client never calls the compaction RPCs. * * @stability unstable * @category constructors * @since 4.0.0 */ export declare const makeEncryptedWith: (options: { readonly compaction?: boolean | undefined; }) => Effect.Effect<{ readonly id: RemoteId; /** * The lowest sequence the remote assigns, or 0 when omitted. */ readonly firstSequence?: number | undefined; readonly changes: (options: { readonly identity: Identity["Service"]; readonly storeId: StoreId; readonly startSequence: number; /** * Looks up locally stored entries by id, so the remote can reuse them * instead of decoding the matching changes. */ readonly knownEntries?: EventJournal["Service"]["entriesById"] | undefined; }) => Effect.Effect, never, Scope.Scope>; readonly write: (options: { readonly identity: Identity["Service"]; readonly storeId: StoreId; readonly entries: ReadonlyArray; }) => Effect.Effect | void, EventLogRemoteError>; readonly whenAuthenticated: (effect: Effect.Effect) => Effect.Effect; /** * Encrypted remote compaction. Present when the remote advertises * `HelloResponse.compaction` and the RPC client includes * `EventLogCompactionRpcs`. */ readonly compaction?: EventLogRemoteCompaction | undefined; }, EventLogRemoteError, EventLogEncryption | EventLogRemoteClient | Registry | Scope.Scope>; /** * Creates an `EventLogRemote` that encrypts outgoing entries and decrypts * incoming changes with `EventLogEncryption`. * * @see {@link makeEncryptedWith} for opting out of running compaction * * @stability unstable * @category constructors * @since 4.0.0 */ export declare const makeEncrypted: Effect.Effect; /** * Creates an `EventLogRemote` that sends and receives plaintext entry payloads. * * @stability unstable * @category constructors * @since 4.0.0 */ export declare const makeUnencrypted: Effect.Effect; /** * Provides an encrypted `EventLogRemote` using the remote RPC client and the * default Web Crypto encryption layer. * * **Details** * * `compaction: false` leaves the remote without its `compaction` member, so * this client never calls the compaction RPCs. * * @stability unstable * @category layers * @since 4.0.0 */ export declare const layerEncryptedWith: (options: { readonly compaction?: boolean | undefined; }) => Layer.Layer; /** * Provides an encrypted `EventLogRemote` using the remote RPC client and the * default Web Crypto encryption layer. * * @see {@link layerEncryptedWith} for opting out of running compaction * * @stability unstable * @category layers * @since 4.0.0 */ export declare const layerEncrypted: Layer.Layer; /** * Provides an unencrypted `EventLogRemote` using the remote RPC client. * * @stability unstable * @category layers * @since 4.0.0 */ export declare const layerUnencrypted: Layer.Layer; export {}; //# sourceMappingURL=EventLogRemote.d.ts.map