// // Copyright 2025 DXOS.org // import { Schema } from 'effect'; import type { Obj, Relation } from '@dxos/echo'; import { EntityKind, TypeAnnotationId, type TypeAnnotation } from '@dxos/echo-schema'; import { type DXN, type ObjectId } from '@dxos/keys'; /** * Client-side view onto an EDGE queue. */ export interface Queue { readonly dxn: DXN; readonly isLoading: boolean; readonly error: Error | null; // TODO(dmaretskyi): Replace with unified query(query) => QueryResult API. readonly objects: T[]; toJSON(): any; /** * Appends objects to the queue. */ append(objects: T[]): Promise; /** * Deletes objects from the queue. */ delete(ids: string[]): Promise; /** * Query all objects in the queue. */ // TODO(dmaretskyi): Replace with unified query(query) => QueryResult API. queryObjects(): Promise; /** * Queries objects by id. */ // TODO(dmaretskyi): Replace with unified query(query) => QueryResult API. getObjectsById(ids: ObjectId[]): Promise<(T | null)[]>; /** * Refreshes the queue from the server. */ // TODO(dmaretskyi): Remove. refresh(): Promise; } // TODO(dmaretskyi): Implement. const isQueue = (value: unknown): value is Queue => { return false; }; export const Queue: Schema.Schema = Schema.declare(isQueue, { [TypeAnnotationId]: { // TODO(dmaretskyi): Perhaps queue should be its own entity kind. kind: EntityKind.Object, typename: 'dxos.org/type/Queue', version: '0.1.0', } satisfies TypeAnnotation, });