EdgeAIG/opencode / .opencode /node_modules /effect /dist /unstable /eventlog /EventLogServerUnencrypted.d.ts
EdgeAIG's picture
download
raw
13.5 kB
import * as Context from "../../Context.ts";
import * as Effect from "../../Effect.ts";
import * as Layer from "../../Layer.ts";
import type * as Scope from "../../Scope.ts";
import * as Stream from "../../Stream.ts";
import type * as Rpc from "../rpc/Rpc.ts";
import type * as RpcGroup from "../rpc/RpcGroup.ts";
import * as RpcServer from "../rpc/RpcServer.ts";
import type * as Event from "./Event.ts";
import type * as EventGroup from "./EventGroup.ts";
import * as EventJournal from "./EventJournal.ts";
import { Entry, RemoteEntry, type RemoteId } from "./EventJournal.ts";
import * as EventLog from "./EventLog.ts";
import { type EventLogAuthentication, EventLogRemoteRpcs, type StoreId } from "./EventLogMessage.ts";
declare const EventLogServerUnencrypted_base: Context.ServiceClass<EventLogServerUnencrypted, "effect/eventlog/EventLogServerUnencrypted", {
readonly makeWrite: <Groups extends EventGroup.Any>(schema: EventLog.EventLogSchema<Groups>) => <Tag extends EventGroup.Events<Groups>["tag"], Event extends Event.Any = Event.WithTag<EventGroup.Events<Groups>, Tag>>(options: {
readonly storeId: StoreId;
readonly event: Tag;
readonly payload: Event.Payload<Event>;
}) => Effect.Effect<Event.Success<Event>, EventLogServerStoreError | Event.Error<Event>>;
}>;
/**
* Service that writes plaintext event-log entries directly to
* unencrypted storage through registered event handlers.
*
* **When to use**
*
* Use to access or provide the server service that handles plaintext
* event-log writes.
*
* @category services
* @since 4.0.0
*/
export declare class EventLogServerUnencrypted extends EventLogServerUnencrypted_base {
}
/**
* Creates a typed server-side write function for events in the supplied
* `EventLogSchema`.
*
* @category EventLogServerUnencrypted
* @since 4.0.0
*/
export declare const makeWrite: <Groups extends EventGroup.Any>(schema: EventLog.EventLogSchema<Groups>) => Effect.Effect<(<Tag extends EventGroup.Events<Groups>["tag"], Event extends Event.Any = Event.WithTag<EventGroup.Events<Groups>, Tag>>(options: {
readonly storeId: StoreId;
readonly event: Tag;
readonly payload: Event.Payload<Event>;
}) => Effect.Effect<Event.Success<Event>, EventLogServerStoreError | Event.Error<Event>>), never, EventLogServerUnencrypted>;
/**
* Provides RPC handlers for the unencrypted event-log server.
*
* **Details**
*
* Incoming plaintext entries are authorized, mapped to a server store, checked
* for conflicts, run through registered handlers, and persisted; change streams
* include compacted backlog entries when compactors are registered.
*
* @category layers
* @since 4.0.0
*/
export declare const layerRpcHandlers: Layer.Layer<Rpc.ToHandler<RpcGroup.Rpcs<typeof EventLogRemoteRpcs>> | EventLogAuthentication, never, Storage | StoreMapping | EventLogServerAuthorization | EventLog.Registry>;
declare const EventLogServerStoreError_base: new <A extends Record<string, any> = {}>(args: import("../../Types.ts").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("../../Cause.ts").YieldableError & {
readonly _tag: "EventLogServerStoreError";
} & Readonly<A>;
/**
* Error raised by unencrypted server storage and store mapping operations.
*
* @category errors
* @since 4.0.0
*/
export declare class EventLogServerStoreError extends EventLogServerStoreError_base<{
readonly reason: "NotFound" | "PersistenceFailure";
readonly publicKey?: string | undefined;
readonly storeId?: StoreId | undefined;
readonly message?: string | undefined;
}> {
}
declare const EventLogServerAuthError_base: new <A extends Record<string, any> = {}>(args: import("../../Types.ts").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("../../Cause.ts").YieldableError & {
readonly _tag: "EventLogServerAuthError";
} & Readonly<A>;
/**
* Error raised when unencrypted server authorization rejects an identity or store
* operation.
*
* @category errors
* @since 4.0.0
*/
export declare class EventLogServerAuthError extends EventLogServerAuthError_base<{
readonly reason: "Unauthorized" | "Forbidden";
readonly publicKey: string;
readonly storeId?: StoreId | undefined;
readonly message?: string | undefined;
}> {
}
declare const EventLogServerAuthorization_base: Context.ServiceClass<EventLogServerAuthorization, "effect/eventlog/EventLogServerUnencrypted/EventLogServerAuthorization", {
readonly authorizeWrite: (options: {
readonly publicKey: string;
readonly storeId: StoreId;
readonly entries: ReadonlyArray<Entry>;
}) => Effect.Effect<void, EventLogServerAuthError>;
readonly authorizeRead: (options: {
readonly publicKey: string;
readonly storeId: StoreId;
}) => Effect.Effect<void, EventLogServerAuthError>;
readonly authorizeIdentity: (options: {
readonly publicKey: string;
}) => Effect.Effect<void, EventLogServerAuthError>;
}>;
/**
* Service that validates unencrypted event-log server
* write access, read access, and identities.
*
* **When to use**
*
* Use to provide authorization checks for plaintext event-log writes, reads,
* and identity authentication.
*
* @category services
* @since 4.0.0
*/
export declare class EventLogServerAuthorization extends EventLogServerAuthorization_base {
}
declare const StoreMapping_base: Context.ServiceClass<StoreMapping, "effect/eventlog/EventLogServerUnencrypted/StoreMapping", {
readonly resolve: (options: {
readonly publicKey: string;
readonly storeId: StoreId;
}) => Effect.Effect<StoreId, EventLogServerStoreError>;
readonly hasStore: (options: {
readonly publicKey: string;
readonly storeId: StoreId;
}) => Effect.Effect<boolean, EventLogServerStoreError>;
}>;
/**
* Service that resolves client-requested store ids to server store ids and checks
* whether a store exists.
*
* **When to use**
*
* Use to map client-visible store identifiers to server storage identifiers
* before authorizing or serving unencrypted event-log requests.
*
* @category services
* @since 4.0.0
*/
export declare class StoreMapping extends StoreMapping_base {
}
/**
* Provides a `StoreMapping` that accepts only one configured store id and fails
* all other store ids as not found.
*
* @category store
* @since 4.0.0
*/
export declare const layerStoreMappingStatic: (options: {
readonly storeId: StoreId;
}) => Layer.Layer<StoreMapping>;
declare const Storage_base: Context.ServiceClass<Storage, "effect/eventlog/EventLogServerUnencrypted/Storage", {
readonly getId: Effect.Effect<RemoteId>;
readonly getOrCreateSessionAuthBinding: (publicKey: string, signingPublicKey: Uint8Array<ArrayBuffer>) => Effect.Effect<Uint8Array<ArrayBuffer>>;
readonly entriesAfter: (storeId: StoreId, entry: Entry) => Effect.Effect<Array<Entry>>;
readonly write: (storeId: StoreId, entries: ReadonlyArray<Entry>) => Effect.Effect<ReadonlyArray<RemoteEntry>>;
readonly changes: (options: {
readonly storeId: StoreId;
readonly startSequence: number;
readonly compactors: ReadonlyMap<string, RegisteredCompactor>;
}) => Stream.Stream<RemoteEntry>;
readonly withTransaction: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
}>;
/**
* Defines the backing store service used by the unencrypted event-log server.
*
* **When to use**
*
* Use to provide durable event-log persistence for an unencrypted event-log
* server layer.
*
* **Details**
*
* It provides the server remote id, stores session authentication bindings,
* allocates remote sequence numbers, persists entries, streams changes, and
* exposes a transaction boundary.
*
* @category storage
* @since 4.0.0
*/
export declare class Storage extends Storage_base {
}
type RegisteredCompactor = {
readonly events: ReadonlySet<string>;
readonly effect: (options: {
readonly entries: ReadonlyArray<Entry>;
readonly write: (entry: Entry) => Effect.Effect<void>;
}) => Effect.Effect<void>;
};
/**
* Runs the registered compactors over a backlog of remote entries.
*
* **When to use**
*
* Use to reduce stored remote entries before replaying them to an unencrypted
* event-log client.
*
* **Details**
*
* Contiguous entries handled by the same compactor may be replaced with compacted
* entries when the replacement count can be mapped back to increasing remote
* sequence numbers; otherwise the original entries are kept.
*
* @category compaction
* @since 4.0.0
*/
export declare const compactBacklog: (options: {
readonly remoteEntries: ReadonlyArray<RemoteEntry>;
readonly compactors: ReadonlyMap<string, RegisteredCompactor>;
}) => Effect.Effect<readonly EventJournal.RemoteEntry[], never, never>;
/**
* Creates an in-memory unencrypted server `Storage`.
*
* **Details**
*
* The implementation keeps per-store journals and session authentication bindings
* in memory, publishes live changes, and serializes transactions with a
* semaphore.
*
* @category storage
* @since 4.0.0
*/
export declare const makeStorageMemory: Effect.Effect<Storage["Service"], never, Scope.Scope>;
/**
* Provides unencrypted server `Storage` using the in-memory implementation.
*
* @category storage
* @since 4.0.0
*/
export declare const layerStorageMemory: Layer.Layer<Storage>;
/**
* Creates the `EventLogServerUnencrypted` service from the configured storage and
* registered event handlers.
*
* **When to use**
*
* Use when you need the unencrypted event-log server service from provided
* `Storage` and an event-log `Registry`.
*
* **Details**
*
* The constructed service exposes `makeWrite`, which builds a typed server-side
* write function from an `EventLogSchema`. Each write encodes the payload with
* the event schema, runs the registered handler, and persists the generated
* entry inside `Storage.withTransaction`.
*
* **Gotchas**
*
* The write function dies if the requested event tag is not present in the
* schema passed to `makeWrite`; it does not report that case as a typed failure.
*
* @see {@link makeWrite} for the accessor that retrieves the typed server-side write function from the service environment
* @see {@link layerServer} for the layer form that provides this service together with an event-log `Registry`
*
* @category constructors
* @since 4.0.0
*/
export declare const make: Effect.Effect<{
readonly makeWrite: <Groups extends EventGroup.Any>(schema: EventLog.EventLogSchema<Groups>) => <Tag extends EventGroup.Events<Groups>["tag"], Event extends Event.Any = Event.WithTag<EventGroup.Events<Groups>, Tag>>(options: {
readonly storeId: StoreId;
readonly event: Tag;
readonly payload: Event.Payload<Event>;
}) => Effect.Effect<Event.Success<Event>, EventLogServerStoreError | Event.Error<Event>>;
}, never, EventLog.Registry | Storage>;
/**
* Provides `EventLogServerUnencrypted` and an event-log `Registry` using the
* configured unencrypted server `Storage`.
*
* **When to use**
*
* Use to provide the unencrypted event-log server service together with the
* registry needed by event handlers.
*
* @category layers
* @since 4.0.0
*/
export declare const layerServer: Layer.Layer<EventLogServerUnencrypted | EventLog.Registry, never, Storage>;
/**
* Builds a full unencrypted event-log RPC server for the supplied schema and
* event-group handler layer.
*
* **When to use**
*
* Use when you need the full unencrypted event-log RPC server layer with
* storage, authorization, RPC protocol, and event-group handler dependencies
* supplied externally.
*
* **Details**
*
* The layer installs `EventLogRemoteRpcs`, wires `layerRpcHandlers`, registers
* the supplied event-group handler layer, and provides `layerServer`, leaving
* only the required infrastructure services in the environment.
*
* **Gotchas**
*
* Entries are persisted and streamed in plaintext. Protect the backing
* `Storage` with the surrounding infrastructure, and use durable storage that
* preserves session authentication bindings when the server must survive
* restarts.
*
* @see {@link layerNoRpcServer} for installing the same unencrypted handlers when an `RpcServer.Protocol` is provided elsewhere
* @see {@link layerRpcHandlers} for wiring the unencrypted RPC handlers directly
* @see {@link layerServer} for constructing the server service and event-log registry without RPC handlers
*
* @category layers
* @since 4.0.0
*/
export declare const layer: <Groups extends EventGroup.Any, E, R>(_schema: EventLog.EventLogSchema<Groups>, layer: Layer.Layer<EventGroup.ToService<Groups>, E, R>) => Layer.Layer<never, E, Exclude<R, EventLogServerUnencrypted | EventLog.Registry> | EventLogServerAuthorization | RpcServer.Protocol | Storage | StoreMapping>;
/**
* Builds the unencrypted event-log server handlers without installing an
* `RpcServer.Protocol` implementation.
*
* @category layers
* @since 4.0.0
*/
export declare const layerNoRpcServer: <Groups extends EventGroup.Any, E, R>(_schema: EventLog.EventLogSchema<Groups>, layer: Layer.Layer<EventGroup.ToService<Groups>, E, R>) => Layer.Layer<Rpc.ToHandler<RpcGroup.Rpcs<typeof EventLogRemoteRpcs>> | EventLogAuthentication, E, Exclude<R, EventLogServerUnencrypted | EventLog.Registry> | EventLogServerAuthorization | Storage | StoreMapping>;
export {};
//# sourceMappingURL=EventLogServerUnencrypted.d.ts.map

Xet Storage Details

Size:
13.5 kB
·
Xet hash:
e0d0b859693598caa838c705f662db52cd9e3761cdc2aec9151a0481adb46cef

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.