/** * @since 1.0.0 */ import type * as Context from "effect/Context"; import type * as Effect from "effect/Effect"; import type { LazyArg } from "effect/Function"; import type * as Layer from "effect/Layer"; import type * as Option from "effect/Option"; import type * as ParseResult from "effect/ParseResult"; import type * as Schema from "effect/Schema"; import type * as PlatformError from "./Error.js"; import type * as FileSystem from "./FileSystem.js"; import type * as Path from "./Path.js"; /** * @since 1.0.0 * @category type id */ export declare const TypeId: unique symbol; /** * @since 1.0.0 * @category type id */ export type TypeId = typeof TypeId; /** * @since 1.0.0 * @category models */ export interface KeyValueStore { readonly [TypeId]: TypeId; /** * Returns the value of the specified key if it exists. */ readonly get: (key: string) => Effect.Effect, PlatformError.PlatformError>; /** * Returns the value of the specified key if it exists. */ readonly getUint8Array: (key: string) => Effect.Effect, PlatformError.PlatformError>; /** * Sets the value of the specified key. */ readonly set: (key: string, value: string | Uint8Array) => Effect.Effect; /** * Removes the specified key. */ readonly remove: (key: string) => Effect.Effect; /** * Removes all entries. */ readonly clear: Effect.Effect; /** * Returns the number of entries. */ readonly size: Effect.Effect; /** * Updates the value of the specified key if it exists. */ readonly modify: (key: string, f: (value: string) => string) => Effect.Effect, PlatformError.PlatformError>; /** * Updates the value of the specified key if it exists. */ readonly modifyUint8Array: (key: string, f: (value: Uint8Array) => Uint8Array) => Effect.Effect, PlatformError.PlatformError>; /** * Returns true if the KeyValueStore contains the specified key. */ readonly has: (key: string) => Effect.Effect; /** * Checks if the KeyValueStore contains any entries. */ readonly isEmpty: Effect.Effect; /** * Create a SchemaStore for the specified schema. */ readonly forSchema: (schema: Schema.Schema) => SchemaStore; } /** * @since 1.0.0 */ export declare namespace KeyValueStore { /** * @since 1.0.0 */ type AnyStore = KeyValueStore | SchemaStore; } /** * @since 1.0.0 * @category tags */ export declare const KeyValueStore: Context.Tag; /** * @since 1.0.0 * @category constructors */ export declare const make: (impl: Omit & Partial) => KeyValueStore; /** * @since 1.0.0 * @category constructors */ export declare const makeStringOnly: (impl: Pick & Partial> & { readonly set: (key: string, value: string) => Effect.Effect; }) => KeyValueStore; /** * @since 1.0.0 * @category combinators */ export declare const prefix: { /** * @since 1.0.0 * @category combinators */ (prefix: string): (self: S) => S; /** * @since 1.0.0 * @category combinators */ (self: S, prefix: string): S; }; /** * @since 1.0.0 * @category layers */ export declare const layerMemory: Layer.Layer; /** * Provides a file-backed key-value store in the specified directory. * * Keys are percent-encoded as single file names. Empty keys, `.` and `..` are * rejected. Keys are only guaranteed to be distinct on case-sensitive file * systems. * * `clear` removes the directory recursively, so it must not be shared with * unrelated data. * * @since 1.0.0 * @category layers */ export declare const layerFileSystem: (directory: string) => Layer.Layer; /** * @since 1.0.0 * @category type id */ export declare const SchemaStoreTypeId: unique symbol; /** * @since 1.0.0 * @category type id */ export type SchemaStoreTypeId = typeof SchemaStoreTypeId; /** * @since 1.0.0 * @category models */ export interface SchemaStore { readonly [SchemaStoreTypeId]: SchemaStoreTypeId; /** * Returns the value of the specified key if it exists. */ readonly get: (key: string) => Effect.Effect, PlatformError.PlatformError | ParseResult.ParseError, R>; /** * Sets the value of the specified key. */ readonly set: (key: string, value: A) => Effect.Effect; /** * Removes the specified key. */ readonly remove: (key: string) => Effect.Effect; /** * Removes all entries. */ readonly clear: Effect.Effect; /** * Returns the number of entries. */ readonly size: Effect.Effect; /** * Updates the value of the specified key if it exists. */ readonly modify: (key: string, f: (value: A) => A) => Effect.Effect, PlatformError.PlatformError | ParseResult.ParseError, R>; /** * Returns true if the KeyValueStore contains the specified key. */ readonly has: (key: string) => Effect.Effect; /** * Checks if the KeyValueStore contains any entries. */ readonly isEmpty: Effect.Effect; } /** * @since 1.0.0 * @category layers */ export declare const layerSchema: (schema: Schema.Schema, tagIdentifier: string) => { readonly tag: Context.Tag, SchemaStore>; readonly layer: Layer.Layer, never, KeyValueStore>; }; /** * Creates an KeyValueStorage from an instance of the `Storage` api. * * @see https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API * * @since 1.0.0 * @category layers */ export declare const layerStorage: (evaluate: LazyArg) => Layer.Layer; //# sourceMappingURL=KeyValueStore.d.ts.map