@dxos/echo-query 0.10.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1870,7 +1870,7 @@ declare function date(constraints?: DateConstraints$1): Arbitrary<Date>;
1870
1870
  * @remarks Since 2.5.0
1871
1871
  * @public
1872
1872
  */
1873
- type CloneValue<T$1, N extends number, Rest$1 extends T$1[] = []> = [number] extends [N] ? T$1[] : Rest$1['length'] extends N ? Rest$1 : CloneValue<T$1, N, [T$1, ...Rest$1]>;
1873
+ type CloneValue<T$1, N$1 extends number, Rest$1 extends T$1[] = []> = [number] extends [N$1] ? T$1[] : Rest$1['length'] extends N$1 ? Rest$1 : CloneValue<T$1, N$1, [T$1, ...Rest$1]>;
1874
1874
  /**
1875
1875
  * Clone the values generated by `arb` in order to produce fully equal values (might not be equal in terms of === or ==)
1876
1876
  *
@@ -1880,7 +1880,7 @@ type CloneValue<T$1, N extends number, Rest$1 extends T$1[] = []> = [number] ext
1880
1880
  * @remarks Since 2.5.0
1881
1881
  * @public
1882
1882
  */
1883
- declare function clone<T$1, N extends number>(arb: Arbitrary<T$1>, numValues: N): Arbitrary<CloneValue<T$1, N>>;
1883
+ declare function clone<T$1, N$1 extends number>(arb: Arbitrary<T$1>, numValues: N$1): Arbitrary<CloneValue<T$1, N$1>>;
1884
1884
  //#endregion
1885
1885
  //#region ../../../../node_modules/.pnpm/fast-check@3.23.2/node_modules/fast-check/lib/types/arbitrary/dictionary.d.ts
1886
1886
  /**
@@ -4892,15 +4892,15 @@ interface Pipeable {
4892
4892
  pipe<A$1, B$1 = never, C = never, D = never, E$1 = never, F = never, G = never, H$1 = never, I$1 = never, J = never, K$1 = never>(this: A$1, ab: (_: A$1) => B$1, bc: (_: B$1) => C, cd: (_: C) => D, de: (_: D) => E$1, ef: (_: E$1) => F, fg: (_: F) => G, gh: (_: G) => H$1, hi: (_: H$1) => I$1, ij: (_: I$1) => J, jk: (_: J) => K$1): K$1;
4893
4893
  pipe<A$1, B$1 = never, C = never, D = never, E$1 = never, F = never, G = never, H$1 = never, I$1 = never, J = never, K$1 = never, L$1 = never>(this: A$1, ab: (_: A$1) => B$1, bc: (_: B$1) => C, cd: (_: C) => D, de: (_: D) => E$1, ef: (_: E$1) => F, fg: (_: F) => G, gh: (_: G) => H$1, hi: (_: H$1) => I$1, ij: (_: I$1) => J, jk: (_: J) => K$1, kl: (_: K$1) => L$1): L$1;
4894
4894
  pipe<A$1, B$1 = never, C = never, D = never, E$1 = never, F = never, G = never, H$1 = never, I$1 = never, J = never, K$1 = never, L$1 = never, M = never>(this: A$1, ab: (_: A$1) => B$1, bc: (_: B$1) => C, cd: (_: C) => D, de: (_: D) => E$1, ef: (_: E$1) => F, fg: (_: F) => G, gh: (_: G) => H$1, hi: (_: H$1) => I$1, ij: (_: I$1) => J, jk: (_: J) => K$1, kl: (_: K$1) => L$1, lm: (_: L$1) => M): M;
4895
- pipe<A$1, B$1 = never, C = never, D = never, E$1 = never, F = never, G = never, H$1 = never, I$1 = never, J = never, K$1 = never, L$1 = never, M = never, N = never>(this: A$1, ab: (_: A$1) => B$1, bc: (_: B$1) => C, cd: (_: C) => D, de: (_: D) => E$1, ef: (_: E$1) => F, fg: (_: F) => G, gh: (_: G) => H$1, hi: (_: H$1) => I$1, ij: (_: I$1) => J, jk: (_: J) => K$1, kl: (_: K$1) => L$1, lm: (_: L$1) => M, mn: (_: M) => N): N;
4896
- pipe<A$1, B$1 = never, C = never, D = never, E$1 = never, F = never, G = never, H$1 = never, I$1 = never, J = never, K$1 = never, L$1 = never, M = never, N = never, O = never>(this: A$1, ab: (_: A$1) => B$1, bc: (_: B$1) => C, cd: (_: C) => D, de: (_: D) => E$1, ef: (_: E$1) => F, fg: (_: F) => G, gh: (_: G) => H$1, hi: (_: H$1) => I$1, ij: (_: I$1) => J, jk: (_: J) => K$1, kl: (_: K$1) => L$1, lm: (_: L$1) => M, mn: (_: M) => N, no: (_: N) => O): O;
4897
- pipe<A$1, B$1 = never, C = never, D = never, E$1 = never, F = never, G = never, H$1 = never, I$1 = never, J = never, K$1 = never, L$1 = never, M = never, N = never, O = never, P$1 = never>(this: A$1, ab: (_: A$1) => B$1, bc: (_: B$1) => C, cd: (_: C) => D, de: (_: D) => E$1, ef: (_: E$1) => F, fg: (_: F) => G, gh: (_: G) => H$1, hi: (_: H$1) => I$1, ij: (_: I$1) => J, jk: (_: J) => K$1, kl: (_: K$1) => L$1, lm: (_: L$1) => M, mn: (_: M) => N, no: (_: N) => O, op: (_: O) => P$1): P$1;
4898
- pipe<A$1, B$1 = never, C = never, D = never, E$1 = never, F = never, G = never, H$1 = never, I$1 = never, J = never, K$1 = never, L$1 = never, M = never, N = never, O = never, P$1 = never, Q = never>(this: A$1, ab: (_: A$1) => B$1, bc: (_: B$1) => C, cd: (_: C) => D, de: (_: D) => E$1, ef: (_: E$1) => F, fg: (_: F) => G, gh: (_: G) => H$1, hi: (_: H$1) => I$1, ij: (_: I$1) => J, jk: (_: J) => K$1, kl: (_: K$1) => L$1, lm: (_: L$1) => M, mn: (_: M) => N, no: (_: N) => O, op: (_: O) => P$1, pq: (_: P$1) => Q): Q;
4899
- pipe<A$1, B$1 = never, C = never, D = never, E$1 = never, F = never, G = never, H$1 = never, I$1 = never, J = never, K$1 = never, L$1 = never, M = never, N = never, O = never, P$1 = never, Q = never, R$1 = never>(this: A$1, ab: (_: A$1) => B$1, bc: (_: B$1) => C, cd: (_: C) => D, de: (_: D) => E$1, ef: (_: E$1) => F, fg: (_: F) => G, gh: (_: G) => H$1, hi: (_: H$1) => I$1, ij: (_: I$1) => J, jk: (_: J) => K$1, kl: (_: K$1) => L$1, lm: (_: L$1) => M, mn: (_: M) => N, no: (_: N) => O, op: (_: O) => P$1, pq: (_: P$1) => Q, qr: (_: Q) => R$1): R$1;
4900
- pipe<A$1, B$1 = never, C = never, D = never, E$1 = never, F = never, G = never, H$1 = never, I$1 = never, J = never, K$1 = never, L$1 = never, M = never, N = never, O = never, P$1 = never, Q = never, R$1 = never, S$1 = never>(this: A$1, ab: (_: A$1) => B$1, bc: (_: B$1) => C, cd: (_: C) => D, de: (_: D) => E$1, ef: (_: E$1) => F, fg: (_: F) => G, gh: (_: G) => H$1, hi: (_: H$1) => I$1, ij: (_: I$1) => J, jk: (_: J) => K$1, kl: (_: K$1) => L$1, lm: (_: L$1) => M, mn: (_: M) => N, no: (_: N) => O, op: (_: O) => P$1, pq: (_: P$1) => Q, qr: (_: Q) => R$1, rs: (_: R$1) => S$1): S$1;
4901
- pipe<A$1, B$1 = never, C = never, D = never, E$1 = never, F = never, G = never, H$1 = never, I$1 = never, J = never, K$1 = never, L$1 = never, M = never, N = never, O = never, P$1 = never, Q = never, R$1 = never, S$1 = never, T$1 = never>(this: A$1, ab: (_: A$1) => B$1, bc: (_: B$1) => C, cd: (_: C) => D, de: (_: D) => E$1, ef: (_: E$1) => F, fg: (_: F) => G, gh: (_: G) => H$1, hi: (_: H$1) => I$1, ij: (_: I$1) => J, jk: (_: J) => K$1, kl: (_: K$1) => L$1, lm: (_: L$1) => M, mn: (_: M) => N, no: (_: N) => O, op: (_: O) => P$1, pq: (_: P$1) => Q, qr: (_: Q) => R$1, rs: (_: R$1) => S$1, st: (_: S$1) => T$1): T$1;
4902
- pipe<A$1, B$1 = never, C = never, D = never, E$1 = never, F = never, G = never, H$1 = never, I$1 = never, J = never, K$1 = never, L$1 = never, M = never, N = never, O = never, P$1 = never, Q = never, R$1 = never, S$1 = never, T$1 = never, U$1 = never>(this: A$1, ab: (_: A$1) => B$1, bc: (_: B$1) => C, cd: (_: C) => D, de: (_: D) => E$1, ef: (_: E$1) => F, fg: (_: F) => G, gh: (_: G) => H$1, hi: (_: H$1) => I$1, ij: (_: I$1) => J, jk: (_: J) => K$1, kl: (_: K$1) => L$1, lm: (_: L$1) => M, mn: (_: M) => N, no: (_: N) => O, op: (_: O) => P$1, pq: (_: P$1) => Q, qr: (_: Q) => R$1, rs: (_: R$1) => S$1, st: (_: S$1) => T$1, tu: (_: T$1) => U$1): U$1;
4903
- pipe<A$1, B$1 = never, C = never, D = never, E$1 = never, F = never, G = never, H$1 = never, I$1 = never, J = never, K$1 = never, L$1 = never, M = never, N = never, O = never, P$1 = never, Q = never, R$1 = never, S$1 = never, T$1 = never, U$1 = never>(this: A$1, ab: (_: A$1) => B$1, bc: (_: B$1) => C, cd: (_: C) => D, de: (_: D) => E$1, ef: (_: E$1) => F, fg: (_: F) => G, gh: (_: G) => H$1, hi: (_: H$1) => I$1, ij: (_: I$1) => J, jk: (_: J) => K$1, kl: (_: K$1) => L$1, lm: (_: L$1) => M, mn: (_: M) => N, no: (_: N) => O, op: (_: O) => P$1, pq: (_: P$1) => Q, qr: (_: Q) => R$1, rs: (_: R$1) => S$1, st: (_: S$1) => T$1, tu: (_: T$1) => U$1): U$1;
4895
+ pipe<A$1, B$1 = never, C = never, D = never, E$1 = never, F = never, G = never, H$1 = never, I$1 = never, J = never, K$1 = never, L$1 = never, M = never, N$1 = never>(this: A$1, ab: (_: A$1) => B$1, bc: (_: B$1) => C, cd: (_: C) => D, de: (_: D) => E$1, ef: (_: E$1) => F, fg: (_: F) => G, gh: (_: G) => H$1, hi: (_: H$1) => I$1, ij: (_: I$1) => J, jk: (_: J) => K$1, kl: (_: K$1) => L$1, lm: (_: L$1) => M, mn: (_: M) => N$1): N$1;
4896
+ pipe<A$1, B$1 = never, C = never, D = never, E$1 = never, F = never, G = never, H$1 = never, I$1 = never, J = never, K$1 = never, L$1 = never, M = never, N$1 = never, O = never>(this: A$1, ab: (_: A$1) => B$1, bc: (_: B$1) => C, cd: (_: C) => D, de: (_: D) => E$1, ef: (_: E$1) => F, fg: (_: F) => G, gh: (_: G) => H$1, hi: (_: H$1) => I$1, ij: (_: I$1) => J, jk: (_: J) => K$1, kl: (_: K$1) => L$1, lm: (_: L$1) => M, mn: (_: M) => N$1, no: (_: N$1) => O): O;
4897
+ pipe<A$1, B$1 = never, C = never, D = never, E$1 = never, F = never, G = never, H$1 = never, I$1 = never, J = never, K$1 = never, L$1 = never, M = never, N$1 = never, O = never, P$1 = never>(this: A$1, ab: (_: A$1) => B$1, bc: (_: B$1) => C, cd: (_: C) => D, de: (_: D) => E$1, ef: (_: E$1) => F, fg: (_: F) => G, gh: (_: G) => H$1, hi: (_: H$1) => I$1, ij: (_: I$1) => J, jk: (_: J) => K$1, kl: (_: K$1) => L$1, lm: (_: L$1) => M, mn: (_: M) => N$1, no: (_: N$1) => O, op: (_: O) => P$1): P$1;
4898
+ pipe<A$1, B$1 = never, C = never, D = never, E$1 = never, F = never, G = never, H$1 = never, I$1 = never, J = never, K$1 = never, L$1 = never, M = never, N$1 = never, O = never, P$1 = never, Q = never>(this: A$1, ab: (_: A$1) => B$1, bc: (_: B$1) => C, cd: (_: C) => D, de: (_: D) => E$1, ef: (_: E$1) => F, fg: (_: F) => G, gh: (_: G) => H$1, hi: (_: H$1) => I$1, ij: (_: I$1) => J, jk: (_: J) => K$1, kl: (_: K$1) => L$1, lm: (_: L$1) => M, mn: (_: M) => N$1, no: (_: N$1) => O, op: (_: O) => P$1, pq: (_: P$1) => Q): Q;
4899
+ pipe<A$1, B$1 = never, C = never, D = never, E$1 = never, F = never, G = never, H$1 = never, I$1 = never, J = never, K$1 = never, L$1 = never, M = never, N$1 = never, O = never, P$1 = never, Q = never, R$1 = never>(this: A$1, ab: (_: A$1) => B$1, bc: (_: B$1) => C, cd: (_: C) => D, de: (_: D) => E$1, ef: (_: E$1) => F, fg: (_: F) => G, gh: (_: G) => H$1, hi: (_: H$1) => I$1, ij: (_: I$1) => J, jk: (_: J) => K$1, kl: (_: K$1) => L$1, lm: (_: L$1) => M, mn: (_: M) => N$1, no: (_: N$1) => O, op: (_: O) => P$1, pq: (_: P$1) => Q, qr: (_: Q) => R$1): R$1;
4900
+ pipe<A$1, B$1 = never, C = never, D = never, E$1 = never, F = never, G = never, H$1 = never, I$1 = never, J = never, K$1 = never, L$1 = never, M = never, N$1 = never, O = never, P$1 = never, Q = never, R$1 = never, S$1 = never>(this: A$1, ab: (_: A$1) => B$1, bc: (_: B$1) => C, cd: (_: C) => D, de: (_: D) => E$1, ef: (_: E$1) => F, fg: (_: F) => G, gh: (_: G) => H$1, hi: (_: H$1) => I$1, ij: (_: I$1) => J, jk: (_: J) => K$1, kl: (_: K$1) => L$1, lm: (_: L$1) => M, mn: (_: M) => N$1, no: (_: N$1) => O, op: (_: O) => P$1, pq: (_: P$1) => Q, qr: (_: Q) => R$1, rs: (_: R$1) => S$1): S$1;
4901
+ pipe<A$1, B$1 = never, C = never, D = never, E$1 = never, F = never, G = never, H$1 = never, I$1 = never, J = never, K$1 = never, L$1 = never, M = never, N$1 = never, O = never, P$1 = never, Q = never, R$1 = never, S$1 = never, T$1 = never>(this: A$1, ab: (_: A$1) => B$1, bc: (_: B$1) => C, cd: (_: C) => D, de: (_: D) => E$1, ef: (_: E$1) => F, fg: (_: F) => G, gh: (_: G) => H$1, hi: (_: H$1) => I$1, ij: (_: I$1) => J, jk: (_: J) => K$1, kl: (_: K$1) => L$1, lm: (_: L$1) => M, mn: (_: M) => N$1, no: (_: N$1) => O, op: (_: O) => P$1, pq: (_: P$1) => Q, qr: (_: Q) => R$1, rs: (_: R$1) => S$1, st: (_: S$1) => T$1): T$1;
4902
+ pipe<A$1, B$1 = never, C = never, D = never, E$1 = never, F = never, G = never, H$1 = never, I$1 = never, J = never, K$1 = never, L$1 = never, M = never, N$1 = never, O = never, P$1 = never, Q = never, R$1 = never, S$1 = never, T$1 = never, U$1 = never>(this: A$1, ab: (_: A$1) => B$1, bc: (_: B$1) => C, cd: (_: C) => D, de: (_: D) => E$1, ef: (_: E$1) => F, fg: (_: F) => G, gh: (_: G) => H$1, hi: (_: H$1) => I$1, ij: (_: I$1) => J, jk: (_: J) => K$1, kl: (_: K$1) => L$1, lm: (_: L$1) => M, mn: (_: M) => N$1, no: (_: N$1) => O, op: (_: O) => P$1, pq: (_: P$1) => Q, qr: (_: Q) => R$1, rs: (_: R$1) => S$1, st: (_: S$1) => T$1, tu: (_: T$1) => U$1): U$1;
4903
+ pipe<A$1, B$1 = never, C = never, D = never, E$1 = never, F = never, G = never, H$1 = never, I$1 = never, J = never, K$1 = never, L$1 = never, M = never, N$1 = never, O = never, P$1 = never, Q = never, R$1 = never, S$1 = never, T$1 = never, U$1 = never>(this: A$1, ab: (_: A$1) => B$1, bc: (_: B$1) => C, cd: (_: C) => D, de: (_: D) => E$1, ef: (_: E$1) => F, fg: (_: F) => G, gh: (_: G) => H$1, hi: (_: H$1) => I$1, ij: (_: I$1) => J, jk: (_: J) => K$1, kl: (_: K$1) => L$1, lm: (_: L$1) => M, mn: (_: M) => N$1, no: (_: N$1) => O, op: (_: O) => P$1, pq: (_: P$1) => Q, qr: (_: Q) => R$1, rs: (_: R$1) => S$1, st: (_: S$1) => T$1, tu: (_: T$1) => U$1): U$1;
4904
4904
  }
4905
4905
  //#endregion
4906
4906
  //#region ../../../../node_modules/.pnpm/effect@3.21.4/node_modules/effect/dist/dts/Unify.d.ts
@@ -5506,13 +5506,13 @@ declare namespace Stream {
5506
5506
  * @category models
5507
5507
  * @deprecated use Types.TupleOf instead
5508
5508
  */
5509
- type DynamicTuple<T$1, N extends number> = N extends N ? number extends N ? Array<T$1> : DynamicTupleOf<T$1, N, []> : never;
5509
+ type DynamicTuple<T$1, N$1 extends number> = N$1 extends N$1 ? number extends N$1 ? Array<T$1> : DynamicTupleOf<T$1, N$1, []> : never;
5510
5510
  /**
5511
5511
  * @since 2.0.0
5512
5512
  * @category models
5513
5513
  * @deprecated use Types.TupleOf instead
5514
5514
  */
5515
- type DynamicTupleOf<T$1, N extends number, R$1 extends Array<unknown>> = R$1["length"] extends N ? R$1 : DynamicTupleOf<T$1, N, [T$1, ...R$1]>;
5515
+ type DynamicTupleOf<T$1, N$1 extends number, R$1 extends Array<unknown>> = R$1["length"] extends N$1 ? R$1 : DynamicTupleOf<T$1, N$1, [T$1, ...R$1]>;
5516
5516
  }
5517
5517
  //#endregion
5518
5518
  //#region ../../../../node_modules/.pnpm/effect@3.21.4/node_modules/effect/dist/dts/Channel.d.ts
@@ -7304,7 +7304,7 @@ declare namespace Annotable {
7304
7304
  /**
7305
7305
  * @since 3.10.0
7306
7306
  */
7307
- type All = Any$4 | Annotable<any, any, never, unknown> | Annotable<any, never, any, unknown> | Annotable<any, never, never, unknown>;
7307
+ type All = Any$5 | Annotable<any, any, never, unknown> | Annotable<any, never, any, unknown> | Annotable<any, never, never, unknown>;
7308
7308
  }
7309
7309
  /**
7310
7310
  * @since 3.10.0
@@ -7353,7 +7353,7 @@ declare namespace Schema {
7353
7353
  *
7354
7354
  * @since 3.10.0
7355
7355
  */
7356
- type All = Any$4 | Schema<any, never, unknown> | Schema<never, any, unknown> | Schema<never, never, unknown>;
7356
+ type All = Any$5 | Schema<any, never, unknown> | Schema<never, any, unknown> | Schema<never, never, unknown>;
7357
7357
  /**
7358
7358
  * Type-level counterpart of `Schema.asSchema` function.
7359
7359
  *
@@ -7416,7 +7416,7 @@ declare const Any_base: SchemaClass<any, any, never>;
7416
7416
  * @category primitives
7417
7417
  * @since 3.10.0
7418
7418
  */
7419
- declare class Any$4 extends Any_base {}
7419
+ declare class Any$5 extends Any_base {}
7420
7420
  declare const String$_base: SchemaClass<string, string, never>;
7421
7421
  /** @ignore */
7422
7422
  declare class String$ extends String$_base {}
@@ -7541,7 +7541,7 @@ declare namespace PropertySignature {
7541
7541
  /**
7542
7542
  * @since 3.10.0
7543
7543
  */
7544
- type All<Key$1 extends PropertyKey = PropertyKey> = Any$4<Key$1> | PropertySignature<Token, never, Key$1, Token, any, boolean, unknown> | PropertySignature<Token, any, Key$1, Token, never, boolean, unknown> | PropertySignature<Token, never, Key$1, Token, never, boolean, unknown>;
7544
+ type All<Key$1 extends PropertyKey = PropertyKey> = Any$5<Key$1> | PropertySignature<Token, never, Key$1, Token, any, boolean, unknown> | PropertySignature<Token, any, Key$1, Token, never, boolean, unknown> | PropertySignature<Token, never, Key$1, Token, never, boolean, unknown>;
7545
7545
  /**
7546
7546
  * @since 3.10.0
7547
7547
  */
@@ -8095,10 +8095,20 @@ declare const SpaceId: Schema<SpaceId, string> & {
8095
8095
  /**
8096
8096
  * Addresses an ECHO object or space. Uses the `echo:` URI scheme.
8097
8097
  *
8098
+ * Canonical forms:
8099
+ * - `echo://<spaceId>/<objectId>` — fully-qualified object.
8100
+ * - `echo://<spaceId>` — space.
8101
+ * - `echo:///<objectId>` — local (space-less) object.
8102
+ *
8103
+ * @deprecated form: the single-slash local form `echo:/<objectId>` is retired in favour of the
8104
+ * triple-slash `echo:///<objectId>` form. It is still accepted on read (and normalized by `parse`)
8105
+ * so existing persisted data keeps resolving, but it is no longer produced — do not emit it in new
8106
+ * code. Construct local EIDs with `make({ entityId })`.
8107
+ *
8098
8108
  * @example
8099
8109
  * ```
8100
8110
  * echo://BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE/01J00J9B45YHYSGZQTQMSKMGJ6
8101
- * echo:/01J00J9B45YHYSGZQTQMSKMGJ6
8111
+ * echo:///01J00J9B45YHYSGZQTQMSKMGJ6
8102
8112
  * echo://BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE
8103
8113
  * ```
8104
8114
  */
@@ -8106,6 +8116,46 @@ type EID = URI & {
8106
8116
  readonly __EID: unique symbol;
8107
8117
  };
8108
8118
  //#endregion
8119
+ //#region ../echo-protocol/dist/types/src/blob.d.ts
8120
+ interface BlobPutRequest {
8121
+ spaceId: SpaceId;
8122
+ data: Uint8Array;
8123
+ contentType?: string;
8124
+ /** Lowercase hex SHA-256 digest of `data`, computed by the manager. The backend does not verify it. */
8125
+ contentHash: string;
8126
+ /** For path-addressed extension backends. */
8127
+ name?: string;
8128
+ }
8129
+ interface BlobPutResponse {
8130
+ /** URI locating the stored bytes; must use a scheme the backend resolves. */
8131
+ uri: string;
8132
+ }
8133
+ /**
8134
+ * Implemented by pluggable blob storage backends and registered on the Hypergraph via
8135
+ * `registerBlobBackend`.
8136
+ */
8137
+ interface BlobBackend {
8138
+ /** URI schemes this backend resolves at read time. */
8139
+ readonly schemes: readonly string[];
8140
+ /** Largest `data.byteLength` this backend accepts, in bytes. `undefined` means unlimited. */
8141
+ readonly maxSize?: number;
8142
+ put(request: BlobPutRequest): Promise<BlobPutResponse>;
8143
+ /** `undefined` means the URI was not found. Rejects on transport failure (e.g. offline). */
8144
+ get(request: {
8145
+ spaceId: SpaceId;
8146
+ uri: string;
8147
+ }): Promise<Uint8Array | undefined>;
8148
+ has(request: {
8149
+ spaceId: SpaceId;
8150
+ uri: string;
8151
+ }): Promise<boolean>;
8152
+ getUrl?(request: {
8153
+ spaceId: SpaceId;
8154
+ uri: string;
8155
+ contentType?: string;
8156
+ }): Promise<string | undefined>;
8157
+ }
8158
+ //#endregion
8109
8159
  //#region ../echo-protocol/dist/types/src/foreign-key.d.ts
8110
8160
  declare const ForeignKey_: Struct<{
8111
8161
  /**
@@ -8158,7 +8208,7 @@ declare const FilterObject_: Struct<{
8158
8208
  * Filter by property.
8159
8209
  * Must not include object ID.
8160
8210
  */
8161
- props: Record$<SchemaClass<string, string, never>, suspend<FilterAnd | FilterChildOf | FilterCompare | FilterContains | FilterIn | FilterNot | FilterObject | FilterOr | FilterRange | FilterTag | FilterTextSearch | FilterTimestamp, FilterAnd | FilterChildOf | FilterCompare | FilterContains | FilterIn | FilterNot | FilterObject | FilterOr | FilterRange | FilterTag | FilterTextSearch | FilterTimestamp, never>>;
8211
+ props: Record$<SchemaClass<string, string, never>, suspend<FilterAnd | FilterChildOf | FilterCompare | FilterContains | FilterIn | FilterInQuery | FilterNot | FilterObject | FilterOr | FilterRange | FilterTag | FilterTextSearch | FilterTimestamp, FilterAnd | FilterChildOf | FilterCompare | FilterContains | FilterIn | FilterInQuery | FilterNot | FilterObject | FilterOr | FilterRange | FilterTag | FilterTextSearch | FilterTimestamp, never>>;
8162
8212
  /**
8163
8213
  * Objects that have any of the given foreign keys.
8164
8214
  */
@@ -8196,16 +8246,32 @@ declare const FilterCompare: Schema<FilterCompare>;
8196
8246
  */
8197
8247
  declare const FilterIn_: Struct<{
8198
8248
  type: Literal<["in"]>;
8199
- values: Array$<typeof Any$4>;
8249
+ values: Array$<typeof Any$5>;
8200
8250
  }>;
8201
8251
  interface FilterIn extends Schema.Type<typeof FilterIn_> {}
8202
8252
  declare const FilterIn: Schema<FilterIn>;
8253
+ /**
8254
+ * In (subquery form) — membership against a value projected from a subquery's results,
8255
+ * e.g. `threadId IN (SELECT threadId FROM feed WHERE tag = 'inbox')`.
8256
+ *
8257
+ * Nested-only (like {@link FilterIn}): valid inside an `object` filter's `props`, not at
8258
+ * the query root — the planner has no selector for a standalone membership predicate.
8259
+ * The subquery may target a different scope than the parent query; it is resolved once at
8260
+ * execution time by projecting `property` from its results into a set.
8261
+ */
8262
+ declare const FilterInQuery_: Struct<{
8263
+ type: Literal<["in-query"]>;
8264
+ subquery: suspend<QueryAggregateClause | QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QuerySkipClause | QueryUnionClause, QueryAggregateClause | QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QuerySkipClause | QueryUnionClause, never>;
8265
+ property: typeof String$;
8266
+ }>;
8267
+ interface FilterInQuery extends Schema.Type<typeof FilterInQuery_> {}
8268
+ declare const FilterInQuery: Schema<FilterInQuery>;
8203
8269
  /**
8204
8270
  * Contains.
8205
8271
  */
8206
8272
  declare const FilterContains_: Struct<{
8207
8273
  type: Literal<["contains"]>;
8208
- value: typeof Any$4;
8274
+ value: typeof Any$5;
8209
8275
  }>;
8210
8276
  interface FilterContains extends Schema.Type<typeof FilterContains_> {}
8211
8277
  /**
@@ -8227,8 +8293,8 @@ declare const FilterTag: Schema<FilterTag>;
8227
8293
  */
8228
8294
  declare const FilterRange_: Struct<{
8229
8295
  type: Literal<["range"]>;
8230
- from: typeof Any$4;
8231
- to: typeof Any$4;
8296
+ from: typeof Any$5;
8297
+ to: typeof Any$5;
8232
8298
  }>;
8233
8299
  interface FilterRange extends Schema.Type<typeof FilterRange_> {}
8234
8300
  declare const FilterRange: Schema<FilterRange>;
@@ -8259,7 +8325,7 @@ declare const FilterTextSearch: Schema<FilterTextSearch>;
8259
8325
  */
8260
8326
  declare const FilterNot_: Struct<{
8261
8327
  type: Literal<["not"]>;
8262
- filter: suspend<FilterAnd | FilterChildOf | FilterCompare | FilterContains | FilterIn | FilterNot | FilterObject | FilterOr | FilterRange | FilterTag | FilterTextSearch | FilterTimestamp, FilterAnd | FilterChildOf | FilterCompare | FilterContains | FilterIn | FilterNot | FilterObject | FilterOr | FilterRange | FilterTag | FilterTextSearch | FilterTimestamp, never>;
8328
+ filter: suspend<FilterAnd | FilterChildOf | FilterCompare | FilterContains | FilterIn | FilterInQuery | FilterNot | FilterObject | FilterOr | FilterRange | FilterTag | FilterTextSearch | FilterTimestamp, FilterAnd | FilterChildOf | FilterCompare | FilterContains | FilterIn | FilterInQuery | FilterNot | FilterObject | FilterOr | FilterRange | FilterTag | FilterTextSearch | FilterTimestamp, never>;
8263
8329
  }>;
8264
8330
  interface FilterNot extends Schema.Type<typeof FilterNot_> {}
8265
8331
  declare const FilterNot: Schema<FilterNot>;
@@ -8268,7 +8334,7 @@ declare const FilterNot: Schema<FilterNot>;
8268
8334
  */
8269
8335
  declare const FilterAnd_: Struct<{
8270
8336
  type: Literal<["and"]>;
8271
- filters: Array$<suspend<FilterAnd | FilterChildOf | FilterCompare | FilterContains | FilterIn | FilterNot | FilterObject | FilterOr | FilterRange | FilterTag | FilterTextSearch | FilterTimestamp, FilterAnd | FilterChildOf | FilterCompare | FilterContains | FilterIn | FilterNot | FilterObject | FilterOr | FilterRange | FilterTag | FilterTextSearch | FilterTimestamp, never>>;
8337
+ filters: Array$<suspend<FilterAnd | FilterChildOf | FilterCompare | FilterContains | FilterIn | FilterInQuery | FilterNot | FilterObject | FilterOr | FilterRange | FilterTag | FilterTextSearch | FilterTimestamp, FilterAnd | FilterChildOf | FilterCompare | FilterContains | FilterIn | FilterInQuery | FilterNot | FilterObject | FilterOr | FilterRange | FilterTag | FilterTextSearch | FilterTimestamp, never>>;
8272
8338
  }>;
8273
8339
  interface FilterAnd extends Schema.Type<typeof FilterAnd_> {}
8274
8340
  declare const FilterAnd: Schema<FilterAnd>;
@@ -8277,7 +8343,7 @@ declare const FilterAnd: Schema<FilterAnd>;
8277
8343
  */
8278
8344
  declare const FilterOr_: Struct<{
8279
8345
  type: Literal<["or"]>;
8280
- filters: Array$<suspend<FilterAnd | FilterChildOf | FilterCompare | FilterContains | FilterIn | FilterNot | FilterObject | FilterOr | FilterRange | FilterTag | FilterTextSearch | FilterTimestamp, FilterAnd | FilterChildOf | FilterCompare | FilterContains | FilterIn | FilterNot | FilterObject | FilterOr | FilterRange | FilterTag | FilterTextSearch | FilterTimestamp, never>>;
8346
+ filters: Array$<suspend<FilterAnd | FilterChildOf | FilterCompare | FilterContains | FilterIn | FilterInQuery | FilterNot | FilterObject | FilterOr | FilterRange | FilterTag | FilterTextSearch | FilterTimestamp, FilterAnd | FilterChildOf | FilterCompare | FilterContains | FilterIn | FilterInQuery | FilterNot | FilterObject | FilterOr | FilterRange | FilterTag | FilterTextSearch | FilterTimestamp, never>>;
8281
8347
  }>;
8282
8348
  interface FilterOr extends Schema.Type<typeof FilterOr_> {}
8283
8349
  declare const FilterOr: Schema<FilterOr>;
@@ -8297,14 +8363,14 @@ declare const FilterChildOf: Schema<FilterChildOf>;
8297
8363
  /**
8298
8364
  * Union of filters.
8299
8365
  */
8300
- declare const Filter$1: Union<[Schema<FilterObject, FilterObject, never>, Schema<FilterCompare, FilterCompare, never>, Schema<FilterIn, FilterIn, never>, Schema<FilterContains, FilterContains, never>, Schema<FilterTag, FilterTag, never>, Schema<FilterRange, FilterRange, never>, Schema<FilterTimestamp, FilterTimestamp, never>, Schema<FilterTextSearch, FilterTextSearch, never>, Schema<FilterChildOf, FilterChildOf, never>, Schema<FilterNot, FilterNot, never>, Schema<FilterAnd, FilterAnd, never>, Schema<FilterOr, FilterOr, never>]>;
8366
+ declare const Filter$1: Union<[Schema<FilterObject, FilterObject, never>, Schema<FilterCompare, FilterCompare, never>, Schema<FilterIn, FilterIn, never>, Schema<FilterInQuery, FilterInQuery, never>, Schema<FilterContains, FilterContains, never>, Schema<FilterTag, FilterTag, never>, Schema<FilterRange, FilterRange, never>, Schema<FilterTimestamp, FilterTimestamp, never>, Schema<FilterTextSearch, FilterTextSearch, never>, Schema<FilterChildOf, FilterChildOf, never>, Schema<FilterNot, FilterNot, never>, Schema<FilterAnd, FilterAnd, never>, Schema<FilterOr, FilterOr, never>]>;
8301
8367
  type Filter$1 = Schema.Type<typeof Filter$1>;
8302
8368
  /**
8303
8369
  * Query objects by type, id, and/or predicates.
8304
8370
  */
8305
8371
  declare const QuerySelectClause_: Struct<{
8306
8372
  type: Literal<["select"]>;
8307
- filter: suspend<FilterAnd | FilterChildOf | FilterCompare | FilterContains | FilterIn | FilterNot | FilterObject | FilterOr | FilterRange | FilterTag | FilterTextSearch | FilterTimestamp, FilterAnd | FilterChildOf | FilterCompare | FilterContains | FilterIn | FilterNot | FilterObject | FilterOr | FilterRange | FilterTag | FilterTextSearch | FilterTimestamp, never>;
8373
+ filter: suspend<FilterAnd | FilterChildOf | FilterCompare | FilterContains | FilterIn | FilterInQuery | FilterNot | FilterObject | FilterOr | FilterRange | FilterTag | FilterTextSearch | FilterTimestamp, FilterAnd | FilterChildOf | FilterCompare | FilterContains | FilterIn | FilterInQuery | FilterNot | FilterObject | FilterOr | FilterRange | FilterTag | FilterTextSearch | FilterTimestamp, never>;
8308
8374
  }>;
8309
8375
  interface QuerySelectClause extends Schema.Type<typeof QuerySelectClause_> {}
8310
8376
  declare const QuerySelectClause: Schema<QuerySelectClause>;
@@ -8313,8 +8379,8 @@ declare const QuerySelectClause: Schema<QuerySelectClause>;
8313
8379
  */
8314
8380
  declare const QueryFilterClause_: Struct<{
8315
8381
  type: Literal<["filter"]>;
8316
- selection: suspend<QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QueryUnionClause, QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QueryUnionClause, never>;
8317
- filter: suspend<FilterAnd | FilterChildOf | FilterCompare | FilterContains | FilterIn | FilterNot | FilterObject | FilterOr | FilterRange | FilterTag | FilterTextSearch | FilterTimestamp, FilterAnd | FilterChildOf | FilterCompare | FilterContains | FilterIn | FilterNot | FilterObject | FilterOr | FilterRange | FilterTag | FilterTextSearch | FilterTimestamp, never>;
8382
+ selection: suspend<QueryAggregateClause | QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QuerySkipClause | QueryUnionClause, QueryAggregateClause | QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QuerySkipClause | QueryUnionClause, never>;
8383
+ filter: suspend<FilterAnd | FilterChildOf | FilterCompare | FilterContains | FilterIn | FilterInQuery | FilterNot | FilterObject | FilterOr | FilterRange | FilterTag | FilterTextSearch | FilterTimestamp, FilterAnd | FilterChildOf | FilterCompare | FilterContains | FilterIn | FilterInQuery | FilterNot | FilterObject | FilterOr | FilterRange | FilterTag | FilterTextSearch | FilterTimestamp, never>;
8318
8384
  }>;
8319
8385
  interface QueryFilterClause extends Schema.Type<typeof QueryFilterClause_> {}
8320
8386
  declare const QueryFilterClause: Schema<QueryFilterClause>;
@@ -8323,7 +8389,7 @@ declare const QueryFilterClause: Schema<QueryFilterClause>;
8323
8389
  */
8324
8390
  declare const QueryReferenceTraversalClause_: Struct<{
8325
8391
  type: Literal<["reference-traversal"]>;
8326
- anchor: suspend<QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QueryUnionClause, QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QueryUnionClause, never>;
8392
+ anchor: suspend<QueryAggregateClause | QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QuerySkipClause | QueryUnionClause, QueryAggregateClause | QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QuerySkipClause | QueryUnionClause, never>;
8327
8393
  property: typeof String$;
8328
8394
  }>;
8329
8395
  interface QueryReferenceTraversalClause extends Schema.Type<typeof QueryReferenceTraversalClause_> {}
@@ -8333,7 +8399,7 @@ declare const QueryReferenceTraversalClause: Schema<QueryReferenceTraversalClaus
8333
8399
  */
8334
8400
  declare const QueryIncomingReferencesClause_: Struct<{
8335
8401
  type: Literal<["incoming-references"]>;
8336
- anchor: suspend<QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QueryUnionClause, QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QueryUnionClause, never>;
8402
+ anchor: suspend<QueryAggregateClause | QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QuerySkipClause | QueryUnionClause, QueryAggregateClause | QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QuerySkipClause | QueryUnionClause, never>;
8337
8403
  /**
8338
8404
  * Property path where the reference is located.
8339
8405
  * If null, matches references from any property.
@@ -8348,14 +8414,14 @@ declare const QueryIncomingReferencesClause: Schema<QueryIncomingReferencesClaus
8348
8414
  */
8349
8415
  declare const QueryRelationClause_: Struct<{
8350
8416
  type: Literal<["relation"]>;
8351
- anchor: suspend<QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QueryUnionClause, QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QueryUnionClause, never>;
8417
+ anchor: suspend<QueryAggregateClause | QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QuerySkipClause | QueryUnionClause, QueryAggregateClause | QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QuerySkipClause | QueryUnionClause, never>;
8352
8418
  /**
8353
8419
  * outgoing: anchor is the source of the relation.
8354
8420
  * incoming: anchor is the target of the relation.
8355
8421
  * both: anchor is either the source or target of the relation.
8356
8422
  */
8357
8423
  direction: Literal<["outgoing", "incoming", "both"]>;
8358
- filter: optional<suspend<FilterAnd | FilterChildOf | FilterCompare | FilterContains | FilterIn | FilterNot | FilterObject | FilterOr | FilterRange | FilterTag | FilterTextSearch | FilterTimestamp, FilterAnd | FilterChildOf | FilterCompare | FilterContains | FilterIn | FilterNot | FilterObject | FilterOr | FilterRange | FilterTag | FilterTextSearch | FilterTimestamp, never>>;
8424
+ filter: optional<suspend<FilterAnd | FilterChildOf | FilterCompare | FilterContains | FilterIn | FilterInQuery | FilterNot | FilterObject | FilterOr | FilterRange | FilterTag | FilterTextSearch | FilterTimestamp, FilterAnd | FilterChildOf | FilterCompare | FilterContains | FilterIn | FilterInQuery | FilterNot | FilterObject | FilterOr | FilterRange | FilterTag | FilterTextSearch | FilterTimestamp, never>>;
8359
8425
  }>;
8360
8426
  interface QueryRelationClause extends Schema.Type<typeof QueryRelationClause_> {}
8361
8427
  declare const QueryRelationClause: Schema<QueryRelationClause>;
@@ -8364,7 +8430,7 @@ declare const QueryRelationClause: Schema<QueryRelationClause>;
8364
8430
  */
8365
8431
  declare const QueryRelationTraversalClause_: Struct<{
8366
8432
  type: Literal<["relation-traversal"]>;
8367
- anchor: suspend<QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QueryUnionClause, QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QueryUnionClause, never>;
8433
+ anchor: suspend<QueryAggregateClause | QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QuerySkipClause | QueryUnionClause, QueryAggregateClause | QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QuerySkipClause | QueryUnionClause, never>;
8368
8434
  direction: Literal<["source", "target", "both"]>;
8369
8435
  }>;
8370
8436
  interface QueryRelationTraversalClause extends Schema.Type<typeof QueryRelationTraversalClause_> {}
@@ -8374,7 +8440,7 @@ declare const QueryRelationTraversalClause: Schema<QueryRelationTraversalClause>
8374
8440
  */
8375
8441
  declare const QueryHierarchyTraversalClause_: Struct<{
8376
8442
  type: Literal<["hierarchy-traversal"]>;
8377
- anchor: suspend<QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QueryUnionClause, QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QueryUnionClause, never>;
8443
+ anchor: suspend<QueryAggregateClause | QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QuerySkipClause | QueryUnionClause, QueryAggregateClause | QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QuerySkipClause | QueryUnionClause, never>;
8378
8444
  /**
8379
8445
  * to-parent: traverse from child to parent.
8380
8446
  * to-children: traverse from parent to children.
@@ -8388,7 +8454,7 @@ declare const QueryHierarchyTraversalClause: Schema<QueryHierarchyTraversalClaus
8388
8454
  */
8389
8455
  declare const QueryUnionClause_: Struct<{
8390
8456
  type: Literal<["union"]>;
8391
- queries: Array$<suspend<QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QueryUnionClause, QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QueryUnionClause, never>>;
8457
+ queries: Array$<suspend<QueryAggregateClause | QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QuerySkipClause | QueryUnionClause, QueryAggregateClause | QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QuerySkipClause | QueryUnionClause, never>>;
8392
8458
  }>;
8393
8459
  interface QueryUnionClause extends Schema.Type<typeof QueryUnionClause_> {}
8394
8460
  declare const QueryUnionClause: Schema<QueryUnionClause>;
@@ -8397,8 +8463,8 @@ declare const QueryUnionClause: Schema<QueryUnionClause>;
8397
8463
  */
8398
8464
  declare const QuerySetDifferenceClause_: Struct<{
8399
8465
  type: Literal<["set-difference"]>;
8400
- source: suspend<QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QueryUnionClause, QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QueryUnionClause, never>;
8401
- exclude: suspend<QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QueryUnionClause, QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QueryUnionClause, never>;
8466
+ source: suspend<QueryAggregateClause | QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QuerySkipClause | QueryUnionClause, QueryAggregateClause | QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QuerySkipClause | QueryUnionClause, never>;
8467
+ exclude: suspend<QueryAggregateClause | QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QuerySkipClause | QueryUnionClause, QueryAggregateClause | QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QuerySkipClause | QueryUnionClause, never>;
8402
8468
  }>;
8403
8469
  interface QuerySetDifferenceClause extends Schema.Type<typeof QuerySetDifferenceClause_> {}
8404
8470
  declare const QuerySetDifferenceClause: Schema<QuerySetDifferenceClause>;
@@ -8406,6 +8472,7 @@ declare const OrderDirection: Literal<["asc", "desc"]>;
8406
8472
  type OrderDirection = Schema.Type<typeof OrderDirection>;
8407
8473
  declare const Order_: Union<[Struct<{
8408
8474
  kind: Literal<["natural"]>;
8475
+ direction: Literal<["asc", "desc"]>;
8409
8476
  }>, Struct<{
8410
8477
  kind: Literal<["property"]>;
8411
8478
  property: typeof String$;
@@ -8426,9 +8493,10 @@ declare const Order$1: Schema<Order$1>;
8426
8493
  */
8427
8494
  declare const QueryOrderClause_: Struct<{
8428
8495
  type: Literal<["order"]>;
8429
- query: suspend<QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QueryUnionClause, QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QueryUnionClause, never>;
8496
+ query: suspend<QueryAggregateClause | QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QuerySkipClause | QueryUnionClause, QueryAggregateClause | QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QuerySkipClause | QueryUnionClause, never>;
8430
8497
  order: Array$<Schema<{
8431
8498
  readonly kind: "natural";
8499
+ readonly direction: "asc" | "desc";
8432
8500
  } | {
8433
8501
  readonly kind: "property";
8434
8502
  readonly property: string;
@@ -8442,6 +8510,7 @@ declare const QueryOrderClause_: Struct<{
8442
8510
  readonly direction: "asc" | "desc";
8443
8511
  }, {
8444
8512
  readonly kind: "natural";
8513
+ readonly direction: "asc" | "desc";
8445
8514
  } | {
8446
8515
  readonly kind: "property";
8447
8516
  readonly property: string;
@@ -8462,7 +8531,7 @@ declare const QueryOrderClause: Schema<QueryOrderClause>;
8462
8531
  */
8463
8532
  declare const QueryOptionsClause_: Struct<{
8464
8533
  type: Literal<["options"]>;
8465
- query: suspend<QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QueryUnionClause, QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QueryUnionClause, never>;
8534
+ query: suspend<QueryAggregateClause | QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QuerySkipClause | QueryUnionClause, QueryAggregateClause | QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QuerySkipClause | QueryUnionClause, never>;
8466
8535
  options: suspend<{
8467
8536
  readonly deleted?: "exclude" | "include" | "only" | undefined;
8468
8537
  readonly debugLabel?: string | undefined;
@@ -8478,14 +8547,109 @@ declare const QueryOptionsClause: Schema<QueryOptionsClause>;
8478
8547
  */
8479
8548
  declare const QueryLimitClause_: Struct<{
8480
8549
  type: Literal<["limit"]>;
8481
- query: suspend<QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QueryUnionClause, QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QueryUnionClause, never>;
8550
+ query: suspend<QueryAggregateClause | QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QuerySkipClause | QueryUnionClause, QueryAggregateClause | QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QuerySkipClause | QueryUnionClause, never>;
8482
8551
  limit: typeof Number$;
8483
8552
  }>;
8484
8553
  interface QueryLimitClause extends Schema.Type<typeof QueryLimitClause_> {}
8485
8554
  declare const QueryLimitClause: Schema<QueryLimitClause>;
8555
+ /**
8556
+ * Skip a number of results (offset). Combined with `limit` and a `natural` order, this expresses
8557
+ * a windowed (paginated) read without any feed-specific query surface.
8558
+ */
8559
+ declare const QuerySkipClause_: Struct<{
8560
+ type: Literal<["skip"]>;
8561
+ query: suspend<QueryAggregateClause | QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QuerySkipClause | QueryUnionClause, QueryAggregateClause | QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QuerySkipClause | QueryUnionClause, never>;
8562
+ skip: typeof Number$;
8563
+ }>;
8564
+ interface QuerySkipClause extends Schema.Type<typeof QuerySkipClause_> {}
8565
+ declare const QuerySkipClause: Schema<QuerySkipClause>;
8566
+ /**
8567
+ * Aggregates results into flat records. `group`-kind entries partition members into contiguous
8568
+ * groups (one row each); with no `group` entries the whole input aggregates into a single row.
8569
+ * Groups are ordered by the first occurrence of their key in the incoming (already-ordered) result
8570
+ * stream — this lets a preceding `orderBy` also control group order (e.g. ordering thread groups by
8571
+ * their most recent message). A following `orderBy(Order.property(name))` referencing an aggregate
8572
+ * or group field reorders whole groups instead. Must be the outermost data clause: only
8573
+ * `from`/`options`/`order` may wrap it.
8574
+ */
8575
+ declare const QueryAggregateClause_: Struct<{
8576
+ type: Literal<["aggregate"]>;
8577
+ query: suspend<QueryAggregateClause | QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QuerySkipClause | QueryUnionClause, QueryAggregateClause | QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QuerySkipClause | QueryUnionClause, never>;
8578
+ aggregates: Array$<Schema<{
8579
+ readonly name: string;
8580
+ readonly kind: "group";
8581
+ readonly property: string;
8582
+ } | {
8583
+ readonly name: string;
8584
+ readonly kind: "max";
8585
+ readonly property: string;
8586
+ } | {
8587
+ readonly name: string;
8588
+ readonly kind: "min";
8589
+ readonly property: string;
8590
+ } | {
8591
+ readonly name: string;
8592
+ readonly kind: "items";
8593
+ readonly limit?: number | undefined;
8594
+ readonly order?: readonly ({
8595
+ readonly kind: "natural";
8596
+ readonly direction: "asc" | "desc";
8597
+ } | {
8598
+ readonly kind: "property";
8599
+ readonly property: string;
8600
+ readonly direction: "asc" | "desc";
8601
+ } | {
8602
+ readonly kind: "rank";
8603
+ readonly direction: "asc" | "desc";
8604
+ } | {
8605
+ readonly kind: "timestamp";
8606
+ readonly field: "createdAt" | "updatedAt";
8607
+ readonly direction: "asc" | "desc";
8608
+ })[] | undefined;
8609
+ } | {
8610
+ readonly name: string;
8611
+ readonly kind: "count";
8612
+ }, {
8613
+ readonly name: string;
8614
+ readonly kind: "group";
8615
+ readonly property: string;
8616
+ } | {
8617
+ readonly name: string;
8618
+ readonly kind: "max";
8619
+ readonly property: string;
8620
+ } | {
8621
+ readonly name: string;
8622
+ readonly kind: "min";
8623
+ readonly property: string;
8624
+ } | {
8625
+ readonly name: string;
8626
+ readonly kind: "items";
8627
+ readonly limit?: number | undefined;
8628
+ readonly order?: readonly ({
8629
+ readonly kind: "natural";
8630
+ readonly direction: "asc" | "desc";
8631
+ } | {
8632
+ readonly kind: "property";
8633
+ readonly property: string;
8634
+ readonly direction: "asc" | "desc";
8635
+ } | {
8636
+ readonly kind: "rank";
8637
+ readonly direction: "asc" | "desc";
8638
+ } | {
8639
+ readonly kind: "timestamp";
8640
+ readonly field: "createdAt" | "updatedAt";
8641
+ readonly direction: "asc" | "desc";
8642
+ })[] | undefined;
8643
+ } | {
8644
+ readonly name: string;
8645
+ readonly kind: "count";
8646
+ }, never>>;
8647
+ }>;
8648
+ interface QueryAggregateClause extends Schema.Type<typeof QueryAggregateClause_> {}
8649
+ declare const QueryAggregateClause: Schema<QueryAggregateClause>;
8486
8650
  declare const QueryFromClause_: Struct<{
8487
8651
  type: Literal<["from"]>;
8488
- query: suspend<QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QueryUnionClause, QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QueryUnionClause, never>;
8652
+ query: suspend<QueryAggregateClause | QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QuerySkipClause | QueryUnionClause, QueryAggregateClause | QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QuerySkipClause | QueryUnionClause, never>;
8489
8653
  from: Union<[TaggedStruct<"scope", {
8490
8654
  scopes: Array$<suspend<{
8491
8655
  readonly _tag: "space";
@@ -8509,12 +8673,12 @@ declare const QueryFromClause_: Struct<{
8509
8673
  readonly location: "local" | "remote";
8510
8674
  }, never>>;
8511
8675
  }>, TaggedStruct<"query", {
8512
- query: suspend<QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QueryUnionClause, QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QueryUnionClause, never>;
8676
+ query: suspend<QueryAggregateClause | QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QuerySkipClause | QueryUnionClause, QueryAggregateClause | QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QuerySkipClause | QueryUnionClause, never>;
8513
8677
  }>]>;
8514
8678
  }>;
8515
8679
  interface QueryFromClause extends Schema.Type<typeof QueryFromClause_> {}
8516
8680
  declare const QueryFromClause: Schema<QueryFromClause>;
8517
- declare const Query_: Union<[Schema<QuerySelectClause, QuerySelectClause, never>, Schema<QueryFilterClause, QueryFilterClause, never>, Schema<QueryReferenceTraversalClause, QueryReferenceTraversalClause, never>, Schema<QueryIncomingReferencesClause, QueryIncomingReferencesClause, never>, Schema<QueryRelationClause, QueryRelationClause, never>, Schema<QueryRelationTraversalClause, QueryRelationTraversalClause, never>, Schema<QueryHierarchyTraversalClause, QueryHierarchyTraversalClause, never>, Schema<QueryUnionClause, QueryUnionClause, never>, Schema<QuerySetDifferenceClause, QuerySetDifferenceClause, never>, Schema<QueryOrderClause, QueryOrderClause, never>, Schema<QueryOptionsClause, QueryOptionsClause, never>, Schema<QueryLimitClause, QueryLimitClause, never>, Schema<QueryFromClause, QueryFromClause, never>]>;
8681
+ declare const Query_: Union<[Schema<QuerySelectClause, QuerySelectClause, never>, Schema<QueryFilterClause, QueryFilterClause, never>, Schema<QueryReferenceTraversalClause, QueryReferenceTraversalClause, never>, Schema<QueryIncomingReferencesClause, QueryIncomingReferencesClause, never>, Schema<QueryRelationClause, QueryRelationClause, never>, Schema<QueryRelationTraversalClause, QueryRelationTraversalClause, never>, Schema<QueryHierarchyTraversalClause, QueryHierarchyTraversalClause, never>, Schema<QueryUnionClause, QueryUnionClause, never>, Schema<QuerySetDifferenceClause, QuerySetDifferenceClause, never>, Schema<QueryOrderClause, QueryOrderClause, never>, Schema<QueryOptionsClause, QueryOptionsClause, never>, Schema<QueryLimitClause, QueryLimitClause, never>, Schema<QuerySkipClause, QuerySkipClause, never>, Schema<QueryAggregateClause, QueryAggregateClause, never>, Schema<QueryFromClause, QueryFromClause, never>]>;
8518
8682
  type Query$1 = Schema.Type<typeof Query_>;
8519
8683
  declare const Query$1: Schema<Query$1>;
8520
8684
  declare const QueryOptions: Struct<{
@@ -8541,180 +8705,39 @@ declare const Scope: Union<[TaggedStruct<"space", {
8541
8705
  location: Literal<["local", "remote"]>;
8542
8706
  }>]>;
8543
8707
  type Scope = Schema.Type<typeof Scope>;
8544
- //#endregion
8545
- //#region ../../../../node_modules/.pnpm/@effect-atom+atom@0.5.3_patch_hash=90a97dcb5aa93197ad34b41c932b405a7ba98679af6885de637f_8e9863696f10bf243333e2648ae3a1f9/node_modules/@effect-atom/atom/dist/dts/Result.d.ts
8546
- type TypeId$4 = "~effect-atom/atom/Result";
8547
- declare const TypeId$4: TypeId$4;
8548
- /**
8549
- * @since 1.0.0
8550
- * @category models
8551
- */
8552
- type Result<A$1, E$1 = never> = Initial<A$1, E$1> | Success$1<A$1, E$1> | Failure$1<A$1, E$1>;
8553
- /**
8554
- * @since 1.0.0
8555
- * @category models
8556
- */
8557
- declare namespace Result {
8558
- /**
8559
- * @since 1.0.0
8560
- * @category models
8561
- */
8562
- interface Proto<A$1, E$1> extends Pipeable {
8563
- readonly [TypeId$4]: {
8564
- readonly E: (_: never) => E$1;
8565
- readonly A: (_: never) => A$1;
8566
- };
8567
- readonly waiting: boolean;
8568
- }
8569
- /**
8570
- * @since 1.0.0
8571
- */
8572
- type Success<R$1> = R$1 extends Result<infer A, infer _> ? A : never;
8573
- /**
8574
- * @since 1.0.0
8575
- */
8576
- type Failure<R$1> = R$1 extends Result<infer _, infer E> ? E : never;
8577
- }
8578
- /**
8579
- * @since 1.0.0
8580
- * @category models
8581
- */
8582
- interface Initial<A$1, E$1 = never> extends Result.Proto<A$1, E$1> {
8583
- readonly _tag: "Initial";
8584
- }
8585
- /**
8586
- * @since 1.0.0
8587
- * @category models
8588
- */
8589
- interface Success$1<A$1, E$1 = never> extends Result.Proto<A$1, E$1> {
8590
- readonly _tag: "Success";
8591
- readonly value: A$1;
8592
- readonly timestamp: number;
8593
- }
8594
- /**
8595
- * @since 1.0.0
8596
- * @category models
8597
- */
8598
- interface Failure$1<A$1, E$1 = never> extends Result.Proto<A$1, E$1> {
8599
- readonly _tag: "Failure";
8600
- readonly cause: Cause<E$1>;
8601
- readonly previousSuccess: Option<Success$1<A$1, E$1>>;
8602
- }
8603
- //#endregion
8604
- //#region ../../../../node_modules/.pnpm/@effect-atom+atom@0.5.3_patch_hash=90a97dcb5aa93197ad34b41c932b405a7ba98679af6885de637f_8e9863696f10bf243333e2648ae3a1f9/node_modules/@effect-atom/atom/dist/dts/Registry.d.ts
8605
- declare const TypeId$3: TypeId$3;
8606
- type TypeId$3 = "~effect-atom/atom/Registry";
8607
- /**
8608
- * @since 1.0.0
8609
- * @category guards
8610
- */
8611
-
8612
- /**
8613
- * @since 1.0.0
8614
- * @category models
8615
- */
8616
- interface Registry$1 {
8617
- readonly [TypeId$3]: TypeId$3;
8618
- readonly getNodes: () => ReadonlyMap<Atom<any> | string, Node<any>>;
8619
- readonly get: <A$1>(atom: Atom<A$1>) => A$1;
8620
- readonly mount: <A$1>(atom: Atom<A$1>) => () => void;
8621
- readonly refresh: <A$1>(atom: Atom<A$1>) => void;
8622
- readonly set: <R$1, W$1>(atom: Writable<R$1, W$1>, value: W$1) => void;
8623
- readonly setSerializable: (key: string, encoded: unknown) => void;
8624
- readonly modify: <R$1, W$1, A$1>(atom: Writable<R$1, W$1>, f: (_: R$1) => [returnValue: A$1, nextValue: W$1]) => A$1;
8625
- readonly update: <R$1, W$1>(atom: Writable<R$1, W$1>, f: (_: R$1) => W$1) => void;
8626
- readonly subscribe: <A$1>(atom: Atom<A$1>, f: (_: A$1) => void, options?: {
8627
- readonly immediate?: boolean;
8628
- }) => () => void;
8629
- readonly reset: () => void;
8630
- readonly dispose: () => void;
8708
+ declare namespace Order_d_exports {
8709
+ export { Any$4 as Any, Order, OrderTypeId, created$1 as created, natural, property, rank, updated$1 as updated };
8631
8710
  }
8632
- /**
8633
- * @since 1.0.0
8634
- * @category models
8635
- */
8636
- interface Node<A$1> {
8637
- readonly atom: Atom<A$1>;
8638
- readonly value: () => A$1;
8711
+ declare const OrderTypeId: '~@dxos/echo/Order';
8712
+ type OrderTypeId = typeof OrderTypeId;
8713
+ interface Order<T$1> {
8714
+ readonly [OrderTypeId]: {
8715
+ value: T$1;
8716
+ };
8717
+ ast: Order$1;
8639
8718
  }
8719
+ type Any$4 = Order<any>;
8640
8720
  /**
8641
- * @since 1.0.0
8642
- * @category constructors
8643
- */
8644
- //#endregion
8645
- //#region ../../../../node_modules/.pnpm/@effect-atom+atom@0.5.3_patch_hash=90a97dcb5aa93197ad34b41c932b405a7ba98679af6885de637f_8e9863696f10bf243333e2648ae3a1f9/node_modules/@effect-atom/atom/dist/dts/Atom.d.ts
8646
- declare const TypeId$2: TypeId$2;
8647
- type TypeId$2 = "~effect-atom/atom/Atom";
8648
- /**
8649
- * @since 1.0.0
8650
- * @category models
8721
+ * Order by the database's default order. For non-feed sources this is by id; for feed sources
8722
+ * this is insertion order, so `desc` reads newest-first. Defaults to `asc`.
8651
8723
  */
8652
- interface Atom<A$1> extends Pipeable, Inspectable {
8653
- readonly [TypeId$2]: TypeId$2;
8654
- readonly keepAlive: boolean;
8655
- readonly lazy: boolean;
8656
- readonly read: (get: Context$2) => A$1;
8657
- readonly refresh?: (f: <A$1>(atom: Atom<A$1>) => void) => void;
8658
- readonly label?: readonly [name: string, stack: string];
8659
- readonly idleTTL?: number;
8660
- }
8661
- type WritableTypeId = "~effect-atom/atom/Atom/Writable";
8662
- declare const WritableTypeId: WritableTypeId;
8724
+ declare const natural: (direction?: OrderDirection) => Order<any>;
8725
+ declare const property: <T$1>(property: keyof T$1 & string, direction: OrderDirection) => Order<T$1>;
8663
8726
  /**
8664
- * @since 1.0.0
8665
- * @category models
8727
+ * Order by relevance rank (for FTS/vector search results).
8728
+ * Higher rank = better match. Default direction is 'desc' (best matches first).
8666
8729
  */
8667
- interface Writable<R$1, W$1 = R$1> extends Atom<R$1> {
8668
- readonly [WritableTypeId]: WritableTypeId;
8669
- readonly write: (ctx: WriteContext<R$1>, value: W$1) => void;
8670
- }
8730
+ declare const rank: <T$1>(direction?: OrderDirection) => Order<T$1>;
8671
8731
  /**
8672
- * @since 1.0.0
8673
- * @category context
8732
+ * Order by the system `updatedAt` timestamp (last re-indexed). Default direction is 'desc'
8733
+ * (most-recently-updated first). Mirrors {@link Filter.updated}.
8674
8734
  */
8675
- interface Context$2 {
8676
- <A$1>(atom: Atom<A$1>): A$1;
8677
- get<A$1>(this: Context$2, atom: Atom<A$1>): A$1;
8678
- result<A$1, E$1>(this: Context$2, atom: Atom<Result<A$1, E$1>>, options?: {
8679
- readonly suspendOnWaiting?: boolean | undefined;
8680
- }): Effect$1<A$1, E$1>;
8681
- resultOnce<A$1, E$1>(this: Context$2, atom: Atom<Result<A$1, E$1>>, options?: {
8682
- readonly suspendOnWaiting?: boolean | undefined;
8683
- }): Effect$1<A$1, E$1>;
8684
- once<A$1>(this: Context$2, atom: Atom<A$1>): A$1;
8685
- addFinalizer(this: Context$2, f: () => void): void;
8686
- mount<A$1>(this: Context$2, atom: Atom<A$1>): void;
8687
- refresh<A$1>(this: Context$2, atom: Atom<A$1>): void;
8688
- refreshSelf(this: Context$2): void;
8689
- self<A$1>(this: Context$2): Option<A$1>;
8690
- setSelf<A$1>(this: Context$2, a: A$1): void;
8691
- set<R$1, W$1>(this: Context$2, atom: Writable<R$1, W$1>, value: W$1): void;
8692
- setResult<A$1, E$1, W$1>(this: Context$2, atom: Writable<Result<A$1, E$1>, W$1>, value: W$1): Effect$1<A$1, E$1>;
8693
- some<A$1>(this: Context$2, atom: Atom<Option<A$1>>): Effect$1<A$1>;
8694
- someOnce<A$1>(this: Context$2, atom: Atom<Option<A$1>>): Effect$1<A$1>;
8695
- stream<A$1>(this: Context$2, atom: Atom<A$1>, options?: {
8696
- readonly withoutInitialValue?: boolean;
8697
- readonly bufferSize?: number;
8698
- }): Stream<A$1>;
8699
- streamResult<A$1, E$1>(this: Context$2, atom: Atom<Result<A$1, E$1>>, options?: {
8700
- readonly withoutInitialValue?: boolean;
8701
- readonly bufferSize?: number;
8702
- }): Stream<A$1, E$1>;
8703
- subscribe<A$1>(this: Context$2, atom: Atom<A$1>, f: (_: A$1) => void, options?: {
8704
- readonly immediate?: boolean;
8705
- }): void;
8706
- readonly registry: Registry$1;
8707
- }
8735
+ declare const updated$1: <T$1>(direction?: OrderDirection) => Order<T$1>;
8708
8736
  /**
8709
- * @since 1.0.0
8710
- * @category context
8737
+ * Order by the system `createdAt` timestamp (first indexed). Default direction is 'desc'
8738
+ * (most-recently-created first). Mirrors {@link Filter.created}.
8711
8739
  */
8712
- interface WriteContext<A$1> {
8713
- get<T$1>(this: WriteContext<A$1>, atom: Atom<T$1>): T$1;
8714
- refreshSelf(this: WriteContext<A$1>): void;
8715
- setSelf(this: WriteContext<A$1>, a: A$1): void;
8716
- set<R$1, W$1>(this: WriteContext<A$1>, atom: Writable<R$1, W$1>, value: W$1): void;
8717
- }
8740
+ declare const created$1: <T$1>(direction?: OrderDirection) => Order<T$1>;
8718
8741
  //#endregion
8719
8742
  //#region ../../../common/util/dist/types/src/types.d.ts
8720
8743
  type MaybePromise<T$1> = T$1 | Promise<T$1>;
@@ -8729,20 +8752,20 @@ type ToMutable<T$1> = T$1 extends object ? { -readonly [K in keyof T$1]: T$1[K]
8729
8752
  type CleanupFn = () => void;
8730
8753
  //#endregion
8731
8754
  //#region ../../../common/context/dist/types/src/context.d.ts
8732
- type ContextErrorHandler = (error: Error, ctx: Context$1) => void;
8755
+ type ContextErrorHandler = (error: Error, ctx: Context$2) => void;
8733
8756
  type DisposeCallback = () => any | Promise<any>;
8734
8757
  type CreateContextProps = {
8735
8758
  name?: string;
8736
- parent?: Context$1;
8759
+ parent?: Context$2;
8737
8760
  attributes?: Record<string, any>;
8738
8761
  onError?: ContextErrorHandler;
8739
8762
  };
8740
8763
  /**
8741
8764
  * NOTE: Context is not reusable after it is disposed.
8742
8765
  */
8743
- declare class Context$1 {
8766
+ declare class Context$2 {
8744
8767
  #private;
8745
- static default(): Context$1;
8768
+ static default(): Context$2;
8746
8769
  maxSafeDisposeCallbacks: number;
8747
8770
  constructor(params?: CreateContextProps, callMeta?: Partial<CallMetadata>);
8748
8771
  get disposed(): boolean;
@@ -8776,7 +8799,7 @@ declare class Context$1 {
8776
8799
  derive({
8777
8800
  onError,
8778
8801
  attributes
8779
- }?: CreateContextProps): Context$1;
8802
+ }?: CreateContextProps): Context$2;
8780
8803
  getAttribute(key: string): any;
8781
8804
  [Symbol.toStringTag]: string;
8782
8805
  [inspect.custom]: () => string;
@@ -8859,7 +8882,7 @@ declare class Event$1<T$1 = void> implements ReadOnlyEvent<T$1> {
8859
8882
  * @returns function that unsubscribes this event listener
8860
8883
  */
8861
8884
  on(callback: EventCallback<T$1>): CleanupFn;
8862
- on(ctx: Context$1, callback: EventCallback<T$1>, options?: ListenerOptions): CleanupFn;
8885
+ on(ctx: Context$2, callback: EventCallback<T$1>, options?: ListenerOptions): CleanupFn;
8863
8886
  /**
8864
8887
  * Unsubscribe this callback from new events. Includes persistent and once-listeners.
8865
8888
  * NOTE: It is recommended to use `Event.on`'s return value instead.
@@ -8875,7 +8898,7 @@ declare class Event$1<T$1 = void> implements ReadOnlyEvent<T$1> {
8875
8898
  * @param callback
8876
8899
  */
8877
8900
  once(callback: (data: T$1) => void): CleanupFn;
8878
- once(ctx: Context$1, callback: (data: T$1) => void): CleanupFn;
8901
+ once(ctx: Context$2, callback: (data: T$1) => void): CleanupFn;
8879
8902
  /**
8880
8903
  * An async iterator that iterates over events.
8881
8904
  * This iterator runs indefinitely.
@@ -8959,7 +8982,7 @@ interface ReadOnlyEvent<T$1 = void> {
8959
8982
  * @returns function that unsubscribes this event listener
8960
8983
  */
8961
8984
  on(callback: (data: T$1) => void): CleanupFn;
8962
- on(ctx: Context$1, callback: (data: T$1) => void, options?: ListenerOptions): CleanupFn;
8985
+ on(ctx: Context$2, callback: (data: T$1) => void, options?: ListenerOptions): CleanupFn;
8963
8986
  /**
8964
8987
  * Unsubscribes this callback from new events. Includes persistent and once-listeners.
8965
8988
  * NOTE: It is recommended to us `Event.on`'s return value.
@@ -9005,1895 +9028,2423 @@ interface ReadOnlyEvent<T$1 = void> {
9005
9028
  debounce(timeout?: number): Event$1<void>;
9006
9029
  }
9007
9030
  //#endregion
9008
- //#region ../echo/dist/types/src/internal/common/types/entity.d.ts
9031
+ //#region ../../../../node_modules/.pnpm/@effect-atom+atom@0.5.3_patch_hash=90a97dcb5aa93197ad34b41c932b405a7ba98679af6885de637f_8e9863696f10bf243333e2648ae3a1f9/node_modules/@effect-atom/atom/dist/dts/Result.d.ts
9032
+ type TypeId$4 = "~effect-atom/atom/Result";
9033
+ declare const TypeId$4: TypeId$4;
9009
9034
  /**
9010
- * String key used to identify the kind of an entity instance (object or relation).
9035
+ * @since 1.0.0
9036
+ * @category models
9011
9037
  */
9012
- declare const KindId$1: '~@dxos/echo/Kind';
9013
- type KindId$1 = typeof KindId$1;
9038
+ type Result<A$1, E$1 = never> = Initial<A$1, E$1> | Success$1<A$1, E$1> | Failure$1<A$1, E$1>;
9014
9039
  /**
9015
- * String key used to identify the kind of a schema (object schema or relation schema).
9016
- * Parallels KindId which identifies instance kinds.
9040
+ * @since 1.0.0
9041
+ * @category models
9017
9042
  */
9018
- declare const SchemaKindId: '~@dxos/echo/SchemaKind';
9019
- type SchemaKindId = typeof SchemaKindId;
9043
+ declare namespace Result {
9044
+ /**
9045
+ * @since 1.0.0
9046
+ * @category models
9047
+ */
9048
+ interface Proto<A$1, E$1> extends Pipeable {
9049
+ readonly [TypeId$4]: {
9050
+ readonly E: (_: never) => E$1;
9051
+ readonly A: (_: never) => A$1;
9052
+ };
9053
+ readonly waiting: boolean;
9054
+ }
9055
+ /**
9056
+ * @since 1.0.0
9057
+ */
9058
+ type Success<R$1> = R$1 extends Result<infer A, infer _> ? A : never;
9059
+ /**
9060
+ * @since 1.0.0
9061
+ */
9062
+ type Failure<R$1> = R$1 extends Result<infer _, infer E> ? E : never;
9063
+ }
9020
9064
  /**
9021
- * Hidden slot on a static `Type.Type` entity that holds the source Effect
9022
- * Schema. `Type.getSchema(...)` reads this for static types; persisted types
9023
- * rebuild from `jsonSchema` instead. Stored as a string key for declaration
9024
- * portability (see KindId comment above).
9065
+ * @since 1.0.0
9066
+ * @category models
9025
9067
  */
9026
- declare const StaticTypeSchemaSlot: '~@dxos/echo/Type.StaticSchema';
9027
- type StaticTypeSchemaSlot = typeof StaticTypeSchemaSlot;
9068
+ interface Initial<A$1, E$1 = never> extends Result.Proto<A$1, E$1> {
9069
+ readonly _tag: "Initial";
9070
+ }
9028
9071
  /**
9029
- * Phantom string key on `Type<A>` entities that carries the instance type `A`.
9030
- * Lets internal helpers (`makeObject`, `createObject`, etc.) pattern-match the
9031
- * instance type from an entity input without importing from the top-level
9032
- * `Type` module. Mirrors `Type.InstancePhantomId` (declared in `Type.ts`).
9033
- *
9034
- * Stored as a string key so declarations remain portable across packages
9035
- * (see KindId comment above).
9072
+ * @since 1.0.0
9073
+ * @category models
9036
9074
  */
9037
- declare const InstancePhantomId$1: '~@dxos/echo/Type.Instance';
9038
- type InstancePhantomId$1 = typeof InstancePhantomId$1;
9039
- /**
9040
- * Nominal brand carried by the well-known "any object" / "any relation"
9041
- * schemas (`Obj.Unknown`, `Relation.Unknown`). The brand lets `Ref.Ref`,
9042
- * `Filter.type`, and `Query.type` accept these schemas in addition to
9043
- * `Type.Type` entities, without opening the door to arbitrary raw schemas.
9044
- *
9045
- * Stored as a string key so declarations remain portable across packages
9046
- * (see KindId comment above).
9047
- */
9048
- declare const UnknownTypeSchemaBrandId: '~@dxos/echo/UnknownTypeSchemaBrand';
9049
- type UnknownTypeSchemaBrandId = typeof UnknownTypeSchemaBrandId;
9050
- /**
9051
- * Schema-side companion to `Type.Type` entities for the "any object" /
9052
- * "any relation" cases. Branded so `Ref.Ref` / `Filter.type` / `Query.type`
9053
- * can pattern-match on it; arbitrary `Schema.Schema` values do not satisfy
9054
- * this shape.
9055
- */
9056
- interface UnknownTypeSchema<A$1, K$1 extends EntityKind> extends Schema<A$1, any, never> {
9057
- readonly [UnknownTypeSchemaBrandId]: K$1;
9075
+ interface Success$1<A$1, E$1 = never> extends Result.Proto<A$1, E$1> {
9076
+ readonly _tag: "Success";
9077
+ readonly value: A$1;
9078
+ readonly timestamp: number;
9058
9079
  }
9059
9080
  /**
9060
- * Kinds of entities stored in ECHO: objects, relations, and types.
9081
+ * @since 1.0.0
9082
+ * @category models
9061
9083
  */
9062
- declare enum EntityKind {
9063
- Object = "object",
9064
- Relation = "relation",
9065
- Type = "type",
9084
+ interface Failure$1<A$1, E$1 = never> extends Result.Proto<A$1, E$1> {
9085
+ readonly _tag: "Failure";
9086
+ readonly cause: Cause<E$1>;
9087
+ readonly previousSuccess: Option<Success$1<A$1, E$1>>;
9066
9088
  }
9067
9089
  //#endregion
9068
- //#region ../echo/dist/types/src/Relation.d.ts
9069
- type Endpoints$1<Source$1, Target$2> = {
9070
- [Source$1]: Source$1;
9071
- [Target$2]: Target$2;
9072
- };
9073
- /**
9074
- * Base type for all ECHO relations.
9075
- * @private
9076
- */
9077
- interface BaseRelation<Source$1, Target$2> extends AnyEntity, Endpoints$1<Source$1, Target$2>, OfKind<EntityKind.Relation> {}
9090
+ //#region ../../../../node_modules/.pnpm/@effect-atom+atom@0.5.3_patch_hash=90a97dcb5aa93197ad34b41c932b405a7ba98679af6885de637f_8e9863696f10bf243333e2648ae3a1f9/node_modules/@effect-atom/atom/dist/dts/Registry.d.ts
9091
+ declare const TypeId$3: TypeId$3;
9092
+ type TypeId$3 = "~effect-atom/atom/Registry";
9078
9093
  /**
9079
- * Relation with no known properties beyond id, kind, source, and target.
9080
- * Use this when the relation's schema/properties are not known.
9081
- *
9082
- * NOTE: This is a TypeScript type only, not a schema.
9083
- * To validate that a value is an ECHO relation, use `Relation.isRelation`.
9094
+ * @since 1.0.0
9095
+ * @category guards
9084
9096
  */
9085
- interface Unknown$3 extends BaseRelation<Unknown$1, Unknown$1> {}
9097
+
9086
9098
  /**
9087
- * Runtime Effect schema for any ECHO relation.
9088
- * Use for validation, parsing, or as a reference target for collections.
9089
- * A relation has `id`, source, and target fields plus any additional properties.
9090
- *
9091
- * NOTE: `Schema.is(Type.Relation)` does STRUCTURAL validation only (checks for `id` field).
9092
- * Use `Relation.isRelation()` for proper ECHO instance type guards that check the KindId brand.
9093
- *
9094
- * @example
9095
- * ```ts
9096
- * // Structural type guard (accepts any object with id field)
9097
- * if (Schema.is(Type.Relation)(unknownValue)) { ... }
9098
- *
9099
- * // ECHO instance type guard (checks KindId brand)
9100
- * if (Relation.isRelation(unknownValue)) { ... }
9101
- * ```
9099
+ * @since 1.0.0
9100
+ * @category models
9102
9101
  */
9103
- declare const Unknown$3: UnknownTypeSchema<Unknown$3, typeof Kind.Relation>;
9102
+ interface Registry$1 {
9103
+ readonly [TypeId$3]: TypeId$3;
9104
+ readonly getNodes: () => ReadonlyMap<Atom<any> | string, Node<any>>;
9105
+ readonly get: <A$1>(atom: Atom<A$1>) => A$1;
9106
+ readonly mount: <A$1>(atom: Atom<A$1>) => () => void;
9107
+ readonly refresh: <A$1>(atom: Atom<A$1>) => void;
9108
+ readonly set: <R$1, W$1>(atom: Writable<R$1, W$1>, value: W$1) => void;
9109
+ readonly setSerializable: (key: string, encoded: unknown) => void;
9110
+ readonly modify: <R$1, W$1, A$1>(atom: Writable<R$1, W$1>, f: (_: R$1) => [returnValue: A$1, nextValue: W$1]) => A$1;
9111
+ readonly update: <R$1, W$1>(atom: Writable<R$1, W$1>, f: (_: R$1) => W$1) => void;
9112
+ readonly subscribe: <A$1>(atom: Atom<A$1>, f: (_: A$1) => void, options?: {
9113
+ readonly immediate?: boolean;
9114
+ }) => () => void;
9115
+ readonly reset: () => void;
9116
+ readonly dispose: () => void;
9117
+ }
9104
9118
  /**
9105
- * Get relation source type.
9119
+ * @since 1.0.0
9120
+ * @category models
9106
9121
  */
9107
- type SourceOf<A$1> = A$1 extends Endpoints$1<infer S, infer _T> ? S : never;
9122
+ interface Node<A$1> {
9123
+ readonly atom: Atom<A$1>;
9124
+ readonly value: () => A$1;
9125
+ }
9108
9126
  /**
9109
- * Get relation target type.
9127
+ * @since 1.0.0
9128
+ * @category constructors
9110
9129
  */
9111
- type TargetOf<A$1> = A$1 extends Endpoints$1<infer _S, infer T> ? T : never;
9112
9130
  //#endregion
9113
- //#region ../echo/dist/types/src/Ref.d.ts
9131
+ //#region ../../../../node_modules/.pnpm/@effect-atom+atom@0.5.3_patch_hash=90a97dcb5aa93197ad34b41c932b405a7ba98679af6885de637f_8e9863696f10bf243333e2648ae3a1f9/node_modules/@effect-atom/atom/dist/dts/Atom.d.ts
9132
+ declare const TypeId$2: TypeId$2;
9133
+ type TypeId$2 = "~effect-atom/atom/Atom";
9114
9134
  /**
9115
- * Instance type for a reference.
9116
- *
9117
- * Reference can point to any object or relation.
9118
- * References are lazy loaded.
9119
- *
9120
- * `ref.dxn` is the DXN of the referenced object.
9121
- *
9122
- * @example
9123
- * ```ts
9124
- * const taskRef: Ref<Task> = Ref.make(task);
9125
- *
9126
- * await taskRef.load(); // Returns Promise<Task>
9127
- * yield* Database.load(taskRef); // Effectful version.
9128
- *
9129
- * database.makeRef(dxn); // Create a ref from a DXN.
9130
- * ```
9135
+ * @since 1.0.0
9136
+ * @category models
9131
9137
  */
9132
- type Ref$1<T$1> = Ref<T$1>;
9133
- type Unknown$2 = Ref<Unknown$1>;
9138
+ interface Atom<A$1> extends Pipeable, Inspectable {
9139
+ readonly [TypeId$2]: TypeId$2;
9140
+ readonly keepAlive: boolean;
9141
+ readonly lazy: boolean;
9142
+ readonly read: (get: Context$1) => A$1;
9143
+ readonly refresh?: (f: <A$1>(atom: Atom<A$1>) => void) => void;
9144
+ readonly label?: readonly [name: string, stack: string];
9145
+ readonly idleTTL?: number;
9146
+ }
9147
+ type WritableTypeId = "~effect-atom/atom/Atom/Writable";
9148
+ declare const WritableTypeId: WritableTypeId;
9134
9149
  /**
9135
- * Factory function to create a Ref schema for the given target schema.
9136
- * Use this in schema definitions to declare reference fields.
9137
- *
9138
- * @example
9139
- * ```ts
9140
- * class Task extends Type.makeObject<Task>(DXN.make('com.example.type.task', '0.1.0'))(
9141
- * Schema.Struct({
9142
- * assignee: Ref.Ref(Person), // Creates a Ref schema
9143
- * }),
9144
- * ) {}
9145
- * ```
9150
+ * @since 1.0.0
9151
+ * @category models
9146
9152
  */
9147
- declare const Ref$1: {
9148
- <S$1 extends AnyObj>(type: S$1): RefSchema$1<InstanceType$1<S$1> & Unknown$1>;
9149
- <S$1 extends AnyRelation>(type: S$1): RefSchema$1<InstanceType$1<S$1> & Unknown$3>;
9150
- <T$1 extends Type$1<any>>(type: T$1): RefSchema$1<InstanceType$1<T$1>>;
9151
- <S$1 extends UnknownTypeSchema<any, any>>(schema: S$1): RefSchema$1<Schema.Type<S$1> & Unknown$1>;
9152
- };
9153
+ interface Writable<R$1, W$1 = R$1> extends Atom<R$1> {
9154
+ readonly [WritableTypeId]: WritableTypeId;
9155
+ readonly write: (ctx: WriteContext<R$1>, value: W$1) => void;
9156
+ }
9153
9157
  /**
9154
- * TypeScript type for a Ref schema.
9155
- * This is the type of the SCHEMA itself, not the runtime ref instance.
9156
- * For the instance type, use `Ref.Ref<T>` from the Ref module.
9157
- *
9158
- * @example
9159
- * ```ts
9160
- * // Schema type annotation (rarely needed, usually inferred):
9161
- * const refSchema: Ref.RefSchema<typeof Task> = Ref.Ref(Task);
9162
- *
9163
- * // Instance type annotation (use Ref.Ref instead):
9164
- * const refInstance: Ref.Ref<Task> = Ref.make(task);
9165
- * ```
9158
+ * @since 1.0.0
9159
+ * @category context
9166
9160
  */
9167
- interface RefSchema$1<T$1 extends Unknown> extends RefSchema<T$1> {}
9161
+ interface Context$1 {
9162
+ <A$1>(atom: Atom<A$1>): A$1;
9163
+ get<A$1>(this: Context$1, atom: Atom<A$1>): A$1;
9164
+ result<A$1, E$1>(this: Context$1, atom: Atom<Result<A$1, E$1>>, options?: {
9165
+ readonly suspendOnWaiting?: boolean | undefined;
9166
+ }): Effect$1<A$1, E$1>;
9167
+ resultOnce<A$1, E$1>(this: Context$1, atom: Atom<Result<A$1, E$1>>, options?: {
9168
+ readonly suspendOnWaiting?: boolean | undefined;
9169
+ }): Effect$1<A$1, E$1>;
9170
+ once<A$1>(this: Context$1, atom: Atom<A$1>): A$1;
9171
+ addFinalizer(this: Context$1, f: () => void): void;
9172
+ mount<A$1>(this: Context$1, atom: Atom<A$1>): void;
9173
+ refresh<A$1>(this: Context$1, atom: Atom<A$1>): void;
9174
+ refreshSelf(this: Context$1): void;
9175
+ self<A$1>(this: Context$1): Option<A$1>;
9176
+ setSelf<A$1>(this: Context$1, a: A$1): void;
9177
+ set<R$1, W$1>(this: Context$1, atom: Writable<R$1, W$1>, value: W$1): void;
9178
+ setResult<A$1, E$1, W$1>(this: Context$1, atom: Writable<Result<A$1, E$1>, W$1>, value: W$1): Effect$1<A$1, E$1>;
9179
+ some<A$1>(this: Context$1, atom: Atom<Option<A$1>>): Effect$1<A$1>;
9180
+ someOnce<A$1>(this: Context$1, atom: Atom<Option<A$1>>): Effect$1<A$1>;
9181
+ stream<A$1>(this: Context$1, atom: Atom<A$1>, options?: {
9182
+ readonly withoutInitialValue?: boolean;
9183
+ readonly bufferSize?: number;
9184
+ }): Stream<A$1>;
9185
+ streamResult<A$1, E$1>(this: Context$1, atom: Atom<Result<A$1, E$1>>, options?: {
9186
+ readonly withoutInitialValue?: boolean;
9187
+ readonly bufferSize?: number;
9188
+ }): Stream<A$1, E$1>;
9189
+ subscribe<A$1>(this: Context$1, atom: Atom<A$1>, f: (_: A$1) => void, options?: {
9190
+ readonly immediate?: boolean;
9191
+ }): void;
9192
+ readonly registry: Registry$1;
9193
+ }
9168
9194
  /**
9169
- * Extract reference target.
9195
+ * @since 1.0.0
9196
+ * @category context
9170
9197
  */
9171
- type Target$1<R$1 extends Unknown$2> = R$1 extends Ref<infer T> ? T : never;
9198
+ interface WriteContext<A$1> {
9199
+ get<T$1>(this: WriteContext<A$1>, atom: Atom<T$1>): T$1;
9200
+ refreshSelf(this: WriteContext<A$1>): void;
9201
+ setSelf(this: WriteContext<A$1>, a: A$1): void;
9202
+ set<R$1, W$1>(this: WriteContext<A$1>, atom: Writable<R$1, W$1>, value: W$1): void;
9203
+ }
9204
+ //#endregion
9205
+ //#region ../../../../node_modules/.pnpm/@effect-atom+atom@0.5.3_patch_hash=90a97dcb5aa93197ad34b41c932b405a7ba98679af6885de637f_8e9863696f10bf243333e2648ae3a1f9/node_modules/@effect-atom/atom/dist/dts/AtomHttpApi.d.ts
9206
+ declare global {
9207
+ interface ErrorConstructor {
9208
+ stackTraceLimit: number;
9209
+ }
9210
+ }
9172
9211
  /**
9173
- * Reference resolver.
9212
+ * @since 1.0.0
9213
+ * @category Constructors
9174
9214
  */
9175
- type Resolver = RefResolver;
9176
9215
  //#endregion
9177
- //#region ../echo/dist/types/src/Obj.d.ts
9216
+ //#region ../../../../node_modules/.pnpm/@effect-atom+atom@0.5.3_patch_hash=90a97dcb5aa93197ad34b41c932b405a7ba98679af6885de637f_8e9863696f10bf243333e2648ae3a1f9/node_modules/@effect-atom/atom/dist/dts/AtomRpc.d.ts
9217
+ declare global {
9218
+ interface ErrorConstructor {
9219
+ stackTraceLimit: number;
9220
+ }
9221
+ }
9178
9222
  /**
9179
- * Base type for all ECHO objects.
9223
+ * @since 1.0.0
9224
+ * @category Constructors
9180
9225
  */
9181
- interface BaseObj extends AnyEntity, OfKind<typeof Kind.Object> {}
9226
+ //#endregion
9227
+ //#region ../../../common/effect/dist/types/src/internal/json-path.d.ts
9228
+ type JsonPath = string & {
9229
+ __JsonPath: true;
9230
+ };
9182
9231
  /**
9183
- * Object type with specific properties.
9232
+ * https://www.ietf.org/archive/id/draft-goessner-dispatch-jsonpath-00.html
9184
9233
  */
9185
- type OfShape<Props$2> = BaseObj & Props$2;
9234
+ declare const JsonPath: Schema<JsonPath>;
9235
+ //#endregion
9236
+ //#region ../echo/dist/types/src/internal/Ref/ref.d.ts
9237
+ declare const RefTypeId: unique symbol;
9186
9238
  /**
9187
- * Object with no known properties beyond id and kind.
9188
- * Use this when the object's schema/properties are not known.
9189
- * For objects with arbitrary properties, use `Obj.AnyProps`.
9190
- *
9191
- * NOTE: This is a TypeScript type only, not a schema.
9192
- * To validate that a value is an ECHO object, use `Schema.is(Type.Obj)`.
9239
+ * Reference Schema.
9193
9240
  */
9194
- interface Unknown$1 extends BaseObj {}
9241
+ interface RefSchema$1<T$1 extends AnyEntity> extends SchemaClass<Ref<T$1>, EncodedReference> {}
9195
9242
  /**
9196
- * Runtime Effect schema for any ECHO object.
9197
- * Use for validation, parsing, or as a reference target for collections.
9198
- *
9199
- * NOTE: `Schema.is(Type.Obj)` does STRUCTURAL validation only (checks for `id` field).
9200
- * Use `Obj.isObject()` for proper ECHO instance type guards that check the KindId brand.
9201
- *
9202
- * @example
9203
- * ```ts
9204
- * // Structural type guard (accepts any object with id field)
9205
- * if (Schema.is(Type.Obj)(unknownValue)) { ... }
9206
- *
9207
- * // ECHO instance type guard (checks KindId brand)
9208
- * if (Obj.isObject(unknownValue)) { ... }
9209
- *
9210
- * // Reference to any object type
9211
- * class Collection extends Type.makeObject<Collection>(DXN.make('com.example.type.collection', '0.1.0'))(
9212
- * Schema.Struct({ objects: Schema.Array(Ref.Ref(Obj.Unknown)) }),
9213
- * ) {}
9214
- * ```
9243
+ * Type of the `Ref` function and extra methods attached to it.
9215
9244
  */
9216
- declare const Unknown$1: UnknownTypeSchema<Unknown$1, typeof Kind.Object>;
9217
- declare namespace Filter_d_exports {
9218
- export { Any$3 as Any, ChildOfOptions, Filter, KeyFilterOptions, Props$1 as Props, TextSearchOptions, Type$3 as Type, and, between, childOf, contains, created$1 as created, eq, everything, foreignKeys, fromAst$1 as fromAst, gt, gte, id, in$ as in, is$1 as is, key$1 as key, lt, lte, neq, not, nothing, or, pretty$1 as pretty, props, tag, text, toPredicate, type$2 as type, updated$1 as updated };
9219
- }
9220
- interface Filter<T$1> {
9221
- '~Filter': {
9222
- value: Covariant<T$1>;
9223
- };
9224
- 'ast': Filter$1;
9225
- }
9226
- type Props$1<T$1> = { [K in keyof T$1 & string]?: Filter<T$1[K]> | T$1[K] };
9227
- type Any$3 = Filter<any>;
9228
- type Type$3<F extends Any$3> = F extends Filter<infer T> ? T : never;
9229
- declare class FilterClass implements Any$3 {
9230
- readonly ast: Filter$1;
9231
- private static 'variance';
9232
- constructor(ast: Filter$1);
9233
- '~Filter': {
9234
- value: Covariant<any>;
9235
- };
9245
+ interface RefFn {
9246
+ <S$1 extends AnyEntity$1 | UnknownTypeSchema<any, any> = AnyEntity$1>(schema: S$1): RefSchema$1<S$1 extends AnyType ? AnyEntity$1 : S$1 extends AnyObj | AnyRelation ? InstanceType$1<S$1> : S$1 extends UnknownTypeSchema<infer A, any> ? A : never>;
9247
+ /**
9248
+ * @returns True if the object is a reference.
9249
+ */
9250
+ isRef: (obj: unknown) => obj is Ref<any>;
9251
+ /**
9252
+ * @returns True if the reference points to the given object id.
9253
+ */
9254
+ hasEntityId: (id: EntityId) => (ref: Ref<any>) => boolean;
9255
+ /**
9256
+ * @returns True if the schema is a reference schema.
9257
+ */
9258
+ isRefSchema: (schema: Schema<any, any>) => schema is RefSchema$1<any>;
9259
+ /**
9260
+ * @returns True if the schema AST is a reference schema.
9261
+ */
9262
+ isRefSchemaAST: (ast: AST) => boolean;
9263
+ /**
9264
+ * Constructs a reference that points to the given object.
9265
+ */
9266
+ make: <T$1 extends AnyEntity>(object: T$1) => Ref<T$1>;
9267
+ /**
9268
+ * Constructs a reference that points to the object specified by the provided URI
9269
+ * (either an `echo:` EID for an object reference or a `dxn:` DXN for a type reference).
9270
+ */
9271
+ fromURI: (uri: URI) => Ref<any>;
9236
9272
  }
9237
- declare const is$1: (value: unknown) => value is Any$3;
9238
- /** Construct a filter from an ast. */
9239
- declare const fromAst$1: (ast: Filter$1) => Any$3;
9240
9273
  /**
9241
- * Filter that matches all objects.
9274
+ * Schema builder for references.
9242
9275
  */
9243
- declare const everything: () => FilterClass;
9276
+ declare const Ref: RefFn;
9244
9277
  /**
9245
- * Filter that matches no objects.
9278
+ * Represents materialized reference to a target.
9279
+ * This is the data type for the fields marked as ref.
9246
9280
  */
9247
- declare const nothing: () => FilterClass;
9248
- declare const id: (...ids: EntityId[]) => Any$3;
9281
+ interface Ref<T$1> extends Pipeable {
9282
+ /**
9283
+ * Target URI (either an `echo:` EID for an object reference or a `dxn:` DXN for a type reference).
9284
+ */
9285
+ get uri(): URI;
9286
+ /**
9287
+ * Returns true if the reference has a target available (inlined or resolver set).
9288
+ */
9289
+ get isAvailable(): boolean;
9290
+ /**
9291
+ * @returns The reference target.
9292
+ * May return `undefined` if the object is not loaded in the working set.
9293
+ * Accessing this property, even if it returns `undefined` will trigger the object to be loaded to the working set.
9294
+ */
9295
+ get target(): T$1 | undefined;
9296
+ /**
9297
+ * @returns Promise that will resolves with the target object.
9298
+ * Will load the object from disk if it is not present in the working set.
9299
+ * Short-circuits immediately when the target is already loaded.
9300
+ * @throws If the object is not available locally.
9301
+ *
9302
+ * @idiom org.dxos.echo.refLoad
9303
+ * applies: Resolving a ref inside an async function or Effect handler — guarantees the object is available before proceeding
9304
+ * instead-of: `ref.target` — not guaranteed to be defined in async contexts; use `await ref.load()` (or `yield* Database.load(ref)` in Effect) to ensure the target is present
9305
+ * uses: {@link load}
9306
+ * related: org.dxos.echo-react.useObjectReactive
9307
+ */
9308
+ load(): Promise<T$1>;
9309
+ /**
9310
+ * @returns Promise that will resolves with the target object or undefined if the object is not loaded locally.
9311
+ */
9312
+ tryLoad(): Promise<T$1 | undefined>;
9313
+ /**
9314
+ * Subscribe to the ref's resolution event.
9315
+ * The callback fires when the target object becomes available in the working set
9316
+ * (e.g. when its document is loaded after sibling-client mutation).
9317
+ * Note: the resolver only schedules a notification when the target is requested
9318
+ * via {@link target} while it is not yet loaded.
9319
+ * @returns Function that unsubscribes the callback.
9320
+ */
9321
+ onResolved(callback: () => void): () => void;
9322
+ /**
9323
+ * Do not inline the target object in the reference.
9324
+ * Makes .target unavailable unless the reference is connected to a database context.
9325
+ *
9326
+ * When serialized with toJSON, the difference is between:
9327
+ * `{ "/": "dxn:..." }`
9328
+ * and
9329
+ * `{ "/": "dxn:...", "target": { ... } }`
9330
+ *
9331
+ * Clones the reference object.
9332
+ */
9333
+ noInline(): Ref<T$1>;
9334
+ /**
9335
+ * Read-only atom for the ref target.
9336
+ * Resolves once when the target loads; does NOT subscribe to target object mutations.
9337
+ * Use `Obj.atom(ref)` if you need reactive snapshots that update on every object mutation.
9338
+ */
9339
+ get atom(): Atom<T$1 | undefined>;
9340
+ /**
9341
+ * Serializes the reference to a JSON object.
9342
+ * The serialization format is compatible with the IPLD-style encoded references.
9343
+ * When a reference has a saved target (i.e. the target or object holding the reference is not in the database),
9344
+ * the target is included in the serialized object.
9345
+ *
9346
+ * Examples:
9347
+ * `{ "/": "dxn:..." }`
9348
+ * `{ "/": "dxn:...", "target": { ... } }`
9349
+ */
9350
+ encode(): EncodedReference;
9351
+ [RefTypeId]: {
9352
+ _T: T$1;
9353
+ };
9354
+ }
9355
+ declare namespace Ref {
9356
+ /**
9357
+ * Target of the reference.
9358
+ */
9359
+ type Target<R$1> = R$1 extends Ref<infer U> ? U : never;
9360
+ }
9249
9361
  /**
9250
- * Filter by type.
9362
+ * Load-source ceiling for a resolution request. Cheaper tiers are always probed first; the
9363
+ * ceiling caps how far a request is allowed to reach:
9364
+ * - `working-set`: synchronous, in-memory only. A miss settles `unavailable` immediately.
9365
+ * - `disk`: probe the working set, then local storage; never the network.
9366
+ * - `network`: probe the working set, disk, then fetch from peers.
9251
9367
  *
9252
- * Accepts a `Type.Type` entity (the value produced by `Type.makeObject` /
9253
- * `Type.makeRelation`), a `Schema.Union` of such entities (for filtering across a
9254
- * union of ECHO types), or a fully-qualified type URI — an `echo:` EID (stored schema)
9255
- * or a `dxn:` DXN (static schema). To filter by a bare typename, wrap it: `DXN.make(typename)`.
9368
+ * `unavailable` is always relative to the requested ceiling (disk-unavailable ≠ network-unavailable).
9256
9369
  */
9257
- declare const type$2: {
9258
- <T$1 extends AnyEntity$1>(type: T$1, props?: Props$1<InstanceType$1<T$1>>): Filter<InstanceType$1<T$1>>;
9259
- <S$1 extends UnknownTypeSchema<any, any>>(schema: S$1, props?: Props$1<Schema.Type<S$1>>): Filter<Schema.Type<S$1>>;
9260
- <S$1 extends Union<readonly Schema.AnyNoContext[]>>(union: S$1, props?: Props$1<Schema.Type<S$1>>): Filter<Schema.Type<S$1>>;
9261
- (uri: URI, props?: Props$1<unknown>): Filter<any>;
9262
- (input: AnyEntity$1 | URI, props?: Props$1<unknown>): Filter<unknown>;
9263
- };
9370
+ type RefSource = 'working-set' | 'disk' | 'network';
9264
9371
  /**
9265
- * Filter by tag.
9372
+ * A stateful, closure-aware handle to an in-flight (or settled) reference resolution.
9373
+ *
9374
+ * `ready` means the entity is FULLY USABLE: its own body and its strong-dependency closure are all
9375
+ * materialized. The body-vs-closure split is internal; `requesting` transparently covers "a
9376
+ * dependency is still loading".
9266
9377
  */
9267
- declare const tag: (tag: string) => Any$3;
9378
+ interface RefResolverRequest {
9379
+ /**
9380
+ * `pending` is a one-way entry state (never re-entered). `requesting` means the body and/or
9381
+ * closure is still loading. `ready` means fully usable. `unavailable` means unreachable at the
9382
+ * requested ceiling.
9383
+ */
9384
+ readonly state: 'pending' | 'requesting' | 'ready' | 'unavailable';
9385
+ /**
9386
+ * Fires (deferred to a microtask) whenever {@link state} changes.
9387
+ */
9388
+ readonly stateChanged: Event$1<void>;
9389
+ /**
9390
+ * Synchronous snapshot of the resolved entity; defined iff `state === 'ready'`.
9391
+ */
9392
+ getResult(): AnyProperties | undefined;
9393
+ /**
9394
+ * Settles when `state ∈ {ready, unavailable}`.
9395
+ */
9396
+ wait(): Promise<AnyProperties | undefined>;
9397
+ /**
9398
+ * Decrements the refcount on the shared load op(s); cancels the underlying IO at zero.
9399
+ */
9400
+ abort(): void;
9401
+ }
9402
+ interface RefResolver {
9403
+ /**
9404
+ * Resolve a reference, returning a stateful handle. `source` is a required ceiling; cheaper
9405
+ * tiers are always probed first.
9406
+ */
9407
+ resolve(uri: URI, options: {
9408
+ source: RefSource;
9409
+ }): RefResolverRequest;
9410
+ /**
9411
+ * Resolve ref synchronously from the objects in the working set.
9412
+ *
9413
+ * @param uri
9414
+ * @param load If true the resolver should attempt to load the object from disk.
9415
+ * @param onLoad Callback to call when the object is loaded.
9416
+ * @deprecated Use {@link resolve} with `{ source: 'working-set' }`. Removed in Task 11.
9417
+ */
9418
+ resolveSync(uri: URI, load: boolean, onLoad?: () => void): AnyProperties | undefined;
9419
+ /**
9420
+ * Resolver ref asynchronously.
9421
+ * @deprecated Use {@link resolve} with `{ source: 'network' }`. Removed in Task 11.
9422
+ */
9423
+ resolveLegacy(uri: URI): Promise<AnyProperties | undefined>;
9424
+ /**
9425
+ * @deprecated Use {@link resolve} + `Type.getSchema`. Removed in Task 11.
9426
+ */
9427
+ resolveSchema(uri: URI): Promise<Schema.AnyNoContext | undefined>;
9428
+ /**
9429
+ * Resolve the source `Type.AnyEntity` entity for a type URI. Used by
9430
+ * deserialization paths (`Obj.fromJSON`) to set the back-reference accessed
9431
+ * via `Obj.getType` / `Entity.getType`. Optional — resolvers that only
9432
+ * carry raw schemas may leave this unimplemented; the deserializer falls
9433
+ * back to leaving the type entity unset.
9434
+ * @deprecated Use {@link resolve}. Removed in Task 11.
9435
+ */
9436
+ resolveType?(uri: URI): Promise<unknown | undefined>;
9437
+ }
9438
+ //#endregion
9439
+ //#region ../echo/dist/types/src/internal/JsonSchema/json-schema-type.d.ts
9268
9440
  /**
9269
- * Options for {@link key} filter.
9441
+ * Describes a schema for the JSON-schema objects stored in ECHO.
9442
+ * Contains extensions for ECHO (e.g., references).
9443
+ * Ref: https://json-schema.org/draft-07/schema
9270
9444
  */
9271
- type KeyFilterOptions = {
9445
+ declare const _JsonSchemaType: Struct<{
9272
9446
  /**
9273
- * Optional semver range expression (e.g. `^1.2.3`, `~2.0.0`, `>=1.0.0 <2.0.0`).
9274
- * Matches the object's meta `version` field against the range.
9275
- * If omitted, matches any version (including objects with no version).
9447
+ * Identifier for this schema.
9448
+ * This schema might be referenced by $ref clause in other schemas.
9276
9449
  */
9277
- version?: string;
9450
+ $id: optional<typeof String$>;
9451
+ /**
9452
+ * Schema of this schema.
9453
+ * Set to "https://json-schema.org/draft-07/schema".
9454
+ */
9455
+ $schema: optional<typeof String$>;
9456
+ /**
9457
+ * Reference to another schema.
9458
+ */
9459
+ $ref: optional<typeof String$>;
9460
+ /**
9461
+ * Comments are ignored when interpreting the schema.
9462
+ */
9463
+ $comment: optional<typeof String$>;
9464
+ /**
9465
+ * Defines whether this schema is an object schema or a relation schema.
9466
+ */
9467
+ entityKind: optional<Enums<typeof EntityKind>>;
9468
+ /**
9469
+ * Typename of this schema.
9470
+ * Only on schema representing an ECHO object.
9471
+ *
9472
+ * @example 'com.example.type.my-type'
9473
+ */
9474
+ typename: optional<typeof String$>;
9475
+ /**
9476
+ * Version of this schema.
9477
+ * Custom dialect for ECHO.
9478
+ */
9479
+ version: optional<typeof String$>;
9480
+ /**
9481
+ * Target of this relation.
9482
+ * Only for relation schemas.
9483
+ * The referenced schema must be an object schema.
9484
+ */
9485
+ relationTarget: optional<suspend<JsonSchemaType, JsonSchemaType, never>>;
9486
+ /**
9487
+ * Source of this relation.
9488
+ * Only for relation schemas.
9489
+ * The referenced schema must be an object schema.
9490
+ */
9491
+ relationSource: optional<suspend<JsonSchemaType, JsonSchemaType, never>>;
9492
+ /**
9493
+ * Title of this schema.
9494
+ */
9495
+ title: optional<typeof String$>;
9496
+ /**
9497
+ * Description of this schema.
9498
+ */
9499
+ description: optional<typeof String$>;
9500
+ /**
9501
+ * Whether this schema is read-only.
9502
+ */
9503
+ readOnly: optional<typeof Boolean$>;
9504
+ /**
9505
+ * Whether this schema is write-only.
9506
+ */
9507
+ writeOnly: optional<typeof Boolean$>;
9508
+ /**
9509
+ * Examples of instances of this schema.
9510
+ */
9511
+ examples: optional<Array$<typeof Any$5>>;
9512
+ /**
9513
+ * Default value for this schema.
9514
+ */
9515
+ default: optional<typeof Any$5>;
9516
+ /**
9517
+ * This schema only matches values that are equal to this value.
9518
+ */
9519
+ const: optional<typeof Any$5>;
9520
+ /**
9521
+ * This schema only matches one of the values in this array.
9522
+ */
9523
+ enum: optional<Array$<typeof Any$5>>;
9524
+ /**
9525
+ * Base type of the schema.
9526
+ */
9527
+ type: optional<Union<[Literal<["array", "boolean", "integer", "null", "number", "object", "string"]>, Array$<Literal<["array", "boolean", "integer", "null", "number", "object", "string"]>>]>>;
9528
+ multipleOf: optional<filter<typeof Number$>>;
9529
+ maximum: optional<typeof Number$>;
9530
+ exclusiveMaximum: optional<typeof Number$>;
9531
+ minimum: optional<typeof Number$>;
9532
+ exclusiveMinimum: optional<typeof Number$>;
9533
+ maxLength: optional<filter<typeof Number$>>;
9534
+ /**
9535
+ * Regex pattern for strings.
9536
+ */
9537
+ pattern: optional<typeof String$>;
9538
+ /**
9539
+ * Serialized from {@link FormatAnnotationId}.
9540
+ */
9541
+ format: optional<typeof String$>;
9542
+ minLength: optional<filter<typeof Number$>>;
9543
+ items: optional<Union<[suspend<JsonSchemaType, JsonSchemaType, never>, Array$<suspend<JsonSchemaType, JsonSchemaType, never>>]>>;
9544
+ additionalItems: optional<Union<[suspend<JsonSchemaType, JsonSchemaType, never>, typeof Boolean$]>>;
9545
+ maxItems: optional<filter<typeof Number$>>;
9546
+ minItems: optional<filter<typeof Number$>>;
9547
+ uniqueItems: optional<typeof Boolean$>;
9548
+ contains: optional<suspend<JsonSchemaType, JsonSchemaType, never>>;
9549
+ maxProperties: optional<filter<typeof Number$>>;
9550
+ minProperties: optional<filter<typeof Number$>>;
9551
+ required: optional<Array$<typeof String$>>;
9552
+ /**
9553
+ * Non-standard JSON Schema extension.
9554
+ * Defines the order of properties in the object.
9555
+ * The unmentioned properties are placed at the end.
9556
+ *
9557
+ * Related: https://github.com/json-schema/json-schema/issues/119
9558
+ */
9559
+ propertyOrder: optional<Array$<typeof String$>>;
9560
+ additionalProperties: optional<Union<[suspend<JsonSchemaType, JsonSchemaType, never>, typeof Boolean$]>>;
9561
+ properties: optional<Record$<typeof String$, suspend<JsonSchemaType, JsonSchemaType, never>>>;
9562
+ patternProperties: optional<Record$<typeof String$, suspend<JsonSchemaType, JsonSchemaType, never>>>;
9563
+ propertyNames: optional<suspend<JsonSchemaType, JsonSchemaType, never>>;
9564
+ definitions: optional<Record$<typeof String$, suspend<JsonSchemaType, JsonSchemaType, never>>>;
9565
+ dependencies: optional<Record$<typeof String$, suspend<string | JsonSchemaType | readonly string[], string | JsonSchemaType | readonly string[], never>>>;
9566
+ contentMediaType: optional<typeof String$>;
9567
+ contentEncoding: optional<typeof String$>;
9568
+ if: optional<suspend<JsonSchemaType, JsonSchemaType, never>>;
9569
+ then: optional<suspend<JsonSchemaType, JsonSchemaType, never>>;
9570
+ else: optional<suspend<JsonSchemaType, JsonSchemaType, never>>;
9571
+ allOf: optional<Array$<suspend<JsonSchemaType, JsonSchemaType, never>>>;
9572
+ anyOf: optional<Array$<suspend<JsonSchemaType, JsonSchemaType, never>>>;
9573
+ oneOf: optional<Array$<suspend<JsonSchemaType, JsonSchemaType, never>>>;
9574
+ not: optional<suspend<JsonSchemaType, JsonSchemaType, never>>;
9575
+ $defs: optional<Record$<typeof String$, suspend<JsonSchemaType, JsonSchemaType, never>>>;
9576
+ currency: optional<typeof String$>;
9577
+ reference: optional<Struct<{
9578
+ schema: suspend<JsonSchemaType, JsonSchemaType, never>;
9579
+ schemaVersion: optional<typeof String$>;
9580
+ schemaObject: optional<typeof String$>;
9581
+ }>>;
9582
+ /**
9583
+ * ECHO-specific annotations.
9584
+ */
9585
+ annotations: optional<Struct<{
9586
+ /**
9587
+ * Label for this schema.
9588
+ * Mapped from {@link LabelAnnotationId}.
9589
+ */
9590
+ labelProp: optional<Union<[Schema<JsonPath, JsonPath, never>, Array$<Schema<JsonPath, JsonPath, never>>]>>;
9591
+ /**
9592
+ * Generator function for this schema.
9593
+ * Mapped from {@link GeneratorAnnotationId}; mirrors `GeneratorAnnotationValue`, whose object
9594
+ * form (`{ generator, args }`) is used by schemas like `Task` — a narrower contract here makes
9595
+ * those schemas unserializable (`Operation.serialize` fails on any operation referencing them).
9596
+ */
9597
+ generator: optional<Union<[typeof String$, Tuple2<typeof String$, typeof Number$>, Struct<{
9598
+ generator: typeof String$;
9599
+ args: optional<Array$<typeof Any$5>>;
9600
+ probability: optional<typeof Number$>;
9601
+ }>]>>;
9602
+ /**
9603
+ * {@link PropertyMeta} annotations get serialized here.
9604
+ */
9605
+ meta: optional<Record$<typeof String$, typeof Any$5>>;
9606
+ /**
9607
+ * @deprecated
9608
+ */
9609
+ type: optional<Struct<{
9610
+ typename: typeof String$;
9611
+ version: typeof String$;
9612
+ schemaId: optional<typeof String$>;
9613
+ }>>;
9614
+ /**
9615
+ * @deprecated Superseded by `meta`.
9616
+ */
9617
+ annotations: optional<Record$<typeof String$, typeof Any$5>>;
9618
+ }>>;
9619
+ /**
9620
+ * @deprecated Use `annotations` instead.
9621
+ */
9622
+ echo: optional<Struct<{
9623
+ /**
9624
+ * Label for this schema.
9625
+ * Mapped from {@link LabelAnnotationId}.
9626
+ */
9627
+ labelProp: optional<Union<[Schema<JsonPath, JsonPath, never>, Array$<Schema<JsonPath, JsonPath, never>>]>>;
9628
+ /**
9629
+ * Generator function for this schema.
9630
+ * Mapped from {@link GeneratorAnnotationId}; mirrors `GeneratorAnnotationValue`, whose object
9631
+ * form (`{ generator, args }`) is used by schemas like `Task` — a narrower contract here makes
9632
+ * those schemas unserializable (`Operation.serialize` fails on any operation referencing them).
9633
+ */
9634
+ generator: optional<Union<[typeof String$, Tuple2<typeof String$, typeof Number$>, Struct<{
9635
+ generator: typeof String$;
9636
+ args: optional<Array$<typeof Any$5>>;
9637
+ probability: optional<typeof Number$>;
9638
+ }>]>>;
9639
+ /**
9640
+ * {@link PropertyMeta} annotations get serialized here.
9641
+ */
9642
+ meta: optional<Record$<typeof String$, typeof Any$5>>;
9643
+ /**
9644
+ * @deprecated
9645
+ */
9646
+ type: optional<Struct<{
9647
+ typename: typeof String$;
9648
+ version: typeof String$;
9649
+ schemaId: optional<typeof String$>;
9650
+ }>>;
9651
+ /**
9652
+ * @deprecated Superseded by `meta`.
9653
+ */
9654
+ annotations: optional<Record$<typeof String$, typeof Any$5>>;
9655
+ }>>;
9656
+ }>;
9657
+ /**
9658
+ * https://json-schema.org/draft-07/schema
9659
+ */
9660
+ interface JsonSchemaType extends Schema.Type<typeof _JsonSchemaType> {}
9661
+ declare const JsonSchemaType: Schema<JsonSchemaType>;
9662
+ //#endregion
9663
+ //#region ../echo/dist/types/src/internal/Entity/entity.d.ts
9664
+ type EchoTypeSchemaProps<T$1, ExtraFields = {}> = Simplify$1<AnyEntity & ToMutable<T$1> & ExtraFields>;
9665
+ /**
9666
+ * Options accepted by every `Type.makeObject` / `Type.makeRelation` / type-kind
9667
+ * factory. Defaults are derived from `(typename, version)` so callers normally
9668
+ * pass nothing.
9669
+ */
9670
+ type EchoTypeOptions = {
9671
+ /**
9672
+ * Override the entity id stamped on the in-memory `Type.Type` value.
9673
+ *
9674
+ * Defaults to `EntityId.deterministic(typename, version)` — stable across processes
9675
+ * and workerd-safe (no `crypto.getRandomValues()` at module-evaluation time).
9676
+ * Pass an explicit id (typically `EntityId.random()`) to opt out of the
9677
+ * deterministic default.
9678
+ */
9679
+ id?: EntityId;
9278
9680
  };
9279
9681
  /**
9280
- * Filter by registry key stored in object meta.
9682
+ * In-memory `Type.Type` entity shape produced by `Type.makeObject(dxn)` /
9683
+ * `Type.makeRelation({...})`. A live reactive `TypeSchema` instance —
9684
+ * identical to a persisted `Type.Type` except for database attachment.
9685
+ *
9686
+ * NOT a `Schema.Schema`. The underlying Effect Schema is cached on the hidden
9687
+ * `StaticTypeSchemaSlot` slot — retrieve it via `Type.getSchema(...)`.
9688
+ */
9689
+ interface EchoTypeSchema<Self extends Schema.Any, ExtraFields = {}, K$1 extends EntityKind = EntityKind, Fields extends Struct.Fields = Struct.Fields> {
9690
+ /**
9691
+ * Entity-kind brand. Type entities are their own kind (`Type`) regardless of
9692
+ * the kind of instance they describe — `[SchemaKindId]` carries the latter.
9693
+ * This lets predicates like `Obj.isObject` / `Relation.isRelation` cleanly
9694
+ * reject type entities without also having to inspect `[SchemaKindId]`.
9695
+ */
9696
+ readonly [KindId]: EntityKind.Type;
9697
+ /** Schema-kind brand indicating what kind of instance this type describes. */
9698
+ readonly [SchemaKindId]: K$1;
9699
+ /**
9700
+ * Entity id. Always present — stamped at construction — but NOT the type's
9701
+ * identity while in-memory: an unattached type resolves its URI to the typename
9702
+ * DXN, switching to `echo:/<id>` only once attached to a database (see
9703
+ * `getTypeURIFromSpecifier`, which discriminates by database attachment).
9704
+ */
9705
+ readonly id: EntityId;
9706
+ /** Source Effect Schema (kept on a hidden slot for `Type.getSchema`). */
9707
+ readonly [StaticTypeSchemaSlot]: Schema.AnyNoContext;
9708
+ readonly jsonSchema: JsonSchemaType;
9709
+ /** Struct fields for introspection. */
9710
+ readonly fields: Fields;
9711
+ /** Phantom — instance type produced by `Obj.make(self, ...)`. */
9712
+ readonly _instance?: EchoTypeSchemaProps<Schema.Type<Self>, ExtraFields>;
9713
+ /**
9714
+ * Phantom slot mirroring `Type<A>` so internal helpers (`makeObject`,
9715
+ * `createObject`, `Ref.make`) infer the instance type uniformly whether
9716
+ * the caller passes an `EchoTypeSchema` or a top-level `Type.Type` entity.
9717
+ *
9718
+ * Includes the instance-kind brand (`[KindId]`) so the phantom is assignable
9719
+ * to the matching public-side interface in `Type.ts` (`Type.Obj` /
9720
+ * `Type.Relation` / `Type.Type`). Each kind projects identity: instances of
9721
+ * an object-kind schema are object-kind entities, type-kind schemas produce
9722
+ * type-kind (persisted Type.Type) entities — the latter additionally carry
9723
+ * the `[SchemaKindId]` / `[StaticTypeSchemaSlot]` brands the echo-handler
9724
+ * proxy exposes on persisted Type entities.
9725
+ */
9726
+ readonly [InstancePhantomId$1]?: EchoTypeSchemaProps<Schema.Type<Self>, ExtraFields> & {
9727
+ readonly [KindId]: K$1;
9728
+ } & (K$1 extends EntityKind.Type ? {
9729
+ readonly [SchemaKindId]: EntityKind.Type;
9730
+ readonly [StaticTypeSchemaSlot]: Schema.AnyNoContext;
9731
+ } : {});
9732
+ }
9733
+ //#endregion
9734
+ //#region ../echo/dist/types/src/internal/Entity/type-kind.d.ts
9735
+ /**
9736
+ * Type-kind schema marker — produced by {@link EchoTypeKindSchema}.
9281
9737
  *
9282
- * @example
9283
- * ```ts
9284
- * Filter.key('org.example.type.foo');
9285
- * Filter.key('org.example.type.foo', { version: '^1.2.3' });
9286
- * ```
9738
+ * Distinguishes meta-schemas (entities of `EntityKind.Type`, such as the
9739
+ * built-in `Type.Type` TypeSchema) from object and relation types.
9287
9740
  */
9288
- declare const key$1: (key: string, options?: KeyFilterOptions) => Any$3;
9741
+ type EchoTypeKindSchema<Self extends Schema.Any, Fields extends Struct.Fields = Struct.Fields> = EchoTypeSchema<Self, {}, EntityKind.Type, Fields>;
9289
9742
  /**
9290
- * Filter by properties.
9743
+ * Pipeable that brands a schema as a type-kind ECHO entity. Mirrors
9744
+ * {@link EchoObjectSchema} / {@link EchoRelationSchema}, but stamps the
9745
+ * resulting entity with `[SchemaKindId]: EntityKind.Type` and a matching
9746
+ * `TypeAnnotation.kind = 'type'` so meta-schemas surface uniformly through
9747
+ * `Type.isTypeKind`, `Filter.type`, etc.
9291
9748
  */
9292
- declare const props: <T$1>(props: Props$1<T$1>) => Filter<T$1>;
9293
- type TextSearchOptions = {
9294
- type?: 'full-text' | 'vector';
9749
+ declare const EchoTypeKindSchema: {
9750
+ (dxn: DXN, options?: EchoTypeOptions): <Self extends Schema.Any, Fields extends Struct.Fields = Struct.Fields>(self: Self & {
9751
+ fields?: Fields;
9752
+ }) => EchoTypeKindSchema<Self, Fields>;
9295
9753
  };
9754
+ //#endregion
9755
+ //#region ../echo/dist/types/src/internal/Type/type-schema.d.ts
9296
9756
  /**
9297
- * Full-text or vector search.
9298
- */
9299
- declare const text: (text: string, options?: TextSearchOptions) => Any$3;
9300
- /**
9301
- * Filter by foreign keys.
9302
- */
9303
- declare const foreignKeys: <S$1 extends AnyEntity$1 | URI>(schema: S$1, keys: ForeignKey[]) => Filter<S$1 extends AnyEntity$1 ? InstanceType$1<S$1> : unknown>;
9304
- /**
9305
- * Predicate for property to be equal to the provided value.
9306
- */
9307
- declare const eq: <T$1>(value: T$1) => Filter<T$1 | undefined>;
9308
- /**
9309
- * Predicate for property to be not equal to the provided value.
9310
- */
9311
- declare const neq: <T$1>(value: T$1) => Filter<T$1 | undefined>;
9312
- /**
9313
- * Predicate for property to be greater than the provided value.
9314
- */
9315
- declare const gt: <T$1>(value: T$1) => Filter<T$1 | undefined>;
9316
- /**
9317
- * Predicate for property to be greater than or equal to the provided value.
9318
- */
9319
- declare const gte: <T$1>(value: T$1) => Filter<T$1 | undefined>;
9320
- /**
9321
- * Predicate for property to be less than the provided value.
9322
- */
9323
- declare const lt: <T$1>(value: T$1) => Filter<T$1 | undefined>;
9324
- /**
9325
- * Predicate for property to be less than or equal to the provided value.
9326
- */
9327
- declare const lte: <T$1>(value: T$1) => Filter<T$1 | undefined>;
9328
- /**
9329
- * Predicate for property to be in the provided array.
9330
- * @param values - Values to check against.
9757
+ * Raw struct backing {@link TypeSchema}. Exposed only so `TypeSchema`
9758
+ * (the TS type) can derive its data fields via `Schema.Schema.Type<typeof ...>`;
9759
+ * runtime callers should use {@link TypeSchema} (the piped, branded entity).
9760
+ *
9761
+ * `typename` and `version` are NOT data fields — they live in `EntityMeta.key` /
9762
+ * `EntityMeta.version` (the canonical registry-provenance pair, queryable via
9763
+ * `Filter.key(...)`). The same `jsonSchema` payload also embeds them so a
9764
+ * standalone JSON-Schema export remains self-describing, but the schema-registry
9765
+ * reads/writes them through meta.
9331
9766
  */
9332
- declare const in$: <T$1>(...values: T$1[]) => Filter<T$1>;
9767
+ declare const TypeSchemaStruct: Struct<{
9768
+ name: optional<typeof String$>;
9769
+ jsonSchema: Schema<JsonSchemaType, JsonSchemaType, never>;
9770
+ }>;
9333
9771
  /**
9334
- * Predicate for an array property to contain the provided value.
9335
- * @param value - Value to check against.
9772
+ * Persistent representation of a schema.
9336
9773
  */
9337
- declare const contains: <T$1>(value: T$1) => Filter<readonly T$1[] | undefined>;
9774
+ declare const TypeSchema: EchoTypeKindSchema<Struct<{
9775
+ name: optional<typeof String$>;
9776
+ jsonSchema: Schema<JsonSchemaType, JsonSchemaType, never>;
9777
+ }>, Readonly<{
9778
+ name: optional<typeof String$>;
9779
+ jsonSchema: Schema<JsonSchemaType, JsonSchemaType, never>;
9780
+ }>>;
9338
9781
  /**
9339
- * Predicate for property to be in the provided range.
9340
- * @param from - Start of the range (inclusive).
9341
- * @param to - End of the range (exclusive).
9782
+ * Persistent representation of a schema the runtime shape that
9783
+ * `db.addType(Type.makeObjectFromJsonSchema(...))` produces
9784
+ * and `Filter.type(Type.Type).run()` returns.
9785
+ *
9786
+ * Structurally identical to a static `Type.Type` entity: the entity-handler's
9787
+ * `get` trap exposes `[SchemaKindId]` (derived from `system.kind` and
9788
+ * `data.jsonSchema.entityKind`) and rebuilds `[StaticTypeSchemaSlot]` lazily
9789
+ * from `jsonSchema`, so a persisted instance satisfies the public `Type<A>`
9790
+ * interface without casting.
9342
9791
  */
9343
- declare const between: <T$1>(from: T$1, to: T$1) => Filter<T$1>;
9344
- type TimeRange = {
9345
- after?: Date | number;
9346
- before?: Date | number;
9792
+ type TypeSchema = Schema.Type<typeof TypeSchemaStruct> & {
9793
+ /** Object identifier — injected by `EchoTypeKindSchema` and stamped at construction. */
9794
+ readonly id: string;
9795
+ /** Entity-kind discriminator (object/relation/type) carried on every entity instance. */
9796
+ readonly [KindId]: EntityKind.Type;
9797
+ /** Kind of schema described by this meta-instance — always `EntityKind.Type` for `Type.Type` itself. */
9798
+ readonly [SchemaKindId]: EntityKind.Type;
9799
+ /** Effect Schema rebuilt lazily from `jsonSchema`; satisfies `Type.getSchema(...)` without an extra cast. */
9800
+ readonly [StaticTypeSchemaSlot]: Schema.AnyNoContext;
9347
9801
  };
9802
+ //#endregion
9803
+ //#region ../echo/dist/types/src/internal/common/types/entity.d.ts
9348
9804
  /**
9349
- * Filter objects by updatedAt timestamp.
9350
- */
9351
- declare const updated$1: (range: TimeRange) => Any$3;
9352
- /**
9353
- * Filter objects by createdAt timestamp.
9805
+ * String key used to identify the kind of an entity instance (object or relation).
9354
9806
  */
9355
- declare const created$1: (range: TimeRange) => Any$3;
9356
- type ChildOfOptions = {
9357
- /** Whether to match transitively (grandchildren, etc.). Defaults to true. */
9358
- transitive?: boolean;
9359
- };
9807
+ declare const KindId: '~@dxos/echo/Kind';
9808
+ type KindId = typeof KindId;
9360
9809
  /**
9361
- * Filter objects that are children of the specified parent(s).
9362
- * Accepts ECHO objects, Refs, or arrays of either.
9363
- * Refs are resolved to DXNs without loading; objects use {@link Obj.getURI}.
9364
- * With transitive=true (default), also matches grandchildren and beyond.
9810
+ * String key used to identify the kind of a schema (object schema or relation schema).
9811
+ * Parallels KindId which identifies instance kinds.
9365
9812
  */
9366
- declare const childOf: (parents: Unknown$1 | Unknown$2 | readonly (Unknown$1 | Unknown$2)[], options?: ChildOfOptions) => Any$3;
9813
+ declare const SchemaKindId: '~@dxos/echo/SchemaKind';
9814
+ type SchemaKindId = typeof SchemaKindId;
9367
9815
  /**
9368
- * Negate the filter.
9816
+ * String key used to brand snapshot types.
9817
+ * Snapshots have SnapshotKindId instead of KindId, making them
9818
+ * distinguishable from reactive objects at the type level.
9369
9819
  */
9370
- declare const not: <F extends Any$3>(filter: F) => Filter<Type$3<F>>;
9820
+ declare const SnapshotKindId$1: '~@dxos/echo/SnapshotKind';
9821
+ type SnapshotKindId$1 = typeof SnapshotKindId$1;
9371
9822
  /**
9372
- * Combine filters with a logical AND.
9823
+ * Hidden slot on a static `Type.Type` entity that holds the source Effect
9824
+ * Schema. `Type.getSchema(...)` reads this for static types; persisted types
9825
+ * rebuild from `jsonSchema` instead. Stored as a string key for declaration
9826
+ * portability (see KindId comment above).
9373
9827
  */
9374
- declare const and: <Filters extends readonly Any$3[]>(...filters: Filters) => Filter<Type$3<Filters[number]>>;
9828
+ declare const StaticTypeSchemaSlot: '~@dxos/echo/Type.StaticSchema';
9829
+ type StaticTypeSchemaSlot = typeof StaticTypeSchemaSlot;
9375
9830
  /**
9376
- * Combine filters with a logical OR.
9831
+ * Phantom string key on `Type<A>` entities that carries the instance type `A`.
9832
+ * Lets internal helpers (`makeObject`, `createObject`, etc.) pattern-match the
9833
+ * instance type from an entity input without importing from the top-level
9834
+ * `Type` module. Mirrors `Type.InstancePhantomId` (declared in `Type.ts`).
9835
+ *
9836
+ * Stored as a string key so declarations remain portable across packages
9837
+ * (see KindId comment above).
9377
9838
  */
9378
- declare const or: <Filters extends readonly Any$3[]>(...filters: Filters) => Filter<Type$3<Filters[number]>>;
9839
+ declare const InstancePhantomId$1: '~@dxos/echo/Type.Instance';
9840
+ type InstancePhantomId$1 = typeof InstancePhantomId$1;
9379
9841
  /**
9380
- * Returns a human-readable string representation of a Filter AST.
9842
+ * Nominal brand carried by the well-known "any object" / "any relation"
9843
+ * schemas (`Obj.Unknown`, `Relation.Unknown`). The brand lets `Ref.Ref`,
9844
+ * `Filter.type`, and `Query.type` accept these schemas in addition to
9845
+ * `Type.Type` entities, without opening the door to arbitrary raw schemas.
9846
+ *
9847
+ * Stored as a string key so declarations remain portable across packages
9848
+ * (see KindId comment above).
9381
9849
  */
9382
- declare const pretty$1: (filter: Any$3) => string;
9850
+ declare const UnknownTypeSchemaBrandId: '~@dxos/echo/UnknownTypeSchemaBrand';
9851
+ type UnknownTypeSchemaBrandId = typeof UnknownTypeSchemaBrandId;
9383
9852
  /**
9384
- * Create a predicate from a filter.
9853
+ * Schema-side companion to `Type.Type` entities for the "any object" /
9854
+ * "any relation" cases. Branded so `Ref.Ref` / `Filter.type` / `Query.type`
9855
+ * can pattern-match on it; arbitrary `Schema.Schema` values do not satisfy
9856
+ * this shape.
9385
9857
  */
9386
- declare const toPredicate: {
9387
- <T$1 extends Unknown>(filter: Filter<T$1>): (entity: Unknown) => entity is T$1;
9388
- <T$1 extends Unknown>(entity: Unknown, filter: Filter<T$1>): entity is T$1;
9389
- };
9390
- //#endregion
9391
- //#region ../echo/dist/types/src/Collection.d.ts
9392
- declare const Collection_base: ObjClass<Collection, {
9393
- readonly name?: string | undefined;
9394
- readonly objects: readonly Ref<Unknown$1>[];
9395
- }, {}>;
9858
+ interface UnknownTypeSchema<A$1, K$1 extends EntityKind> extends Schema<A$1, any, never> {
9859
+ readonly [UnknownTypeSchemaBrandId]: K$1;
9860
+ }
9396
9861
  /**
9397
- * A an ordered set of objects.
9862
+ * Kinds of entities stored in ECHO: objects, relations, and types.
9398
9863
  */
9399
- declare class Collection extends Collection_base {}
9400
- //#endregion
9401
- //#region ../../../../node_modules/.pnpm/@effect-atom+atom@0.5.3_patch_hash=90a97dcb5aa93197ad34b41c932b405a7ba98679af6885de637f_8e9863696f10bf243333e2648ae3a1f9/node_modules/@effect-atom/atom/dist/dts/AtomHttpApi.d.ts
9402
- declare global {
9403
- interface ErrorConstructor {
9404
- stackTraceLimit: number;
9405
- }
9864
+ declare enum EntityKind {
9865
+ Object = "object",
9866
+ Relation = "relation",
9867
+ Type = "type",
9406
9868
  }
9869
+ //#endregion
9870
+ //#region ../echo/dist/types/src/Ref.d.ts
9407
9871
  /**
9408
- * @since 1.0.0
9409
- * @category Constructors
9872
+ * Instance type for a reference.
9873
+ *
9874
+ * Reference can point to any object or relation.
9875
+ * References are lazy loaded.
9876
+ *
9877
+ * `ref.dxn` is the DXN of the referenced object.
9878
+ *
9879
+ * @example
9880
+ * ```ts
9881
+ * const taskRef: Ref<Task> = Ref.make(task);
9882
+ *
9883
+ * await taskRef.load(); // Returns Promise<Task>
9884
+ * yield* Database.load(taskRef); // Effectful version.
9885
+ *
9886
+ * database.makeRef(dxn); // Create a ref from a DXN.
9887
+ * ```
9410
9888
  */
9411
- //#endregion
9412
- //#region ../../../../node_modules/.pnpm/@effect-atom+atom@0.5.3_patch_hash=90a97dcb5aa93197ad34b41c932b405a7ba98679af6885de637f_8e9863696f10bf243333e2648ae3a1f9/node_modules/@effect-atom/atom/dist/dts/AtomRpc.d.ts
9413
- declare global {
9414
- interface ErrorConstructor {
9415
- stackTraceLimit: number;
9416
- }
9417
- }
9889
+ type Ref$1<T$1> = Ref<T$1>;
9890
+ type Unknown$3 = Ref<Unknown>;
9418
9891
  /**
9419
- * @since 1.0.0
9420
- * @category Constructors
9892
+ * Factory function to create a Ref schema for the given target schema.
9893
+ * Use this in schema definitions to declare reference fields.
9894
+ *
9895
+ * @example
9896
+ * ```ts
9897
+ * class Task extends Type.makeObject<Task>(DXN.make('com.example.type.task', '0.1.0'))(
9898
+ * Schema.Struct({
9899
+ * assignee: Ref.Ref(Person), // Creates a Ref schema
9900
+ * }),
9901
+ * ) {}
9902
+ * ```
9421
9903
  */
9422
- //#endregion
9423
- //#region ../../../common/effect/dist/types/src/internal/json-path.d.ts
9424
- type JsonPath = string & {
9425
- __JsonPath: true;
9904
+ declare const Ref$1: {
9905
+ <S$1 extends AnyObj>(type: S$1): RefSchema<InstanceType$1<S$1> & Unknown>;
9906
+ <S$1 extends AnyRelation>(type: S$1): RefSchema<InstanceType$1<S$1> & Unknown$2>;
9907
+ <T$1 extends Type$3<any>>(type: T$1): RefSchema<InstanceType$1<T$1>>;
9908
+ <S$1 extends UnknownTypeSchema<any, any>>(schema: S$1): RefSchema<Schema.Type<S$1> & Unknown>;
9426
9909
  };
9427
9910
  /**
9428
- * https://www.ietf.org/archive/id/draft-goessner-dispatch-jsonpath-00.html
9429
- */
9430
- declare const JsonPath: Schema<JsonPath>;
9431
- //#endregion
9432
- //#region ../echo/dist/types/src/View.d.ts
9433
- declare const View_base: ObjClass<View, {
9434
- readonly query: {
9435
- readonly raw?: string | undefined;
9436
- readonly ast: QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QueryUnionClause;
9437
- };
9438
- readonly projection: {
9439
- readonly schema?: JsonSchemaType | undefined;
9440
- readonly fields: readonly {
9441
- readonly id: string;
9442
- readonly path: JsonPath;
9443
- readonly visible?: boolean | undefined;
9444
- readonly referencePath?: JsonPath | undefined;
9445
- }[];
9446
- readonly pivotFieldId?: string | undefined;
9447
- };
9448
- }, {}>;
9911
+ * TypeScript type for a Ref schema.
9912
+ * This is the type of the SCHEMA itself, not the runtime ref instance.
9913
+ * For the instance type, use `Ref.Ref<T>` from the Ref module.
9914
+ *
9915
+ * @example
9916
+ * ```ts
9917
+ * // Schema type annotation (rarely needed, usually inferred):
9918
+ * const refSchema: Ref.RefSchema<typeof Task> = Ref.Ref(Task);
9919
+ *
9920
+ * // Instance type annotation (use Ref.Ref instead):
9921
+ * const refInstance: Ref.Ref<Task> = Ref.make(task);
9922
+ * ```
9923
+ */
9924
+ interface RefSchema<T$1 extends Unknown$1> extends RefSchema$1<T$1> {}
9449
9925
  /**
9450
- * Views are generated or user-defined projections of a schema's properties.
9451
- * They are used to configure the visual representation of the data.
9926
+ * Extract reference target.
9452
9927
  */
9453
- declare class View extends View_base {}
9928
+ type Target$1<R$1 extends Unknown$3> = R$1 extends Ref<infer T> ? T : never;
9929
+ /**
9930
+ * Reference resolver.
9931
+ */
9932
+ type Resolver = RefResolver;
9454
9933
  //#endregion
9455
- //#region ../echo/dist/types/src/Dataset.d.ts
9934
+ //#region ../echo/dist/types/src/Relation.d.ts
9935
+ type Endpoints$1<Source$1, Target$2> = {
9936
+ [Source$1]: Source$1;
9937
+ [Target$2]: Target$2;
9938
+ };
9456
9939
  /**
9457
- * Abstract set of objects, represented by a view, feed, or collection.
9458
- * Schema-level union of the underlying type entities (rebuilt via
9459
- * `Type.getSchema`) so this can still be consumed by Schema-side APIs such
9460
- * as `Filter.type(...)` on a union.
9940
+ * Base type for all ECHO relations.
9941
+ * @private
9461
9942
  */
9462
- type Dataset = Feed | Collection | View;
9463
- declare const Dataset: Union<[Schema<Feed & OfKind<EntityKind.Object>, Feed & OfKind<EntityKind.Object>, never>, Schema<Collection & OfKind<EntityKind.Object>, Collection & OfKind<EntityKind.Object>, never>, Schema<View & OfKind<EntityKind.Object>, View & OfKind<EntityKind.Object>, never>]>;
9464
- declare namespace Order_d_exports {
9465
- export { Any$2 as Any, Order, created, natural, property, rank, updated };
9466
- }
9467
- interface Order<T$1> {
9468
- '~Order': {
9469
- value: T$1;
9470
- };
9471
- 'ast': Order$1;
9472
- }
9473
- type Any$2 = Order<any>;
9474
- declare const natural: Order<any>;
9475
- declare const property: <T$1>(property: keyof T$1 & string, direction: OrderDirection) => Order<T$1>;
9943
+ interface BaseRelation<Source$1, Target$2> extends AnyEntity, Endpoints$1<Source$1, Target$2>, OfKind<EntityKind.Relation> {}
9476
9944
  /**
9477
- * Order by relevance rank (for FTS/vector search results).
9478
- * Higher rank = better match. Default direction is 'desc' (best matches first).
9945
+ * Relation with no known properties beyond id, kind, source, and target.
9946
+ * Use this when the relation's schema/properties are not known.
9947
+ *
9948
+ * NOTE: This is a TypeScript type only, not a schema.
9949
+ * To validate that a value is an ECHO relation, use `Relation.isRelation`.
9479
9950
  */
9480
- declare const rank: <T$1>(direction?: OrderDirection) => Order<T$1>;
9951
+ interface Unknown$2 extends BaseRelation<Unknown, Unknown> {}
9481
9952
  /**
9482
- * Order by the system `updatedAt` timestamp (last re-indexed). Default direction is 'desc'
9483
- * (most-recently-updated first). Mirrors {@link Filter.updated}.
9953
+ * Runtime Effect schema for any ECHO relation.
9954
+ * Use for validation, parsing, or as a reference target for collections.
9955
+ * A relation has `id`, source, and target fields plus any additional properties.
9956
+ *
9957
+ * NOTE: `Schema.is(Type.Relation)` does STRUCTURAL validation only (checks for `id` field).
9958
+ * Use `Relation.isRelation()` for proper ECHO instance type guards that check the KindId brand.
9959
+ *
9960
+ * @example
9961
+ * ```ts
9962
+ * // Structural type guard (accepts any object with id field)
9963
+ * if (Schema.is(Type.Relation)(unknownValue)) { ... }
9964
+ *
9965
+ * // ECHO instance type guard (checks KindId brand)
9966
+ * if (Relation.isRelation(unknownValue)) { ... }
9967
+ * ```
9484
9968
  */
9485
- declare const updated: <T$1>(direction?: OrderDirection) => Order<T$1>;
9969
+ declare const Unknown$2: UnknownTypeSchema<Unknown$2, typeof Kind.Relation>;
9486
9970
  /**
9487
- * Order by the system `createdAt` timestamp (first indexed). Default direction is 'desc'
9488
- * (most-recently-created first). Mirrors {@link Filter.created}.
9971
+ * Get relation source type.
9489
9972
  */
9490
- declare const created: <T$1>(direction?: OrderDirection) => Order<T$1>;
9491
- declare namespace Query_d_exports {
9492
- export { Any$1 as Any, Query, Type$2 as Type, all, from, fromAst, is, pretty, select, type$1 as type, without };
9493
- }
9973
+ type SourceOf<A$1> = A$1 extends Endpoints$1<infer S, infer _T> ? S : never;
9494
9974
  /**
9495
- * All property paths inside T that are references.
9975
+ * Get relation target type.
9496
9976
  */
9497
- type RefPropKey<T$1> = keyof T$1 & string;
9498
- type RefArrayElement<A$1> = A$1 extends readonly (infer E)[] ? E : A$1 extends (infer E)[] ? E : never;
9499
- /** Target entity when traversing an outgoing ref or array-of-refs property. */
9500
- type ReferenceTraversalTarget<P$1> = P$1 extends Unknown$2 ? Target$1<P$1> : P$1 extends Unknown$2 | undefined ? Target$1<Exclude<P$1, undefined>> : RefArrayElement<P$1> extends Unknown$2 ? Target$1<RefArrayElement<P$1>> : never;
9501
- interface Query<T$1> {
9502
- '~Query': {
9503
- value: T$1;
9504
- };
9505
- 'ast': Query$1;
9506
- /**
9507
- * Filter the current selection based on a filter.
9508
- * @param filter - Filter to select the objects.
9509
- * @returns Query for the selected objects.
9510
- */
9511
- 'select'(filter: Filter<T$1>): Query<T$1>;
9512
- 'select'(props: Props$1<T$1>): Query<T$1>;
9513
- /**
9514
- * Traverse an outgoing reference.
9515
- * @param key - Property path inside T that is a reference or optional reference.
9516
- * @returns Query for the target of the reference.
9517
- */
9518
- 'reference'<K$1 extends RefPropKey<T$1>>(key: K$1): Query<ReferenceTraversalTarget<T$1[K$1]>>;
9519
- /**
9520
- * Find objects referencing this object.
9521
- * @param target - Schema of the referencing object. If not provided, matches any type.
9522
- * @param key - Property path inside the referencing object that is a reference. If not provided, matches any property.
9523
- * @returns Query for the referencing objects.
9524
- */
9525
- 'referencedBy'<S$1 extends AnyEntity$1>(target: S$1 | URI, key: RefPropKey<InstanceType$1<S$1>>): Query<InstanceType$1<S$1>>;
9526
- 'referencedBy'<S$1 extends AnyEntity$1>(target: S$1 | URI): Query<InstanceType$1<S$1>>;
9527
- 'referencedBy'(): Query<any>;
9528
- /**
9529
- * Find relations where this object is the source.
9530
- * @returns Query for the relation objects.
9531
- * @param relation - Schema of the relation.
9532
- * @param predicates - Predicates to filter the relation objects.
9533
- */
9534
- 'sourceOf'<R$1 extends AnyRelation>(relation?: R$1 | URI, predicates?: Props$1<InstanceType$1<R$1>>): Query<InstanceType$1<R$1>>;
9535
- /**
9536
- * Find relations where this object is the target.
9537
- * @returns Query for the relation objects.
9538
- * @param relation - Type entity of the relation.
9539
- * @param predicates - Predicates to filter the relation objects.
9540
- */
9541
- 'targetOf'<R$1 extends AnyRelation>(relation?: R$1 | URI, predicates?: Props$1<InstanceType$1<R$1>>): Query<InstanceType$1<R$1>>;
9542
- /**
9543
- * For a query for relations, get the source objects.
9544
- * @returns Query for the source objects.
9545
- */
9546
- 'source'(): Query<SourceOf<T$1>>;
9547
- /**
9548
- * For a query for relations, get the target objects.
9549
- * @returns Query for the target objects.
9550
- */
9551
- 'target'(): Query<TargetOf<T$1>>;
9552
- /**
9553
- * Get the parent object of the current selection.
9554
- * @returns Query for the parent objects.
9555
- */
9556
- 'parent'(): Query<any>;
9557
- /**
9558
- * Get all child objects of the current selection.
9559
- * @returns Query for the child objects.
9560
- */
9561
- 'children'(): Query<any>;
9562
- /**
9563
- * Order the query results.
9564
- * Orders are specified in priority order. The first order will be applied first, etc.
9565
- * @param order - Order to sort the results.
9566
- * @returns Query for the ordered results.
9567
- */
9568
- 'orderBy'(...order: NonEmptyArray<Order<T$1>>): Query<T$1>;
9569
- /**
9570
- * Limit the number of results.
9571
- * @param limit - Maximum number of results to return.
9572
- * @returns Query for the limited results.
9573
- */
9574
- 'limit'(limit: number): Query<T$1>;
9575
- /**
9576
- * Query from selected databases only.
9577
- *
9578
- * Example:
9579
- *
9580
- * ```ts
9581
- * Query.select(Filter.type(Person)).from(db);
9582
- * ```
9583
- *
9584
- * @param options.includeFeeds [false] - Whether to include feeds in the query. Default is to query from automerge documents only.
9585
- */
9586
- 'from'(database: Database | Database[], options?: {
9587
- includeFeeds?: boolean;
9588
- }): Query<T$1>;
9589
- /**
9590
- * Query from selected feeds only.
9591
- *
9592
- * Example:
9593
- *
9594
- * ```ts
9595
- * Query.select(Filter.type(Person)).from(feed);
9596
- * ```
9597
- *
9598
- */
9599
- 'from'(feeds: Feed | Feed[]): Query<T$1>;
9600
- /**
9601
- * Query from all accessible spaces.
9602
- *
9603
- * Example:
9604
- *
9605
- * ```ts
9606
- * Query.select(Filter.type(Person)).from('all-accessible-spaces');
9607
- * ```
9608
- *
9609
- * @param options.includeFeeds [false] - Whether to include feeds in the query. Default is to query from automerge documents only.
9610
- */
9611
- 'from'(allSpaces: 'all-accessible-spaces', options?: {
9612
- includeFeeds?: boolean;
9613
- }): Query<T$1>;
9614
- /**
9615
- * Query from a dataset.
9616
- * Currently only feeds are supported.
9617
- *
9618
- * Example:
9619
- *
9620
- * ```ts
9621
- * Query.type(Person).from(feed);
9622
- * ```
9623
- */
9624
- 'from'(dataset: Dataset): Query<T$1>;
9625
- /**
9626
- * Query from the results of another query.
9627
- *
9628
- * Example:
9629
- *
9630
- * ```ts
9631
- * Query.select(Filter.props({ foo: 'foo' })).from(Query.select(Filter.type(Contact)).reference('org'));
9632
- * ```
9633
- */
9634
- 'from'(query: Any$1): Query<T$1>;
9977
+ type TargetOf<A$1> = A$1 extends Endpoints$1<infer _S, infer T> ? T : never;
9978
+ //#endregion
9979
+ //#region ../echo/dist/types/src/Type.d.ts
9980
+ /**
9981
+ * Structural base shared by the three sibling type-entity interfaces
9982
+ * ({@link Obj}, {@link Relation}, {@link Type}). NOT exported — callers
9983
+ * should constrain on {@link AnyEntity} when they want "any of the three"
9984
+ * and on the specific kind interface otherwise.
9985
+ */
9986
+ interface BaseTypeEntity<A$1> {
9635
9987
  /**
9636
- * Query from one or more raw scopes.
9637
- *
9638
- * Use the {@link Scope} constructors rather than raw tagged objects:
9639
- *
9640
- * ```ts
9641
- * Query.select(Filter.type(Type.Type)).from(Scope.space(), Scope.registry());
9642
- * ```
9988
+ * Entity-kind brand of the type-entity value itself — always `EntityKind.Type`.
9989
+ * The kind of instance the type *describes* lives on `[SchemaKindId]`
9990
+ * (Object / Relation / Type). Lets `Obj.isObject` / `Relation.isRelation`
9991
+ * reject type entities by a single `[KindId]` check.
9643
9992
  */
9644
- 'from'(...scopes: Scope[]): Query<T$1>;
9993
+ readonly [KindId]: EntityKind.Type;
9645
9994
  /**
9646
- * Query from a raw scope or array of scopes.
9995
+ * Object id. Like all ECHO entities, type entities always carry an id —
9996
+ * stamped at construction for in-memory (static) declarations and assigned by
9997
+ * the database once persisted. The id does NOT determine the entity's URI:
9998
+ * static types resolve to their typename DXN, persisted types to `echo:/<id>`
9999
+ * (see `getTypeURIFromSpecifier`).
9647
10000
  */
9648
- 'from'(scope: Scope | Scope[]): Query<T$1>;
10001
+ readonly id: EntityId;
10002
+ readonly name?: string;
10003
+ readonly jsonSchema: JsonSchemaType;
10004
+ readonly [InstancePhantomId]?: A$1;
10005
+ }
10006
+ /**
10007
+ * TypeScript type for an ECHO object type — a `Type.Type<A>` entity.
10008
+ *
10009
+ * `T` is the instance type produced by `Obj.make(Foo, props)`. `Fields` is
10010
+ * retained as a structural hint (the runtime value still carries `.fields`),
10011
+ * but consumers should derive instance/encoded types via `Type.InstanceType`.
10012
+ *
10013
+ * **Not a `Schema.Schema`.** `Foo.ast` / `Schema.Schema.Type<typeof Foo>` /
10014
+ * `Schema.extend(Foo)` no longer typecheck — extract the Effect Schema via
10015
+ * `Type.getSchema(Foo)` first, or derive instance types via
10016
+ * `Type.InstanceType<typeof Foo>`.
10017
+ *
10018
+ * @example
10019
+ * ```ts
10020
+ * class Person extends Type.makeObject<Person>(DXN.make('com.example.type.person', '0.1.0'))(
10021
+ * Schema.Struct({ name: Schema.String }),
10022
+ * ) {}
10023
+ * ```
10024
+ */
10025
+ interface Obj$1<T$1, Fields extends Struct.Fields = Struct.Fields> extends BaseTypeEntity<T$1 & OfKind<typeof Kind.Object>> {
10026
+ /** Schema-kind brand (object). */
10027
+ readonly [SchemaKindId]: EntityKind.Object;
10028
+ /** Source Effect Schema — used internally by `Type.getSchema(self)`. */
10029
+ readonly [StaticTypeSchemaSlot]: Schema.AnyNoContext;
9649
10030
  /**
9650
- * Add options to a query.
10031
+ * The fields defined in the original struct schema.
10032
+ * Allows accessing field definitions for introspection.
9651
10033
  */
9652
- 'options'(options: QueryOptions): Query<T$1>;
10034
+ readonly fields: Fields;
10035
+ }
10036
+ /**
10037
+ * Return type for {@link makeObject}.
10038
+ *
10039
+ * Not to be used directly, but must be exported for typescript to infer the type.
10040
+ */
10041
+ interface ObjClass<Self, T$1, Fields extends Struct.Fields> extends Obj$1<Self, Fields> {
10042
+ new (_: never): T$1 & OfKind<typeof Kind.Object>;
10043
+ }
10044
+ /**
10045
+ * Type that represents any ECHO object type — a `Type.Type` entity branded
10046
+ * with the object entity kind, i.e. what `Type.makeObject(dxn)` produces.
10047
+ */
10048
+ type AnyObj = Obj$1<unknown>;
10049
+ /**
10050
+ * ECHO meta-schema entity — stores `{ name?, typename, version, jsonSchema }`.
10051
+ * Type-kind sibling of `Type.makeObject(...)` / `Type.makeRelation(...)` outputs.
10052
+ * Stored types live under this entity; filter via `Filter.type(Type.Type)`.
10053
+ */
10054
+ declare const Type$3: Type$3<TypeSchema>;
10055
+ /**
10056
+ * TypeScript type for an ECHO relation type — a `Type.Type<A>` entity.
10057
+ *
10058
+ * `T` is the instance-property type produced by `Relation.make(...)` (excluding
10059
+ * source/target endpoints). `Source` and `Target` are the endpoint types.
10060
+ *
10061
+ * **Not a `Schema.Schema`.** See {@link Obj}'s note.
10062
+ */
10063
+ interface Relation<T$1, Source$1, Target$2, Fields extends Struct.Fields = Struct.Fields> extends BaseTypeEntity<Endpoints$1<Source$1, Target$2> & T$1 & OfKind<typeof Kind.Relation>> {
10064
+ /** Schema-kind brand (relation). */
10065
+ readonly [SchemaKindId]: EntityKind.Relation;
10066
+ /** Source Effect Schema — used internally by `Type.getSchema(self)`. */
10067
+ readonly [StaticTypeSchemaSlot]: Schema.AnyNoContext;
9653
10068
  /**
9654
- * Attach a diagnostic label for logs and tooling (execution semantics unchanged).
10069
+ * The fields defined in the original struct schema.
10070
+ * Allows accessing field definitions for introspection.
9655
10071
  */
9656
- 'debugLabel'(label: string): Query<T$1>;
10072
+ readonly fields: Fields;
9657
10073
  }
9658
- type Any$1 = Query<any>;
9659
- type Type$2<Q extends Any$1> = Q extends Query<infer T> ? T : never;
9660
- declare const is: (value: unknown) => value is Any$1;
9661
- /** Construct a query from an ast. */
9662
- declare const fromAst: (ast: Query$1) => Any$1;
9663
10074
  /**
9664
- * Select objects based on a filter.
9665
- * @param filter - Filter to select the objects.
9666
- * @returns Query for the selected objects.
10075
+ * Return type for {@link makeRelation}.
10076
+ *
10077
+ * Not to be used directly, but must be exported for typescript to infer the type.
9667
10078
  */
9668
- declare const select: <F extends Any$3>(filter: F) => Query<Type$3<F>>;
10079
+ interface RelationClass<Self, T$1, Source$1, Target$2, Fields extends Struct.Fields> extends Relation<Self, Source$1, Target$2, Fields> {
10080
+ new (_: never): Endpoints$1<Source$1, Target$2> & T$1 & OfKind<typeof Kind.Relation>;
10081
+ }
9669
10082
  /**
9670
- * Query for objects of a given schema.
9671
- * @param schema - Schema of the objects.
9672
- * @param predicates - Predicates to filter the objects.
9673
- * @returns Query for the objects.
9674
- *
9675
- * Shorthand for: `Query.select(Filter.type(schema, predicates))`.
10083
+ * Type that represents any ECHO relation type — a `Type.Type` entity branded
10084
+ * with the relation entity kind, i.e. what `Type.makeRelation(...)` produces.
9676
10085
  */
9677
- declare const type$1: {
9678
- <T$1 extends AnyEntity$1>(type: T$1, predicates?: Props$1<InstanceType$1<T$1>>): Query<InstanceType$1<T$1>>;
9679
- <S$1 extends UnknownTypeSchema<any, any>>(schema: S$1, predicates?: Props$1<Schema.Type<S$1>>): Query<Schema.Type<S$1>>;
9680
- <S$1 extends Union<readonly Schema.AnyNoContext[]>>(union: S$1, predicates?: Props$1<Schema.Type<S$1>>): Query<Schema.Type<S$1>>;
9681
- (uri: URI, predicates?: Props$1<unknown>): Query<any>;
9682
- };
10086
+ type AnyRelation = Relation<unknown, unknown, unknown>;
9683
10087
  /**
9684
- * Combine results of multiple queries.
9685
- * @param queries - Queries to combine.
9686
- * @returns Query for the combined results.
10088
+ * Type that represents any ECHO type-kind entity — a `Type.Type` meta-schema
10089
+ * value (static `Type.Type` or a persisted draft from `db.addType(...)`).
10090
+ * Mirrors {@link AnyObj} / {@link AnyRelation} for the third sibling kind.
9687
10091
  */
9688
- declare const all: (...queries: Any$1[]) => Any$1;
10092
+ type AnyType = Type$3<unknown>;
9689
10093
  /**
9690
- * Subtract one query from another.
9691
- * @param source - Query to subtract from.
9692
- * @param exclude - Query to subtract.
9693
- * @returns Query for the results of the source query minus the results of the exclude query.
10094
+ * Any ECHO type-entity — one of the three sibling kinds: object-kind, relation-kind,
10095
+ * or type-kind (the meta-schema). APIs that want "any ECHO type" use this union;
10096
+ * the underlying Effect Schema is retrieved via `Type.getSchema`.
9694
10097
  */
9695
- declare const without: <T$1>(source: Query<T$1>, exclude: Query<T$1>) => Query<T$1>;
10098
+ type AnyEntity$1 = AnyObj | AnyRelation | AnyType;
9696
10099
  /**
9697
- * Create a query scoped to a data source.
9698
- * The returned query selects everything from the source; chain `.select()` to narrow results.
10100
+ * String key used to phantom-carry the instance type produced by a `Type.Type`.
10101
+ * Used by `Type.InstanceType<typeof Foo>` to recover the schema instance type
10102
+ * since `Type.makeObject(dxn)` does not return a `Schema.Schema`.
9699
10103
  *
9700
- * @param source - Data source: database, feed, 'all-accessible-spaces', or another query.
9701
- * @returns Query scoped to the given source.
10104
+ * Re-exported from the internal types layer so both `Type.ts` and internal
10105
+ * helpers (`makeObject`, `createObject`) reference the same phantom key.
9702
10106
  */
9703
- declare const from: (...args: [(Database | Database[] | Feed | Feed[] | Any$1 | Scope | Scope[] | 'all-accessible-spaces'), {
9704
- includeFeeds?: boolean;
9705
- }?] | Scope[]) => Any$1;
10107
+ declare const InstancePhantomId: "~@dxos/echo/Type.Instance";
10108
+ type InstancePhantomId = InstancePhantomId$1;
9706
10109
  /**
9707
- * Returns a human-readable string representation of a Query AST.
10110
+ * Sibling of {@link Obj} / {@link Relation} for the third ECHO entity kind:
10111
+ * **type-kind** entities (meta-schemas). The singleton {@link Type} const is
10112
+ * the canonical example — it describes stored type definitions themselves.
10113
+ *
10114
+ * Not a `Schema.Schema`. Use `Type.getSchema(value)` to obtain the underlying
10115
+ * Effect Schema and `Type.update(value, draft => ...)` to mutate.
10116
+ *
10117
+ * `A` is the instance-type phantom — what `Obj.make(value, ...)` would produce.
10118
+ * Merged with the `Type` const value via TypeScript declaration merging.
10119
+ */
10120
+ interface Type$3<A$1 = unknown> extends BaseTypeEntity<A$1 & OfKind<typeof Kind.Type>> {
10121
+ /** Schema-kind brand (type — the meta-schema kind). */
10122
+ readonly [SchemaKindId]: EntityKind.Type;
10123
+ /** Source Effect Schema — used internally by `Type.getSchema(self)`. */
10124
+ readonly [StaticTypeSchemaSlot]: Schema.AnyNoContext;
10125
+ }
10126
+ /**
10127
+ * Instance type produced by a Type entity.
10128
+ *
10129
+ * Accepts ONLY {@link AnyEntity} inputs — `Type.Obj`, `Type.Relation`, or
10130
+ * `Type.Type`. Raw Effect `Schema.Schema` values are rejected: for those, use
10131
+ * `Schema.Schema.Type<typeof Foo>` directly. This separation keeps the type
10132
+ * system honest about which values represent ECHO entities versus plain
10133
+ * Effect schemas.
10134
+ *
10135
+ * Dispatches on the entity kind:
10136
+ * - `Relation<Props, S, T>` → `Endpoints<S,T> & Props & OfKind<Relation>`
10137
+ * - `Obj<A>` → `A & OfKind<Object>`
10138
+ * - `Type<A>` → `A & OfKind<Type>`
9708
10139
  */
9709
- declare const pretty: (query: Any$1) => string;
10140
+ type InstanceType$1<T$1 extends AnyEntity$1> = T$1 extends RelationClass<any, infer Props, infer Source, infer Target, any> ? Endpoints$1<Source, Target> & Props & OfKind<typeof Kind.Relation> : T$1 extends Relation<infer Props, infer Source, infer Target, any> ? Endpoints$1<Source, Target> & Props & OfKind<typeof Kind.Relation> : T$1 extends ObjClass<any, infer A, any> ? A & OfKind<typeof Kind.Object> : T$1 extends Obj$1<infer A, any> ? A & OfKind<typeof Kind.Object> : T$1 extends Type$3<infer A> ? A & OfKind<typeof Kind.Type> : never;
9710
10141
  //#endregion
9711
- //#region ../echo/dist/types/src/QueryResult.d.ts
10142
+ //#region ../echo/dist/types/src/internal/common/types/base.d.ts
9712
10143
  /**
9713
- * Individual query result entry.
10144
+ * Base type for all data objects (reactive, ECHO, and other raw objects).
10145
+ * NOTE: This describes the base type for all database objects.
10146
+ * It is stricter than `T extends {}` or `T extends object`.
9714
10147
  */
9715
- type Entry$1<T$1> = {
9716
- id: string;
9717
- /**
9718
- * May not be present for remote results.
9719
- */
9720
- result?: T$1;
9721
- match?: {
9722
- /**
9723
- * Higher means better match.
9724
- */
9725
- rank: number;
9726
- };
9727
- /**
9728
- * Query resolution metadata.
9729
- */
9730
- resolution?: {
9731
- source: 'remote' | 'local' | 'index';
9732
- /**
9733
- * Query resolution time in milliseconds.
9734
- */
9735
- time: number;
10148
+ type AnyProperties = Record<string, any>;
10149
+ /**
10150
+ * Canonical type for all ECHO entities (objects and relations).
10151
+ * @depreacted Remove, use Entity.Unknown instead.
10152
+ */
10153
+ interface AnyEntity {
10154
+ readonly id: EntityId;
10155
+ }
10156
+ //#endregion
10157
+ //#region ../echo/dist/types/src/internal/common/types/projection.d.ts
10158
+ /**
10159
+ * Brand for a query projected to a single scalar property (`Query.project`), consumed by
10160
+ * `Filter.in` to build a subquery-membership predicate — an uncorrelated
10161
+ * `col IN (SELECT property FROM ...)` semi-join. Defined in common/ (not in Query/) so
10162
+ * Filter.ts can recognize the brand without importing Query.ts as a value: Query.ts already
10163
+ * imports Filter.ts as a value, so a reverse value import would create a cycle. Both
10164
+ * Filter.ts and Query.ts import this shared leaf module instead.
10165
+ *
10166
+ * A string-literal id (not a `Symbol.for`), matching `FilterTypeId`/`QueryTypeId`/`OrderTypeId` —
10167
+ * this lets the sandboxed `query-lite` mirror (which cannot import `@dxos/echo`'s runtime) declare
10168
+ * its own local constant with the same literal and construct structurally-compatible objects,
10169
+ * the same way it already does for those brands.
10170
+ */
10171
+ declare const ProjectionTypeId$1: '~@dxos/echo/Query.Projection';
10172
+ type ProjectionTypeId$1 = typeof ProjectionTypeId$1;
10173
+ /**
10174
+ * `V` is the projected property's value type — carried only as a phantom brand (like
10175
+ * `Filter<T>`'s `[FilterTypeId]: { value: Types.Covariant<T> }`) so `Filter.in(query.project(k))`
10176
+ * infers its own type parameter from the projected property instead of defaulting to `unknown`.
10177
+ */
10178
+ interface Projection$1<V$1 = unknown> {
10179
+ readonly [ProjectionTypeId$1]: {
10180
+ value: Covariant<V$1>;
9736
10181
  };
9737
- };
9738
- type RunOptions = {
9739
- timeout?: number;
9740
- };
9741
- type SubscriptionOptions = {
9742
- /**
9743
- * Fire the callback immediately.
9744
- */
9745
- fire?: boolean;
9746
- };
9747
- interface QueryResult<T$1> {
9748
- /**
9749
- * Currently available results along with their match metadata.
9750
- */
9751
- readonly entries: Entry$1<T$1>[];
9752
- /**
9753
- * Currently available results.
9754
- */
9755
- readonly results: T$1[];
9756
- /**
9757
- * Returns all known results.
9758
- */
9759
- run(opts?: RunOptions): Promise<T$1[]>;
9760
- /**
9761
- * Returns all known results along with their match metadata.
9762
- */
9763
- runEntries(opts?: RunOptions): Promise<Entry$1<T$1>[]>;
9764
- /**
9765
- * Returns currently available results synchronously.
9766
- */
9767
- runSync(): T$1[];
9768
- /**
9769
- * Returns currently available results synchronously along with their match metadata.
9770
- */
9771
- runSyncEntries(): Entry$1<T$1>[];
9772
- /**
9773
- * Returns first result.
9774
- */
9775
- first(opts?: RunOptions): Promise<T$1>;
9776
- /**
9777
- * Returns first result if there is one.
9778
- */
9779
- firstOrUndefined(opts?: RunOptions): Promise<T$1 | undefined>;
9780
- /**
9781
- * Subscribes to changes in query results.
9782
- */
9783
- subscribe(callback?: (query: QueryResult<T$1>) => void, opts?: SubscriptionOptions): CleanupFn;
9784
- /**
9785
- * Self-updating atom. Updates automatically when query results change.
9786
- *
9787
- * Memoized per QueryResult instance — repeated accesses on the same instance return the same
9788
- * Atom. Safe only when the QueryResult is itself held stable across re-renders (e.g. behind a
9789
- * `useMemo`). It must NOT be used in graph-builder connectors/actions or other atom computes,
9790
- * where `db.query(...)` is called fresh on each re-evaluation: every run constructs a new
9791
- * QueryResult and so a new atom + subscription, leaking the previous ones. Use the memoized
9792
- * {@link atom} family there instead.
9793
- */
9794
- readonly atom: Atom<T$1[]>;
10182
+ readonly query: Query$1;
10183
+ readonly property: string;
9795
10184
  }
9796
10185
  //#endregion
9797
- //#region ../echo/dist/types/src/Feed.d.ts
9798
- declare const Feed_base: ObjClass<Feed, {
9799
- readonly name?: string | undefined;
9800
- readonly kind?: string | undefined;
9801
- readonly namespace?: "data" | "trace" | undefined;
9802
- }, {}>;
10186
+ //#region ../echo/dist/types/src/Entity.d.ts
10187
+ declare const KindId$1: "~@dxos/echo/Kind";
10188
+ type KindId$1 = typeof KindId;
10189
+ declare const SnapshotKindId: "~@dxos/echo/SnapshotKind";
10190
+ type SnapshotKindId = typeof SnapshotKindId$1;
10191
+ declare const Kind: typeof EntityKind;
10192
+ type Kind = EntityKind;
10193
+ /**
10194
+ * Assigns a kind to an Object or Relation instance.
10195
+ * NOTE: Needed to make `isRelation` and `isObject` checks work.
10196
+ */
10197
+ interface OfKind<K$1 extends Kind> {
10198
+ readonly [KindId$1]: K$1;
10199
+ readonly id: EntityId;
10200
+ }
10201
+ /**
10202
+ * Unknown Obj or Relation (reactive).
10203
+ */
10204
+ interface Unknown$1 extends OfKind<Kind> {}
10205
+ /**
10206
+ * Effect Schema for any ECHO entity (object or relation).
10207
+ *
10208
+ * Kind-agnostic counterpart to `Obj.Unknown` / `Relation.Unknown` — validates
10209
+ * the structural shape (id + properties) without constraining `[KindId]`. Used
10210
+ * in operation input schemas that accept any entity flavour (e.g.
10211
+ * `Schema.Array(Entity.Unknown)`).
10212
+ *
10213
+ * The cast bridges the runtime structural schema to the branded `Unknown` type:
10214
+ * `[KindId]` is a symbol brand that can't be expressed in a runtime `Struct`,
10215
+ * so the entity guarantee is carried at the type level only (same approach as
10216
+ * `Obj.Unknown` / `Relation.Unknown`). Unlike those, this is kind-agnostic so it
10217
+ * isn't an `UnknownTypeSchema<_, K>` (there's no single `K`) and carries no
10218
+ * `TypeAnnotation`.
10219
+ */
10220
+ declare const Unknown$1: Schema<Unknown$1>;
10221
+ //#endregion
10222
+ //#region ../echo/dist/types/src/Obj.d.ts
10223
+ /**
10224
+ * Base type for all ECHO objects.
10225
+ */
10226
+ interface BaseObj extends AnyEntity, OfKind<typeof Kind.Object> {}
10227
+ /**
10228
+ * Object type with specific properties.
10229
+ */
10230
+ type OfShape<Props$2> = BaseObj & Props$2;
10231
+ /**
10232
+ * Object with no known properties beyond id and kind.
10233
+ * Use this when the object's schema/properties are not known.
10234
+ * For objects with arbitrary properties, use `Obj.AnyProps`.
10235
+ *
10236
+ * NOTE: This is a TypeScript type only, not a schema.
10237
+ * To validate that a value is an ECHO object, use `Schema.is(Type.Obj)`.
10238
+ */
10239
+ interface Unknown extends BaseObj {}
9803
10240
  /**
9804
- * Runtime schema for a Feed object.
10241
+ * Runtime Effect schema for any ECHO object.
10242
+ * Use for validation, parsing, or as a reference target for collections.
10243
+ *
10244
+ * NOTE: `Schema.is(Type.Obj)` does STRUCTURAL validation only (checks for `id` field).
10245
+ * Use `Obj.isObject()` for proper ECHO instance type guards that check the KindId brand.
9805
10246
  *
9806
10247
  * @example
9807
10248
  * ```ts
9808
- * const feed = Obj.make(Feed.Feed, { name: 'notifications', kind: 'org.dxos.plugin.notifications.v1' });
10249
+ * // Structural type guard (accepts any object with id field)
10250
+ * if (Schema.is(Type.Obj)(unknownValue)) { ... }
10251
+ *
10252
+ * // ECHO instance type guard (checks KindId brand)
10253
+ * if (Obj.isObject(unknownValue)) { ... }
10254
+ *
10255
+ * // Reference to any object type
10256
+ * class Collection extends Type.makeObject<Collection>(DXN.make('com.example.type.collection', '0.1.0'))(
10257
+ * Schema.Struct({ objects: Schema.Array(Ref.Ref(Obj.Unknown)) }),
10258
+ * ) {}
9809
10259
  * ```
9810
10260
  */
9811
- declare class Feed extends Feed_base {}
10261
+ declare const Unknown: UnknownTypeSchema<Unknown, typeof Kind.Object>;
9812
10262
  /**
9813
- * Sync options for a feed.
10263
+ * Base type for snapshot objects (has SnapshotKindId instead of KindId).
9814
10264
  */
9815
- interface SyncOptions {
9816
- /** Push local changes to the server. Defaults to true. */
9817
- shouldPush?: boolean;
9818
- /** Pull remote changes from the server. Defaults to true. */
9819
- shouldPull?: boolean;
10265
+ interface BaseSnapshot extends AnyEntity {
10266
+ readonly [SnapshotKindId]: typeof Kind.Object;
10267
+ readonly id: EntityId;
9820
10268
  }
9821
10269
  /**
9822
- * Queue replication backlog for a feed namespace.
9823
- * `0` / `0` means caught up on pull and push.
10270
+ * Immutable snapshot of an ECHO object.
10271
+ * Branded with SnapshotKindId (not KindId).
10272
+ * Property values are frozen at the time the snapshot was created.
10273
+ * Returned by getSnapshot() and hooks like useObject().
10274
+ *
10275
+ * Snapshots are structurally identical to reactive objects but have a different brand,
10276
+ * making them distinguishable at the TypeScript level. Neither is assignable to the other.
9824
10277
  */
9825
- interface SyncState {
9826
- /** Blocks still to pull from remote. */
9827
- blocksToPull: number;
9828
- /** Unpositioned blocks still to push to remote. */
9829
- blocksToPush: number;
9830
- /** Total blocks stored locally for the feed namespace. */
9831
- totalBlocks: number;
9832
- }
10278
+ type Snapshot<T$1 extends Unknown = Unknown> = Omit<T$1, KindId$1> & BaseSnapshot;
9833
10279
  //#endregion
9834
- //#region ../echo/dist/types/src/Registry.d.ts
9835
- /**
9836
- * Identifier denoting an ECHO Registry.
9837
- */
9838
- declare const TypeId$1: unique symbol;
9839
- type TypeId$1 = typeof TypeId$1;
10280
+ //#region ../echo/dist/types/src/Blob.d.ts
10281
+ declare const Blob_base: ObjClass<Blob$1, {
10282
+ readonly type?: string | undefined;
10283
+ readonly size: number;
10284
+ readonly data: {
10285
+ readonly _tag: "inline";
10286
+ readonly bytes: Uint8Array<ArrayBufferLike>;
10287
+ } | {
10288
+ readonly _tag: "external";
10289
+ readonly uri: string;
10290
+ };
10291
+ }, {}>;
9840
10292
  /**
9841
- * Composable, in-memory registry of keyed ECHO entities.
9842
- *
9843
- * Entities are stored by id and queried via the standard ECHO Query API.
9844
- * A registry may delegate to an optional upstream registry: results from the local
9845
- * registry take precedence and upstream results fill in anything not found locally.
9846
- *
9847
- * Intended use cases include caches of schemas, operations, skills, routines, plugins,
9848
- * etc., sourced from 3rd-party plugins, local code, or local space objects.
10293
+ * Runtime schema for a Blob object.
9849
10294
  *
9850
- * Types (schema-definition entities produced by `Type.makeObject` / `Type.makeRelation`) are
9851
- * stored the same way as any other entity — via `add()`. Use `list().filter(Type.isType)` to
9852
- * retrieve them.
9853
- *
9854
- * Scope: a Registry is independent of any ECHO space or Hypergraph — it is a process-local,
9855
- * in-memory cache. Wire one per space (e.g. as a Layer scoped to the space's Effect runtime)
9856
- * or share a single instance across spaces depending on the use case.
10295
+ * NOTE: This export shadows the DOM `Blob` global within modules that import it as a namespace.
10296
+ * Code that needs the DOM class should use `globalThis.Blob` explicitly.
9857
10297
  *
9858
- * The concrete implementation (and the `makeRegistry` / `registryLayer` factories) lives in
9859
- * `@dxos/echo-client`; this module declares only the interface so that the `@dxos/echo` API surface
9860
- * stays free of query-matching dependencies.
10298
+ * @example
10299
+ * ```ts
10300
+ * const blob = yield* Blob.fromBytes(bytes, { type: 'image/png' });
10301
+ * ```
9861
10302
  */
9862
- interface Registry {
9863
- readonly [TypeId$1]: TypeId$1;
9864
- /**
9865
- * Stable per-instance identifier. Used to key process-local resources (e.g. memoized
9866
- * reactive atoms) to a specific registry instance, analogous to {@link Database.spaceId}.
9867
- */
9868
- readonly id: string;
9869
- /**
9870
- * Fires whenever local registry contents change (add, remove, or clear).
9871
- */
9872
- readonly changed: ReadOnlyEvent<void>;
9873
- /**
9874
- * All locally-stored entities.
9875
- * Does not include upstream entities — use {@link list} for that.
9876
- */
9877
- readonly local: readonly Unknown[];
9878
- /**
9879
- * Add or replace one or more entities in the local registry.
9880
- * Existing entries with the same id are replaced.
9881
- * Also indexes type entities by DXN for fast lookup.
9882
- */
9883
- add(entities: readonly Unknown[]): void;
9884
- /**
9885
- * Remove an entity by id from the local registry.
9886
- * @returns true if an entity was removed, false if it was not found.
9887
- */
9888
- remove(id: string): boolean;
9889
- /**
9890
- * Remove all locally-stored entities.
9891
- * Does not affect the upstream registry.
9892
- */
9893
- clear(): void;
9894
- /**
9895
- * Get an entity by id.
9896
- * Searches the local registry first, then falls back to the upstream registry.
9897
- */
9898
- get(id: string): Unknown | undefined;
9899
- /**
9900
- * Get an entity by one of its addressing URIs — a type entity by its typename DXN (or, when
9901
- * persisted, its identifier EID), a keyed entity by its `dxn:<key>[:<version>]`. Accepts legacy
9902
- * DXN forms (normalized internally). Searches the local registry first, then falls back to the
9903
- * upstream registry. Narrow the result with `Type.isType` when a type entity is required.
9904
- */
9905
- getByURI(uri: string): Unknown | undefined;
9906
- /**
9907
- * List all entities.
9908
- * Local entities take precedence over upstream entities with the same id.
9909
- */
9910
- list(): Unknown[];
9911
- /**
9912
- * Run an ECHO query against the registry's entities (implements {@link Database.Queryable}).
9913
- *
9914
- * Matching happens in-memory over {@link list}. Scope (`from`) clauses are unwrapped and
9915
- * ignored — a direct registry query always targets the registry's own entities. The primary
9916
- * way to query registry contents is still through the database (`db.query(...).from(Scope.registry())`),
9917
- * which fans the database and registry together; this method is for querying a registry directly.
9918
- *
9919
- * Only locally-evaluable AST nodes are supported: `select`, `filter`, `limit`, `from`, `options`,
9920
- * and boolean combinators. Server-side concerns (order, traversal, text/timestamp filters) throw.
9921
- */
9922
- query: QueryFn;
10303
+ declare class Blob$1 extends Blob_base {}
10304
+ declare namespace Filter_d_exports {
10305
+ export { Any$3 as Any, ChildOfOptions, Filter, FilterTypeId, KeyFilterOptions, Props$1 as Props, TextSearchOptions, Type$2 as Type, and, between, childOf, contains, created, eq, everything, foreignKeys, fromAst$1 as fromAst, gt, gte, id, in$ as in, is$1 as is, key$1 as key, lt, lte, neq, not, nothing, or, pretty$1 as pretty, props, tag, text, toPredicate, type$2 as type, updated };
9923
10306
  }
9924
- //#endregion
9925
- //#region ../echo/dist/types/src/Hypergraph.d.ts
9926
- /**
9927
- * Resolution context.
9928
- * Affects how non-absolute DXNs are resolved.
9929
- */
9930
- interface RefResolutionContext {
9931
- /**
9932
- * Space that the resolution is happening from.
9933
- */
9934
- space?: SpaceId;
9935
- /**
9936
- * Feed that the resolution is happening from.
9937
- * This feed will be searched first, and then the space it belongs to.
9938
- */
9939
- feed?: URI;
10307
+ declare const FilterTypeId: '~@dxos/echo/Filter';
10308
+ type FilterTypeId = typeof FilterTypeId;
10309
+ interface Filter<T$1> {
10310
+ readonly [FilterTypeId]: {
10311
+ value: Covariant<T$1>;
10312
+ };
10313
+ ast: Filter$1;
9940
10314
  }
9941
- interface RefResolverOptions {
9942
- /**
9943
- * Resolution context.
9944
- * Affects how non-absolute DXNs are resolved.
9945
- */
9946
- context?: RefResolutionContext;
10315
+ type Props$1<T$1> = { [K in keyof T$1 & string]?: Filter<T$1[K]> | T$1[K] };
10316
+ type Any$3 = Filter<any>;
10317
+ type Type$2<F extends Any$3> = F extends Filter<infer T> ? T : never;
10318
+ declare class FilterClass implements Any$3 {
10319
+ readonly ast: Filter$1;
10320
+ private static 'variance';
10321
+ constructor(ast: Filter$1);
10322
+ [FilterTypeId]: {
10323
+ value: Covariant<any>;
10324
+ };
9947
10325
  }
10326
+ declare const is$1: (value: unknown) => value is Any$3;
10327
+ /** Construct a filter from an ast. */
10328
+ declare const fromAst$1: (ast: Filter$1) => Any$3;
9948
10329
  /**
9949
- * Manages cross-space database interactions.
10330
+ * Filter that matches all objects.
9950
10331
  */
9951
- interface Hypergraph extends Queryable {
9952
- /**
9953
- * In-process registry of keyed objects and static schema types.
9954
- * Populated at startup via `registry.add(objects)` / `registry.add(schemas)`.
9955
- * Queries that include no explicit from() clause will fan out to this registry automatically.
9956
- */
9957
- get registry(): Registry;
9958
- /**
9959
- * Query objects.
9960
- */
9961
- query: QueryFn;
9962
- /**
9963
- * Creates a reference to an existing object in the database.
9964
- *
9965
- * NOTE: The reference may be dangling if the object is not present in the database.
9966
- * NOTE: Difference from `Ref.fromURI`
9967
- * `Ref.fromURI(dxn)` returns an unhydrated reference. The `.load` and `.target` APIs will not work.
9968
- * `db.makeRef(dxn)` is preferable in cases with access to the database.
9969
- */
9970
- makeRef<T$1 extends Unknown = Unknown>(uri: URI): Ref$1<T$1>;
9971
- /**
9972
- * Create a resolver that dereferences `Ref`s against this graph. Persisted schema objects are
9973
- * surfaced as their registered `Type.Type` entity.
9974
- */
9975
- createRefResolver(options: RefResolverOptions): Resolver;
10332
+ declare const everything: () => FilterClass;
10333
+ /**
10334
+ * Filter that matches no objects.
10335
+ */
10336
+ declare const nothing: () => FilterClass;
10337
+ declare const id: (...ids: EntityId[]) => Any$3;
10338
+ /**
10339
+ * Filter by type.
10340
+ *
10341
+ * Accepts a `Type.Type` entity (the value produced by `Type.makeObject` /
10342
+ * `Type.makeRelation`), a `Schema.Union` of such entities (for filtering across a
10343
+ * union of ECHO types), or a fully-qualified type URI — an `echo:` EID (stored schema)
10344
+ * or a `dxn:` DXN (static schema). To filter by a bare typename, wrap it: `DXN.make(typename)`.
10345
+ */
10346
+ declare const type$2: {
10347
+ <T$1 extends AnyEntity$1>(type: T$1, props?: Props$1<InstanceType$1<T$1>>): Filter<InstanceType$1<T$1>>;
10348
+ <S$1 extends UnknownTypeSchema<any, any>>(schema: S$1, props?: Props$1<Schema.Type<S$1>>): Filter<Schema.Type<S$1>>;
10349
+ <S$1 extends Union<readonly Schema.AnyNoContext[]>>(union: S$1, props?: Props$1<Schema.Type<S$1>>): Filter<Schema.Type<S$1>>;
10350
+ (uri: URI, props?: Props$1<unknown>): Filter<any>;
10351
+ (input: AnyEntity$1 | URI, props?: Props$1<unknown>): Filter<unknown>;
10352
+ };
10353
+ /**
10354
+ * Filter by tag.
10355
+ */
10356
+ declare const tag: (tag: string) => Any$3;
10357
+ /**
10358
+ * Options for {@link key} filter.
10359
+ */
10360
+ type KeyFilterOptions = {
9976
10361
  /**
9977
- * Get a database by space ID.
9978
- * @returns The database for the given space ID, or undefined if not found.
10362
+ * Optional semver range expression (e.g. `^1.2.3`, `~2.0.0`, `>=1.0.0 <2.0.0`).
10363
+ * Matches the object's meta `version` field against the range.
10364
+ * If omitted, matches any version (including objects with no version).
9979
10365
  */
9980
- getDatabase(spaceId: SpaceId): Database | undefined;
9981
- }
9982
- //#endregion
9983
- //#region ../echo/dist/types/src/Database.d.ts
10366
+ version?: string;
10367
+ };
10368
+ /**
10369
+ * Filter by registry key stored in object meta.
10370
+ *
10371
+ * @example
10372
+ * ```ts
10373
+ * Filter.key('org.example.type.foo');
10374
+ * Filter.key('org.example.type.foo', { version: '^1.2.3' });
10375
+ * ```
10376
+ */
10377
+ declare const key$1: (key: string, options?: KeyFilterOptions) => Any$3;
10378
+ /**
10379
+ * Filter by properties.
10380
+ */
10381
+ declare const props: <T$1>(props: Props$1<T$1>) => Filter<T$1>;
10382
+ type TextSearchOptions = {
10383
+ type?: 'full-text' | 'vector';
10384
+ };
10385
+ /**
10386
+ * Full-text or vector search.
10387
+ */
10388
+ declare const text: (text: string, options?: TextSearchOptions) => Any$3;
10389
+ /**
10390
+ * Filter by foreign keys.
10391
+ */
10392
+ declare const foreignKeys: <S$1 extends AnyEntity$1 | URI>(schema: S$1, keys: ForeignKey[]) => Filter<S$1 extends AnyEntity$1 ? InstanceType$1<S$1> : unknown>;
10393
+ /**
10394
+ * Predicate for property to be equal to the provided value.
10395
+ */
10396
+ declare const eq: <T$1>(value: T$1) => Filter<T$1 | undefined>;
9984
10397
  /**
9985
- * `query` API function declaration.
10398
+ * Predicate for property to be not equal to the provided value.
9986
10399
  */
9987
- interface QueryFn {
9988
- <Q extends Any$1>(query: Q): QueryResult<Type$2<Q>>;
9989
- <F extends Any$3>(filter: F): QueryResult<Type$3<F>>;
9990
- }
10400
+ declare const neq: <T$1>(value: T$1) => Filter<T$1 | undefined>;
9991
10401
  /**
9992
- * Common interface for Database, Feed, and Hypergraph.
10402
+ * Predicate for property to be greater than the provided value.
9993
10403
  */
9994
- interface Queryable {
9995
- query: QueryFn;
9996
- }
9997
- type GetObjectByIdOptions = {
9998
- deleted?: boolean;
10404
+ declare const gt: <T$1>(value: T$1) => Filter<T$1 | undefined>;
10405
+ /**
10406
+ * Predicate for property to be greater than or equal to the provided value.
10407
+ */
10408
+ declare const gte: <T$1>(value: T$1) => Filter<T$1 | undefined>;
10409
+ /**
10410
+ * Predicate for property to be less than the provided value.
10411
+ */
10412
+ declare const lt: <T$1>(value: T$1) => Filter<T$1 | undefined>;
10413
+ /**
10414
+ * Predicate for property to be less than or equal to the provided value.
10415
+ */
10416
+ declare const lte: <T$1>(value: T$1) => Filter<T$1 | undefined>;
10417
+ /**
10418
+ * Predicate for property to be in the provided array, or in the set of values projected
10419
+ * from a subquery's results (an uncorrelated `col IN (SELECT property FROM ...)` semi-join —
10420
+ * see `Query.project`). The subquery may target a different scope than the parent query; it
10421
+ * is resolved once at execution time.
10422
+ * @param values - Values to check against, or a single subquery projection.
10423
+ */
10424
+ declare const in$: {
10425
+ <T$1>(projection: Projection$1<T$1>): Filter<T$1>;
10426
+ <T$1>(...values: T$1[]): Filter<T$1>;
9999
10427
  };
10000
- type ObjectPlacement = 'root-doc' | 'linked-doc';
10001
- type AddOptions = {
10002
- /**
10003
- * Where to place the object in the Automerge document tree.
10004
- * Root document is always loaded with the space.
10005
- * Linked documents are loaded lazily.
10006
- * Placing large number of objects in the root document may slow down the initial load.
10007
- *
10008
- * @default 'linked-doc'
10009
- */
10010
- placeIn?: ObjectPlacement;
10428
+ /**
10429
+ * Predicate for an array property to contain the provided value.
10430
+ * @param value - Value to check against.
10431
+ */
10432
+ declare const contains: <T$1>(value: T$1) => Filter<readonly T$1[] | undefined>;
10433
+ /**
10434
+ * Predicate for property to be in the provided range.
10435
+ * @param from - Start of the range (inclusive).
10436
+ * @param to - End of the range (exclusive).
10437
+ */
10438
+ declare const between: <T$1>(from: T$1, to: T$1) => Filter<T$1>;
10439
+ type TimeRange = {
10440
+ after?: Date | number;
10441
+ before?: Date | number;
10011
10442
  };
10012
10443
  /**
10013
- * Rejects Type entities from {@link Database.add} at compile time via their `[KindId]` brand. Used
10014
- * as `T & RejectTypeEntity<T>` to preserve inference of `T`. Bounding `add` on
10015
- * `Obj.Unknown | Relation.Unknown` instead would reject broadly-typed instance adds (e.g.
10016
- * `Entity.Any`, `Obj.OfShape<T>`), forcing casts repo-wide.
10444
+ * Filter objects by updatedAt timestamp.
10017
10445
  */
10018
- type RejectTypeEntity<T$1> = T$1 extends {
10019
- readonly [KindId$1]: EntityKind.Type;
10020
- } ? {
10021
- __error: 'Type entities must be persisted via db.addType(), not db.add().';
10022
- } : T$1;
10023
- type FlushOptions = {
10024
- /**
10025
- * Write any pending changes to disk.
10026
- * @default true
10027
- */
10028
- disk?: boolean;
10029
- /**
10030
- * Wait for pending index updates.
10031
- * @default true
10032
- */
10033
- indexes?: boolean;
10034
- /**
10035
- * Flush pending updates to objects and queries.
10036
- * @default false
10037
- */
10038
- updates?: boolean;
10446
+ declare const updated: (range: TimeRange) => Any$3;
10447
+ /**
10448
+ * Filter objects by createdAt timestamp.
10449
+ */
10450
+ declare const created: (range: TimeRange) => Any$3;
10451
+ type ChildOfOptions = {
10452
+ /** Whether to match transitively (grandchildren, etc.). Defaults to true. */
10453
+ transitive?: boolean;
10039
10454
  };
10040
10455
  /**
10041
- * Identifier denoting an ECHO Database.
10456
+ * Filter objects that are children of the specified parent(s).
10457
+ * Accepts ECHO objects, Refs, or arrays of either.
10458
+ * Refs are resolved to DXNs without loading; objects use {@link Obj.getURI}.
10459
+ * With transitive=true (default), also matches grandchildren and beyond.
10042
10460
  */
10043
- declare const TypeId: unique symbol;
10044
- type TypeId = typeof TypeId;
10461
+ declare const childOf: (parents: Unknown | Unknown$3 | readonly (Unknown | Unknown$3)[], options?: ChildOfOptions) => Any$3;
10045
10462
  /**
10046
- * ECHO Database interface.
10463
+ * Negate the filter.
10047
10464
  */
10048
- interface Database extends Queryable {
10049
- readonly [TypeId]: TypeId;
10050
- get spaceId(): SpaceId;
10051
- get graph(): Hypergraph;
10052
- /**
10053
- * Registry for this database. Delegates type lookups to the shared hypergraph registry.
10054
- * To persist a schema so it replicates to other clients, add the type entity with
10055
- * {@link addType} (e.g. `await db.addType(Type.makeObjectFromJsonSchema(...))`).
10056
- */
10057
- readonly registry: Registry;
10058
- toJSON(): object;
10465
+ declare const not: <F extends Any$3>(filter: F) => Filter<Type$2<F>>;
10466
+ /**
10467
+ * Combine filters with a logical AND.
10468
+ */
10469
+ declare const and: <Filters extends readonly Any$3[]>(...filters: Filters) => Filter<Type$2<Filters[number]>>;
10470
+ /**
10471
+ * Combine filters with a logical OR.
10472
+ */
10473
+ declare const or: <Filters extends readonly Any$3[]>(...filters: Filters) => Filter<Type$2<Filters[number]>>;
10474
+ /**
10475
+ * Returns a human-readable string representation of a Filter AST.
10476
+ */
10477
+ declare const pretty$1: (filter: Any$3) => string;
10478
+ /**
10479
+ * Create a predicate from a filter.
10480
+ */
10481
+ declare const toPredicate: {
10482
+ <T$1 extends Unknown$1>(filter: Filter<T$1>): (entity: Unknown$1) => entity is T$1;
10483
+ <T$1 extends Unknown$1>(entity: Unknown$1, filter: Filter<T$1>): entity is T$1;
10484
+ };
10485
+ //#endregion
10486
+ //#region ../echo/dist/types/src/QueryResult.d.ts
10487
+ /**
10488
+ * Individual query result entry.
10489
+ */
10490
+ type Entry$1<T$1> = {
10491
+ id: string;
10059
10492
  /**
10060
- * Return object by local ID.
10061
- * @deprecated Use `db.query(Filter.id(id)).runSync()[0]` for a working-set lookup, or resolve via a {@link Ref}.
10493
+ * May not be present for remote results.
10062
10494
  */
10063
- getObjectById<T$1 extends Unknown$1 = OfShape<AnyProperties>>(id: string, opts?: GetObjectByIdOptions): T$1 | undefined;
10495
+ result?: T$1;
10496
+ match?: {
10497
+ /**
10498
+ * Higher means better match.
10499
+ */
10500
+ rank: number;
10501
+ };
10064
10502
  /**
10065
- * Query objects.
10503
+ * Query resolution metadata.
10066
10504
  */
10067
- query: QueryFn;
10505
+ resolution?: {
10506
+ source: 'remote' | 'local' | 'index';
10507
+ /**
10508
+ * Query resolution time in milliseconds.
10509
+ */
10510
+ time: number;
10511
+ };
10512
+ };
10513
+ type RunOptions = {
10514
+ timeout?: number;
10515
+ };
10516
+ type SubscriptionOptions = {
10068
10517
  /**
10069
- * Creates a reference to an existing object in the database.
10070
- *
10071
- * NOTE: The reference may be dangling if the object is not present in the database.
10072
- * NOTE: Difference from `Ref.fromURI`
10073
- * `Ref.fromURI(dxn)` returns an unhydrated reference. The `.load` and `.target` APIs will not work.
10074
- * `db.makeRef(dxn)` is preferable in cases with access to the database.
10518
+ * Fire the callback immediately.
10075
10519
  */
10076
- makeRef<T$1 extends Unknown = Unknown>(uri: URI): Ref<T$1>;
10520
+ fire?: boolean;
10521
+ };
10522
+ interface QueryResult<T$1> {
10077
10523
  /**
10078
- * Adds an object or relation to the database.
10079
- *
10080
- * Only Object and Relation entities are accepted. To persist a Type definition use
10081
- * {@link addType} — passing a Type entity is rejected at compile time (and at runtime).
10524
+ * Currently available results along with their match metadata.
10082
10525
  */
10083
- add<T$1 extends Unknown = Unknown>(obj: T$1 & RejectTypeEntity<T$1>, opts?: AddOptions): T$1;
10526
+ readonly entries: Entry$1<T$1>[];
10084
10527
  /**
10085
- * Persists a Type definition (clones/forks the entity) so it replicates to other peers.
10086
- *
10087
- * Runs a conflict query first: if a type with the same typename + version already exists in
10088
- * this space, the existing persisted entity is returned and no duplicate is created. This is
10089
- * the only supported way to add Type entities — {@link add} rejects them.
10528
+ * Currently available results.
10090
10529
  */
10091
- addType<T$1 extends AnyEntity$1>(type: T$1): Promise<T$1>;
10530
+ readonly results: T$1[];
10092
10531
  /**
10093
- * Removes object from the database.
10532
+ * Returns all known results.
10094
10533
  */
10095
- remove(obj: Unknown): void;
10534
+ run(opts?: RunOptions): Promise<T$1[]>;
10096
10535
  /**
10097
- * Appends entities to a feed.
10098
- *
10099
- * The feed must already be stored in the database (added via {@link add}); its underlying
10100
- * queue is addressed by the feed object's URI.
10536
+ * Returns all known results along with their match metadata.
10101
10537
  */
10102
- appendToFeed(feed: Feed, entities: Unknown[]): Promise<void>;
10538
+ runEntries(opts?: RunOptions): Promise<Entry$1<T$1>[]>;
10103
10539
  /**
10104
- * Removes entities from a feed.
10540
+ * Returns currently available results synchronously.
10105
10541
  */
10106
- deleteFromFeed(feed: Feed, entities: Unknown[]): Promise<void>;
10542
+ runSync(): T$1[];
10107
10543
  /**
10108
- * Wait for all pending changes to be saved to disk.
10109
- * Optionaly waits for changes to be propagated to indexes and event handlers.
10544
+ * Returns currently available results synchronously along with their match metadata.
10110
10545
  */
10111
- flush(opts?: FlushOptions): Promise<void>;
10546
+ runSyncEntries(): Entry$1<T$1>[];
10112
10547
  /**
10113
- * Removes feed items by ID.
10548
+ * Returns first result.
10114
10549
  */
10115
- removeFeedItemsByIds(feed: Feed, ids: string[]): Promise<void>;
10550
+ first(opts?: RunOptions): Promise<T$1>;
10116
10551
  /**
10117
- * Queries items in a feed associated with this database.
10552
+ * Returns first result if there is one.
10118
10553
  */
10119
- queryFeed(feed: Feed, queryOrFilter: Any$1 | Any$3): QueryResult<any>;
10554
+ firstOrUndefined(opts?: RunOptions): Promise<T$1 | undefined>;
10120
10555
  /**
10121
- * Syncs a feed with the server.
10556
+ * Subscribes to changes in query results.
10122
10557
  */
10123
- syncFeed(feed: Feed, options?: SyncOptions): Promise<void>;
10558
+ subscribe(callback?: (query: QueryResult<T$1>) => void, opts?: SubscriptionOptions): CleanupFn;
10124
10559
  /**
10125
- * Returns queue replication backlog for the feed's namespace.
10560
+ * Self-updating atom. Updates automatically when query results change.
10561
+ *
10562
+ * Memoized per QueryResult instance — repeated accesses on the same instance return the same
10563
+ * Atom. Safe only when the QueryResult is itself held stable across re-renders (e.g. behind a
10564
+ * `useMemo`). It must NOT be used in graph-builder connectors/actions or other atom computes,
10565
+ * where `db.query(...)` is called fresh on each re-evaluation: every run constructs a new
10566
+ * QueryResult and so a new atom + subscription, leaking the previous ones. Use the memoized
10567
+ * {@link atom} family there instead.
10126
10568
  */
10127
- getFeedSyncState(feed: Feed): Promise<SyncState>;
10569
+ readonly atom: Atom<T$1[]>;
10128
10570
  }
10129
- declare const Database: Schema<Database>;
10130
10571
  //#endregion
10131
- //#region ../echo/dist/types/src/internal/JsonSchema/json-schema-type.d.ts
10572
+ //#region ../echo/dist/types/src/Feed.d.ts
10573
+ declare const Feed_base: ObjClass<Feed, {
10574
+ readonly name?: string | undefined;
10575
+ readonly kind?: string | undefined;
10576
+ readonly namespace?: "data" | "trace" | undefined;
10577
+ readonly rewindFrom?: string | undefined;
10578
+ }, {}>;
10579
+ /**
10580
+ * Runtime schema for a Feed object.
10581
+ *
10582
+ * @example
10583
+ * ```ts
10584
+ * const feed = Obj.make(Feed.Feed, { name: 'notifications', kind: 'org.dxos.plugin.notifications.v1' });
10585
+ * ```
10586
+ */
10587
+ declare class Feed extends Feed_base {}
10588
+ /**
10589
+ * Sync options for a feed.
10590
+ */
10591
+ interface SyncOptions {
10592
+ /** Push local changes to the server. Defaults to true. */
10593
+ shouldPush?: boolean;
10594
+ /** Pull remote changes from the server. Defaults to true. */
10595
+ shouldPull?: boolean;
10596
+ }
10597
+ /**
10598
+ * Queue replication backlog for a feed namespace.
10599
+ * `0` / `0` means caught up on pull and push.
10600
+ */
10601
+ interface SyncState$1 {
10602
+ /** Blocks still to pull from remote. */
10603
+ blocksToPull: number;
10604
+ /** Unpositioned blocks still to push to remote. */
10605
+ blocksToPush: number;
10606
+ /** Total blocks stored locally for the feed namespace. */
10607
+ totalBlocks: number;
10608
+ }
10609
+ //#endregion
10610
+ //#region ../echo/dist/types/src/Registry.d.ts
10611
+ /**
10612
+ * Identifier denoting an ECHO Registry.
10613
+ */
10614
+ declare const TypeId$1: unique symbol;
10615
+ type TypeId$1 = typeof TypeId$1;
10132
10616
  /**
10133
- * Describes a schema for the JSON-schema objects stored in ECHO.
10134
- * Contains extensions for ECHO (e.g., references).
10135
- * Ref: https://json-schema.org/draft-07/schema
10617
+ * Composable, in-memory registry of keyed ECHO entities.
10618
+ *
10619
+ * Entities are stored by id and queried via the standard ECHO Query API.
10620
+ * A registry may delegate to an optional upstream registry: results from the local
10621
+ * registry take precedence and upstream results fill in anything not found locally.
10622
+ *
10623
+ * Intended use cases include caches of schemas, operations, skills, routines, plugins,
10624
+ * etc., sourced from 3rd-party plugins, local code, or local space objects.
10625
+ *
10626
+ * Types (schema-definition entities produced by `Type.makeObject` / `Type.makeRelation`) are
10627
+ * stored the same way as any other entity — via `add()`. Use `list().filter(Type.isType)` to
10628
+ * retrieve them.
10629
+ *
10630
+ * Scope: a Registry is independent of any ECHO space or Hypergraph — it is a process-local,
10631
+ * in-memory cache. Wire one per space (e.g. as a Layer scoped to the space's Effect runtime)
10632
+ * or share a single instance across spaces depending on the use case.
10633
+ *
10634
+ * The concrete implementation (and the `makeRegistry` / `registryLayer` factories) lives in
10635
+ * `@dxos/echo-client`; this module declares only the interface so that the `@dxos/echo` API surface
10636
+ * stays free of query-matching dependencies.
10136
10637
  */
10137
- declare const _JsonSchemaType: Struct<{
10138
- /**
10139
- * Identifier for this schema.
10140
- * This schema might be referenced by $ref clause in other schemas.
10141
- */
10142
- $id: optional<typeof String$>;
10143
- /**
10144
- * Schema of this schema.
10145
- * Set to "https://json-schema.org/draft-07/schema".
10146
- */
10147
- $schema: optional<typeof String$>;
10148
- /**
10149
- * Reference to another schema.
10150
- */
10151
- $ref: optional<typeof String$>;
10152
- /**
10153
- * Comments are ignored when interpreting the schema.
10154
- */
10155
- $comment: optional<typeof String$>;
10156
- /**
10157
- * Defines whether this schema is an object schema or a relation schema.
10158
- */
10159
- entityKind: optional<Enums<typeof EntityKind>>;
10160
- /**
10161
- * Typename of this schema.
10162
- * Only on schema representing an ECHO object.
10163
- *
10164
- * @example 'com.example.type.my-type'
10165
- */
10166
- typename: optional<typeof String$>;
10167
- /**
10168
- * Version of this schema.
10169
- * Custom dialect for ECHO.
10170
- */
10171
- version: optional<typeof String$>;
10172
- /**
10173
- * Target of this relation.
10174
- * Only for relation schemas.
10175
- * The referenced schema must be an object schema.
10176
- */
10177
- relationTarget: optional<suspend<JsonSchemaType, JsonSchemaType, never>>;
10178
- /**
10179
- * Source of this relation.
10180
- * Only for relation schemas.
10181
- * The referenced schema must be an object schema.
10182
- */
10183
- relationSource: optional<suspend<JsonSchemaType, JsonSchemaType, never>>;
10184
- /**
10185
- * Title of this schema.
10186
- */
10187
- title: optional<typeof String$>;
10638
+ interface Registry {
10639
+ readonly [TypeId$1]: TypeId$1;
10188
10640
  /**
10189
- * Description of this schema.
10641
+ * Stable per-instance identifier. Used to key process-local resources (e.g. memoized
10642
+ * reactive atoms) to a specific registry instance, analogous to {@link Database.spaceId}.
10190
10643
  */
10191
- description: optional<typeof String$>;
10644
+ readonly id: string;
10192
10645
  /**
10193
- * Whether this schema is read-only.
10646
+ * Fires whenever local registry contents change (add, remove, or clear).
10194
10647
  */
10195
- readOnly: optional<typeof Boolean$>;
10648
+ readonly changed: ReadOnlyEvent<void>;
10196
10649
  /**
10197
- * Whether this schema is write-only.
10650
+ * All locally-stored entities.
10651
+ * Does not include upstream entities — use {@link list} for that.
10198
10652
  */
10199
- writeOnly: optional<typeof Boolean$>;
10653
+ readonly local: readonly Unknown$1[];
10200
10654
  /**
10201
- * Examples of instances of this schema.
10655
+ * Add or replace one or more entities in the local registry.
10656
+ * Existing entries with the same id are replaced.
10657
+ * Also indexes type entities by DXN for fast lookup.
10202
10658
  */
10203
- examples: optional<Array$<typeof Any$4>>;
10659
+ add(entities: readonly Unknown$1[]): void;
10204
10660
  /**
10205
- * Default value for this schema.
10661
+ * Remove an entity by id from the local registry.
10662
+ * @returns true if an entity was removed, false if it was not found.
10206
10663
  */
10207
- default: optional<typeof Any$4>;
10664
+ remove(id: string): boolean;
10208
10665
  /**
10209
- * This schema only matches values that are equal to this value.
10666
+ * Remove all locally-stored entities.
10667
+ * Does not affect the upstream registry.
10210
10668
  */
10211
- const: optional<typeof Any$4>;
10669
+ clear(): void;
10212
10670
  /**
10213
- * This schema only matches one of the values in this array.
10671
+ * Get an entity by id.
10672
+ * Searches the local registry first, then falls back to the upstream registry.
10214
10673
  */
10215
- enum: optional<Array$<typeof Any$4>>;
10674
+ get(id: string): Unknown$1 | undefined;
10216
10675
  /**
10217
- * Base type of the schema.
10676
+ * Get an entity by one of its addressing URIs — a type entity by its typename DXN (or, when
10677
+ * persisted, its identifier EID), a keyed entity by its `dxn:<key>[:<version>]`. Accepts legacy
10678
+ * DXN forms (normalized internally). Searches the local registry first, then falls back to the
10679
+ * upstream registry. Narrow the result with `Type.isType` when a type entity is required.
10218
10680
  */
10219
- type: optional<Union<[Literal<["array", "boolean", "integer", "null", "number", "object", "string"]>, Array$<Literal<["array", "boolean", "integer", "null", "number", "object", "string"]>>]>>;
10220
- multipleOf: optional<filter<typeof Number$>>;
10221
- maximum: optional<typeof Number$>;
10222
- exclusiveMaximum: optional<typeof Number$>;
10223
- minimum: optional<typeof Number$>;
10224
- exclusiveMinimum: optional<typeof Number$>;
10225
- maxLength: optional<filter<typeof Number$>>;
10681
+ getByURI(uri: string): Unknown$1 | undefined;
10226
10682
  /**
10227
- * Regex pattern for strings.
10683
+ * List all entities.
10684
+ * Local entities take precedence over upstream entities with the same id.
10228
10685
  */
10229
- pattern: optional<typeof String$>;
10686
+ list(): Unknown$1[];
10230
10687
  /**
10231
- * Serialized from {@link FormatAnnotationId}.
10688
+ * Run an ECHO query against the registry's entities (implements {@link Database.Queryable}).
10689
+ *
10690
+ * Matching happens in-memory over {@link list}. Scope (`from`) clauses are unwrapped and
10691
+ * ignored — a direct registry query always targets the registry's own entities. The primary
10692
+ * way to query registry contents is still through the database (`db.query(...).from(Scope.registry())`),
10693
+ * which fans the database and registry together; this method is for querying a registry directly.
10694
+ *
10695
+ * Only locally-evaluable AST nodes are supported: `select`, `filter`, `limit`, `from`, `options`,
10696
+ * and boolean combinators. Server-side concerns (order, traversal, text/timestamp filters) throw.
10232
10697
  */
10233
- format: optional<typeof String$>;
10234
- minLength: optional<filter<typeof Number$>>;
10235
- items: optional<Union<[suspend<JsonSchemaType, JsonSchemaType, never>, Array$<suspend<JsonSchemaType, JsonSchemaType, never>>]>>;
10236
- additionalItems: optional<Union<[suspend<JsonSchemaType, JsonSchemaType, never>, typeof Boolean$]>>;
10237
- maxItems: optional<filter<typeof Number$>>;
10238
- minItems: optional<filter<typeof Number$>>;
10239
- uniqueItems: optional<typeof Boolean$>;
10240
- contains: optional<suspend<JsonSchemaType, JsonSchemaType, never>>;
10241
- maxProperties: optional<filter<typeof Number$>>;
10242
- minProperties: optional<filter<typeof Number$>>;
10243
- required: optional<Array$<typeof String$>>;
10698
+ query: QueryFn;
10699
+ }
10700
+ //#endregion
10701
+ //#region ../echo/dist/types/src/Hypergraph.d.ts
10702
+ /**
10703
+ * Resolution context.
10704
+ * Affects how non-absolute DXNs are resolved.
10705
+ */
10706
+ interface RefResolutionContext {
10244
10707
  /**
10245
- * Non-standard JSON Schema extension.
10246
- * Defines the order of properties in the object.
10247
- * The unmentioned properties are placed at the end.
10248
- *
10249
- * Related: https://github.com/json-schema/json-schema/issues/119
10708
+ * Space that the resolution is happening from.
10250
10709
  */
10251
- propertyOrder: optional<Array$<typeof String$>>;
10252
- additionalProperties: optional<Union<[suspend<JsonSchemaType, JsonSchemaType, never>, typeof Boolean$]>>;
10253
- properties: optional<Record$<typeof String$, suspend<JsonSchemaType, JsonSchemaType, never>>>;
10254
- patternProperties: optional<Record$<typeof String$, suspend<JsonSchemaType, JsonSchemaType, never>>>;
10255
- propertyNames: optional<suspend<JsonSchemaType, JsonSchemaType, never>>;
10256
- definitions: optional<Record$<typeof String$, suspend<JsonSchemaType, JsonSchemaType, never>>>;
10257
- dependencies: optional<Record$<typeof String$, suspend<string | JsonSchemaType | readonly string[], string | JsonSchemaType | readonly string[], never>>>;
10258
- contentMediaType: optional<typeof String$>;
10259
- contentEncoding: optional<typeof String$>;
10260
- if: optional<suspend<JsonSchemaType, JsonSchemaType, never>>;
10261
- then: optional<suspend<JsonSchemaType, JsonSchemaType, never>>;
10262
- else: optional<suspend<JsonSchemaType, JsonSchemaType, never>>;
10263
- allOf: optional<Array$<suspend<JsonSchemaType, JsonSchemaType, never>>>;
10264
- anyOf: optional<Array$<suspend<JsonSchemaType, JsonSchemaType, never>>>;
10265
- oneOf: optional<Array$<suspend<JsonSchemaType, JsonSchemaType, never>>>;
10266
- not: optional<suspend<JsonSchemaType, JsonSchemaType, never>>;
10267
- $defs: optional<Record$<typeof String$, suspend<JsonSchemaType, JsonSchemaType, never>>>;
10268
- currency: optional<typeof String$>;
10269
- reference: optional<Struct<{
10270
- schema: suspend<JsonSchemaType, JsonSchemaType, never>;
10271
- schemaVersion: optional<typeof String$>;
10272
- schemaObject: optional<typeof String$>;
10273
- }>>;
10710
+ space?: SpaceId;
10274
10711
  /**
10275
- * ECHO-specific annotations.
10712
+ * Feed that the resolution is happening from.
10713
+ * This feed will be searched first, and then the space it belongs to.
10276
10714
  */
10277
- annotations: optional<Struct<{
10278
- /**
10279
- * Label for this schema.
10280
- * Mapped from {@link LabelAnnotationId}.
10281
- */
10282
- labelProp: optional<Union<[Schema<JsonPath, JsonPath, never>, Array$<Schema<JsonPath, JsonPath, never>>]>>;
10283
- /**
10284
- * Generator function for this schema.
10285
- * Mapped from {@link GeneratorAnnotationId}.
10286
- */
10287
- generator: optional<Union<[typeof String$, Tuple2<typeof String$, typeof Number$>]>>;
10288
- /**
10289
- * {@link PropertyMeta} annotations get serialized here.
10290
- */
10291
- meta: optional<Record$<typeof String$, typeof Any$4>>;
10292
- /**
10293
- * @deprecated
10294
- */
10295
- type: optional<Struct<{
10296
- typename: typeof String$;
10297
- version: typeof String$;
10298
- schemaId: optional<typeof String$>;
10299
- }>>;
10300
- /**
10301
- * @deprecated Superseded by `meta`.
10302
- */
10303
- annotations: optional<Record$<typeof String$, typeof Any$4>>;
10304
- }>>;
10715
+ feed?: URI;
10716
+ }
10717
+ interface RefResolverOptions {
10305
10718
  /**
10306
- * @deprecated Use `annotations` instead.
10719
+ * Resolution context.
10720
+ * Affects how non-absolute DXNs are resolved.
10307
10721
  */
10308
- echo: optional<Struct<{
10309
- /**
10310
- * Label for this schema.
10311
- * Mapped from {@link LabelAnnotationId}.
10312
- */
10313
- labelProp: optional<Union<[Schema<JsonPath, JsonPath, never>, Array$<Schema<JsonPath, JsonPath, never>>]>>;
10314
- /**
10315
- * Generator function for this schema.
10316
- * Mapped from {@link GeneratorAnnotationId}.
10317
- */
10318
- generator: optional<Union<[typeof String$, Tuple2<typeof String$, typeof Number$>]>>;
10319
- /**
10320
- * {@link PropertyMeta} annotations get serialized here.
10321
- */
10322
- meta: optional<Record$<typeof String$, typeof Any$4>>;
10323
- /**
10324
- * @deprecated
10325
- */
10326
- type: optional<Struct<{
10327
- typename: typeof String$;
10328
- version: typeof String$;
10329
- schemaId: optional<typeof String$>;
10330
- }>>;
10331
- /**
10332
- * @deprecated Superseded by `meta`.
10333
- */
10334
- annotations: optional<Record$<typeof String$, typeof Any$4>>;
10335
- }>>;
10336
- }>;
10337
- /**
10338
- * https://json-schema.org/draft-07/schema
10339
- */
10340
- interface JsonSchemaType extends Schema.Type<typeof _JsonSchemaType> {}
10341
- declare const JsonSchemaType: Schema<JsonSchemaType>;
10342
- //#endregion
10343
- //#region ../echo/dist/types/src/internal/Entity/entity.d.ts
10344
- type EchoTypeSchemaProps<T$1, ExtraFields = {}> = Simplify$1<AnyEntity & ToMutable<T$1> & ExtraFields>;
10722
+ context?: RefResolutionContext;
10723
+ }
10345
10724
  /**
10346
- * Options accepted by every `Type.makeObject` / `Type.makeRelation` / type-kind
10347
- * factory. Defaults are derived from `(typename, version)` so callers normally
10348
- * pass nothing.
10725
+ * Manages cross-space database interactions.
10349
10726
  */
10350
- type EchoTypeOptions = {
10727
+ interface Hypergraph extends Queryable {
10728
+ /**
10729
+ * In-process registry of keyed objects and static schema types.
10730
+ * Populated at startup via `registry.add(objects)` / `registry.add(schemas)`.
10731
+ * Queries that include no explicit from() clause will fan out to this registry automatically.
10732
+ */
10733
+ get registry(): Registry;
10351
10734
  /**
10352
- * Override the entity id stamped on the in-memory `Type.Type` value.
10735
+ * Query objects.
10736
+ */
10737
+ query: QueryFn;
10738
+ /**
10739
+ * Creates a reference to an existing object in the database.
10353
10740
  *
10354
- * Defaults to `EntityId.deterministic(typename, version)` stable across processes
10355
- * and workerd-safe (no `crypto.getRandomValues()` at module-evaluation time).
10356
- * Pass an explicit id (typically `EntityId.random()`) to opt out of the
10357
- * deterministic default.
10741
+ * NOTE: The reference may be dangling if the object is not present in the database.
10742
+ * NOTE: Difference from `Ref.fromURI`
10743
+ * `Ref.fromURI(dxn)` returns an unhydrated reference. The `.load` and `.target` APIs will not work.
10744
+ * `db.makeRef(dxn)` is preferable in cases with access to the database.
10358
10745
  */
10359
- id?: EntityId;
10360
- };
10361
- /**
10362
- * In-memory `Type.Type` entity shape produced by `Type.makeObject(dxn)` /
10363
- * `Type.makeRelation({...})`. A live reactive `TypeSchema` instance —
10364
- * identical to a persisted `Type.Type` except for database attachment.
10365
- *
10366
- * NOT a `Schema.Schema`. The underlying Effect Schema is cached on the hidden
10367
- * `StaticTypeSchemaSlot` slot — retrieve it via `Type.getSchema(...)`.
10368
- */
10369
- interface EchoTypeSchema<Self extends Schema.Any, ExtraFields = {}, K$1 extends EntityKind = EntityKind, Fields extends Struct.Fields = Struct.Fields> {
10746
+ makeRef<T$1 extends Unknown$1 = Unknown$1>(uri: URI): Ref$1<T$1>;
10370
10747
  /**
10371
- * Entity-kind brand. Type entities are their own kind (`Type`) regardless of
10372
- * the kind of instance they describe — `[SchemaKindId]` carries the latter.
10373
- * This lets predicates like `Obj.isObject` / `Relation.isRelation` cleanly
10374
- * reject type entities without also having to inspect `[SchemaKindId]`.
10748
+ * Create a resolver that dereferences `Ref`s against this graph. Persisted schema objects are
10749
+ * surfaced as their registered `Type.Type` entity.
10375
10750
  */
10376
- readonly [KindId$1]: EntityKind.Type;
10377
- /** Schema-kind brand indicating what kind of instance this type describes. */
10378
- readonly [SchemaKindId]: K$1;
10751
+ createRefResolver(options: RefResolverOptions): Resolver;
10379
10752
  /**
10380
- * Entity id. Always present stamped at construction — but NOT the type's
10381
- * identity while in-memory: an unattached type resolves its URI to the typename
10382
- * DXN, switching to `echo:/<id>` only once attached to a database (see
10383
- * `getTypeURIFromSpecifier`, which discriminates by database attachment).
10753
+ * Get a database by space ID.
10754
+ * @returns The database for the given space ID, or undefined if not found.
10384
10755
  */
10385
- readonly id: EntityId;
10386
- /** Source Effect Schema (kept on a hidden slot for `Type.getSchema`). */
10387
- readonly [StaticTypeSchemaSlot]: Schema.AnyNoContext;
10388
- readonly jsonSchema: JsonSchemaType;
10389
- /** Struct fields for introspection. */
10390
- readonly fields: Fields;
10391
- /** Phantom — instance type produced by `Obj.make(self, ...)`. */
10392
- readonly _instance?: EchoTypeSchemaProps<Schema.Type<Self>, ExtraFields>;
10756
+ getDatabase(spaceId: SpaceId): Database | undefined;
10393
10757
  /**
10394
- * Phantom slot mirroring `Type<A>` so internal helpers (`makeObject`,
10395
- * `createObject`, `Ref.make`) infer the instance type uniformly whether
10396
- * the caller passes an `EchoTypeSchema` or a top-level `Type.Type` entity.
10758
+ * Registers a pluggable blob storage backend under `name`, claiming its declared URI schemes.
10759
+ * Registering a scheme already claimed by another backend is an error.
10397
10760
  *
10398
- * Includes the instance-kind brand (`[KindId]`) so the phantom is assignable
10399
- * to the matching public-side interface in `Type.ts` (`Type.Obj` /
10400
- * `Type.Relation` / `Type.Type`). Each kind projects identity: instances of
10401
- * an object-kind schema are object-kind entities, type-kind schemas produce
10402
- * type-kind (persisted Type.Type) entities — the latter additionally carry
10403
- * the `[SchemaKindId]` / `[StaticTypeSchemaSlot]` brands the echo-handler
10404
- * proxy exposes on persisted Type entities.
10761
+ * @param options.default - When true, `name` becomes the storage used when
10762
+ * `Blob.fromBytes`'s `storage` option is omitted.
10763
+ * @returns A cleanup function that unregisters the backend.
10405
10764
  */
10406
- readonly [InstancePhantomId$1]?: EchoTypeSchemaProps<Schema.Type<Self>, ExtraFields> & {
10407
- readonly [KindId$1]: K$1;
10408
- } & (K$1 extends EntityKind.Type ? {
10409
- readonly [SchemaKindId]: EntityKind.Type;
10410
- readonly [StaticTypeSchemaSlot]: Schema.AnyNoContext;
10411
- } : {});
10765
+ registerBlobBackend(name: string, backend: BlobBackend, options?: {
10766
+ default?: boolean;
10767
+ }): CleanupFn;
10768
+ /**
10769
+ * Storage name `Blob.fromBytes` uses when its `storage` option is omitted. Starts as `'inline'`;
10770
+ * reflects the most recent `registerBlobBackend(name, backend, { default: true })` call.
10771
+ */
10772
+ get defaultBlobStorage(): string;
10412
10773
  }
10413
10774
  //#endregion
10414
- //#region ../echo/dist/types/src/internal/Entity/type-kind.d.ts
10775
+ //#region ../echo/dist/types/src/Database.d.ts
10415
10776
  /**
10416
- * Type-kind schema marker — produced by {@link EchoTypeKindSchema}.
10417
- *
10418
- * Distinguishes meta-schemas (entities of `EntityKind.Type`, such as the
10419
- * built-in `Type.Type` TypeSchema) from object and relation types.
10777
+ * `query` API function declaration.
10420
10778
  */
10421
- type EchoTypeKindSchema<Self extends Schema.Any, Fields extends Struct.Fields = Struct.Fields> = EchoTypeSchema<Self, {}, EntityKind.Type, Fields>;
10779
+ interface QueryFn {
10780
+ <Q extends Any$2>(query: Q): QueryResult<Type$1<Q>>;
10781
+ <F extends Any$3>(filter: F): QueryResult<Type$2<F>>;
10782
+ }
10422
10783
  /**
10423
- * Pipeable that brands a schema as a type-kind ECHO entity. Mirrors
10424
- * {@link EchoObjectSchema} / {@link EchoRelationSchema}, but stamps the
10425
- * resulting entity with `[SchemaKindId]: EntityKind.Type` and a matching
10426
- * `TypeAnnotation.kind = 'type'` so meta-schemas surface uniformly through
10427
- * `Type.isTypeKind`, `Filter.type`, etc.
10784
+ * Common interface for Database, Feed, and Hypergraph.
10428
10785
  */
10429
- declare const EchoTypeKindSchema: {
10430
- (dxn: DXN, options?: EchoTypeOptions): <Self extends Schema.Any, Fields extends Struct.Fields = Struct.Fields>(self: Self & {
10431
- fields?: Fields;
10432
- }) => EchoTypeKindSchema<Self, Fields>;
10786
+ interface Queryable {
10787
+ query: QueryFn;
10788
+ }
10789
+ type GetObjectByIdOptions = {
10790
+ deleted?: boolean;
10791
+ };
10792
+ type ObjectPlacement = 'root-doc' | 'linked-doc';
10793
+ type AddOptions = {
10794
+ /**
10795
+ * Where to place the object in the Automerge document tree.
10796
+ * Root document is always loaded with the space.
10797
+ * Linked documents are loaded lazily.
10798
+ * Placing large number of objects in the root document may slow down the initial load.
10799
+ *
10800
+ * @default 'linked-doc'
10801
+ */
10802
+ placeIn?: ObjectPlacement;
10803
+ /**
10804
+ * Append the object to this feed instead of the automerge-backed space database. The object is
10805
+ * returned synchronously (a live feed object) and persisted in the background — confirm the write
10806
+ * completed with {@link Database.flush}. Synchronous alternative to the async
10807
+ * {@link Database.appendToFeed}; `placeIn` is ignored when set.
10808
+ */
10809
+ to?: Feed;
10433
10810
  };
10434
- //#endregion
10435
- //#region ../echo/dist/types/src/internal/Type/type-schema.d.ts
10436
10811
  /**
10437
- * Raw struct backing {@link TypeSchema}. Exposed only so `TypeSchema`
10438
- * (the TS type) can derive its data fields via `Schema.Schema.Type<typeof ...>`;
10439
- * runtime callers should use {@link TypeSchema} (the piped, branded entity).
10440
- *
10441
- * `typename` and `version` are NOT data fields — they live in `EntityMeta.key` /
10442
- * `EntityMeta.version` (the canonical registry-provenance pair, queryable via
10443
- * `Filter.key(...)`). The same `jsonSchema` payload also embeds them so a
10444
- * standalone JSON-Schema export remains self-describing, but the schema-registry
10445
- * reads/writes them through meta.
10812
+ * Rejects Type entities from {@link Database.add} at compile time via their `[KindId]` brand. Used
10813
+ * as `T & RejectTypeEntity<T>` to preserve inference of `T`. Bounding `add` on
10814
+ * `Obj.Unknown | Relation.Unknown` instead would reject broadly-typed instance adds (e.g.
10815
+ * `Entity.Any`, `Obj.OfShape<T>`), forcing casts repo-wide.
10446
10816
  */
10447
- declare const TypeSchemaStruct: Struct<{
10448
- name: optional<typeof String$>;
10449
- jsonSchema: Schema<JsonSchemaType, JsonSchemaType, never>;
10450
- }>;
10817
+ type RejectTypeEntity<T$1> = T$1 extends {
10818
+ readonly [KindId]: EntityKind.Type;
10819
+ } ? {
10820
+ __error: 'Type entities must be persisted via db.addType(), not db.add().';
10821
+ } : T$1;
10822
+ type FlushOptions = {
10823
+ /**
10824
+ * Write any pending changes to disk.
10825
+ * @default true
10826
+ */
10827
+ disk?: boolean;
10828
+ /**
10829
+ * Wait for pending index updates.
10830
+ * @default true
10831
+ */
10832
+ indexes?: boolean;
10833
+ /**
10834
+ * Flush pending updates to objects and queries.
10835
+ * @default false
10836
+ */
10837
+ updates?: boolean;
10838
+ };
10451
10839
  /**
10452
- * Persistent representation of a schema.
10840
+ * A caller-owned, writable **independent instance** of one object bound to one branch: a distinct
10841
+ * object instance (not a UI surface), separate from the device-global canonical object.
10842
+ * @see Database.branch
10453
10843
  */
10454
- declare const TypeSchema: EchoTypeKindSchema<Struct<{
10455
- name: optional<typeof String$>;
10456
- jsonSchema: Schema<JsonSchemaType, JsonSchemaType, never>;
10457
- }>, Readonly<{
10458
- name: optional<typeof String$>;
10459
- jsonSchema: Schema<JsonSchemaType, JsonSchemaType, never>;
10460
- }>>;
10844
+ type BranchBinding<T$1 extends Unknown = Unknown> = {
10845
+ /** Live object bound to the branch document (`'main'` -> the canonical live object). */
10846
+ readonly object: T$1;
10847
+ /** Release the binding (drops the doc-handle listener; never deletes the branch document). */
10848
+ dispose(): void;
10849
+ };
10461
10850
  /**
10462
- * Persistent representation of a schema — the runtime shape that
10463
- * `db.addType(Type.makeObjectFromJsonSchema(...))` produces
10464
- * and `Filter.type(Type.Type).run()` returns.
10465
- *
10466
- * Structurally identical to a static `Type.Type` entity: the entity-handler's
10467
- * `get` trap exposes `[SchemaKindId]` (derived from `system.kind` and
10468
- * `data.jsonSchema.entityKind`) and rebuilds `[StaticTypeSchemaSlot]` lazily
10469
- * from `jsonSchema`, so a persisted instance satisfies the public `Type<A>`
10470
- * interface without casting.
10851
+ * Identifier denoting an ECHO Database.
10471
10852
  */
10472
- type TypeSchema = Schema.Type<typeof TypeSchemaStruct> & {
10473
- /** Object identifier injected by `EchoTypeKindSchema` and stamped at construction. */
10474
- readonly id: string;
10475
- /** Entity-kind discriminator (object/relation/type) carried on every entity instance. */
10476
- readonly [KindId$1]: EntityKind.Type;
10477
- /** Kind of schema described by this meta-instance — always `EntityKind.Type` for `Type.Type` itself. */
10478
- readonly [SchemaKindId]: EntityKind.Type;
10479
- /** Effect Schema rebuilt lazily from `jsonSchema`; satisfies `Type.getSchema(...)` without an extra cast. */
10480
- readonly [StaticTypeSchemaSlot]: Schema.AnyNoContext;
10481
- };
10482
- //#endregion
10483
- //#region ../echo/dist/types/src/Type.d.ts
10853
+ declare const TypeId: unique symbol;
10854
+ type TypeId = typeof TypeId;
10484
10855
  /**
10485
- * Structural base shared by the three sibling type-entity interfaces
10486
- * ({@link Obj}, {@link Relation}, {@link Type}). NOT exported — callers
10487
- * should constrain on {@link AnyEntity} when they want "any of the three"
10488
- * and on the specific kind interface otherwise.
10856
+ * ECHO Database interface.
10489
10857
  */
10490
- interface BaseTypeEntity<A$1> {
10858
+ interface Database extends Queryable {
10859
+ readonly [TypeId]: TypeId;
10860
+ get spaceId(): SpaceId;
10861
+ get graph(): Hypergraph;
10862
+ /**
10863
+ * Registry for this database. Delegates type lookups to the shared hypergraph registry.
10864
+ * To persist a schema so it replicates to other clients, add the type entity with
10865
+ * {@link addType} (e.g. `await db.addType(Type.makeObjectFromJsonSchema(...))`).
10866
+ */
10867
+ readonly registry: Registry;
10868
+ toJSON(): object;
10869
+ /**
10870
+ * Return object by local ID.
10871
+ * @deprecated Use `db.query(Filter.id(id)).runSync()[0]` for a working-set lookup, or resolve via a {@link Ref}.
10872
+ */
10873
+ getObjectById<T$1 extends Unknown = OfShape<AnyProperties>>(id: string, opts?: GetObjectByIdOptions): T$1 | undefined;
10874
+ /**
10875
+ * Query objects.
10876
+ */
10877
+ query: QueryFn;
10878
+ /**
10879
+ * Creates a reference to an existing object in the database.
10880
+ *
10881
+ * NOTE: The reference may be dangling if the object is not present in the database.
10882
+ * NOTE: Difference from `Ref.fromURI`
10883
+ * `Ref.fromURI(dxn)` returns an unhydrated reference. The `.load` and `.target` APIs will not work.
10884
+ * `db.makeRef(dxn)` is preferable in cases with access to the database.
10885
+ */
10886
+ makeRef<T$1 extends Unknown$1 = Unknown$1>(uri: URI): Ref<T$1>;
10887
+ /**
10888
+ * Adds an object or relation to the database.
10889
+ *
10890
+ * Only Object and Relation entities are accepted. To persist a Type definition use
10891
+ * {@link addType} — passing a Type entity is rejected at compile time (and at runtime).
10892
+ *
10893
+ * Pass `{ to: feed }` to append to a feed instead (synchronous; confirm with {@link flush}).
10894
+ */
10895
+ add<T$1 extends Unknown$1 = Unknown$1>(obj: T$1 & RejectTypeEntity<T$1>, opts?: AddOptions): T$1;
10896
+ /**
10897
+ * Persists a Type definition (clones/forks the entity) so it replicates to other peers.
10898
+ *
10899
+ * Runs a conflict query first: if a type with the same typename + version already exists in
10900
+ * this space, the existing persisted entity is returned and no duplicate is created. This is
10901
+ * the only supported way to add Type entities — {@link add} rejects them.
10902
+ */
10903
+ addType<T$1 extends AnyEntity$1>(type: T$1): Promise<T$1>;
10904
+ /**
10905
+ * Removes object from the database.
10906
+ */
10907
+ remove(obj: Unknown$1): void;
10908
+ /**
10909
+ * Appends entities to a feed.
10910
+ *
10911
+ * The feed must already be stored in the database (added via {@link add}); its underlying
10912
+ * queue is addressed by the feed object's URI.
10913
+ */
10914
+ appendToFeed(feed: Feed, entities: Unknown$1[]): Promise<void>;
10915
+ /**
10916
+ * Removes entities from a feed.
10917
+ */
10918
+ deleteFromFeed(feed: Feed, entities: Unknown$1[]): Promise<void>;
10919
+ /**
10920
+ * Wait for all pending changes to be saved to disk.
10921
+ * Optionaly waits for changes to be propagated to indexes and event handlers.
10922
+ */
10923
+ flush(opts?: FlushOptions): Promise<void>;
10924
+ /**
10925
+ * The device-global current branch for an object id (`'main'` by default).
10926
+ * @deprecated Prefer `Obj.getBranch(obj)` — it takes the object and reports the branch of that
10927
+ * specific instance (including `db.branch()` independent instances), not just the device selection.
10928
+ */
10929
+ getCurrentBranch(objectId: string): string;
10930
+ /**
10931
+ * An immutable snapshot of the object at the given historical heads — a detached instance, not a
10932
+ * pin on the live object. Prefer `Obj.getVersion(obj, heads)`.
10933
+ */
10934
+ getVersion<T$1 extends Unknown>(obj: T$1, heads: readonly string[]): Snapshot<T$1>;
10935
+ /** All branch names available for an object, including the implicit `'main'` (always first). */
10936
+ listBranches(objectId: string): string[];
10937
+ /**
10938
+ * Fork the object and its referenced subtree into a new branch (does not switch to it).
10939
+ * @param opts.fromHeads Fork from a historical frontier instead of the tip (a bare heads array
10940
+ * applies to the root only; a map forks each member from its own frontier).
10941
+ */
10942
+ createBranch(rootObjectId: string, name: string, opts?: {
10943
+ fromHeads?: readonly string[] | Record<string, readonly string[]>;
10944
+ }): Promise<void>;
10945
+ /** Switch the object's subtree to a branch (or back to `'main'`). Device-local; cascades to children. */
10946
+ switchBranch(rootObjectId: string, name: string): Promise<void>;
10947
+ /** Merge a branch back into main across the subtree, then switch back to main. */
10948
+ mergeBranch(rootObjectId: string, name: string, opts?: {
10949
+ deleteAfter?: boolean;
10950
+ }): Promise<void>;
10951
+ /** Fold main's changes into a branch across the subtree (the reverse of {@link mergeBranch}). */
10952
+ syncBranch(rootObjectId: string, name: string): Promise<void>;
10953
+ /** Delete a branch (its documents lose their sync reference). Cannot delete `'main'`. */
10954
+ deleteBranch(rootObjectId: string, name: string): void;
10955
+ /**
10956
+ * Create a caller-owned, writable binding to one branch of one object — a live object whose reads
10957
+ * resolve the branch document and whose writes land on the branch document only. Multiple bindings
10958
+ * to different branches of the same object may coexist; the device-global current branch and other
10959
+ * bindings are unaffected. Binding to `'main'` returns the canonical live object. Bindings are
10960
+ * ephemeral and never persisted — the caller must `dispose()`.
10961
+ */
10962
+ branch<T$1 extends Unknown>(obj: T$1, name: string): Promise<BranchBinding<T$1>>;
10963
+ /**
10964
+ * Removes feed items by ID.
10965
+ */
10966
+ removeFeedItemsByIds(feed: Feed, ids: string[]): Promise<void>;
10967
+ /**
10968
+ * Syncs a feed with the server.
10969
+ */
10970
+ syncFeed(feed: Feed, options?: SyncOptions): Promise<void>;
10971
+ /**
10972
+ * Returns queue replication backlog for the feed's namespace.
10973
+ */
10974
+ getFeedSyncState(feed: Feed): Promise<SyncState$1>;
10491
10975
  /**
10492
- * Entity-kind brand of the type-entity value itself always `EntityKind.Type`.
10493
- * The kind of instance the type *describes* lives on `[SchemaKindId]`
10494
- * (Object / Relation / Type). Lets `Obj.isObject` / `Relation.isRelation`
10495
- * reject type entities by a single `[KindId]` check.
10976
+ * Disposes and drops the in-memory handle (live working-set / core cache) for a feed, so the next
10977
+ * access re-reads it cold. Advanced cache-control; primarily used by tests to model a spawned
10978
+ * process reading the feed with an empty in-memory cache. Public (not `_`-prefixed) so it survives
10979
+ * declaration stripping for cross-package test use.
10496
10980
  */
10497
- readonly [KindId$1]: EntityKind.Type;
10981
+ evictFeedHandle(feed: Feed): Promise<void>;
10498
10982
  /**
10499
- * Object id. Like all ECHO entities, type entities always carry an id
10500
- * stamped at construction for in-memory (static) declarations and assigned by
10501
- * the database once persisted. The id does NOT determine the entity's URI:
10502
- * static types resolve to their typename DXN, persisted types to `echo:/<id>`
10503
- * (see `getTypeURIFromSpecifier`).
10983
+ * Hashes and uploads `bytes` via the chosen storage backend, returning an un-added Blob object.
10984
+ * Rejects with `Err.BlobTooLargeError` (over inline storage's fixed cap, or the backend's own
10985
+ * `maxSize`), `Err.BlobWriteError` (backend upload failure), or `Err.BlobNotAvailableError`
10986
+ * (`reason: 'backend-not-registered'` the requested storage name has no registered backend).
10504
10987
  */
10505
- readonly id: EntityId;
10506
- readonly name?: string;
10507
- readonly jsonSchema: JsonSchemaType;
10508
- readonly [InstancePhantomId]?: A$1;
10509
- }
10510
- /**
10511
- * TypeScript type for an ECHO object type — a `Type.Type<A>` entity.
10512
- *
10513
- * `T` is the instance type produced by `Obj.make(Foo, props)`. `Fields` is
10514
- * retained as a structural hint (the runtime value still carries `.fields`),
10515
- * but consumers should derive instance/encoded types via `Type.InstanceType`.
10516
- *
10517
- * **Not a `Schema.Schema`.** `Foo.ast` / `Schema.Schema.Type<typeof Foo>` /
10518
- * `Schema.extend(Foo)` no longer typecheck — extract the Effect Schema via
10519
- * `Type.getSchema(Foo)` first, or derive instance types via
10520
- * `Type.InstanceType<typeof Foo>`.
10521
- *
10522
- * @example
10523
- * ```ts
10524
- * class Person extends Type.makeObject<Person>(DXN.make('com.example.type.person', '0.1.0'))(
10525
- * Schema.Struct({ name: Schema.String }),
10526
- * ) {}
10527
- * ```
10528
- */
10529
- interface Obj$1<T$1, Fields extends Struct.Fields = Struct.Fields> extends BaseTypeEntity<T$1 & OfKind<typeof Kind.Object>> {
10530
- /** Schema-kind brand (object). */
10531
- readonly [SchemaKindId]: EntityKind.Object;
10532
- /** Source Effect Schema — used internally by `Type.getSchema(self)`. */
10533
- readonly [StaticTypeSchemaSlot]: Schema.AnyNoContext;
10988
+ createBlob(bytes: Uint8Array, options?: {
10989
+ type?: string;
10990
+ storage?: string;
10991
+ }): Promise<Blob$1>;
10534
10992
  /**
10535
- * The fields defined in the original struct schema.
10536
- * Allows accessing field definitions for introspection.
10993
+ * Loads a blob's bytes. Rejects with `Err.BlobNotAvailableError` if the backend for the blob's
10994
+ * storage scheme is not registered, offline, or cannot find the bytes.
10537
10995
  */
10538
- readonly fields: Fields;
10539
- }
10540
- /**
10541
- * Return type for {@link makeObject}.
10542
- *
10543
- * Not to be used directly, but must be exported for typescript to infer the type.
10544
- */
10545
- interface ObjClass<Self, T$1, Fields extends Struct.Fields> extends Obj$1<Self, Fields> {
10546
- new (_: never): T$1 & OfKind<typeof Kind.Object>;
10996
+ readBlob(blob: Blob$1): Promise<Uint8Array>;
10997
+ /**
10998
+ * Checks whether a blob's bytes are currently available.
10999
+ */
11000
+ blobExists(blob: Blob$1): Promise<boolean>;
11001
+ /**
11002
+ * Returns a renderable URL for the blob, if one can be produced.
11003
+ */
11004
+ getBlobUrl(blob: Blob$1): Promise<string | undefined>;
11005
+ /**
11006
+ * Get the current combined (automerge documents + feed blocks) sync state, reported against a
11007
+ * single remote peer.
11008
+ */
11009
+ getSyncState(options?: GetSyncStateOptions): Promise<SyncState>;
11010
+ /**
11011
+ * Subscribe to combined sync state changes.
11012
+ */
11013
+ subscribeToSyncState(cb: (state: SyncState) => void, options?: GetSyncStateOptions): CleanupFn;
10547
11014
  }
11015
+ declare const Database: Schema<Database>;
10548
11016
  /**
10549
- * Type that represents any ECHO object type a `Type.Type` entity branded
10550
- * with the object entity kind, i.e. what `Type.makeObject(dxn)` produces.
10551
- */
10552
- type AnyObj = Obj$1<unknown>;
10553
- /**
10554
- * ECHO meta-schema entity — stores `{ name?, typename, version, jsonSchema }`.
10555
- * Type-kind sibling of `Type.makeObject(...)` / `Type.makeRelation(...)` outputs.
10556
- * Stored types live under this entity; filter via `Filter.type(Type.Type)`.
10557
- */
10558
- declare const Type$1: Type$1<TypeSchema>;
10559
- /**
10560
- * TypeScript type for an ECHO relation type — a `Type.Type<A>` entity.
10561
- *
10562
- * `T` is the instance-property type produced by `Relation.make(...)` (excluding
10563
- * source/target endpoints). `Source` and `Target` are the endpoint types.
10564
- *
10565
- * **Not a `Schema.Schema`.** See {@link Obj}'s note.
11017
+ * Sync state of the database in relation to EDGE.
10566
11018
  */
10567
- interface Relation<T$1, Source$1, Target$2, Fields extends Struct.Fields = Struct.Fields> extends BaseTypeEntity<Endpoints$1<Source$1, Target$2> & T$1 & OfKind<typeof Kind.Relation>> {
10568
- /** Schema-kind brand (relation). */
10569
- readonly [SchemaKindId]: EntityKind.Relation;
10570
- /** Source Effect Schema — used internally by `Type.getSchema(self)`. */
10571
- readonly [StaticTypeSchemaSlot]: Schema.AnyNoContext;
11019
+ interface SyncState {
10572
11020
  /**
10573
- * The fields defined in the original struct schema.
10574
- * Allows accessing field definitions for introspection.
11021
+ * Total number of documents locally.
10575
11022
  */
10576
- readonly fields: Fields;
11023
+ readonly localDocumentCount: number;
11024
+ /**
11025
+ * Total number of documents on the remote peer.
11026
+ */
11027
+ readonly remoteDocumentCount: number;
11028
+ /**
11029
+ * Total number of documents across this peer and the remote peer.
11030
+ */
11031
+ readonly totalDocumentCount: number;
11032
+ /**
11033
+ * Total number of documents that are not synced.
11034
+ * Includes documents that are present only locally, only on the remote peer, or whether the peers have different versions.
11035
+ */
11036
+ readonly unsyncedDocumentCount: number;
11037
+ /**
11038
+ * Blocks still to pull from remote. 0 when caught up.
11039
+ */
11040
+ readonly blocksToPull: string;
11041
+ /**
11042
+ * Unpositioned blocks still to push to remote. 0 when caught up.
11043
+ */
11044
+ readonly blocksToPush: string;
11045
+ /**
11046
+ * Total blocks stored locally for this namespace in the space.
11047
+ */
11048
+ readonly totalBlocks: string;
10577
11049
  }
10578
11050
  /**
10579
- * Return type for {@link makeRelation}.
10580
- *
10581
- * Not to be used directly, but must be exported for typescript to infer the type.
11051
+ * Options for reading combined sync state.
10582
11052
  */
10583
- interface RelationClass<Self, T$1, Source$1, Target$2, Fields extends Struct.Fields> extends Relation<Self, Source$1, Target$2, Fields> {
10584
- new (_: never): Endpoints$1<Source$1, Target$2> & T$1 & OfKind<typeof Kind.Relation>;
11053
+ interface GetSyncStateOptions {
11054
+ /**
11055
+ * Peer to report the automerge document backlog against. Defaults to the EDGE peer.
11056
+ * Provide explicitly in local/test topologies where there is no EDGE peer.
11057
+ */
11058
+ readonly peerId?: string;
10585
11059
  }
11060
+ //#endregion
11061
+ //#region ../echo/dist/types/src/Collection.d.ts
11062
+ declare const Collection_base: ObjClass<Collection, {
11063
+ readonly name?: string | undefined;
11064
+ readonly objects: readonly Ref<Unknown>[];
11065
+ }, {}>;
10586
11066
  /**
10587
- * Type that represents any ECHO relation type — a `Type.Type` entity branded
10588
- * with the relation entity kind, i.e. what `Type.makeRelation(...)` produces.
10589
- */
10590
- type AnyRelation = Relation<unknown, unknown, unknown>;
10591
- /**
10592
- * Type that represents any ECHO type-kind entity — a `Type.Type` meta-schema
10593
- * value (static `Type.Type` or a persisted draft from `db.addType(...)`).
10594
- * Mirrors {@link AnyObj} / {@link AnyRelation} for the third sibling kind.
10595
- */
10596
- type AnyType = Type$1<unknown>;
10597
- /**
10598
- * Any ECHO type-entity — one of the three sibling kinds: object-kind, relation-kind,
10599
- * or type-kind (the meta-schema). APIs that want "any ECHO type" use this union;
10600
- * the underlying Effect Schema is retrieved via `Type.getSchema`.
11067
+ * A an ordered set of objects.
10601
11068
  */
10602
- type AnyEntity$1 = AnyObj | AnyRelation | AnyType;
11069
+ declare class Collection extends Collection_base {}
11070
+ //#endregion
11071
+ //#region ../echo/dist/types/src/View.d.ts
11072
+ declare const View_base: ObjClass<View, {
11073
+ readonly query: {
11074
+ readonly raw?: string | undefined;
11075
+ readonly ast: QueryAggregateClause | QueryFilterClause | QueryFromClause | QueryHierarchyTraversalClause | QueryIncomingReferencesClause | QueryLimitClause | QueryOptionsClause | QueryOrderClause | QueryReferenceTraversalClause | QueryRelationClause | QueryRelationTraversalClause | QuerySelectClause | QuerySetDifferenceClause | QuerySkipClause | QueryUnionClause;
11076
+ };
11077
+ readonly projection: {
11078
+ readonly schema?: JsonSchemaType | undefined;
11079
+ readonly fields: readonly {
11080
+ readonly id: string;
11081
+ readonly path: JsonPath;
11082
+ readonly visible?: boolean | undefined;
11083
+ readonly referencePath?: JsonPath | undefined;
11084
+ }[];
11085
+ readonly pivotFieldId?: string | undefined;
11086
+ };
11087
+ }, {}>;
10603
11088
  /**
10604
- * String key used to phantom-carry the instance type produced by a `Type.Type`.
10605
- * Used by `Type.InstanceType<typeof Foo>` to recover the schema instance type
10606
- * since `Type.makeObject(dxn)` does not return a `Schema.Schema`.
10607
- *
10608
- * Re-exported from the internal types layer so both `Type.ts` and internal
10609
- * helpers (`makeObject`, `createObject`) reference the same phantom key.
11089
+ * Views are generated or user-defined projections of a schema's properties.
11090
+ * They are used to configure the visual representation of the data.
10610
11091
  */
10611
- declare const InstancePhantomId: "~@dxos/echo/Type.Instance";
10612
- type InstancePhantomId = InstancePhantomId$1;
11092
+ declare class View extends View_base {}
11093
+ //#endregion
11094
+ //#region ../echo/dist/types/src/Dataset.d.ts
10613
11095
  /**
10614
- * Sibling of {@link Obj} / {@link Relation} for the third ECHO entity kind:
10615
- * **type-kind** entities (meta-schemas). The singleton {@link Type} const is
10616
- * the canonical example it describes stored type definitions themselves.
10617
- *
10618
- * Not a `Schema.Schema`. Use `Type.getSchema(value)` to obtain the underlying
10619
- * Effect Schema and `Type.update(value, draft => ...)` to mutate.
10620
- *
10621
- * `A` is the instance-type phantom — what `Obj.make(value, ...)` would produce.
10622
- * Merged with the `Type` const value via TypeScript declaration merging.
11096
+ * Abstract set of objects, represented by a view, feed, or collection.
11097
+ * Schema-level union of the underlying type entities (rebuilt via
11098
+ * `Type.getSchema`) so this can still be consumed by Schema-side APIs such
11099
+ * as `Filter.type(...)` on a union.
10623
11100
  */
10624
- interface Type$1<A$1 = unknown> extends BaseTypeEntity<A$1 & OfKind<typeof Kind.Type>> {
10625
- /** Schema-kind brand (type the meta-schema kind). */
10626
- readonly [SchemaKindId]: EntityKind.Type;
10627
- /** Source Effect Schema used internally by `Type.getSchema(self)`. */
10628
- readonly [StaticTypeSchemaSlot]: Schema.AnyNoContext;
11101
+ type Dataset = Feed | Collection | View;
11102
+ declare const Dataset: Union<[Schema<Feed & OfKind<EntityKind.Object>, Feed & OfKind<EntityKind.Object>, never>, Schema<Collection & OfKind<EntityKind.Object>, Collection & OfKind<EntityKind.Object>, never>, Schema<View & OfKind<EntityKind.Object>, View & OfKind<EntityKind.Object>, never>]>;
11103
+ declare namespace Query_d_exports {
11104
+ export { AggregateResult, Any$2 as Any, Projection, ProjectionTypeId, Query, QueryTypeId, Type$1 as Type, all, from, fromAst, is, pretty, project, select, type$1 as type, without };
10629
11105
  }
10630
11106
  /**
10631
- * Instance type produced by a Type entity.
10632
- *
10633
- * Accepts ONLY {@link AnyEntity} inputs — `Type.Obj`, `Type.Relation`, or
10634
- * `Type.Type`. Raw Effect `Schema.Schema` values are rejected: for those, use
10635
- * `Schema.Schema.Type<typeof Foo>` directly. This separation keeps the type
10636
- * system honest about which values represent ECHO entities versus plain
10637
- * Effect schemas.
10638
- *
10639
- * Dispatches on the entity kind:
10640
- * - `Relation<Props, S, T>` → `Endpoints<S,T> & Props & OfKind<Relation>`
10641
- * - `Obj<A>` → `A & OfKind<Object>`
10642
- * - `Type<A>` → `A & OfKind<Type>`
10643
- */
10644
- type InstanceType$1<T$1 extends AnyEntity$1> = T$1 extends RelationClass<any, infer Props, infer Source, infer Target, any> ? Endpoints$1<Source, Target> & Props & OfKind<typeof Kind.Relation> : T$1 extends Relation<infer Props, infer Source, infer Target, any> ? Endpoints$1<Source, Target> & Props & OfKind<typeof Kind.Relation> : T$1 extends ObjClass<any, infer A, any> ? A & OfKind<typeof Kind.Object> : T$1 extends Obj$1<infer A, any> ? A & OfKind<typeof Kind.Object> : T$1 extends Type$1<infer A> ? A & OfKind<typeof Kind.Type> : never;
10645
- //#endregion
10646
- //#region ../echo/dist/types/src/internal/Ref/ref.d.ts
10647
- declare const RefTypeId: unique symbol;
10648
- /**
10649
- * Reference Schema.
11107
+ * All property paths inside T that are references.
10650
11108
  */
10651
- interface RefSchema<T$1 extends AnyEntity> extends SchemaClass<Ref<T$1>, EncodedReference> {}
11109
+ type RefPropKey<T$1> = keyof T$1 & string;
11110
+ type RefArrayElement<A$1> = A$1 extends readonly (infer E)[] ? E : A$1 extends (infer E)[] ? E : never;
11111
+ /** Target entity when traversing an outgoing ref or array-of-refs property. */
11112
+ type ReferenceTraversalTarget<P$1> = P$1 extends Unknown$3 ? Target$1<P$1> : P$1 extends Unknown$3 | undefined ? Target$1<Exclude<P$1, undefined>> : RefArrayElement<P$1> extends Unknown$3 ? Target$1<RefArrayElement<P$1>> : never;
10652
11113
  /**
10653
- * Type of the `Ref` function and extra methods attached to it.
11114
+ * Phantom brand on the flat row produced by {@link Query.aggregate}. Present only at the type level
11115
+ * (never at runtime), it lets hooks like `useQuery`/`usePagination` distinguish an aggregate-row
11116
+ * query from an entity query and avoid wrapping the row in `Entity.Entity`. The brand is a required
11117
+ * property so `T extends AggregateResult` discriminates — an optional one would be satisfied by any
11118
+ * type. Consumers never read it.
10654
11119
  */
10655
- interface RefFn {
10656
- <S$1 extends AnyEntity$1 | UnknownTypeSchema<any, any> = AnyEntity$1>(schema: S$1): RefSchema<S$1 extends AnyType ? AnyEntity$1 : S$1 extends AnyObj | AnyRelation ? InstanceType$1<S$1> : S$1 extends UnknownTypeSchema<infer A, any> ? A : never>;
10657
- /**
10658
- * @returns True if the object is a reference.
10659
- */
10660
- isRef: (obj: unknown) => obj is Ref<any>;
10661
- /**
10662
- * @returns True if the reference points to the given object id.
10663
- */
10664
- hasEntityId: (id: EntityId) => (ref: Ref<any>) => boolean;
11120
+ interface AggregateResult {
11121
+ readonly '~@dxos/echo/Query.AggregateResult': true;
11122
+ }
11123
+ declare const QueryTypeId: '~@dxos/echo/Query';
11124
+ type QueryTypeId = typeof QueryTypeId;
11125
+ interface Query<T$1> {
11126
+ readonly [QueryTypeId]: {
11127
+ value: T$1;
11128
+ };
11129
+ ast: Query$1;
10665
11130
  /**
10666
- * @returns True if the schema is a reference schema.
11131
+ * Filter the current selection based on a filter.
11132
+ * @param filter - Filter to select the objects.
11133
+ * @returns Query for the selected objects.
10667
11134
  */
10668
- isRefSchema: (schema: Schema<any, any>) => schema is RefSchema<any>;
11135
+ select(filter: Filter<T$1>): Query<T$1>;
11136
+ select(props: Props$1<T$1>): Query<T$1>;
10669
11137
  /**
10670
- * @returns True if the schema AST is a reference schema.
11138
+ * Project the query's results to a single scalar property, for use as a membership set in
11139
+ * `Filter.in(query.project('col'))` — an uncorrelated `col IN (SELECT property FROM ...)`
11140
+ * semi-join. The subquery is resolved once at execution time. A projection is a terminal
11141
+ * value, not a `Query`, so it cannot be chained further.
11142
+ * @param property - Property path to project.
10671
11143
  */
10672
- isRefSchemaAST: (ast: AST) => boolean;
11144
+ project<K$1 extends RefPropKey<T$1>>(property: K$1): Projection<T$1[K$1]>;
10673
11145
  /**
10674
- * Constructs a reference that points to the given object.
11146
+ * Traverse an outgoing reference.
11147
+ * @param key - Property path inside T that is a reference or optional reference.
11148
+ * @returns Query for the target of the reference.
10675
11149
  */
10676
- make: <T$1 extends AnyEntity>(object: T$1) => Ref<T$1>;
11150
+ reference<K$1 extends RefPropKey<T$1>>(key: K$1): Query<ReferenceTraversalTarget<T$1[K$1]>>;
10677
11151
  /**
10678
- * Constructs a reference that points to the object specified by the provided URI
10679
- * (either an `echo:` EID for an object reference or a `dxn:` DXN for a type reference).
11152
+ * Find objects referencing this object.
11153
+ * @param target - Schema of the referencing object. If not provided, matches any type.
11154
+ * @param key - Property path inside the referencing object that is a reference. If not provided, matches any property.
11155
+ * @returns Query for the referencing objects.
10680
11156
  */
10681
- fromURI: (uri: URI) => Ref<any>;
10682
- }
10683
- /**
10684
- * Schema builder for references.
10685
- */
10686
- declare const Ref: RefFn;
10687
- /**
10688
- * Represents materialized reference to a target.
10689
- * This is the data type for the fields marked as ref.
10690
- */
10691
- interface Ref<T$1> extends Pipeable {
11157
+ referencedBy<S$1 extends AnyEntity$1>(target: S$1 | URI, key: RefPropKey<InstanceType$1<S$1>>): Query<InstanceType$1<S$1>>;
11158
+ referencedBy<S$1 extends AnyEntity$1>(target: S$1 | URI): Query<InstanceType$1<S$1>>;
11159
+ referencedBy(): Query<any>;
10692
11160
  /**
10693
- * Target URI (either an `echo:` EID for an object reference or a `dxn:` DXN for a type reference).
11161
+ * Find relations where this object is the source.
11162
+ * @returns Query for the relation objects.
11163
+ * @param relation - Schema of the relation.
11164
+ * @param predicates - Predicates to filter the relation objects.
10694
11165
  */
10695
- get uri(): URI;
11166
+ sourceOf<R$1 extends AnyRelation>(relation?: R$1 | URI, predicates?: Props$1<InstanceType$1<R$1>>): Query<InstanceType$1<R$1>>;
10696
11167
  /**
10697
- * Returns true if the reference has a target available (inlined or resolver set).
11168
+ * Find relations where this object is the target.
11169
+ * @returns Query for the relation objects.
11170
+ * @param relation - Type entity of the relation.
11171
+ * @param predicates - Predicates to filter the relation objects.
10698
11172
  */
10699
- get isAvailable(): boolean;
11173
+ targetOf<R$1 extends AnyRelation>(relation?: R$1 | URI, predicates?: Props$1<InstanceType$1<R$1>>): Query<InstanceType$1<R$1>>;
10700
11174
  /**
10701
- * @returns The reference target.
10702
- * May return `undefined` if the object is not loaded in the working set.
10703
- * Accessing this property, even if it returns `undefined` will trigger the object to be loaded to the working set.
11175
+ * For a query for relations, get the source objects.
11176
+ * @returns Query for the source objects.
10704
11177
  */
10705
- get target(): T$1 | undefined;
11178
+ source(): Query<SourceOf<T$1>>;
10706
11179
  /**
10707
- * @returns Promise that will resolves with the target object.
10708
- * Will load the object from disk if it is not present in the working set.
10709
- * Short-circuits immediately when the target is already loaded.
10710
- * @throws If the object is not available locally.
10711
- *
10712
- * @idiom org.dxos.echo.refLoad
10713
- * applies: Resolving a ref inside an async function or Effect handler — guarantees the object is available before proceeding
10714
- * instead-of: `ref.target` — not guaranteed to be defined in async contexts; use `await ref.load()` (or `yield* Database.load(ref)` in Effect) to ensure the target is present
10715
- * uses: {@link load}
10716
- * related: org.dxos.echo-react.useObjectReactive
11180
+ * For a query for relations, get the target objects.
11181
+ * @returns Query for the target objects.
10717
11182
  */
10718
- load(): Promise<T$1>;
11183
+ target(): Query<TargetOf<T$1>>;
10719
11184
  /**
10720
- * @returns Promise that will resolves with the target object or undefined if the object is not loaded locally.
11185
+ * Get the parent object of the current selection.
11186
+ * @returns Query for the parent objects.
10721
11187
  */
10722
- tryLoad(): Promise<T$1 | undefined>;
11188
+ parent(): Query<any>;
10723
11189
  /**
10724
- * Subscribe to the ref's resolution event.
10725
- * The callback fires when the target object becomes available in the working set
10726
- * (e.g. when its document is loaded after sibling-client mutation).
10727
- * Note: the resolver only schedules a notification when the target is requested
10728
- * via {@link target} while it is not yet loaded.
10729
- * @returns Function that unsubscribes the callback.
11190
+ * Get all child objects of the current selection.
11191
+ * @returns Query for the child objects.
10730
11192
  */
10731
- onResolved(callback: () => void): () => void;
11193
+ children(): Query<any>;
10732
11194
  /**
10733
- * Do not inline the target object in the reference.
10734
- * Makes .target unavailable unless the reference is connected to a database context.
10735
- *
10736
- * When serialized with toJSON, the difference is between:
10737
- * `{ "/": "dxn:..." }`
10738
- * and
10739
- * `{ "/": "dxn:...", "target": { ... } }`
11195
+ * Order the query results.
11196
+ * Orders are specified in priority order. The first order will be applied first, etc.
10740
11197
  *
10741
- * Clones the reference object.
10742
- */
10743
- noInline(): Ref<T$1>;
10744
- /**
10745
- * Read-only atom for the ref target.
10746
- * Resolves once when the target loads; does NOT subscribe to target object mutations.
10747
- * Use `Obj.atom(ref)` if you need reactive snapshots that update on every object mutation.
11198
+ * `Order.property` orders by the current result shape's fields, so it works both before and after
11199
+ * an {@link aggregate}: before, by member (row) properties; after, by the flat record's fields
11200
+ * (any group or aggregate field — e.g. `Order.property('lastMessageAt')` reorders the groups by
11201
+ * that aggregate).
11202
+ * @param order - Order to sort the results.
11203
+ * @returns Query for the ordered results.
10748
11204
  */
10749
- get atom(): Atom<T$1 | undefined>;
11205
+ orderBy(...order: NonEmptyArray<Order<T$1>>): Query<T$1>;
10750
11206
  /**
10751
- * Serializes the reference to a JSON object.
10752
- * The serialization format is compatible with the IPLD-style encoded references.
10753
- * When a reference has a saved target (i.e. the target or object holding the reference is not in the database),
10754
- * the target is included in the serialized object.
11207
+ * Aggregate the query results into flat records. {@link Aggregate.group} entries partition the
11208
+ * results into contiguous groups (one record each), keyed by the record field the group is named
11209
+ * after; with no `group` entries the entire input aggregates into a single record. Each declared
11210
+ * aggregate becomes a top-level field and can be ordered by with a following {@link orderBy} using
11211
+ * {@link Order.property}.
10755
11212
  *
10756
- * Examples:
10757
- * `{ "/": "dxn:..." }`
10758
- * `{ "/": "dxn:...", "target": { ... } }`
11213
+ * Groups are ordered by the first occurrence of their key in the incoming stream, so a preceding
11214
+ * `orderBy` controls group order in the absence of a following one. {@link Aggregate.items}'s own
11215
+ * `order` option is a separate, explicit per-group member ordering — pass it there rather than
11216
+ * relying on a preceding `orderBy`, whose only well-defined job once `aggregate` follows is
11217
+ * establishing initial group order. For example, message threads ordered by their most recent
11218
+ * message, each retaining up to 20 members newest-first:
11219
+ *
11220
+ * ```ts
11221
+ * Query.type(Message)
11222
+ * .aggregate({
11223
+ * threadId: Aggregate.group('threadId'),
11224
+ * lastMessageAt: Aggregate.max('created'),
11225
+ * items: Aggregate.items({ limit: 20, order: [Order.property('created', 'desc')] }),
11226
+ * })
11227
+ * .orderBy(Order.property('lastMessageAt', 'desc'));
11228
+ * ```
11229
+ *
11230
+ * Must be the last data-selecting clause in the chain — only `from`/`options`/`orderBy`/`limit`/
11231
+ * `skip` may follow.
11232
+ * @param aggregates - Record of aggregate declarations keyed by result field name.
11233
+ * @returns Query whose flat result records carry the named aggregates as fields.
10759
11234
  */
10760
- encode(): EncodedReference;
10761
- [RefTypeId]: {
10762
- _T: T$1;
10763
- };
10764
- }
10765
- declare namespace Ref {
11235
+ aggregate<const A$1 extends Record<string, Aggregate<T$1, any>>>(aggregates: A$1): Query<AggregationResult<A$1>>;
10766
11236
  /**
10767
- * Target of the reference.
11237
+ * Limit the number of results.
11238
+ * @param limit - Maximum number of results to return.
11239
+ * @returns Query for the limited results.
10768
11240
  */
10769
- type Target<R$1> = R$1 extends Ref<infer U> ? U : never;
10770
- }
10771
- /**
10772
- * Load-source ceiling for a resolution request. Cheaper tiers are always probed first; the
10773
- * ceiling caps how far a request is allowed to reach:
10774
- * - `working-set`: synchronous, in-memory only. A miss settles `unavailable` immediately.
10775
- * - `disk`: probe the working set, then local storage; never the network.
10776
- * - `network`: probe the working set, disk, then fetch from peers.
10777
- *
10778
- * `unavailable` is always relative to the requested ceiling (disk-unavailable ≠ network-unavailable).
10779
- */
10780
- type RefSource = 'working-set' | 'disk' | 'network';
10781
- /**
10782
- * A stateful, closure-aware handle to an in-flight (or settled) reference resolution.
10783
- *
10784
- * `ready` means the entity is FULLY USABLE: its own body and its strong-dependency closure are all
10785
- * materialized. The body-vs-closure split is internal; `requesting` transparently covers "a
10786
- * dependency is still loading".
10787
- */
10788
- interface RefResolverRequest {
11241
+ limit(limit: number): Query<T$1>;
10789
11242
  /**
10790
- * `pending` is a one-way entry state (never re-entered). `requesting` means the body and/or
10791
- * closure is still loading. `ready` means fully usable. `unavailable` means unreachable at the
10792
- * requested ceiling.
11243
+ * Skip a number of results (offset). Combined with `orderBy` and `limit`, expresses a windowed
11244
+ * (paginated) read.
11245
+ * @param skip - Number of leading results to skip.
11246
+ * @returns Query for the remaining results.
10793
11247
  */
10794
- readonly state: 'pending' | 'requesting' | 'ready' | 'unavailable';
11248
+ skip(skip: number): Query<T$1>;
10795
11249
  /**
10796
- * Fires (deferred to a microtask) whenever {@link state} changes.
11250
+ * Query from selected databases only.
11251
+ *
11252
+ * Example:
11253
+ *
11254
+ * ```ts
11255
+ * Query.select(Filter.type(Person)).from(db);
11256
+ * ```
11257
+ *
11258
+ * @param options.includeFeeds [false] - Whether to include feeds in the query. Default is to query from automerge documents only.
10797
11259
  */
10798
- readonly stateChanged: Event$1<void>;
11260
+ from(database: Database | Database[], options?: {
11261
+ includeFeeds?: boolean;
11262
+ }): Query<T$1>;
10799
11263
  /**
10800
- * Synchronous snapshot of the resolved entity; defined iff `state === 'ready'`.
11264
+ * Query from selected feeds only.
11265
+ *
11266
+ * Example:
11267
+ *
11268
+ * ```ts
11269
+ * Query.select(Filter.type(Person)).from(feed);
11270
+ * ```
11271
+ *
10801
11272
  */
10802
- getResult(): AnyProperties | undefined;
11273
+ from(feeds: Feed | Feed[]): Query<T$1>;
10803
11274
  /**
10804
- * Settles when `state {ready, unavailable}`.
11275
+ * Query from all accessible spaces.
11276
+ *
11277
+ * Example:
11278
+ *
11279
+ * ```ts
11280
+ * Query.select(Filter.type(Person)).from('all-accessible-spaces');
11281
+ * ```
11282
+ *
11283
+ * @param options.includeFeeds [false] - Whether to include feeds in the query. Default is to query from automerge documents only.
10805
11284
  */
10806
- wait(): Promise<AnyProperties | undefined>;
11285
+ from(allSpaces: 'all-accessible-spaces', options?: {
11286
+ includeFeeds?: boolean;
11287
+ }): Query<T$1>;
10807
11288
  /**
10808
- * Decrements the refcount on the shared load op(s); cancels the underlying IO at zero.
11289
+ * Query from a dataset.
11290
+ * Currently only feeds are supported.
11291
+ *
11292
+ * Example:
11293
+ *
11294
+ * ```ts
11295
+ * Query.type(Person).from(feed);
11296
+ * ```
10809
11297
  */
10810
- abort(): void;
10811
- }
10812
- interface RefResolver {
11298
+ from(dataset: Dataset): Query<T$1>;
10813
11299
  /**
10814
- * Resolve a reference, returning a stateful handle. `source` is a required ceiling; cheaper
10815
- * tiers are always probed first.
11300
+ * Query from the results of another query.
11301
+ *
11302
+ * Example:
11303
+ *
11304
+ * ```ts
11305
+ * Query.select(Filter.props({ foo: 'foo' })).from(Query.select(Filter.type(Contact)).reference('org'));
11306
+ * ```
10816
11307
  */
10817
- resolve(uri: URI, options: {
10818
- source: RefSource;
10819
- }): RefResolverRequest;
11308
+ from(query: Any$2): Query<T$1>;
10820
11309
  /**
10821
- * Resolve ref synchronously from the objects in the working set.
11310
+ * Query from one or more raw scopes.
10822
11311
  *
10823
- * @param uri
10824
- * @param load If true the resolver should attempt to load the object from disk.
10825
- * @param onLoad Callback to call when the object is loaded.
10826
- * @deprecated Use {@link resolve} with `{ source: 'working-set' }`. Removed in Task 11.
11312
+ * Use the {@link Scope} constructors rather than raw tagged objects:
11313
+ *
11314
+ * ```ts
11315
+ * Query.select(Filter.type(Type.Type)).from(Scope.space(), Scope.registry());
11316
+ * ```
10827
11317
  */
10828
- resolveSync(uri: URI, load: boolean, onLoad?: () => void): AnyProperties | undefined;
11318
+ from(...scopes: Scope[]): Query<T$1>;
10829
11319
  /**
10830
- * Resolver ref asynchronously.
10831
- * @deprecated Use {@link resolve} with `{ source: 'network' }`. Removed in Task 11.
11320
+ * Query from a raw scope or array of scopes.
10832
11321
  */
10833
- resolveLegacy(uri: URI): Promise<AnyProperties | undefined>;
11322
+ from(scope: Scope | Scope[]): Query<T$1>;
10834
11323
  /**
10835
- * @deprecated Use {@link resolve} + `Type.getSchema`. Removed in Task 11.
11324
+ * Add options to a query.
10836
11325
  */
10837
- resolveSchema(uri: URI): Promise<Schema.AnyNoContext | undefined>;
11326
+ options(options: QueryOptions): Query<T$1>;
10838
11327
  /**
10839
- * Resolve the source `Type.AnyEntity` entity for a type URI. Used by
10840
- * deserialization paths (`Obj.fromJSON`) to set the back-reference accessed
10841
- * via `Obj.getType` / `Entity.getType`. Optional — resolvers that only
10842
- * carry raw schemas may leave this unimplemented; the deserializer falls
10843
- * back to leaving the type entity unset.
10844
- * @deprecated Use {@link resolve}. Removed in Task 11.
11328
+ * Attach a diagnostic label for logs and tooling (execution semantics unchanged).
10845
11329
  */
10846
- resolveType?(uri: URI): Promise<unknown | undefined>;
11330
+ debugLabel(label: string): Query<T$1>;
10847
11331
  }
10848
- //#endregion
10849
- //#region ../echo/dist/types/src/Entity.d.ts
10850
- declare const KindId: "~@dxos/echo/Kind";
10851
- type KindId = typeof KindId$1;
10852
- declare const Kind: typeof EntityKind;
10853
- type Kind = EntityKind;
11332
+ type Any$2 = Query<any>;
11333
+ type Type$1<Q extends Any$2> = Q extends Query<infer T> ? T : never;
10854
11334
  /**
10855
- * Assigns a kind to an Object or Relation instance.
10856
- * NOTE: Needed to make `isRelation` and `isObject` checks work.
11335
+ * A query projected to a single scalar property (see {@link Query.project}).
10857
11336
  */
10858
- interface OfKind<K$1 extends Kind> {
10859
- readonly [KindId]: K$1;
10860
- readonly id: EntityId;
10861
- }
11337
+ type Projection<V$1 = unknown> = Projection$1<V$1>;
10862
11338
  /**
10863
- * Unknown Obj or Relation (reactive).
11339
+ * Brand key for {@link Projection}. Re-exported (like {@link QueryTypeId}) so the sandboxed
11340
+ * `query-lite` mirror can declare its own local constant with the same string literal and
11341
+ * construct structurally-compatible projections without importing this module's runtime.
10864
11342
  */
10865
- interface Unknown extends OfKind<Kind> {}
11343
+ type ProjectionTypeId = ProjectionTypeId$1;
11344
+ declare const is: (value: unknown) => value is Any$2;
11345
+ /** Construct a query from an ast. */
11346
+ declare const fromAst: (ast: Query$1) => Any$2;
10866
11347
  /**
10867
- * Effect Schema for any ECHO entity (object or relation).
11348
+ * Select objects based on a filter.
11349
+ * @param filter - Filter to select the objects.
11350
+ * @returns Query for the selected objects.
11351
+ */
11352
+ declare const select: <F extends Any$3>(filter: F) => Query<Type$2<F>>;
11353
+ /**
11354
+ * Query for objects of a given schema.
11355
+ * @param schema - Schema of the objects.
11356
+ * @param predicates - Predicates to filter the objects.
11357
+ * @returns Query for the objects.
10868
11358
  *
10869
- * Kind-agnostic counterpart to `Obj.Unknown` / `Relation.Unknown` — validates
10870
- * the structural shape (id + properties) without constraining `[KindId]`. Used
10871
- * in operation input schemas that accept any entity flavour (e.g.
10872
- * `Schema.Array(Entity.Unknown)`).
11359
+ * Shorthand for: `Query.select(Filter.type(schema, predicates))`.
11360
+ */
11361
+ declare const type$1: {
11362
+ <T$1 extends AnyEntity$1>(type: T$1, predicates?: Props$1<InstanceType$1<T$1>>): Query<InstanceType$1<T$1>>;
11363
+ <S$1 extends UnknownTypeSchema<any, any>>(schema: S$1, predicates?: Props$1<Schema.Type<S$1>>): Query<Schema.Type<S$1>>;
11364
+ <S$1 extends Union<readonly Schema.AnyNoContext[]>>(union: S$1, predicates?: Props$1<Schema.Type<S$1>>): Query<Schema.Type<S$1>>;
11365
+ (uri: URI, predicates?: Props$1<unknown>): Query<any>;
11366
+ };
11367
+ /**
11368
+ * Project a query's results to a single scalar property, for use as a membership set in
11369
+ * `Filter.in(Query.project(query, 'col'))`.
11370
+ * @param query - Query to project.
11371
+ * @param property - Property path to project.
11372
+ * @returns Projection for use in `Filter.in`.
11373
+ */
11374
+ declare const project: <T$1, K$1 extends RefPropKey<T$1>>(query: Query<T$1>, property: K$1) => Projection<T$1[K$1]>;
11375
+ /**
11376
+ * Combine results of multiple queries.
11377
+ * @param queries - Queries to combine.
11378
+ * @returns Query for the combined results.
11379
+ */
11380
+ declare const all: (...queries: Any$2[]) => Any$2;
11381
+ /**
11382
+ * Subtract one query from another.
11383
+ * @param source - Query to subtract from.
11384
+ * @param exclude - Query to subtract.
11385
+ * @returns Query for the results of the source query minus the results of the exclude query.
11386
+ */
11387
+ declare const without: <T$1>(source: Query<T$1>, exclude: Query<T$1>) => Query<T$1>;
11388
+ /**
11389
+ * Create a query scoped to a data source.
11390
+ * The returned query selects everything from the source; chain `.select()` to narrow results.
10873
11391
  *
10874
- * The cast bridges the runtime structural schema to the branded `Unknown` type:
10875
- * `[KindId]` is a symbol brand that can't be expressed in a runtime `Struct`,
10876
- * so the entity guarantee is carried at the type level only (same approach as
10877
- * `Obj.Unknown` / `Relation.Unknown`). Unlike those, this is kind-agnostic so it
10878
- * isn't an `UnknownTypeSchema<_, K>` (there's no single `K`) and carries no
10879
- * `TypeAnnotation`.
11392
+ * @param source - Data source: database, feed, 'all-accessible-spaces', or another query.
11393
+ * @returns Query scoped to the given source.
11394
+ */
11395
+ declare const from: (...args: [(Database | Database[] | Feed | Feed[] | Any$2 | Scope | Scope[] | 'all-accessible-spaces'), {
11396
+ includeFeeds?: boolean;
11397
+ }?] | Scope[]) => Any$2;
11398
+ /**
11399
+ * Returns a human-readable string representation of a Query AST.
10880
11400
  */
10881
- declare const Unknown: Schema<Unknown>;
11401
+ declare const pretty: (query: Any$2) => string;
10882
11402
  //#endregion
10883
- //#region ../echo/dist/types/src/internal/common/types/base.d.ts
11403
+ //#region ../echo/dist/types/src/Aggregate.d.ts
10884
11404
  /**
10885
- * Base type for all data objects (reactive, ECHO, and other raw objects).
10886
- * NOTE: This describes the base type for all database objects.
10887
- * It is stricter than `T extends {}` or `T extends object`.
11405
+ * The aggregate spec sans name; the name is supplied by the `Query.aggregate` record key. A tagged
11406
+ * union per kind so `property`/`limit`/`order` are present exactly when the kind uses them (no
11407
+ * unused optional fields to guard against at read sites).
10888
11408
  */
10889
- type AnyProperties = Record<string, any>;
11409
+ type Spec = {
11410
+ kind: 'group';
11411
+ property: string;
11412
+ } | {
11413
+ kind: 'max';
11414
+ property: string;
11415
+ } | {
11416
+ kind: 'min';
11417
+ property: string;
11418
+ } | {
11419
+ kind: 'items';
11420
+ limit?: number;
11421
+ order?: readonly Order$1[];
11422
+ } | {
11423
+ kind: 'count';
11424
+ };
11425
+ declare const AggregateTypeId: '~@dxos/echo/Aggregate';
11426
+ type AggregateTypeId = typeof AggregateTypeId;
10890
11427
  /**
10891
- * Canonical type for all ECHO entities (objects and relations).
10892
- * @depreacted Remove, use Entity.Unknown instead.
11428
+ * A per-group aggregate declaration, materialised as a top-level field on the flat result record
11429
+ * `Query.aggregate` produces and orderable via a following `orderBy(Order.property(name))`. Name it
11430
+ * via the record passed to `Query.aggregate({ name: Aggregate.max('created') })`.
11431
+ *
11432
+ * `T` is the query's element type (so a reduced/grouped property is checked against it); `V` is the
11433
+ * value the aggregate produces. {@link group} entries define the grouping keys; a record with no
11434
+ * `group` entries aggregates the entire input into a single row.
10893
11435
  */
10894
- interface AnyEntity {
10895
- readonly id: EntityId;
11436
+ interface Aggregate<T$1, V$1> {
11437
+ readonly [AggregateTypeId]: {
11438
+ element: T$1;
11439
+ value: V$1;
11440
+ };
11441
+ spec: Spec;
10896
11442
  }
11443
+ type Any$1 = Aggregate<any, any>;
11444
+ /** Extracts the value type a {@link Aggregate} produces. */
11445
+ type ValueOf<A$1> = A$1 extends Aggregate<any, infer V> ? V : never;
11446
+ /** Computes the flat result type of `Query.aggregate(aggregates)` for a given aggregate record `A`. */
11447
+ type AggregationResult<A$1 extends Record<string, Any$1>> = Simplify$1<AggregateResult & { readonly [N in keyof A$1]: ValueOf<A$1[N]> }>;
10897
11448
  //#endregion
10898
11449
  //#region src/query-lite/query-lite.d.ts
10899
11450
  declare const Order2: typeof Order_d_exports;