import type { UnknownError } from '@livestore/common'; import type { LiveStoreEvent, LiveStoreSchema } from '@livestore/common/schema'; import type { Cause, OtelTracer, Scope } from '@livestore/utils/effect'; import { Context, Deferred, Effect, Layer } from '@livestore/utils/effect'; import type { LiveStoreContextProps } from '../store/create-store.ts'; import { DeferredStoreContext, LiveStoreContextRunning } from '../store/create-store.ts'; import type { LiveStoreContextRunning as LiveStoreContextRunningType, Queryable } from '../store/store-types.ts'; export declare const makeLiveStoreContext: ({ schema, storeId, context, boot, adapter, disableDevtools, onBootStatus, batchUpdates, syncPayload, syncPayloadSchema, }: LiveStoreContextProps) => Effect.Effect; /** * @deprecated Use `Store.Tag(schema, storeId)` instead for type-safe store contexts. * * @example Migration * ```ts * // Before * const layer = LiveStoreContextLayer({ schema, adapter, ... }) * * // After * class MainStore extends Store.Tag(schema, 'main') {} * const layer = MainStore.layer({ adapter, ... }) * ``` */ export declare const LiveStoreContextLayer: (props: LiveStoreContextProps) => Layer.Layer; /** * @deprecated Use `Store.Tag(schema, storeId)` and `MainStore.DeferredLayer` instead. */ export declare const LiveStoreContextDeferred: Layer.Layer; /** Branded type for unique store context identity */ declare const StoreContextTypeId: unique symbol; /** Phantom type carrying schema and storeId information */ export interface StoreContextId { readonly [StoreContextTypeId]: { readonly schema: TSchema; readonly storeId: TStoreId; }; } /** Phantom type for deferred store context */ declare const DeferredContextTypeId: unique symbol; export interface DeferredContextId { readonly [DeferredContextTypeId]: { readonly storeId: TStoreId; }; } /** Props for creating a store layer (schema and storeId are already provided) */ export type StoreLayerProps = Omit, 'storeId' | 'schema'>; /** * Type for a Store.Tag class. This is the return type of `Store.Tag(schema, storeId)`. * Can be extended as a class and is yieldable in Effect.gen. * * Note: This uses a type alias with a new() signature to make it extendable. */ /** * Type for a Store.Tag class. Uses self-referential identifier so that `yield*` * and method R channels resolve to the same type, enabling proper layer composition. * * Uses `interface` (not `type`) to allow the self-referential identifier without * triggering TS2456 (circular type alias). */ export interface StoreTagClass extends Context.Tag, LiveStoreContextRunningType> { /** Constructor signature (makes the type extendable as a class) */ new (): Context.Tag, LiveStoreContextRunningType>; /** Tag identity type (from Context.Tag) */ readonly Id: StoreTagClass; /** Service type (from Context.Tag) */ readonly Type: LiveStoreContextRunningType; /** The LiveStore schema for this store */ readonly schema: TSchema; /** Unique identifier for this store */ readonly storeId: TStoreId; /** Creates a layer that initializes the store */ layer(props: StoreLayerProps): Layer.Layer, UnknownError | Cause.TimeoutException, OtelTracer.OtelTracer>; /** Deferred store tag for async initialization patterns */ readonly Deferred: Context.Tag, Deferred.Deferred, UnknownError>>; /** Layer that provides the Deferred tag */ readonly DeferredLayer: Layer.Layer>; /** Layer that waits for Deferred and provides the running store */ readonly fromDeferred: Layer.Layer, UnknownError, DeferredContextId>; /** Query the store. Returns an Effect that yields the query result. */ query(query: Queryable): Effect.Effect>; /** Commit events to the store. */ commit(...eventInputs: LiveStoreEvent.Input.ForSchema[]): Effect.Effect>; /** Use the store with a callback function. */ use(f: (ctx: LiveStoreContextRunningType) => Effect.Effect): Effect.Effect>; } /** * Store utilities for Effect integration. * * @example * ```ts * import { Store } from '@livestore/livestore/effect' * * export class MainStore extends Store.Tag(schema, 'main') {} * ``` */ export declare const Store: { /** * Create a typed store context class for use with Effect. * @see {@link makeStoreTag} for full documentation */ Tag: (schema: TSchema, storeId: TStoreId) => StoreTagClass; }; /** * @deprecated Use `Store.Tag(schema, storeId)` instead. * * @example Migration * ```ts * // Before * const MainStoreContext = makeStoreContext()('main') * export const MainStore = MainStoreContext.Tag * export const MainStoreLayer = MainStoreContext.Layer * * // After * export class MainStore extends Store.Tag(schema, 'main') {} * // MainStore.layer({ ... }) for the layer * ``` */ export interface StoreContext { readonly storeId: TStoreId; readonly Tag: Context.Tag, LiveStoreContextRunningType>; readonly DeferredTag: Context.Tag, Deferred.Deferred, UnknownError>>; readonly Layer: (props: Omit, 'storeId'>) => Layer.Layer, UnknownError | Cause.TimeoutException, OtelTracer.OtelTracer>; readonly DeferredLayer: Layer.Layer>; readonly fromDeferred: Layer.Layer, UnknownError, DeferredContextId>; } /** * @deprecated Use `Store.Tag(schema, storeId)` instead. * * @example Migration * ```ts * // Before * const MainStoreContext = makeStoreContext()('main') * * // After * class MainStore extends Store.Tag(schema, 'main') {} * ``` */ export declare const makeStoreContext: () => (storeId: TStoreId) => StoreContext; export {}; //# sourceMappingURL=LiveStore.d.ts.map