/** * Describes request values whose results can be persisted. * * A `Persistable` request has a primary key and schemas for its success and * error results. `Persistence` and `PersistedCache` use that information to * store the request's `Exit` value and restore it later from a backing store. * * @stability unstable * @since 4.0.0 */ import type * as Duration from "../Duration.ts"; import type * as Effect from "../Effect.ts"; import type * as Exit from "../Exit.ts"; import * as PrimaryKey from "../PrimaryKey.ts"; import * as Request from "../Request.ts"; import * as Schema from "../Schema.ts"; import type * as Types from "../Types.ts"; import type { PersistenceError } from "./Persistence.ts"; /** * Defines the property key used to attach success and error schemas to persistable * requests. * * **When to use** * * Use to implement persistable request values by attaching success and error * schemas at this property key. * * @stability unstable * @category symbols * @since 4.0.0 */ export declare const symbol: "~effect/persistence/Persistable"; /** * A primary-keyed request value whose success and error results can be * serialized for persistence. * * @stability unstable * @category models * @since 4.0.0 */ export interface Persistable extends PrimaryKey.PrimaryKey { readonly [symbol]: { readonly success: A; readonly error: E; }; } /** * Any persistable request regardless of its success and error schemas. * * @stability unstable * @category models * @since 4.0.0 */ export type Any = Persistable; /** * Extracts the success schema from a persistable request. * * @stability unstable * @category utility types * @since 4.0.0 */ export type SuccessSchema = A["~effect/persistence/Persistable"]["success"]; /** * Extracts the success value type from a persistable request. * * @stability unstable * @category utility types * @since 4.0.0 */ export type Success = A["~effect/persistence/Persistable"]["success"]["Type"]; /** * Extracts the error schema from a persistable request. * * @stability unstable * @category utility types * @since 4.0.0 */ export type ErrorSchema = A["~effect/persistence/Persistable"]["error"]; /** * Extracts the error value type from a persistable request. * * @stability unstable * @category utility types * @since 4.0.0 */ export type Error = A["~effect/persistence/Persistable"]["error"]["Type"]; /** * Services required to decode a persisted success or error value for the * request. * * @stability unstable * @category utility types * @since 4.0.0 */ export type DecodingServices = A["~effect/persistence/Persistable"]["success"]["DecodingServices"] | A["~effect/persistence/Persistable"]["error"]["DecodingServices"]; /** * Services required to encode a success or error value for persistence. * * @stability unstable * @category utility types * @since 4.0.0 */ export type EncodingServices = A["~effect/persistence/Persistable"]["success"]["EncodingServices"] | A["~effect/persistence/Persistable"]["error"]["EncodingServices"]; /** * All schema services required to encode and decode a persistable request * result. * * @stability unstable * @category utility types * @since 4.0.0 */ export type Services = A["~effect/persistence/Persistable"]["success"]["DecodingServices"] | A["~effect/persistence/Persistable"]["success"]["EncodingServices"] | A["~effect/persistence/Persistable"]["error"]["DecodingServices"] | A["~effect/persistence/Persistable"]["error"]["EncodingServices"]; /** * Computes the time to live for a persisted result from the result `Exit` and * request value. * * @stability unstable * @category utility types * @since 4.0.0 */ export type TimeToLiveFn = (exit: Exit.Exit, Error>, request: K) => Duration.Input; /** * Creates request classes that implement `Persistable` and `Request.Request`. * * **Details** * * The generated class stores the supplied tag, derives its primary key from * the payload, and carries schemas for persisted success and error exits. * * @stability unstable * @category constructors * @since 4.0.0 */ export declare const Class: ; requires?: any; requestError?: any; } = { payload: {}; }>() => (tag: Tag, options: { readonly primaryKey: (payload: Config["payload"]) => string; readonly success?: A | undefined; readonly error?: E | undefined; }) => new (args: Types.EqualsWith) => { readonly _tag: Tag; } & { readonly [K in keyof Config["payload"]]: Config["payload"][K]; } & Persistable & Request.Request; /** * Returns the cached `Exit` schema for a persistable request's success and * error schemas. * * @stability unstable * @category accessors * @since 4.0.0 */ export declare const exitSchema: (self: Persistable) => Schema.Exit; /** * Encodes an `Exit` for a persistable request using its success and error * schemas. * * @stability unstable * @category serialization * @since 4.0.0 */ export declare const serializeExit: (self: Persistable, exit: Exit.Exit) => Effect.Effect; /** * Decodes a persisted value into an `Exit` for a persistable request using its * success and error schemas. * * @stability unstable * @category serialization * @since 4.0.0 */ export declare const deserializeExit: (self: Persistable, encoded: unknown) => Effect.Effect, Schema.SchemaError, A["DecodingServices"] | E["DecodingServices"]>; //# sourceMappingURL=Persistable.d.ts.map