@dxos/echo-protocol 0.10.0 → 0.11.1

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/reference.ts","../../src/space-id.ts","../../src/document-structure.ts","../../src/edge-peer.ts","../../src/echo-feed-codec.ts","../../src/foreign-key.ts","../../src/query/ast.ts","../../src/space-doc-version.ts"],"sourcesContent":["//\n// Copyright 2022 DXOS.org\n//\n\nimport { assertArgument } from '@dxos/invariant';\nimport { URI } from '@dxos/keys';\n\n// TODO(dmaretskyi): Is this used anywhere?\nexport const REFERENCE_TYPE_TAG = 'dxos.echo.model.document.Reference';\n\n/**\n * Reference as it is stored in Automerge document.\n */\nexport type EncodedReference = {\n '/': URI.URI;\n};\n\nexport const isEncodedReference = (value: any): value is EncodedReference =>\n typeof value === 'object' && value !== null && Object.keys(value).length === 1 && typeof value['/'] === 'string';\n\nexport const EncodedReference = Object.freeze({\n isEncodedReference,\n /**\n * Returns the opaque URI stored in the encoded reference (any scheme: `echo:` or `dxn:`).\n * Consumers can narrow with `EID.isEID(uri)` / `DXN.isDXN(uri)`.\n */\n toURI: (value: EncodedReference): URI.URI => {\n assertArgument(isEncodedReference(value), 'value', 'invalid reference');\n return value['/'];\n },\n /**\n * Creates an encoded reference from an opaque URI.\n */\n fromURI: (uri: URI.URI): EncodedReference => {\n return { '/': uri };\n },\n});\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport { subtleCrypto } from '@dxos/crypto';\nimport { PublicKey, SpaceId } from '@dxos/keys';\nimport { ComplexMap } from '@dxos/util';\n\nconst SPACE_IDS_CACHE = new ComplexMap<PublicKey, SpaceId>(PublicKey.hash);\n\n/**\n * Space keys are generated by creating a keypair, and then taking the first 20 bytes of the SHA-256 hash of the public key and encoding them to multibase RFC4648 base-32 format (prefixed with B, see Multibase Table).\n * Inspired by how ethereum addresses are derived.\n */\nexport const createIdFromSpaceKey = async (spaceKey: PublicKey): Promise<SpaceId> => {\n const cachedValue = SPACE_IDS_CACHE.get(spaceKey);\n if (cachedValue !== undefined) {\n return cachedValue;\n }\n\n const digest = await subtleCrypto.digest('SHA-256', spaceKey.asUint8Array() as Uint8Array<ArrayBuffer>);\n\n const bytes = new Uint8Array(digest).slice(0, SpaceId.byteLength);\n const spaceId = SpaceId.encode(bytes);\n SPACE_IDS_CACHE.set(spaceKey, spaceId);\n return spaceId;\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport { invariant } from '@dxos/invariant';\nimport { type EntityId, PublicKey, SpaceId, type URI } from '@dxos/keys';\nimport { visitValues } from '@dxos/util';\n\nimport { type RawString } from './automerge';\nimport type { ForeignKey } from './foreign-key';\nimport { type EncodedReference, isEncodedReference } from './reference';\nimport { type SpaceDocVersion } from './space-doc-version';\nimport { createIdFromSpaceKey } from './space-id';\n\nexport type SpaceState = {\n // Url of the root automerge document.\n rootUrl?: string;\n};\n\n/**\n * Array indexes get converted to strings.\n */\nexport type EntityProp = string;\nexport type EntityPropPath = EntityProp[];\n\n/**\n * Link to all documents that hold objects in the space.\n */\nexport interface DatabaseDirectory {\n version?: SpaceDocVersion;\n\n access?: {\n /**\n * ID of the space that owns the document.\n */\n spaceId?: SpaceId;\n\n /**\n * @deprecated Use {@link spaceId}. Still written alongside `spaceId` so older clients\n * (and code paths that need the space public key, which cannot be recovered from the id)\n * keep working.\n *\n * Space key of the owning space in hex format without the 0x prefix.\n */\n spaceKey?: string;\n };\n /**\n * Objects inlined in the current document.\n */\n objects?: {\n [id: string]: EntityStructure;\n };\n /**\n * Object id points to an automerge doc url where the object is embedded.\n */\n links?: {\n [echoUri: string]: string | RawString;\n };\n\n /**\n * Per-object branch registry. Keyed by the subtree-root object id, then by branch name; each\n * branch records the automerge doc url holding each subtree member at that branch.\n *\n * This is the single synced source of truth for branches: it is both the branch list/membership\n * AND the set of branch documents the space must replicate (the host collects these urls in\n * {@link getAllBranchDocUrls}). The client document loader does NOT treat these urls as object\n * links, so branch docs never materialize as phantom objects. The implicit `'main'` branch is\n * never listed here (it is the object's main doc via {@link links}).\n *\n * Which branch a device is currently viewing is NOT stored here — that is device-local,\n * non-synced state.\n */\n branches?: SpaceBranchRegistry;\n\n /**\n * @deprecated\n * For backward compatibility.\n */\n experimental_spaceKey?: string;\n}\n\n/**\n * @see DatabaseDirectory.branches\n */\nexport type SpaceBranchRegistry = {\n [rootObjectId: string]: {\n [branchName: string]: BranchRecord;\n };\n};\n\nexport type BranchRecord = {\n /** Subtree member object id -> automerge doc url holding that member on this branch. */\n members: { [objectId: string]: string | RawString };\n /**\n * The root object's main-doc heads at fork time. Provenance only — currently written but never\n * read; the merge relies on shared automerge ancestry, not this field.\n */\n baseHeads?: string[];\n /** Unix ms timestamp at branch creation. */\n createdAt?: number;\n};\n\nexport const DatabaseDirectory = Object.freeze({\n /**\n * @returns ID of the space that owns the document.\n * Coalesces `access.spaceId` with the deprecated space key fields (`access.spaceKey`,\n * `experimental_spaceKey`), deriving the id from the key for documents that predate `spaceId`.\n */\n getSpaceId: async (doc: DatabaseDirectory): Promise<SpaceId | null> => {\n if (doc.access?.spaceId != null) {\n invariant(SpaceId.isValid(doc.access.spaceId), 'Invalid space ID');\n return doc.access.spaceId;\n }\n\n const spaceKeyHex = DatabaseDirectory.getSpaceKey(doc);\n if (spaceKeyHex == null) {\n return null;\n }\n\n return createIdFromSpaceKey(PublicKey.fromHex(spaceKeyHex));\n },\n\n /**\n * @deprecated Use {@link DatabaseDirectory.getSpaceId}. Only paths that require the space\n * public key (which cannot be derived from the space id) should read the key.\n *\n * @returns Space key in hex of the space that owns the document. In hex format. Without 0x prefix.\n */\n getSpaceKey: (doc: DatabaseDirectory): string | null => {\n // experimental_spaceKey is set on old documents, new ones are created with doc.access.spaceKey\n const rawSpaceKey = doc.access?.spaceKey ?? doc.experimental_spaceKey;\n if (rawSpaceKey == null) {\n return null;\n }\n\n const rawKey = String(rawSpaceKey);\n invariant(!rawKey.startsWith('0x'), 'Space key must not start with 0x');\n return rawKey;\n },\n\n getInlineObject: (doc: DatabaseDirectory, id: EntityId): EntityStructure | undefined => {\n return doc.objects?.[id];\n },\n\n getLink: (doc: DatabaseDirectory, id: EntityId): string | undefined => {\n return doc.links?.[id]?.toString();\n },\n\n /**\n * @returns The branch registry for a subtree-root object, or undefined if it has no branches.\n */\n getBranches: (doc: DatabaseDirectory, rootObjectId: EntityId): Record<string, BranchRecord> | undefined => {\n return doc.branches?.[rootObjectId];\n },\n\n /**\n * @returns All branch document urls referenced anywhere in the registry. Used by the host to\n * decide which documents to replicate (branch docs are NOT object links).\n */\n getAllBranchDocUrls: (doc: DatabaseDirectory): string[] => {\n const urls: string[] = [];\n for (const byName of Object.values(doc.branches ?? {})) {\n for (const record of Object.values(byName)) {\n for (const url of Object.values(record.members ?? {})) {\n urls.push(url.toString());\n }\n }\n }\n return urls;\n },\n\n make: ({\n spaceId,\n spaceKey,\n objects,\n links,\n }: {\n spaceId?: SpaceId;\n /**\n * @deprecated Provide {@link spaceId}. The key is still stamped for older clients.\n */\n spaceKey?: string;\n objects?: Record<string, EntityStructure>;\n links?: Record<string, RawString>;\n }): DatabaseDirectory => ({\n access: {\n ...(spaceId != null ? { spaceId } : {}),\n ...(spaceKey != null ? { spaceKey } : {}),\n },\n objects: objects ?? {},\n links: links ?? {},\n }),\n});\n\n/**\n * Representation of an ECHO object in an AM document.\n */\nexport type EntityStructure = {\n // TODO(dmaretskyi): Missing in some cases.\n system?: EntitySystem;\n\n meta: EntityMeta;\n /**\n * User-defined data.\n * Adheres to schema in `system.type`\n */\n data: Record<string, any>;\n};\n\n// Helper methods to interact with the {@link EntityStructure}.\nexport const EntityStructure = Object.freeze({\n /**\n * @throws On invalid object structure.\n */\n getTypeReference: (object: EntityStructure): EncodedReference | undefined => {\n return object.system?.type;\n },\n\n /**\n * @throws On invalid object structure.\n */\n getEntityKind: (object: EntityStructure): 'object' | 'relation' | 'type' => {\n const kind = object.system?.kind ?? 'object';\n invariant(kind === 'object' || kind === 'relation' || kind === 'type', 'Invalid kind');\n return kind;\n },\n\n isDeleted: (object: EntityStructure): boolean => {\n return object.system?.deleted ?? false;\n },\n\n getRelationSource: (object: EntityStructure): EncodedReference | undefined => {\n return object.system?.source;\n },\n\n getRelationTarget: (object: EntityStructure): EncodedReference | undefined => {\n return object.system?.target;\n },\n\n getParent: (object: EntityStructure): EncodedReference | undefined => {\n return object.system?.parent;\n },\n\n /**\n * @returns All references in the data section of the object.\n */\n getAllOutgoingReferences: (object: EntityStructure): { path: EntityPropPath; reference: EncodedReference }[] => {\n const references: { path: EntityPropPath; reference: EncodedReference }[] = [];\n const visit = (path: EntityPropPath, value: unknown) => {\n if (isEncodedReference(value)) {\n references.push({ path, reference: value });\n } else {\n visitValues(value, (value, key) => visit([...path, String(key)], value));\n }\n };\n visitValues(object.data, (value, key) => visit([String(key)], value));\n return references;\n },\n\n getTags: (object: EntityStructure): (EncodedReference | string)[] => {\n return object.meta.tags ?? [];\n },\n\n makeObject: ({\n type,\n data,\n keys,\n }: {\n type: URI.URI;\n deleted?: boolean;\n keys?: ForeignKey[];\n data?: unknown;\n }): EntityStructure => {\n return {\n system: {\n kind: 'object',\n type: { '/': type },\n },\n meta: {\n keys: keys ?? [],\n },\n data: data ?? {},\n };\n },\n\n makeRelation: ({\n type,\n source,\n target,\n deleted,\n keys,\n data,\n }: {\n type: URI.URI;\n source: EncodedReference;\n target: EncodedReference;\n deleted?: boolean;\n keys?: ForeignKey[];\n data?: unknown;\n }): EntityStructure => {\n return {\n system: {\n kind: 'relation',\n type: { '/': type },\n source,\n target,\n deleted: deleted ?? false,\n },\n meta: {\n keys: keys ?? [],\n },\n data: data ?? {},\n };\n },\n\n makeType: ({ type, keys, data }: { type: URI.URI; keys?: ForeignKey[]; data?: unknown }): EntityStructure => {\n return {\n system: {\n kind: 'type',\n type: { '/': type },\n },\n meta: {\n keys: keys ?? [],\n },\n data: data ?? {},\n };\n },\n});\n\n/**\n * Echo object metadata.\n */\nexport type EntityMeta = {\n /**\n * Foreign keys.\n */\n keys: ForeignKey[];\n\n /**\n * Tags.\n * Encoded references to Tag objects within the space.\n *\n * NOTE: Optional for backwards compatibility; legacy data may store bare DXN strings, which are\n * upgraded to encoded references on read (see `object-core.ts`).\n */\n tags?: (EncodedReference | string)[];\n\n /**\n * Fully-qualified registry key for the object (FQN format, e.g. `org.example.type.foo`).\n * Identifies the canonical registry entry the object instance was created from.\n */\n key?: string;\n\n /**\n * Semantic version of the registry entry the object was created from.\n * Must be a valid semver string (e.g. `1.2.3`).\n */\n version?: string;\n\n /**\n * Dictionary of annotations to this entity.\n *\n * NOTE: Optional for backwards compatibility. Values are arbitrary decoded automerge primitives;\n * typed as `any` so `EntityStructure` stays assignable to `DecodedAutomergePrimaryValue`.\n */\n annotations?: { readonly [key: string]: any };\n};\n\n/**\n * Automerge object system properties.\n * (Is automerge specific.)\n */\nexport type EntitySystem = {\n /**\n * Entity kind. `'type'` covers persisted ECHO type definitions (instances of\n * the `Type.Type` meta-schema); `'object'` / `'relation'` cover regular ECHO\n * instances.\n */\n kind?: 'object' | 'relation' | 'type';\n\n /**\n * Object reference ('protobuf' protocol) type — DXN of the schema this\n * entity instantiates.\n *\n * - For `kind === 'object'` / `'relation'` instances, this is the URI of the\n * user-defined schema the entity was created from (e.g. `dxn:org.example.Person:1.0.0`).\n * - For `kind === 'type'` entities (persisted Type.Type meta-instances) this\n * is always the URI of the `TypeSchema` meta-schema itself\n * (`dxn:org.dxos.type.schema:0.1.0`). The kind that the meta-instance\n * _describes_ (object/relation/type) lives in `data.jsonSchema.entityKind`.\n */\n type?: EncodedReference;\n\n /**\n * Deletion marker.\n */\n deleted?: boolean;\n\n /**\n * Object parent.\n * Objects with no parent are at the top level of the object hierarchy in the space.\n */\n parent?: EncodedReference;\n\n /**\n * Only for relations.\n */\n source?: EncodedReference;\n\n /**\n * Only for relations.\n */\n target?: EncodedReference;\n\n /**\n * Unix ms timestamp recorded at object creation time.\n * Set once when the ObjectStructure is first written; never modified after that.\n * Survives compaction / migrations (unlike automerge change timestamps).\n */\n createdAt?: number;\n};\n\n/**\n * Id property name.\n */\nexport const PROPERTY_ID = 'id';\n\n/**\n * Data namespace.\n * The key on {@link EntityStructure} that contains the user-defined data.\n */\nexport const DATA_NAMESPACE = 'data';\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport { type SpaceId } from '@dxos/keys';\nimport { EdgeService } from '@dxos/protocols';\nimport { compositeKey } from '@dxos/util';\n\n/**\n * Returns true if the given peerId belongs to an EDGE replicator (Automerge or Subduction).\n *\n * When `spaceId` is provided, the match is scoped to that space (peerId must start with\n * `<service>:<spaceId>`). When omitted, only the leading service segment is checked\n * (peerId must start with `<service>:`), which is useful when the caller doesn't have a\n * spaceId on hand or wants to match any edge replicator regardless of space.\n */\nexport const isEdgePeerId = (peerId: string, spaceId?: SpaceId): boolean => {\n const automergePrefix =\n spaceId !== undefined\n ? compositeKey(EdgeService.AUTOMERGE_REPLICATOR, spaceId)\n : `${EdgeService.AUTOMERGE_REPLICATOR}:`;\n const subductionPrefix =\n spaceId !== undefined\n ? compositeKey(EdgeService.SUBDUCTION_REPLICATOR, spaceId)\n : `${EdgeService.SUBDUCTION_REPLICATOR}:`;\n return peerId.startsWith(automergePrefix) || peerId.startsWith(subductionPrefix);\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport { FeedProtocol } from '@dxos/protocols';\n\nimport type { ForeignKey } from './foreign-key';\n\n/** Property name for meta when object is serialized to JSON. Matches @dxos/echo/internal ATTR_META. */\nconst ATTR_META = '@meta';\n\n/**\n * Codec for ECHO objects in feed block payload: JSON object ↔ UTF-8 bytes.\n * Encodes with queue position stripped; decodes with optional position injection.\n */\nexport class EchoFeedCodec {\n static readonly #encoder = new TextEncoder();\n static readonly #decoder = new TextDecoder();\n\n /**\n * Feed blocks are always whole-object snapshots; the index collapses entries by id to the latest\n * block. TODO(wittjosiah): Follow-up — a partial-object update block format with field-level\n * last-write-wins merge at the index (see EntityMetaIndex.update).\n */\n static encode(value: Record<string, unknown>): Uint8Array {\n const prepared = EchoFeedCodec.stripQueuePosition(value);\n return EchoFeedCodec.#encoder.encode(JSON.stringify(prepared));\n }\n\n /**\n * Decodes feed block bytes to a JSON value.\n * If position is provided, injects queue position into the decoded object's metadata.\n */\n static decode(data: Uint8Array, position?: number): Record<string, unknown> {\n const decoded = JSON.parse(EchoFeedCodec.#decoder.decode(data));\n if (position !== undefined && typeof decoded === 'object' && decoded !== null) {\n EchoFeedCodec.#setQueuePosition(decoded, position);\n }\n return decoded;\n }\n\n /**\n * Strips the queue-position foreign key from an object's metadata, producing a canonical form\n * comparable across a local snapshot and an inbound feed block (positions differ per-append).\n */\n static stripQueuePosition(value: Record<string, unknown>): Record<string, unknown> {\n if (typeof value !== 'object' || value === null) {\n return value;\n }\n const obj = structuredClone(value);\n const meta = obj[ATTR_META] as { keys?: ForeignKey[] } | undefined;\n if (meta?.keys?.some((key: ForeignKey) => key.source === FeedProtocol.KEY_QUEUE_POSITION)) {\n meta.keys = meta.keys.filter((key: ForeignKey) => key.source !== FeedProtocol.KEY_QUEUE_POSITION);\n }\n return obj;\n }\n\n static #setQueuePosition(obj: Record<string, any>, position: number): void {\n obj[ATTR_META] ??= { keys: [] };\n obj[ATTR_META]!.keys ??= [];\n const keys = obj[ATTR_META]!.keys!;\n for (let i = 0; i < keys.length; i++) {\n if (keys[i].source === FeedProtocol.KEY_QUEUE_POSITION) {\n keys.splice(i, 1);\n i--;\n }\n }\n keys.push({\n source: FeedProtocol.KEY_QUEUE_POSITION,\n id: position.toString(),\n });\n }\n}\n\n/**\n * Foreign-key source for the global position a feed block was assigned.\n * Re-exported so `@dxos/echo` can read it without depending on `@dxos/protocols`.\n */\nexport const KEY_QUEUE_POSITION = FeedProtocol.KEY_QUEUE_POSITION;\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\n\nconst ForeignKey_ = Schema.Struct({\n /**\n * Name of the foreign database/system.\n * E.g., `github.com`.\n */\n source: Schema.String,\n\n /**\n * Id within the foreign database.\n */\n // TODO(wittjosiah): This annotation is currently used to ensure id field shows up in forms.\n // TODO(dmaretskyi): `false` is not a valid value for the annotation. Use a different annotation.\n id: Schema.String.annotations({ [SchemaAST.IdentifierAnnotationId]: 'false' }),\n});\n\nexport type ForeignKey = Schema.Schema.Type<typeof ForeignKey_>;\n\n/**\n * Reference to an object in a foreign database.\n */\nexport const ForeignKey: Schema.Schema<ForeignKey> = ForeignKey_;\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Match from 'effect/Match';\nimport * as Schema from 'effect/Schema';\n\nimport { EID, EntityId, URI } from '@dxos/keys';\n\nimport { ForeignKey } from '../foreign-key';\n\n// Type identifier URI — either a DXN (typename) or an EID (stored-schema-as-object).\n// Matches the URI written into an object's `system.type` (see `getSchemaURI`). Null\n// matches any type.\nconst TypenameSpecifier = Schema.Union(URI.Schema, Schema.Null);\n\n// NOTE: This pattern with 3 definitions per schema is need to make the types opaque, and circular references in AST to not cause compiler errors.\n\n/**\n * Filter by object type and properties.\n *\n * Clauses are combined using logical AND.\n */\n// TODO(burdon): Filter object vs. relation.\nconst FilterObject_ = Schema.Struct({\n type: Schema.Literal('object'),\n\n typename: TypenameSpecifier,\n\n id: Schema.optional(Schema.Array(EntityId)),\n\n /**\n * Filter by property.\n * Must not include object ID.\n */\n props: Schema.Record({\n key: Schema.String.annotations({ description: 'Property name' }),\n value: Schema.suspend(() => Filter),\n }),\n\n /**\n * Objects that have any of the given foreign keys.\n */\n foreignKeys: Schema.optional(Schema.Array(ForeignKey)),\n\n /**\n * Match objects whose meta `key` equals this fully-qualified registry key (FQN format).\n */\n metaKey: Schema.optional(Schema.String),\n\n /**\n * Semver range matched against the object's meta `version`.\n * Only consulted when {@link metaKey} is set. Objects with no `version` do not satisfy a version-constrained filter.\n */\n metaVersion: Schema.optional(Schema.String),\n\n // NOTE: Make sure to update `FilterStep.isNoop` if you change this.\n});\nexport interface FilterObject extends Schema.Schema.Type<typeof FilterObject_> {}\nexport const FilterObject: Schema.Schema<FilterObject> = FilterObject_;\n\n/**\n * Compare.\n */\nconst FilterCompare_ = Schema.Struct({\n type: Schema.Literal('compare'),\n operator: Schema.Literal('eq', 'neq', 'gt', 'gte', 'lt', 'lte'),\n value: Schema.Unknown,\n});\nexport interface FilterCompare extends Schema.Schema.Type<typeof FilterCompare_> {}\nexport const FilterCompare: Schema.Schema<FilterCompare> = FilterCompare_;\n\n/**\n * In.\n */\nconst FilterIn_ = Schema.Struct({\n type: Schema.Literal('in'),\n values: Schema.Array(Schema.Any),\n});\nexport interface FilterIn extends Schema.Schema.Type<typeof FilterIn_> {}\nexport const FilterIn: Schema.Schema<FilterIn> = FilterIn_;\n\n/**\n * In (subquery form) — membership against a value projected from a subquery's results,\n * e.g. `threadId IN (SELECT threadId FROM feed WHERE tag = 'inbox')`.\n *\n * Nested-only (like {@link FilterIn}): valid inside an `object` filter's `props`, not at\n * the query root — the planner has no selector for a standalone membership predicate.\n * The subquery may target a different scope than the parent query; it is resolved once at\n * execution time by projecting `property` from its results into a set.\n */\nconst FilterInQuery_ = Schema.Struct({\n type: Schema.Literal('in-query'),\n subquery: Schema.suspend(() => Query),\n property: Schema.String,\n});\nexport interface FilterInQuery extends Schema.Schema.Type<typeof FilterInQuery_> {}\nexport const FilterInQuery: Schema.Schema<FilterInQuery> = FilterInQuery_;\n\n/**\n * Contains.\n */\nconst FilterContains_ = Schema.Struct({\n type: Schema.Literal('contains'),\n value: Schema.Any,\n});\n\nexport interface FilterContains extends Schema.Schema.Type<typeof FilterContains_> {}\n\n/**\n * Predicate for an array property to contain the provided value.\n * Nested objects are matched using strict structural matching.\n */\nexport const FilterContains: Schema.Schema<FilterContains> = FilterContains_;\n\n/**\n * Filters objects that have certain tag.\n */\nconst FilterTag_ = Schema.Struct({\n type: Schema.Literal('tag'),\n tag: Schema.String, // TODO(burdon): Make OR-collection?\n});\n\nexport interface FilterTag extends Schema.Schema.Type<typeof FilterTag_> {}\nexport const FilterTag: Schema.Schema<FilterTag> = FilterTag_;\n\n/**\n * Range.\n */\nconst FilterRange_ = Schema.Struct({\n type: Schema.Literal('range'),\n from: Schema.Any,\n to: Schema.Any,\n});\n\nexport interface FilterRange extends Schema.Schema.Type<typeof FilterRange_> {}\nexport const FilterRange: Schema.Schema<FilterRange> = FilterRange_;\n\n/**\n * Filter by system timestamp (createdAt / updatedAt).\n * Timestamps are unix milliseconds stored in the object meta index.\n */\nconst FilterTimestamp_ = Schema.Struct({\n type: Schema.Literal('timestamp'),\n field: Schema.Literal('createdAt', 'updatedAt'),\n operator: Schema.Literal('gt', 'gte', 'lt', 'lte'),\n value: Schema.Number,\n});\n\nexport interface FilterTimestamp extends Schema.Schema.Type<typeof FilterTimestamp_> {}\nexport const FilterTimestamp: Schema.Schema<FilterTimestamp> = FilterTimestamp_;\n\n/**\n * Text search.\n */\nconst FilterTextSearch_ = Schema.Struct({\n type: Schema.Literal('text-search'),\n text: Schema.String,\n searchKind: Schema.optional(Schema.Literal('full-text', 'vector')),\n});\n\nexport interface FilterTextSearch extends Schema.Schema.Type<typeof FilterTextSearch_> {}\nexport const FilterTextSearch: Schema.Schema<FilterTextSearch> = FilterTextSearch_;\n\n/**\n * Not.\n */\nconst FilterNot_ = Schema.Struct({\n type: Schema.Literal('not'),\n filter: Schema.suspend(() => Filter),\n});\n\nexport interface FilterNot extends Schema.Schema.Type<typeof FilterNot_> {}\nexport const FilterNot: Schema.Schema<FilterNot> = FilterNot_;\n\n/**\n * And.\n */\nconst FilterAnd_ = Schema.Struct({\n type: Schema.Literal('and'),\n filters: Schema.Array(Schema.suspend(() => Filter)),\n});\n\nexport interface FilterAnd extends Schema.Schema.Type<typeof FilterAnd_> {}\nexport const FilterAnd: Schema.Schema<FilterAnd> = FilterAnd_;\n\n/**\n * Or.\n */\nconst FilterOr_ = Schema.Struct({\n type: Schema.Literal('or'),\n filters: Schema.Array(Schema.suspend(() => Filter)),\n});\n\nexport interface FilterOr extends Schema.Schema.Type<typeof FilterOr_> {}\nexport const FilterOr: Schema.Schema<FilterOr> = FilterOr_;\n\n/**\n * Filter objects that are children of the specified parents.\n * With transitive=true (default), matches grandchildren and beyond.\n */\nconst FilterChildOf_ = Schema.Struct({\n type: Schema.Literal('child-of'),\n /** Parent DXNs to match children of. */\n parents: Schema.Array(EID.Schema),\n /** Whether to match transitively (grandchildren, etc.). Defaults to true. */\n transitive: Schema.Boolean,\n});\n\nexport interface FilterChildOf extends Schema.Schema.Type<typeof FilterChildOf_> {}\nexport const FilterChildOf: Schema.Schema<FilterChildOf> = FilterChildOf_;\n\n/**\n * Union of filters.\n */\nexport const Filter = Schema.Union(\n FilterObject,\n FilterCompare,\n FilterIn,\n FilterInQuery,\n FilterContains,\n FilterTag,\n FilterRange,\n FilterTimestamp,\n FilterTextSearch,\n FilterChildOf,\n FilterNot,\n FilterAnd,\n FilterOr,\n).annotations({ identifier: 'org.dxos.schema.filter' });\n\nexport type Filter = Schema.Schema.Type<typeof Filter>;\n\n/**\n * Query objects by type, id, and/or predicates.\n */\nconst QuerySelectClause_ = Schema.Struct({\n type: Schema.Literal('select'),\n filter: Schema.suspend(() => Filter),\n});\n\nexport interface QuerySelectClause extends Schema.Schema.Type<typeof QuerySelectClause_> {}\nexport const QuerySelectClause: Schema.Schema<QuerySelectClause> = QuerySelectClause_;\n\n/**\n * Filter objects from selection.\n */\nconst QueryFilterClause_ = Schema.Struct({\n type: Schema.Literal('filter'),\n selection: Schema.suspend(() => Query),\n filter: Schema.suspend(() => Filter),\n});\n\nexport interface QueryFilterClause extends Schema.Schema.Type<typeof QueryFilterClause_> {}\nexport const QueryFilterClause: Schema.Schema<QueryFilterClause> = QueryFilterClause_;\n\n/**\n * Traverse references from an anchor object.\n */\nconst QueryReferenceTraversalClause_ = Schema.Struct({\n type: Schema.Literal('reference-traversal'),\n anchor: Schema.suspend(() => Query),\n property: Schema.String, // TODO(dmaretskyi): Change to EscapedPropPath.\n});\n\nexport interface QueryReferenceTraversalClause extends Schema.Schema.Type<typeof QueryReferenceTraversalClause_> {}\nexport const QueryReferenceTraversalClause: Schema.Schema<QueryReferenceTraversalClause> =\n QueryReferenceTraversalClause_;\n\n/**\n * Traverse incoming references to an anchor object.\n */\nconst QueryIncomingReferencesClause_ = Schema.Struct({\n type: Schema.Literal('incoming-references'),\n anchor: Schema.suspend(() => Query),\n /**\n * Property path where the reference is located.\n * If null, matches references from any property.\n */\n property: Schema.NullOr(Schema.String),\n typename: TypenameSpecifier,\n});\n\nexport interface QueryIncomingReferencesClause extends Schema.Schema.Type<typeof QueryIncomingReferencesClause_> {}\nexport const QueryIncomingReferencesClause: Schema.Schema<QueryIncomingReferencesClause> =\n QueryIncomingReferencesClause_;\n\n/**\n * Traverse relations connecting to an anchor object.\n */\nconst QueryRelationClause_ = Schema.Struct({\n type: Schema.Literal('relation'),\n anchor: Schema.suspend(() => Query),\n /**\n * outgoing: anchor is the source of the relation.\n * incoming: anchor is the target of the relation.\n * both: anchor is either the source or target of the relation.\n */\n direction: Schema.Literal('outgoing', 'incoming', 'both'),\n filter: Schema.optional(Schema.suspend(() => Filter)),\n});\n\nexport interface QueryRelationClause extends Schema.Schema.Type<typeof QueryRelationClause_> {}\nexport const QueryRelationClause: Schema.Schema<QueryRelationClause> = QueryRelationClause_;\n\n/**\n * Traverse into the source or target of a relation.\n */\nconst QueryRelationTraversalClause_ = Schema.Struct({\n type: Schema.Literal('relation-traversal'),\n anchor: Schema.suspend(() => Query),\n direction: Schema.Literal('source', 'target', 'both'),\n});\n\nexport interface QueryRelationTraversalClause extends Schema.Schema.Type<typeof QueryRelationTraversalClause_> {}\nexport const QueryRelationTraversalClause: Schema.Schema<QueryRelationTraversalClause> = QueryRelationTraversalClause_;\n\n/**\n * Traverse parent-child hierarchy.\n */\nconst QueryHierarchyTraversalClause_ = Schema.Struct({\n type: Schema.Literal('hierarchy-traversal'),\n anchor: Schema.suspend(() => Query),\n /**\n * to-parent: traverse from child to parent.\n * to-children: traverse from parent to children.\n */\n direction: Schema.Literal('to-parent', 'to-children'),\n});\n\nexport interface QueryHierarchyTraversalClause extends Schema.Schema.Type<typeof QueryHierarchyTraversalClause_> {}\nexport const QueryHierarchyTraversalClause: Schema.Schema<QueryHierarchyTraversalClause> =\n QueryHierarchyTraversalClause_;\n\n/**\n * Union of multiple queries.\n */\nconst QueryUnionClause_ = Schema.Struct({\n type: Schema.Literal('union'),\n queries: Schema.Array(Schema.suspend(() => Query)),\n});\n\nexport interface QueryUnionClause extends Schema.Schema.Type<typeof QueryUnionClause_> {}\nexport const QueryUnionClause: Schema.Schema<QueryUnionClause> = QueryUnionClause_;\n\n/**\n * Set difference of two queries.\n */\nconst QuerySetDifferenceClause_ = Schema.Struct({\n type: Schema.Literal('set-difference'),\n source: Schema.suspend(() => Query),\n exclude: Schema.suspend(() => Query),\n});\n\nexport interface QuerySetDifferenceClause extends Schema.Schema.Type<typeof QuerySetDifferenceClause_> {}\nexport const QuerySetDifferenceClause: Schema.Schema<QuerySetDifferenceClause> = QuerySetDifferenceClause_;\n\nexport const OrderDirection = Schema.Literal('asc', 'desc');\nexport type OrderDirection = Schema.Schema.Type<typeof OrderDirection>;\n\nconst Order_ = Schema.Union(\n Schema.Struct({\n // How the database wants to order them by default. For non-feed sources this is by id;\n // for feed sources this is insertion order, so `desc` gives newest-first head reads.\n kind: Schema.Literal('natural'),\n direction: OrderDirection,\n }),\n Schema.Struct({\n kind: Schema.Literal('property'),\n property: Schema.String,\n direction: OrderDirection,\n }),\n Schema.Struct({\n // Order by relevance rank (for FTS/vector search results).\n // Default direction is 'desc' (higher rank = better match first).\n kind: Schema.Literal('rank'),\n direction: OrderDirection,\n }),\n Schema.Struct({\n // Order by system timestamp (createdAt / updatedAt) from the object meta index.\n kind: Schema.Literal('timestamp'),\n field: Schema.Literal('createdAt', 'updatedAt'),\n direction: OrderDirection,\n }),\n);\n\nexport type Order = Schema.Schema.Type<typeof Order_>;\nexport const Order: Schema.Schema<Order> = Order_;\n\n/**\n * Order the query results.\n * Left-to-right the orders dominate.\n */\nconst QueryOrderClause_ = Schema.Struct({\n type: Schema.Literal('order'),\n query: Schema.suspend(() => Query),\n order: Schema.Array(Order),\n});\n\nexport interface QueryOrderClause extends Schema.Schema.Type<typeof QueryOrderClause_> {}\nexport const QueryOrderClause: Schema.Schema<QueryOrderClause> = QueryOrderClause_;\n\n/**\n * Add options to a query.\n */\nconst QueryOptionsClause_ = Schema.Struct({\n type: Schema.Literal('options'),\n query: Schema.suspend(() => Query),\n options: Schema.suspend(() => QueryOptions),\n});\n\nexport interface QueryOptionsClause extends Schema.Schema.Type<typeof QueryOptionsClause_> {}\nexport const QueryOptionsClause: Schema.Schema<QueryOptionsClause> = QueryOptionsClause_;\n\n/**\n * Limit the number of results.\n */\nconst QueryLimitClause_ = Schema.Struct({\n type: Schema.Literal('limit'),\n query: Schema.suspend(() => Query),\n limit: Schema.Number,\n});\n\nexport interface QueryLimitClause extends Schema.Schema.Type<typeof QueryLimitClause_> {}\nexport const QueryLimitClause: Schema.Schema<QueryLimitClause> = QueryLimitClause_;\n\n/**\n * Skip a number of results (offset). Combined with `limit` and a `natural` order, this expresses\n * a windowed (paginated) read without any feed-specific query surface.\n */\nconst QuerySkipClause_ = Schema.Struct({\n type: Schema.Literal('skip'),\n query: Schema.suspend(() => Query),\n skip: Schema.Number,\n});\n\nexport interface QuerySkipClause extends Schema.Schema.Type<typeof QuerySkipClause_> {}\nexport const QuerySkipClause: Schema.Schema<QuerySkipClause> = QuerySkipClause_;\n\n/**\n * A named aggregate computed per group over its members, exposed as a top-level field on the flat\n * result record (`row[name]`) and orderable via a following `orderBy(Order.property(name))`. A\n * tagged union per kind — `property`/`limit`/`order` are present exactly when the kind uses them,\n * so read sites narrow by `kind` instead of guarding an unused optional field.\n * - `group` partitions members by a scalar `property`; its coerced key value is the field's value.\n * Composite keys are formed from multiple `group` entries. A query with no `group` entries\n * aggregates its entire input into a single row.\n * - `max`/`min` reduce a scalar member `property`.\n * - `items` collects the group's members, optionally ordered by `order` and capped to `limit`.\n * Opt-in — a row carries no members otherwise. `order` is this aggregate's own per-group\n * ordering, independent of any `orderBy` clause elsewhere in the query (which orders the whole\n * input stream / the resulting groups, not this aggregate's member selection).\n * - `count` yields the member count. Opt-in — a row carries no count otherwise.\n */\nconst GroupAggregateGroup_ = Schema.Struct({\n name: Schema.String,\n kind: Schema.Literal('group'),\n property: Schema.String,\n});\nconst GroupAggregateMax_ = Schema.Struct({ name: Schema.String, kind: Schema.Literal('max'), property: Schema.String });\nconst GroupAggregateMin_ = Schema.Struct({ name: Schema.String, kind: Schema.Literal('min'), property: Schema.String });\nconst GroupAggregateItems_ = Schema.Struct({\n name: Schema.String,\n kind: Schema.Literal('items'),\n limit: Schema.optional(Schema.Number),\n order: Schema.optional(Schema.Array(Order)),\n});\nconst GroupAggregateCount_ = Schema.Struct({ name: Schema.String, kind: Schema.Literal('count') });\n\nconst GroupAggregate_ = Schema.Union(\n GroupAggregateGroup_,\n GroupAggregateMax_,\n GroupAggregateMin_,\n GroupAggregateItems_,\n GroupAggregateCount_,\n);\n\nexport type GroupAggregate = Schema.Schema.Type<typeof GroupAggregate_>;\nexport const GroupAggregate: Schema.Schema<GroupAggregate> = GroupAggregate_;\n\n/**\n * Aggregates results into flat records. `group`-kind entries partition members into contiguous\n * groups (one row each); with no `group` entries the whole input aggregates into a single row.\n * Groups are ordered by the first occurrence of their key in the incoming (already-ordered) result\n * stream — this lets a preceding `orderBy` also control group order (e.g. ordering thread groups by\n * their most recent message). A following `orderBy(Order.property(name))` referencing an aggregate\n * or group field reorders whole groups instead. Must be the outermost data clause: only\n * `from`/`options`/`order` may wrap it.\n */\nconst QueryAggregateClause_ = Schema.Struct({\n type: Schema.Literal('aggregate'),\n query: Schema.suspend(() => Query),\n aggregates: Schema.Array(GroupAggregate),\n});\n\nexport interface QueryAggregateClause extends Schema.Schema.Type<typeof QueryAggregateClause_> {}\nexport const QueryAggregateClause: Schema.Schema<QueryAggregateClause> = QueryAggregateClause_;\n\nexport const QueryFromClause_ = Schema.Struct({\n type: Schema.Literal('from'),\n query: Schema.suspend(() => Query),\n from: Schema.Union(\n Schema.TaggedStruct('scope', {\n scopes: Schema.Array(Schema.suspend(() => Scope)),\n }),\n Schema.TaggedStruct('query', {\n query: Schema.suspend(() => Query),\n }),\n ),\n});\nexport interface QueryFromClause extends Schema.Schema.Type<typeof QueryFromClause_> {}\nexport const QueryFromClause: Schema.Schema<QueryFromClause> = QueryFromClause_;\n\nconst Query_ = Schema.Union(\n QuerySelectClause,\n QueryFilterClause,\n QueryReferenceTraversalClause,\n QueryIncomingReferencesClause,\n QueryRelationClause,\n QueryRelationTraversalClause,\n QueryHierarchyTraversalClause,\n QueryUnionClause,\n QuerySetDifferenceClause,\n QueryOrderClause,\n QueryOptionsClause,\n QueryLimitClause,\n QuerySkipClause,\n QueryAggregateClause,\n QueryFromClause,\n).annotations({ identifier: 'org.dxos.schema.query' });\n\nexport type Query = Schema.Schema.Type<typeof Query_>;\nexport const Query: Schema.Schema<Query> = Query_;\n\nexport const QueryOptions = Schema.Struct({\n /**\n * Nested select statements will use this option to filter deleted objects.\n */\n deleted: Schema.optional(Schema.Literal('include', 'exclude', 'only')),\n\n /**\n * Diagnostics-only label for logs / tooling (not used by execution semantics).\n */\n debugLabel: Schema.optional(Schema.String),\n});\n\nexport interface QueryOptions extends Schema.Schema.Type<typeof QueryOptions> {}\n\n/**\n * Selects from a space (automerge documents).\n * When `spaceId` is omitted, targets the owning space — i.e. the space of whichever\n * database executes the query. This lets callers reference \"this space\" without\n * having to look up its id.\n * When `includeAllFeeds` is true, also selects from all feeds belonging to that space.\n */\nexport const SpaceScope = Schema.TaggedStruct('space', {\n spaceId: Schema.optional(Schema.String),\n includeAllFeeds: Schema.optional(Schema.Boolean),\n});\nexport interface SpaceScope extends Schema.Schema.Type<typeof SpaceScope> {}\n\n/**\n * Selects from a specific feed (by its underlying queue DXN).\n */\nexport const FeedScope = Schema.TaggedStruct('feed', {\n feedUri: Schema.String,\n});\nexport interface FeedScope extends Schema.Schema.Type<typeof FeedScope> {}\n\n/**\n * Selects from a code-shipped object registry.\n *\n * - `'local'` — the in-process registry attached to the hypergraph.\n * - `'remote'` — a future remote registry service (not yet implemented).\n *\n * To include both, add two separate `RegistryScope` entries to the `scopes` array.\n */\nexport const RegistryScope = Schema.TaggedStruct('registry', {\n location: Schema.Literal('local', 'remote'),\n});\nexport interface RegistryScope extends Schema.Schema.Type<typeof RegistryScope> {}\n\n/**\n * Specifies the scope of the data to query from.\n * A `from` clause may carry multiple scopes; results are unioned across them.\n */\nexport const Scope = Schema.Union(SpaceScope, FeedScope, RegistryScope);\nexport type Scope = Schema.Schema.Type<typeof Scope>;\n\nexport const visit = (query: Query, visitor: (node: Query) => void) => {\n visitor(query);\n\n Match.value(query).pipe(\n Match.when({ type: 'filter' }, ({ selection }) => visit(selection, visitor)),\n Match.when({ type: 'reference-traversal' }, ({ anchor }) => visit(anchor, visitor)),\n Match.when({ type: 'incoming-references' }, ({ anchor }) => visit(anchor, visitor)),\n Match.when({ type: 'relation' }, ({ anchor }) => visit(anchor, visitor)),\n Match.when({ type: 'options' }, ({ query }) => visit(query, visitor)),\n Match.when({ type: 'relation-traversal' }, ({ anchor }) => visit(anchor, visitor)),\n Match.when({ type: 'hierarchy-traversal' }, ({ anchor }) => visit(anchor, visitor)),\n Match.when({ type: 'union' }, ({ queries }) => queries.forEach((q) => visit(q, visitor))),\n Match.when({ type: 'set-difference' }, ({ source, exclude }) => {\n visit(source, visitor);\n visit(exclude, visitor);\n }),\n Match.when({ type: 'order' }, ({ query }) => visit(query, visitor)),\n Match.when({ type: 'limit' }, ({ query }) => visit(query, visitor)),\n Match.when({ type: 'skip' }, ({ query }) => visit(query, visitor)),\n Match.when({ type: 'aggregate' }, ({ query }) => visit(query, visitor)),\n Match.when({ type: 'from' }, (node) => {\n visit(node.query, visitor);\n if (node.from._tag === 'query') {\n visit(node.from.query, visitor);\n }\n }),\n Match.when({ type: 'select' }, () => {}),\n Match.exhaustive,\n );\n};\n\n/**\n * Recursively transforms a query tree bottom-up.\n * The mapper receives each node with its children already transformed.\n */\nexport const map = (query: Query, mapper: (node: Query) => Query): Query => {\n const mapped: Query = Match.value(query).pipe(\n Match.when({ type: 'filter' }, (node) => ({ ...node, selection: map(node.selection, mapper) })),\n Match.when({ type: 'reference-traversal' }, (node) => ({ ...node, anchor: map(node.anchor, mapper) })),\n Match.when({ type: 'incoming-references' }, (node) => ({ ...node, anchor: map(node.anchor, mapper) })),\n Match.when({ type: 'relation' }, (node) => ({ ...node, anchor: map(node.anchor, mapper) })),\n Match.when({ type: 'relation-traversal' }, (node) => ({ ...node, anchor: map(node.anchor, mapper) })),\n Match.when({ type: 'hierarchy-traversal' }, (node) => ({ ...node, anchor: map(node.anchor, mapper) })),\n Match.when({ type: 'options' }, (node) => ({ ...node, query: map(node.query, mapper) })),\n Match.when({ type: 'order' }, (node) => ({ ...node, query: map(node.query, mapper) })),\n Match.when({ type: 'limit' }, (node) => ({ ...node, query: map(node.query, mapper) })),\n Match.when({ type: 'skip' }, (node) => ({ ...node, query: map(node.query, mapper) })),\n Match.when({ type: 'aggregate' }, (node) => ({ ...node, query: map(node.query, mapper) })),\n Match.when({ type: 'from' }, (node) => ({\n ...node,\n query: map(node.query, mapper),\n ...(node.from._tag === 'query' ? { from: { _tag: 'query' as const, query: map(node.from.query, mapper) } } : {}),\n })),\n Match.when({ type: 'union' }, (node) => ({ ...node, queries: node.queries.map((q) => map(q, mapper)) })),\n Match.when({ type: 'set-difference' }, (node) => ({\n ...node,\n source: map(node.source, mapper),\n exclude: map(node.exclude, mapper),\n })),\n Match.when({ type: 'select' }, (node) => node),\n Match.exhaustive,\n );\n return mapper(mapped);\n};\n\nexport const fold = <T>(query: Query, reducer: (node: Query) => T): T[] => {\n return Match.value(query).pipe(\n Match.withReturnType<T[]>(),\n Match.when({ type: 'filter' }, ({ selection }) => fold(selection, reducer)),\n Match.when({ type: 'reference-traversal' }, ({ anchor }) => fold(anchor, reducer)),\n Match.when({ type: 'incoming-references' }, ({ anchor }) => fold(anchor, reducer)),\n Match.when({ type: 'relation' }, ({ anchor }) => fold(anchor, reducer)),\n Match.when({ type: 'options' }, ({ query }) => fold(query, reducer)),\n Match.when({ type: 'relation-traversal' }, ({ anchor }) => fold(anchor, reducer)),\n Match.when({ type: 'hierarchy-traversal' }, ({ anchor }) => fold(anchor, reducer)),\n Match.when({ type: 'union' }, ({ queries }) => queries.flatMap((q) => fold(q, reducer))),\n Match.when({ type: 'set-difference' }, ({ source, exclude }) =>\n fold(source, reducer).concat(fold(exclude, reducer)),\n ),\n Match.when({ type: 'order' }, ({ query }) => fold(query, reducer)),\n Match.when({ type: 'limit' }, ({ query }) => fold(query, reducer)),\n Match.when({ type: 'skip' }, ({ query }) => fold(query, reducer)),\n Match.when({ type: 'aggregate' }, ({ query }) => fold(query, reducer)),\n Match.when({ type: 'from' }, (node) => {\n const results = fold(node.query, reducer);\n if (node.from._tag === 'query') {\n return results.concat(fold(node.from.query, reducer));\n }\n return results;\n }),\n Match.when({ type: 'select' }, () => []),\n Match.exhaustive,\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\n/**\n * Denotes the data version of the space automerge document as well as the leaf documents for each individual ECHO object.\n */\nexport type SpaceDocVersion = number & { __type: 'SpaceDocVersion' };\n\nexport const SpaceDocVersion = Object.freeze({\n /**\n * For the documents created before the versioning was introduced.\n */\n LEGACY: 0 as SpaceDocVersion,\n\n /**\n * Current version.\n */\n CURRENT: 1 as SpaceDocVersion,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAQA,IAAa,qBAAqB;AASlC,IAAa,sBAAsB,UACjC,OAAO,UAAU,YAAY,UAAU,QAAQ,OAAO,KAAK,KAAK,CAAC,CAAC,WAAW,KAAK,OAAO,MAAM,SAAS;AAE1G,IAAa,mBAAmB,OAAO,OAAO;CAC5C;;;;;CAKA,QAAQ,UAAqC;EAC3C,eAAe,mBAAmB,KAA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AAI,SAAS;EACrC,MAAM,UAAU,KAAK,KAAK,OAAO,OAAO;EACxC,IAAI,KAAK,KAAK,SAAS,SACrB,OAAO,QAAQ,OAAO,KAAK,KAAK,KAAK,OAAO,OAAO,CAAC;EAEtD,OAAO;CACT,CAAC,GACD,MAAM,KAAK,EAAE,MAAM,SAAS,SAAS,CAAC,CAAC,GACvC,MAAM,UACR;AACF;;;ACjqBA,IAAa,kBAAkB,OAAO,OAAO;;;;CAI3C,QAAQ;;;;CAKR,SAAS;AACX,CAAC"}
@@ -0,0 +1,40 @@
1
+ import { type SpaceId } from '@dxos/keys';
2
+ export interface BlobPutRequest {
3
+ spaceId: SpaceId;
4
+ data: Uint8Array;
5
+ contentType?: string;
6
+ /** Lowercase hex SHA-256 digest of `data`, computed by the manager. The backend does not verify it. */
7
+ contentHash: string;
8
+ /** For path-addressed extension backends. */
9
+ name?: string;
10
+ }
11
+ export interface BlobPutResponse {
12
+ /** URI locating the stored bytes; must use a scheme the backend resolves. */
13
+ uri: string;
14
+ }
15
+ /**
16
+ * Implemented by pluggable blob storage backends and registered on the Hypergraph via
17
+ * `registerBlobBackend`.
18
+ */
19
+ export interface BlobBackend {
20
+ /** URI schemes this backend resolves at read time. */
21
+ readonly schemes: readonly string[];
22
+ /** Largest `data.byteLength` this backend accepts, in bytes. `undefined` means unlimited. */
23
+ readonly maxSize?: number;
24
+ put(request: BlobPutRequest): Promise<BlobPutResponse>;
25
+ /** `undefined` means the URI was not found. Rejects on transport failure (e.g. offline). */
26
+ get(request: {
27
+ spaceId: SpaceId;
28
+ uri: string;
29
+ }): Promise<Uint8Array | undefined>;
30
+ has(request: {
31
+ spaceId: SpaceId;
32
+ uri: string;
33
+ }): Promise<boolean>;
34
+ getUrl?(request: {
35
+ spaceId: SpaceId;
36
+ uri: string;
37
+ contentType?: string;
38
+ }): Promise<string | undefined>;
39
+ }
40
+ //# sourceMappingURL=blob.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blob.d.ts","sourceRoot":"","sources":["../../../src/blob.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,UAAU,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uGAAuG;IACvG,WAAW,EAAE,MAAM,CAAC;IACpB,6CAA6C;IAC7C,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,eAAe;IAC9B,6EAA6E;IAC7E,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,sDAAsD;IACtD,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,6FAA6F;IAC7F,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,GAAG,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IACvD,4FAA4F;IAC5F,GAAG,CAAC,OAAO,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC;IACjF,GAAG,CAAC,OAAO,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAClE,MAAM,CAAC,CAAC,OAAO,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;CACxG"}
@@ -1,4 +1,4 @@
1
- import type { EntityId, URI } from '@dxos/keys';
1
+ import { type EntityId, SpaceId, type URI } from '@dxos/keys';
2
2
  import { type RawString } from './automerge';
3
3
  import type { ForeignKey } from './foreign-key';
4
4
  import { type EncodedReference } from './reference';
@@ -17,7 +17,18 @@ export type EntityPropPath = EntityProp[];
17
17
  export interface DatabaseDirectory {
18
18
  version?: SpaceDocVersion;
19
19
  access?: {
20
- spaceKey: string;
20
+ /**
21
+ * ID of the space that owns the document.
22
+ */
23
+ spaceId?: SpaceId;
24
+ /**
25
+ * @deprecated Use {@link spaceId}. Still written alongside `spaceId` so older clients
26
+ * (and code paths that need the space public key, which cannot be recovered from the id)
27
+ * keep working.
28
+ *
29
+ * Space key of the owning space in hex format without the 0x prefix.
30
+ */
31
+ spaceKey?: string;
21
32
  };
22
33
  /**
23
34
  * Objects inlined in the current document.
@@ -31,21 +42,78 @@ export interface DatabaseDirectory {
31
42
  links?: {
32
43
  [echoUri: string]: string | RawString;
33
44
  };
45
+ /**
46
+ * Per-object branch registry. Keyed by the subtree-root object id, then by branch name; each
47
+ * branch records the automerge doc url holding each subtree member at that branch.
48
+ *
49
+ * This is the single synced source of truth for branches: it is both the branch list/membership
50
+ * AND the set of branch documents the space must replicate (the host collects these urls in
51
+ * {@link getAllBranchDocUrls}). The client document loader does NOT treat these urls as object
52
+ * links, so branch docs never materialize as phantom objects. The implicit `'main'` branch is
53
+ * never listed here (it is the object's main doc via {@link links}).
54
+ *
55
+ * Which branch a device is currently viewing is NOT stored here — that is device-local,
56
+ * non-synced state.
57
+ */
58
+ branches?: SpaceBranchRegistry;
34
59
  /**
35
60
  * @deprecated
36
61
  * For backward compatibility.
37
62
  */
38
63
  experimental_spaceKey?: string;
39
64
  }
65
+ /**
66
+ * @see DatabaseDirectory.branches
67
+ */
68
+ export type SpaceBranchRegistry = {
69
+ [rootObjectId: string]: {
70
+ [branchName: string]: BranchRecord;
71
+ };
72
+ };
73
+ export type BranchRecord = {
74
+ /** Subtree member object id -> automerge doc url holding that member on this branch. */
75
+ members: {
76
+ [objectId: string]: string | RawString;
77
+ };
78
+ /**
79
+ * The root object's main-doc heads at fork time. Provenance only — currently written but never
80
+ * read; the merge relies on shared automerge ancestry, not this field.
81
+ */
82
+ baseHeads?: string[];
83
+ /** Unix ms timestamp at branch creation. */
84
+ createdAt?: number;
85
+ };
40
86
  export declare const DatabaseDirectory: Readonly<{
41
87
  /**
88
+ * @returns ID of the space that owns the document.
89
+ * Coalesces `access.spaceId` with the deprecated space key fields (`access.spaceKey`,
90
+ * `experimental_spaceKey`), deriving the id from the key for documents that predate `spaceId`.
91
+ */
92
+ getSpaceId: (doc: DatabaseDirectory) => Promise<SpaceId | null>;
93
+ /**
94
+ * @deprecated Use {@link DatabaseDirectory.getSpaceId}. Only paths that require the space
95
+ * public key (which cannot be derived from the space id) should read the key.
96
+ *
42
97
  * @returns Space key in hex of the space that owns the document. In hex format. Without 0x prefix.
43
98
  */
44
99
  getSpaceKey: (doc: DatabaseDirectory) => string | null;
45
100
  getInlineObject: (doc: DatabaseDirectory, id: EntityId) => EntityStructure | undefined;
46
101
  getLink: (doc: DatabaseDirectory, id: EntityId) => string | undefined;
47
- make: ({ spaceKey, objects, links, }: {
48
- spaceKey: string;
102
+ /**
103
+ * @returns The branch registry for a subtree-root object, or undefined if it has no branches.
104
+ */
105
+ getBranches: (doc: DatabaseDirectory, rootObjectId: EntityId) => Record<string, BranchRecord> | undefined;
106
+ /**
107
+ * @returns All branch document urls referenced anywhere in the registry. Used by the host to
108
+ * decide which documents to replicate (branch docs are NOT object links).
109
+ */
110
+ getAllBranchDocUrls: (doc: DatabaseDirectory) => string[];
111
+ make: ({ spaceId, spaceKey, objects, links, }: {
112
+ spaceId?: SpaceId;
113
+ /**
114
+ * @deprecated Provide {@link spaceId}. The key is still stamped for older clients.
115
+ */
116
+ spaceKey?: string;
49
117
  objects?: Record<string, EntityStructure>;
50
118
  links?: Record<string, RawString>;
51
119
  }) => DatabaseDirectory;
@@ -1 +1 @@
1
- {"version":3,"file":"document-structure.d.ts","sourceRoot":"","sources":["../../../src/document-structure.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,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EtC;;;;;;;;;;OAUG;IACH,IAAI,CAAC,EAAE,gBAAgB,CAAC;IAExB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;OAGG;IACH,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAE1B;;OAEG;IACH,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAE1B;;OAEG;IACH,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAE1B;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,OAAO,CAAC;AAEhC;;;GAGG;AACH,eAAO,MAAM,cAAc,SAAS,CAAC"}
@@ -5,7 +5,9 @@
5
5
  export declare class EchoFeedCodec {
6
6
  #private;
7
7
  /**
8
- * Prepares a value for feed storage (strips queue position from metadata) and encodes to bytes.
8
+ * Feed blocks are always whole-object snapshots; the index collapses entries by id to the latest
9
+ * block. TODO(wittjosiah): Follow-up — a partial-object update block format with field-level
10
+ * last-write-wins merge at the index (see EntityMetaIndex.update).
9
11
  */
10
12
  static encode(value: Record<string, unknown>): Uint8Array;
11
13
  /**
@@ -13,5 +15,15 @@ export declare class EchoFeedCodec {
13
15
  * If position is provided, injects queue position into the decoded object's metadata.
14
16
  */
15
17
  static decode(data: Uint8Array, position?: number): Record<string, unknown>;
18
+ /**
19
+ * Strips the queue-position foreign key from an object's metadata, producing a canonical form
20
+ * comparable across a local snapshot and an inbound feed block (positions differ per-append).
21
+ */
22
+ static stripQueuePosition(value: Record<string, unknown>): Record<string, unknown>;
16
23
  }
24
+ /**
25
+ * Foreign-key source for the global position a feed block was assigned.
26
+ * Re-exported so `@dxos/echo` can read it without depending on `@dxos/protocols`.
27
+ */
28
+ export declare const KEY_QUEUE_POSITION = "org.dxos.key.queue-position";
17
29
  //# sourceMappingURL=echo-feed-codec.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"echo-feed-codec.d.ts","sourceRoot":"","sources":["../../../src/echo-feed-codec.ts"],"names":[],"mappings":"AAWA;;;GAGG;AACH,qBAAa,aAAa;;IAIxB;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,UAAU,CAGxD;IAED;;;OAGG;IACH,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAM1E;CA6BF"}
1
+ {"version":3,"file":"echo-feed-codec.d.ts","sourceRoot":"","sources":["../../../src/echo-feed-codec.ts"],"names":[],"mappings":"AAWA;;;GAGG;AACH,qBAAa,aAAa;;IAIxB;;;;OAIG;IACH,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,UAAU,CAGxD;IAED;;;OAGG;IACH,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAM1E;IAED;;;OAGG;IACH,MAAM,CAAC,kBAAkB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAUjF;CAiBF;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB,gCAAkC,CAAC"}
@@ -1,3 +1,4 @@
1
+ export * from './blob';
1
2
  export type * from './collection-sync';
2
3
  export * from './document-structure';
3
4
  export * from './edge-peer';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,mBAAmB,mBAAmB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,QAAQ,CAAC;AACvB,mBAAmB,mBAAmB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC"}