UNPKG

trellis

Version:

Agentic State Engine — event-sourced causal graph with branching, decision traces, and realtime sync for AI-native applications

41 lines 2.2 kB
/** * Trellis Vue — schema-typed, live entity composables. * * The Vue half of the typed read surface. Identical semantics to * `trellis/react/typed`, bridging the same Signal-first {@link liveEntities} * (live subscription + hydration) into Vue's reactivity via `shallowRef` + * `onScopeDispose`. Shipped under `trellis/vue/typed`. * * import { defineType } from 'trellis/schema'; * import { useEntities, useMutation } from 'trellis/vue/typed'; * * const sections = useEntities(client, NavSection); // ComputedRef<{ data, loading, error }> * const nav = useMutation(client, NavSection); * * @module trellis/vue/typed */ import { type ComputedRef } from 'vue'; import { type LiveEntitiesOptions, type LiveEntityOptions } from '../client/live.js'; import type { TrellisDb } from '../client/sdk.js'; import { type EntityMutations } from '../schema/mutations.js'; import type { AnyType, InferEntitiesRead, InferEntityRead, InferType, ResolveSpecFor } from '../schema/define.js'; import type { WhereInput } from '../schema/eql.js'; export interface TypedRead<T> { data: T; loading: boolean; error: Error | null; } export type TypedReadOptions<S extends AnyType> = LiveEntitiesOptions & { where?: WhereInput; resolve?: ResolveSpecFor<S>; }; export type TypedEntityOptions<S extends AnyType> = LiveEntityOptions & { resolve?: ResolveSpecFor<S>; }; /** Live list of a type — filter with `where`, expand relations with `resolve`. */ export declare function useEntities<S extends AnyType, O extends Partial<InferType<S>> | TypedReadOptions<S> | undefined = undefined>(client: TrellisDb, schema: S, opts?: O): ComputedRef<TypedRead<InferEntitiesRead<S, O>>>; /** Live single entity by id — read-first, then type subscription. */ export declare function useEntity<S extends AnyType, O extends TypedEntityOptions<S> | undefined = undefined>(client: TrellisDb, schema: S, id: string | null | undefined, opts?: O): ComputedRef<TypedRead<InferEntityRead<S, O>>>; /** Schema-typed create/update/remove. */ export declare function useMutation<S extends AnyType>(client: TrellisDb, schema: S): EntityMutations<InferType<S>>; //# sourceMappingURL=schema-hooks.d.ts.map