import * as Context from 'effect/Context'; import * as Effect from 'effect/Effect'; import * as Layer from 'effect/Layer'; import type * as Option from 'effect/Option'; import * as Schema from 'effect/Schema'; import { EID } from '@dxos/keys'; import type * as Entity from './Entity'; import type * as Filter from './Filter'; import * as Obj from './Obj'; import type * as Query from './Query'; import type * as QueryResult from './QueryResult'; import * as Type from './Type'; /** * Runtime schema for a Feed object. * * @example * ```ts * const feed = Obj.make(Feed.Feed, { name: 'notifications', kind: 'org.dxos.plugin.notifications.v1' }); * ``` */ export declare const Feed: Type.Obj<{ readonly name?: string | undefined; readonly kind?: string | undefined; readonly namespace?: "data" | "trace" | undefined; }, Schema.Struct.Fields>; /** * TypeScript instance type for a Feed object. */ export type Feed = Type.InstanceType; /** * Opaque cursor for iterating over feed items. */ export interface Cursor { readonly _tag: 'Cursor'; } /** * Retention options for a feed. */ export interface RetentionOptions { /** Retain items after this cursor position. */ cursor?: string; } /** * Sync options for a feed. */ export interface SyncOptions { /** Push local changes to the server. Defaults to true. */ shouldPush?: boolean; /** Pull remote changes from the server. Defaults to true. */ shouldPull?: boolean; } /** * Queue replication backlog for a feed namespace. * `0` / `0` means caught up on pull and push. */ export interface SyncState { /** Blocks still to pull from remote. */ blocksToPull: number; /** Unpositioned blocks still to push to remote. */ blocksToPush: number; /** Total blocks stored locally for the feed namespace. */ totalBlocks: number; } /** * Creates a new feed object. * * @example * ```ts * const feed = Feed.make({ name: 'notifications', kind: 'org.dxos.plugin.notifications.v1' }); * ``` */ export declare const make: (props?: Obj.MakeProps) => Feed; /** * Returns the feed object's EID when the feed is stored in a space. * * Used internally by the feed service layer. */ export declare const getQueueUri: (feed: Feed) => EID.EID | undefined; declare const FeedService_base: Context.TagClass; /** * Removes items from a feed by ID. */ remove(feed: Feed, ids: string[]): Promise; /** * Queries items in a feed. */ query: { (feed: Feed, query: Q): QueryResult.QueryResult>; (feed: Feed, filter: F): QueryResult.QueryResult>; }; /** * Syncs the feed with the server. */ sync(feed: Feed, options?: SyncOptions): Promise; /** * Returns queue replication backlog for the feed's namespace. */ getSyncState(feed: Feed): Promise; }>; /** * Effect service for feed operations. * Provides the bridge to the underlying storage implementation. * Must be provided by the application layer (e.g., echo-db). */ export declare class FeedService extends FeedService_base { } /** * @deprecated Use `FeedService` instead. */ export type Service = FeedService; /** * @deprecated Use `FeedService` instead. */ export declare const Service: typeof FeedService; declare const ContextFeedService_base: Context.TagClass; /** * Effect context service that holds the current feed for a scoped operation. * * @deprecated Prefer threading a `Feed.Feed` explicitly through function signatures * over hiding it behind a context service. */ export declare class ContextFeedService extends ContextFeedService_base { static layer: (feed: Feed) => Layer.Layer; } /** * Layer that provides a Feed service that throws when accessed. * Useful as a default layer when no feed service is available. */ export declare const notAvailable: Layer.Layer; /** * Appends items to a feed. * * @example * ```ts * yield* Feed.append(feed, [Obj.make(Notification, { title: 'Hello' })]); * ``` */ export declare const append: (feed: Feed, items: Entity.Unknown[]) => Effect.Effect; /** * Removes items from a feed. * * @example * ```ts * yield* Feed.remove(feed, [item]); * ``` */ export declare const remove: (feed: Feed, items: (Entity.Unknown | Obj.Snapshot)[]) => Effect.Effect; /** * Creates a reactive query over items in a feed. * * @example * ```ts * const result = yield* Feed.query(feed, Filter.type(Person)); * ``` */ export declare const query: { (feed: Feed, query: Q): Effect.Effect>, never, FeedService>; (feed: Feed, filter: F): Effect.Effect>, never, FeedService>; }; /** * Executes a feed query once and returns the results. * * @example * ```ts * const items = yield* Feed.runQuery(feed, Filter.type(Person)); * ``` */ export declare const runQuery: { (feed: Feed, query: Q): Effect.Effect[], never, FeedService>; (feed: Feed, filter: F): Effect.Effect[], never, FeedService>; }; /** * Syncs the feed with the server. * * @example * ```ts * yield* Feed.sync(feed); * yield* Feed.sync(feed, { shouldPush: false }); * ``` */ export declare const sync: (feed: Feed, options?: SyncOptions) => Effect.Effect; /** * Returns queue replication backlog for the feed's namespace. * * @example * ```ts * const { blocksToPull, blocksToPush } = yield* Feed.getSyncState(feed); * ``` */ export declare const getSyncState: (feed: Feed) => Effect.Effect; /** * Creates a cursor for iterating over feed items. * Currently stubbed — cursor operations are not yet implemented. * * @example * ```ts * const cursor = yield* Feed.cursor(feed); * const item = yield* Feed.next(cursor); * ``` */ export declare const cursor: (_feed: Feed) => Effect.Effect, never, FeedService>; /** * Returns the next item from a feed cursor. * Currently stubbed — cursor operations are not yet implemented. */ export declare const next: (_cursor: Cursor) => Effect.Effect; /** * Returns the next item from a feed cursor as an Option. * Currently stubbed — cursor operations are not yet implemented. */ export declare const nextOption: (_cursor: Cursor) => Effect.Effect, never, FeedService>; /** * Sets the local retention policy for a feed. * Currently stubbed — feeds do not yet support retention. * * @example * ```ts * yield* Feed.setRetention(feed, { count: 1000 }); * ``` */ export declare const setRetention: (_feed: Feed, _options: RetentionOptions) => Effect.Effect; export {}; //# sourceMappingURL=Feed.d.ts.map