@dxos/index-core 0.0.0 → 0.8.4-main.59c2e9b

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.
Files changed (42) hide show
  1. package/dist/lib/browser/index.mjs +559 -0
  2. package/dist/lib/browser/index.mjs.map +7 -0
  3. package/dist/lib/browser/meta.json +1 -0
  4. package/dist/lib/node-esm/index.mjs +561 -0
  5. package/dist/lib/node-esm/index.mjs.map +7 -0
  6. package/dist/lib/node-esm/meta.json +1 -0
  7. package/dist/types/src/index-engine.d.ts +63 -0
  8. package/dist/types/src/index-engine.d.ts.map +1 -0
  9. package/dist/types/src/index-engine.test.d.ts +2 -0
  10. package/dist/types/src/index-engine.test.d.ts.map +1 -0
  11. package/dist/types/src/index-tracker.d.ts +44 -0
  12. package/dist/types/src/index-tracker.d.ts.map +1 -0
  13. package/dist/types/src/index-tracker.test.d.ts +2 -0
  14. package/dist/types/src/index-tracker.test.d.ts.map +1 -0
  15. package/dist/types/src/index.d.ts +7 -0
  16. package/dist/types/src/index.d.ts.map +1 -0
  17. package/dist/types/src/indexes/fts-index.d.ts +63 -0
  18. package/dist/types/src/indexes/fts-index.d.ts.map +1 -0
  19. package/dist/types/src/indexes/fts-index.test.d.ts +2 -0
  20. package/dist/types/src/indexes/fts-index.test.d.ts.map +1 -0
  21. package/dist/types/src/indexes/fts5.test.d.ts +2 -0
  22. package/dist/types/src/indexes/fts5.test.d.ts.map +1 -0
  23. package/dist/types/src/indexes/index.d.ts +5 -0
  24. package/dist/types/src/indexes/index.d.ts.map +1 -0
  25. package/dist/types/src/indexes/interface.d.ts +47 -0
  26. package/dist/types/src/indexes/interface.d.ts.map +1 -0
  27. package/dist/types/src/indexes/object-meta-index.d.ts +37 -0
  28. package/dist/types/src/indexes/object-meta-index.d.ts.map +1 -0
  29. package/dist/types/src/indexes/object-meta-index.test.d.ts +2 -0
  30. package/dist/types/src/indexes/object-meta-index.test.d.ts.map +1 -0
  31. package/dist/types/src/indexes/reverse-ref-index.d.ts +37 -0
  32. package/dist/types/src/indexes/reverse-ref-index.d.ts.map +1 -0
  33. package/dist/types/src/indexes/reverse-ref-index.test.d.ts +2 -0
  34. package/dist/types/src/indexes/reverse-ref-index.test.d.ts.map +1 -0
  35. package/dist/types/src/utils.d.ts +17 -0
  36. package/dist/types/src/utils.d.ts.map +1 -0
  37. package/dist/types/tsconfig.tsbuildinfo +1 -0
  38. package/package.json +7 -2
  39. package/src/index-engine.test.ts +8 -5
  40. package/src/index-engine.ts +18 -7
  41. package/src/index.ts +2 -2
  42. package/src/indexes/fts-index.ts +41 -2
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/index-engine.ts", "../../../src/index-tracker.ts", "../../../src/indexes/fts-index.ts", "../../../src/indexes/object-meta-index.ts", "../../../src/indexes/reverse-ref-index.ts", "../../../src/utils.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2026 DXOS.org\n//\n\nimport type * as SqlClient from '@effect/sql/SqlClient';\nimport type * as SqlError from '@effect/sql/SqlError';\nimport * as Effect from 'effect/Effect';\n\nimport type { SpaceId } from '@dxos/keys';\nimport * as SqlTransaction from '@dxos/sql-sqlite/SqlTransaction';\n\nimport { type IndexCursor, IndexTracker } from './index-tracker';\nimport {\n FtsIndex,\n type FtsQuery,\n type FtsQueryResult,\n type Index,\n type IndexerObject,\n type ObjectMeta,\n ObjectMetaIndex,\n ReverseRefIndex,\n type ReverseRefQuery,\n} from './indexes';\n\n/**\n * Cursor into indexable data-source.\n */\nexport interface DataSourceCursor {\n spaceId: SpaceId | null;\n\n /**\n * documentId or queueId.\n */\n resourceId: string | null;\n\n /**\n * heads or queue position.\n */\n cursor: number | string;\n}\n\nexport interface IndexDataSource {\n readonly sourceName: string; // e.g. queue, automerge, etc.\n\n getChangedObjects(\n cursors: DataSourceCursor[],\n opts?: { limit?: number },\n ): Effect.Effect<{ objects: IndexerObject[]; cursors: DataSourceCursor[] }>;\n}\n\nexport interface IndexEngineParams {\n tracker: IndexTracker;\n objectMetaIndex: ObjectMetaIndex;\n ftsIndex: FtsIndex;\n reverseRefIndex: ReverseRefIndex;\n}\n\nexport class IndexEngine {\n readonly #tracker: IndexTracker;\n readonly #objectMetaIndex: ObjectMetaIndex;\n readonly #ftsIndex: FtsIndex;\n readonly #reverseRefIndex: ReverseRefIndex;\n\n constructor(params?: IndexEngineParams) {\n this.#tracker = params?.tracker ?? new IndexTracker();\n this.#objectMetaIndex = params?.objectMetaIndex ?? new ObjectMetaIndex();\n this.#ftsIndex = params?.ftsIndex ?? new FtsIndex();\n this.#reverseRefIndex = params?.reverseRefIndex ?? new ReverseRefIndex();\n }\n\n migrate() {\n return Effect.gen(this, function* () {\n yield* this.#tracker.migrate();\n yield* this.#objectMetaIndex.migrate();\n yield* this.#ftsIndex.migrate();\n yield* this.#reverseRefIndex.migrate();\n });\n }\n\n /**\n * Query text index and return full object metadata with rank.\n */\n queryText(query: FtsQuery): Effect.Effect<readonly FtsQueryResult[], SqlError.SqlError, SqlClient.SqlClient> {\n return Effect.gen(this, function* () {\n return yield* this.#ftsIndex.query(query);\n });\n }\n\n queryReverseRef(query: ReverseRefQuery) {\n // TODO(mykola): Join with metadata table here.\n return this.#reverseRefIndex.query(query);\n }\n\n /**\n * Query snapshots by recordIds.\n * Used to load queue objects from indexed snapshots.\n */\n querySnapshotsJSON(recordIds: number[]) {\n return this.#ftsIndex.querySnapshotsJSON(recordIds);\n }\n\n queryType(\n query: Pick<ObjectMeta, 'spaceId' | 'typeDxn'>,\n ): Effect.Effect<readonly ObjectMeta[], SqlError.SqlError, SqlClient.SqlClient> {\n return this.#objectMetaIndex.query(query);\n }\n\n update(\n dataSource: IndexDataSource,\n opts: { spaceId: SpaceId | null; limit?: number },\n ): Effect.Effect<\n { updated: number; done: boolean },\n SqlError.SqlError,\n SqlTransaction.SqlTransaction | SqlClient.SqlClient\n > {\n return Effect.gen(this, function* () {\n let updated = 0;\n\n const { updated: updatedFtsIndex, done: doneFtsIndex } = yield* this.#update(this.#ftsIndex, dataSource, {\n indexName: 'fts',\n spaceId: opts.spaceId,\n limit: opts.limit,\n });\n updated += updatedFtsIndex;\n\n const { updated: updatedReverseRefIndex, done: doneReverseRefIndex } = yield* this.#update(\n this.#reverseRefIndex,\n dataSource,\n {\n indexName: 'reverseRef',\n spaceId: opts.spaceId,\n limit: opts.limit,\n },\n );\n updated += updatedReverseRefIndex;\n\n return { updated, done: doneFtsIndex && doneReverseRefIndex };\n }).pipe(Effect.withSpan('IndexEngine.update'));\n }\n\n /**\n * Update a dependent index that requires recordId enrichment.\n * This method:\n * 1. Gets changed objects from the source.\n * 2. Ensures those objects exist in ObjectMetaIndex.\n * 3. Looks up recordIds for those objects.\n * 4. Enriches objects with recordIds.\n * 5. Updates the dependent index.\n */\n #update(\n index: Index,\n source: IndexDataSource,\n opts: { indexName: string; spaceId: SpaceId | null; limit?: number },\n ): Effect.Effect<\n { updated: number; done: boolean },\n SqlError.SqlError,\n SqlTransaction.SqlTransaction | SqlClient.SqlClient\n > {\n return Effect.gen(this, function* () {\n const sqlTransaction = yield* SqlTransaction.SqlTransaction;\n\n return yield* sqlTransaction.withTransaction(\n Effect.gen(this, function* () {\n const cursors = yield* this.#tracker.queryCursors({\n indexName: opts.indexName,\n sourceName: source.sourceName,\n // Pass undefined to get all cursors when spaceId is null.\n spaceId: opts.spaceId ?? undefined,\n });\n const { objects, cursors: updatedCursors } = yield* source.getChangedObjects(cursors, { limit: opts.limit });\n if (objects.length === 0) {\n return { updated: 0, done: true };\n }\n\n // Ensure objects exist in ObjectMetaIndex.\n yield* this.#objectMetaIndex.update(objects);\n\n // Look up recordIds for the objects.\n yield* this.#objectMetaIndex.lookupRecordIds(objects);\n\n yield* index.update(objects);\n yield* this.#tracker.updateCursors(\n updatedCursors.map(\n (_): IndexCursor => ({\n indexName: opts.indexName,\n spaceId: _.spaceId,\n sourceName: source.sourceName,\n resourceId: _.resourceId,\n cursor: _.cursor,\n }),\n ),\n );\n return { updated: objects.length, done: false };\n }),\n );\n }).pipe(Effect.withSpan('IndexEngine.#updateDependentIndex'));\n }\n}\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport * as SqlClient from '@effect/sql/SqlClient';\nimport type * as SqlError from '@effect/sql/SqlError';\nimport * as Effect from 'effect/Effect';\nimport * as Schema from 'effect/Schema';\n\nimport { SpaceId } from '@dxos/keys';\n\nexport const IndexCursor = Schema.Struct({\n /**\n * Name of the index owning this cursor.\n */\n indexName: Schema.String,\n /**\n * Space id.\n */\n spaceId: Schema.NullOr(SpaceId),\n /**\n * Source name.\n * 'automerge' / 'queue' / 'index' (for secondary indexes)\n */\n sourceName: Schema.String,\n /**\n * Document id or queue id.\n * doc_id, queue_id, '' <empty string> (if indexing entire namespace)\n */\n resourceId: Schema.NullOr(Schema.String),\n /**\n * Heads, queue position, version.\n */\n cursor: Schema.Union(Schema.Number, Schema.String),\n});\nexport interface IndexCursor extends Schema.Schema.Type<typeof IndexCursor> {}\n\nexport class IndexTracker {\n migrate = Effect.fn('IndexTracker.migrate')(function* () {\n const sql = yield* SqlClient.SqlClient;\n\n // For automerge: last-indexed heads of the document\n // For queue: the position of the item that was indexed last\n yield* sql`CREATE TABLE IF NOT EXISTS indexCursor (\n indexName TEXT NOT NULL,\n spaceId TEXT NOT NULL DEFAULT '',\n sourceName TEXT NOT NULL,\n resourceId TEXT NOT NULL DEFAULT '',\n cursor,\n PRIMARY KEY (indexName, spaceId, sourceName, resourceId)\n )`;\n });\n\n queryCursors = Effect.fn('IndexTracker.queryCursors')(\n (\n query: Pick<IndexCursor, 'indexName'> & Partial<Pick<IndexCursor, 'sourceName' | 'resourceId' | 'spaceId'>>,\n ): Effect.Effect<IndexCursor[], SqlError.SqlError, SqlClient.SqlClient> =>\n Effect.gen(function* () {\n const sql = yield* SqlClient.SqlClient;\n\n const spaceIdParam = query.spaceId === undefined ? null : (query.spaceId ?? '');\n const sourceNameParam = query.sourceName === undefined ? null : query.sourceName;\n const resourceIdParam = query.resourceId === undefined ? null : (query.resourceId ?? '');\n\n const rows = yield* sql<IndexCursor>`\n SELECT * FROM indexCursor \n WHERE indexName = ${query.indexName}\n AND (${spaceIdParam} IS NULL OR spaceId = ${spaceIdParam})\n AND (${sourceNameParam} IS NULL OR sourceName = ${sourceNameParam})\n AND (${resourceIdParam} IS NULL OR resourceId = ${resourceIdParam})\n `;\n\n return rows.map(\n (row): IndexCursor => ({\n indexName: row.indexName,\n spaceId: row.spaceId === '' ? null : Schema.decodeSync(SpaceId)(row.spaceId!),\n sourceName: row.sourceName,\n resourceId: row.resourceId === '' ? null : row.resourceId,\n cursor: row.cursor,\n }),\n );\n }),\n );\n\n updateCursors = Effect.fn('IndexTracker.updateCursors')(\n (cursors: IndexCursor[]): Effect.Effect<void, SqlError.SqlError, SqlClient.SqlClient> =>\n Effect.gen(function* () {\n const sql = yield* SqlClient.SqlClient;\n yield* Effect.forEach(\n cursors,\n (cursor) => {\n const spaceId = cursor.spaceId ?? '';\n const resourceId = cursor.resourceId ?? '';\n return sql`\n INSERT INTO indexCursor (indexName, spaceId, sourceName, resourceId, cursor)\n VALUES (${cursor.indexName}, ${spaceId}, ${cursor.sourceName}, ${resourceId}, ${cursor.cursor})\n ON CONFLICT(indexName, spaceId, sourceName, resourceId) DO UPDATE SET cursor = excluded.cursor\n `;\n },\n { discard: true },\n );\n }),\n );\n}\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport * as SqlClient from '@effect/sql/SqlClient';\nimport type * as SqlError from '@effect/sql/SqlError';\nimport type * as Statement from '@effect/sql/Statement';\nimport * as Effect from 'effect/Effect';\n\nimport type { Obj } from '@dxos/echo';\nimport type { ObjectId, SpaceId } from '@dxos/keys';\n\nimport type { Index, IndexerObject } from './interface';\nimport type { ObjectMeta } from './object-meta-index';\n\n/**\n * The space and queue constrains are combined together using a logical OR.\n */\nexport interface FtsQuery {\n /**\n * Text to search.\n */\n query: string;\n\n /**\n * Space ID to search within.\n */\n spaceId: readonly SpaceId[] | null;\n\n /**\n * If true, include all queues in the spaces specified by `spaceId`.\n */\n includeAllQueues: boolean;\n\n /**\n * Queue IDs to search within.\n */\n queueIds: readonly ObjectId[] | null;\n}\n\n/**\n * Result of FTS query including the indexed snapshot data.\n */\nexport interface FtsResult extends ObjectMeta {\n /**\n * The indexed snapshot data (JSON string).\n * Used to load queue objects without going through document loading.\n */\n snapshot: string;\n}\n\n/**\n * Result of FTS query with rank.\n */\nexport interface FtsQueryResult extends ObjectMeta {\n /**\n * Relevance rank from FTS5.\n * Higher values indicate better matches.\n * Uses BM25 algorithm when available, falls back to 1 for non-BM25 queries.\n */\n rank: number;\n}\n\n/**\n * Escapes user input for safe FTS5 queries.\n *\n * FTS5 has special syntax characters that can cause errors or unexpected behavior:\n * - `*` suffix for prefix matching (e.g., `prog*` matches \"program\", \"programming\")\n * - `\"...\"` for phrase queries\n * - `.` for column specification\n * - `AND`, `OR`, `NOT` boolean operators\n * - `+`, `-` for required/excluded terms\n *\n * This function wraps each whitespace-separated term in double quotes, treating all\n * characters as literals. Double quotes within terms are escaped by doubling (`\"\"`).\n *\n * Example: `prog* AND test.` becomes `\"prog*\" \"AND\" \"test.\"`.\n */\nconst escapeFts5Query = (text: string): string => {\n return text\n .split(/\\s+/)\n .filter(Boolean)\n .map((term) => `\"${term.replace(/\"/g, '\"\"')}\"`)\n .join(' ');\n};\n\nexport class FtsIndex implements Index {\n migrate = Effect.fn('FtsIndex.migrate')(function* () {\n const sql = yield* SqlClient.SqlClient;\n\n // https://sqlite.org/fts5.html#the_trigram_tokenizer\n // FTS5 tables are created as virtual tables; they implicitly have a `rowid`.\n // Trigram tokenizer enables substring matching (e.g., \"rog\" matches \"programming\").\n //\n // Data structure: inverted index mapping trigrams to document IDs.\n // \"hello\" → trigrams [\"hel\", \"ell\", \"llo\"] → B-tree entries: \"hel\"→[1], \"ell\"→[1], \"llo\"→[1].\n // Query \"ell\" → O(log n) B-tree lookup → returns [1].\n // Posting lists are compressed, so index size scales well with document count.\n yield* sql`CREATE VIRTUAL TABLE IF NOT EXISTS ftsIndex USING fts5(snapshot, tokenize='trigram')`;\n });\n\n query({\n query,\n spaceId,\n includeAllQueues,\n queueIds,\n }: FtsQuery): Effect.Effect<readonly FtsQueryResult[], SqlError.SqlError, SqlClient.SqlClient> {\n return Effect.gen(function* () {\n const trimmed = query.trim();\n if (trimmed.length === 0) {\n return [];\n }\n\n const sql = yield* SqlClient.SqlClient;\n\n // Trigram tokenizer requires at least 3 characters per term.\n // Check if ALL terms are at least 3 chars; otherwise use LIKE fallback.\n const terms = trimmed.split(/\\s+/).filter(Boolean);\n const minTermLength = Math.min(...terms.map((t) => t.length));\n\n // Use BM25 ranking for FTS5 MATCH queries, fall back to rank 1 for LIKE queries.\n // BM25 returns negative values where lower (more negative) means better match,\n // so we negate it to get higher = better.\n const useBm25 = minTermLength >= 3;\n\n const conditions =\n minTermLength < 3\n ? // LIKE fallback - scan the entire table, AND all terms.\n terms.map((term) => sql`f.snapshot LIKE ${'%' + term + '%'}`)\n : // MATCH - fast index lookup.\n [sql`f.snapshot MATCH ${escapeFts5Query(trimmed)}`];\n\n // Space and queue constraints are combined with OR.\n const sourceConditions: Statement.Statement<{}>[] = [];\n\n if (spaceId && spaceId.length > 0) {\n if (includeAllQueues) {\n // All items from these spaces (both space objects and queue objects).\n sourceConditions.push(sql`m.spaceId IN ${sql.in(spaceId)}`);\n } else {\n // Only space objects (not queue objects) from these spaces.\n sourceConditions.push(sql`(m.spaceId IN ${sql.in(spaceId)} AND m.queueId = '')`);\n }\n }\n\n if (queueIds && queueIds.length > 0) {\n // Items from specific queues.\n sourceConditions.push(sql`m.queueId IN ${sql.in(queueIds)}`);\n }\n\n if (sourceConditions.length > 0) {\n conditions.push(sql`(${sql.or(sourceConditions)})`);\n }\n\n if (useBm25) {\n // Use BM25 ranking for FTS5 MATCH queries.\n // BM25 returns negative values, negate to get higher = better match.\n // Order by rank descending so best matches come first.\n // Note: bm25() requires the actual table name, not an alias.\n const rows = yield* sql<ObjectMeta & { rank: number }>`\n SELECT m.*, -bm25(ftsIndex) AS rank \n FROM ftsIndex AS f \n JOIN objectMeta AS m ON f.rowid = m.recordId \n WHERE ${sql.and(conditions)}\n ORDER BY rank DESC\n `;\n return rows;\n } else {\n // LIKE fallback - no ranking available, default to 1.\n const rows = yield* sql<ObjectMeta>`\n SELECT m.* \n FROM ftsIndex AS f \n JOIN objectMeta AS m ON f.rowid = m.recordId \n WHERE ${sql.and(conditions)}\n `;\n return rows.map((row) => ({ ...row, rank: 1 }));\n }\n });\n }\n\n /**\n * Query snapshots by recordIds.\n * Returns the parsed JSON snapshots for queue objects.\n */\n querySnapshotsJSON(\n recordIds: number[],\n ): Effect.Effect<readonly { recordId: number; snapshot: Obj.JSON }[], SqlError.SqlError, SqlClient.SqlClient> {\n return Effect.gen(function* () {\n if (recordIds.length === 0) {\n return [];\n }\n const sql = yield* SqlClient.SqlClient;\n const results = yield* sql<{\n rowid: number;\n snapshot: string;\n }>`SELECT rowid, snapshot FROM ftsIndex WHERE rowid IN ${sql.in(recordIds)}`;\n return results.map((r) => ({\n recordId: r.rowid,\n snapshot: JSON.parse(r.snapshot),\n }));\n });\n }\n\n update = Effect.fn('FtsIndex.update')(\n (objects: IndexerObject[]): Effect.Effect<void, SqlError.SqlError, SqlClient.SqlClient> =>\n Effect.gen(function* () {\n const sql = yield* SqlClient.SqlClient;\n\n yield* Effect.forEach(\n objects,\n (object) =>\n Effect.gen(function* () {\n const { recordId, data } = object;\n if (recordId === null) {\n return yield* Effect.die(new Error('FtsIndex.update requires recordId to be set'));\n }\n\n const snapshot = JSON.stringify(data);\n\n // FTS5 doesn't support UPDATE, need DELETE + INSERT for upsert.\n const existing = yield* sql<{ rowid: number }>`SELECT rowid FROM ftsIndex WHERE rowid = ${recordId}`;\n if (existing.length > 0) {\n yield* sql`DELETE FROM ftsIndex WHERE rowid = ${recordId}`;\n }\n\n yield* sql`INSERT INTO ftsIndex (rowid, snapshot) VALUES (${recordId}, ${snapshot})`;\n }),\n { discard: true },\n );\n }),\n );\n}\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport * as SqlClient from '@effect/sql/SqlClient';\nimport type * as SqlError from '@effect/sql/SqlError';\nimport * as Effect from 'effect/Effect';\nimport * as Schema from 'effect/Schema';\n\nimport { ATTR_DELETED, ATTR_RELATION_SOURCE, ATTR_RELATION_TARGET, ATTR_TYPE } from '@dxos/echo/internal';\n\nimport type { IndexerObject } from './interface';\nimport type { Index } from './interface';\n\nexport const ObjectMeta = Schema.Struct({\n recordId: Schema.Number,\n objectId: Schema.String,\n queueId: Schema.String,\n spaceId: Schema.String,\n documentId: Schema.String,\n entityKind: Schema.String,\n typeDxn: Schema.String,\n deleted: Schema.Boolean,\n source: Schema.NullOr(Schema.String),\n target: Schema.NullOr(Schema.String),\n /** Monotonically increasing sequence number assigned on insert/update for tracking indexing order. */\n version: Schema.Number,\n});\nexport interface ObjectMeta extends Schema.Schema.Type<typeof ObjectMeta> {}\n\nexport class ObjectMetaIndex implements Index {\n migrate = Effect.fn('ObjectMetaIndex.runMigrations')(function* () {\n const sql = yield* SqlClient.SqlClient;\n\n yield* sql`CREATE TABLE IF NOT EXISTS objectMeta (\n recordId INTEGER PRIMARY KEY AUTOINCREMENT,\n objectId TEXT NOT NULL,\n queueId TEXT NOT NULL DEFAULT '',\n spaceId TEXT NOT NULL,\n documentId TEXT NOT NULL DEFAULT '',\n entityKind TEXT NOT NULL,\n typeDxn TEXT NOT NULL,\n deleted INTEGER NOT NULL,\n source TEXT,\n target TEXT,\n version INTEGER NOT NULL\n )`;\n\n yield* sql`CREATE INDEX IF NOT EXISTS idx_object_index_objectId ON objectMeta(spaceId, objectId)`;\n yield* sql`CREATE INDEX IF NOT EXISTS idx_object_index_typeDxn ON objectMeta(spaceId, typeDxn)`;\n yield* sql`CREATE INDEX IF NOT EXISTS idx_object_index_version ON objectMeta(version)`;\n });\n\n query = Effect.fn('ObjectMetaIndex.queryType')(\n (\n query: Pick<ObjectMeta, 'spaceId' | 'typeDxn'>,\n ): Effect.Effect<readonly ObjectMeta[], SqlError.SqlError, SqlClient.SqlClient> =>\n Effect.gen(function* () {\n const sql = yield* SqlClient.SqlClient;\n // SQLite stores booleans as integers, so we need to specify the raw row type.\n const rows =\n yield* sql<ObjectMeta>`SELECT * FROM objectMeta WHERE spaceId = ${query.spaceId} AND typeDxn = ${query.typeDxn}`;\n return rows.map((row) => ({\n ...row,\n deleted: !!row.deleted,\n }));\n }),\n );\n\n // TODO(dmaretskyi): Update recordId on objects so that we don't need to look it up separately.\n update = Effect.fn('ObjectMetaIndex.update')(\n (objects: IndexerObject[]): Effect.Effect<void, SqlError.SqlError, SqlClient.SqlClient> =>\n Effect.gen(function* () {\n const sql = yield* SqlClient.SqlClient;\n\n yield* Effect.forEach(\n objects,\n (object) =>\n Effect.gen(function* () {\n const { spaceId, queueId, documentId, data } = object;\n\n // Extract metadata (Logic emulating Echo APIs as strict imports are unavailable).\n // TODO(agent): Verify property access matches Obj.JSON structure.\n const castData = data;\n const objectId = castData.id;\n\n // Check for existing record by (spaceId, queueId) or (spaceId, documentId).\n let existing: readonly { recordId: number }[];\n if (documentId) {\n existing = yield* sql<{\n recordId: number;\n }>`SELECT recordId FROM objectMeta WHERE spaceId = ${spaceId} AND documentId = ${documentId} AND objectId = ${objectId} LIMIT 1`;\n } else if (queueId) {\n existing = yield* sql<{\n recordId: number;\n }>`SELECT recordId FROM objectMeta WHERE spaceId = ${spaceId} AND queueId = ${queueId} AND objectId = ${objectId} LIMIT 1`;\n } else {\n // Should not happen based on IndexerObject definition (one must be present ideally), but handle gracefully.\n existing = [];\n }\n\n // Get max version + 1.\n const result = yield* sql<{ v: number | null }>`SELECT MAX(version) as v FROM objectMeta`;\n const [{ v }] = result;\n const version = (v ?? 0) + 1;\n\n // Extract metadata.\n const entityKind = castData[ATTR_RELATION_SOURCE] ? 'relation' : 'object';\n const typeDxn = castData[ATTR_TYPE] ? String(castData[ATTR_TYPE]) : 'type';\n const deleted = castData[ATTR_DELETED] ? 1 : 0;\n // Relations.\n const source = entityKind === 'relation' ? (castData[ATTR_RELATION_SOURCE] ?? null) : null;\n const target = entityKind === 'relation' ? (castData[ATTR_RELATION_TARGET] ?? null) : null;\n\n if (existing.length > 0) {\n yield* sql`\n UPDATE objectMeta SET\n version = ${version},\n entityKind = ${entityKind},\n typeDxn = ${typeDxn},\n deleted = ${deleted},\n source = ${source},\n target = ${target}\n WHERE recordId = ${existing[0].recordId}\n `;\n } else {\n yield* sql`\n INSERT INTO objectMeta (\n objectId, queueId, spaceId, documentId, \n entityKind, typeDxn, deleted, source, target, version\n ) VALUES (\n ${objectId}, ${queueId ?? ''}, ${spaceId}, ${documentId ?? ''}, \n ${entityKind}, ${typeDxn}, ${deleted}, \n ${source}, ${target}, ${version}\n )\n `;\n }\n }),\n { discard: true },\n );\n }),\n );\n\n /**\n * Look up `recordIds` for objects that are already stored in the ObjectMetaIndex.\n * Mutates the objects in place.\n */\n lookupRecordIds = Effect.fn('ObjectMetaIndex.lookupRecordIds')(\n (objects: IndexerObject[]): Effect.Effect<void, SqlError.SqlError, SqlClient.SqlClient> =>\n Effect.gen(function* () {\n const sql = yield* SqlClient.SqlClient;\n\n for (const object of objects) {\n const { spaceId, queueId, documentId, data } = object;\n const objectId = data.id;\n\n let result: readonly { recordId: number }[];\n if (documentId) {\n result = yield* sql<{\n recordId: number;\n }>`SELECT recordId FROM objectMeta WHERE spaceId = ${spaceId} AND documentId = ${documentId} AND objectId = ${objectId} LIMIT 1`;\n } else if (queueId) {\n result = yield* sql<{\n recordId: number;\n }>`SELECT recordId FROM objectMeta WHERE spaceId = ${spaceId} AND queueId = ${queueId} AND objectId = ${objectId} LIMIT 1`;\n } else {\n result = [];\n }\n\n if (result.length === 0) {\n // TODO(mykola): Handle this case gracefully.\n yield* Effect.die(\n new Error(`Object not found in ObjectMetaIndex: ${spaceId}/${documentId ?? queueId}/${objectId}`),\n );\n }\n object.recordId = result[0].recordId;\n }\n }),\n );\n\n /**\n * Look up object metadata by recordIds.\n */\n lookupByRecordIds = Effect.fn('ObjectMetaIndex.lookupByRecordIds')(\n (recordIds: number[]): Effect.Effect<readonly ObjectMeta[], SqlError.SqlError, SqlClient.SqlClient> =>\n Effect.gen(function* () {\n if (recordIds.length === 0) {\n return [];\n }\n\n const sql = yield* SqlClient.SqlClient;\n const placeholders = recordIds.map(() => '?').join(', ');\n const rows = yield* sql.unsafe<ObjectMeta>(\n `SELECT * FROM objectMeta WHERE recordId IN (${placeholders})`,\n recordIds,\n );\n\n return rows.map((row) => ({\n ...row,\n deleted: !!row.deleted,\n }));\n }),\n );\n}\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport * as SqlClient from '@effect/sql/SqlClient';\nimport type * as SqlError from '@effect/sql/SqlError';\nimport * as Effect from 'effect/Effect';\nimport * as Schema from 'effect/Schema';\n\nimport { EncodedReference, isEncodedReference } from '@dxos/echo-protocol';\n\nimport { EscapedPropPath } from '../utils';\n\nimport type { Index, IndexerObject } from './interface';\n\n/**\n * Extracts all outgoing references from an object's data.\n */\nconst extractReferences = (data: Record<string, unknown>): { path: string[]; targetDxn: string }[] => {\n const refs: { path: string[]; targetDxn: string }[] = [];\n const visit = (path: string[], value: unknown) => {\n if (isEncodedReference(value)) {\n const dxn = EncodedReference.toDXN(value);\n const echoId = dxn.asEchoDXN()?.echoId;\n if (!echoId) {\n return; // Skip non-echo references.\n }\n refs.push({ path, targetDxn: dxn.toString() });\n } else if (typeof value === 'object' && value !== null && !Array.isArray(value)) {\n for (const [key, v] of Object.entries(value)) {\n visit([...path, key], v);\n }\n } else if (Array.isArray(value)) {\n for (let i = 0; i < value.length; i++) {\n visit([...path, String(i)], value[i]);\n }\n }\n };\n visit([], data);\n return refs;\n};\n\nexport const ReverseRef = Schema.Struct({\n recordId: Schema.Number,\n targetDxn: Schema.String,\n /**\n * Escaped property path within an object.\n *\n * Escaping rules:\n *\n * - '.' -> '\\.'\n * - '\\' -> '\\\\'\n * - contact with .\n */\n propPath: Schema.String,\n});\nexport interface ReverseRef extends Schema.Schema.Type<typeof ReverseRef> {}\n\nexport interface ReverseRefQuery {\n targetDxn: string;\n // TODO: Add prop filter\n}\n\n/**\n * Indexes reverse references - tracks which objects reference which targets.\n * Only indexes references, not relations.\n */\nexport class ReverseRefIndex implements Index {\n migrate = Effect.fn('ReverseRefIndex.migrate')(function* () {\n const sql = yield* SqlClient.SqlClient;\n\n yield* sql`CREATE TABLE IF NOT EXISTS reverseRef (\n recordId INTEGER NOT NULL,\n targetDxn TEXT NOT NULL,\n propPath TEXT NOT NULL,\n PRIMARY KEY (recordId, targetDxn, propPath)\n )`;\n\n yield* sql`CREATE INDEX IF NOT EXISTS idx_reverse_ref_target ON reverseRef(targetDxn)`;\n });\n\n /**\n * Query all references pointing to a target DXN.\n */\n query = Effect.fn('ReverseRefIndex.query')(\n ({ targetDxn }: ReverseRefQuery): Effect.Effect<readonly ReverseRef[], SqlError.SqlError, SqlClient.SqlClient> =>\n Effect.gen(function* () {\n const sql = yield* SqlClient.SqlClient;\n // TODO(mykola): Join objectMeta table here.\n const rows = yield* sql`SELECT * FROM reverseRef WHERE targetDxn = ${targetDxn}`;\n return rows as ReverseRef[];\n }),\n );\n\n update = Effect.fn('ReverseRefIndex.update')(\n (objects: IndexerObject[]): Effect.Effect<void, SqlError.SqlError, SqlClient.SqlClient> =>\n Effect.gen(function* () {\n const sql = yield* SqlClient.SqlClient;\n\n yield* Effect.forEach(\n objects,\n (object) =>\n Effect.gen(function* () {\n const { recordId, data } = object;\n if (recordId === null) {\n yield* Effect.die(new Error('ReverseRefIndex.update requires recordId to be set'));\n }\n\n // Delete existing references for this record.\n yield* sql`DELETE FROM reverseRef WHERE recordId = ${recordId}`;\n\n // Extract references from data.\n const refs = extractReferences(data as unknown as Record<string, unknown>);\n\n // Insert new references.\n yield* Effect.forEach(\n refs,\n (ref) =>\n sql`INSERT INTO reverseRef (recordId, targetDxn, propPath) VALUES (${recordId}, ${ref.targetDxn}, ${EscapedPropPath.escape(ref.path)})`,\n { discard: true },\n );\n }),\n { discard: true },\n );\n }),\n );\n}\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { invariant } from '@dxos/invariant';\n\nexport type ObjectPropPath = (string | number)[];\n\n/**\n * Escaped property path within an object.\n *\n * Escaping rules:\n *\n * - '.' -> '\\.'\n * - '\\' -> '\\\\'\n * - contact with .\n */\nexport const EscapedPropPath: Schema.SchemaClass<string, string> & {\n escape: (path: ObjectPropPath) => EscapedPropPath;\n unescape: (path: EscapedPropPath) => ObjectPropPath;\n} = class extends Schema.String.annotations({ title: 'EscapedPropPath' }) {\n static escape(path: ObjectPropPath): EscapedPropPath {\n return path.map((p) => p.toString().replaceAll('\\\\', '\\\\\\\\').replaceAll('.', '\\\\.')).join('.');\n }\n\n static unescape(path: EscapedPropPath): ObjectPropPath {\n const parts: string[] = [];\n let current = '';\n\n for (let i = 0; i < path.length; i++) {\n if (path[i] === '\\\\') {\n invariant(i + 1 < path.length && (path[i + 1] === '.' || path[i + 1] === '\\\\'), 'Malformed escaping.');\n current = current + path[i + 1];\n i++;\n } else if (path[i] === '.') {\n parts.push(current);\n current = '';\n } else {\n current += path[i];\n }\n }\n parts.push(current);\n\n return parts;\n }\n};\nexport type EscapedPropPath = Schema.Schema.Type<typeof EscapedPropPath>;\n"],
5
+ "mappings": ";;;AAMA,YAAYA,aAAY;AAGxB,YAAYC,oBAAoB;;;ACLhC,YAAYC,eAAe;AAE3B,YAAYC,YAAY;AACxB,YAAYC,YAAY;AAExB,SAASC,eAAe;AAEjB,IAAMC,cAAqBC,cAAO;;;;EAIvCC,WAAkBC;;;;EAIlBC,SAAgBC,cAAOC,OAAAA;;;;;EAKvBC,YAAmBJ;;;;;EAKnBK,YAAmBH,cAAcF,aAAM;;;;EAIvCM,QAAeC,aAAaC,eAAeR,aAAM;AACnD,CAAA;AAGO,IAAMS,eAAN,MAAMA;EACXC,UAAiBC,UAAG,sBAAA,EAAwB,aAAA;AAC1C,UA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,OAAOM;;UAEnBb,SAASN,KAAKM,WAAWc;QAC3B,CAAA;AACA,cAAM,EAAEC,SAASJ,SAASK,eAAc,IAAK,OAAOT,OAAOU,kBAAkBN,SAAS;UAAEV,OAAOP,KAAKO;QAAM,CAAA;AAC1G,YAAIc,QAAQG,WAAW,GAAG;AACxB,iBAAO;YAAEvB,SAAS;YAAGE,MAAM;UAAK;QAClC;AAGA,eAAO,KAAK,iBAAiBL,OAAOuB,OAAAA;AAGpC,eAAO,KAAK,iBAAiBI,gBAAgBJ,OAAAA;AAE7C,eAAOT,MAAMd,OAAOuB,OAAAA;AACpB,eAAO,KAAK,SAASK,cACnBJ,eAAeK,IACb,CAACC,OAAoB;UACnBvB,WAAWL,KAAKK;UAChBC,SAASsB,EAAEtB;UACXa,YAAYN,OAAOM;UACnBU,YAAYD,EAAEC;UACdC,QAAQF,EAAEE;QACZ,EAAA,CAAA;AAGJ,eAAO;UAAE7B,SAASoB,QAAQG;UAAQrB,MAAM;QAAM;MAChD,CAAA,CAAA;IAEJ,CAAA,EAAGO,KAAYC,iBAAS,mCAAA,CAAA;EAC1B;AACF;",
6
+ "names": ["Effect", "SqlTransaction", "SqlClient", "Effect", "Schema", "SpaceId", "IndexCursor", "Struct", "indexName", "String", "spaceId", "NullOr", "SpaceId", "sourceName", "resourceId", "cursor", "Union", "Number", "IndexTracker", "migrate", "fn", "sql", "SqlClient", "queryCursors", "query", "gen", "spaceIdParam", "undefined", "sourceNameParam", "resourceIdParam", "rows", "map", "row", "decodeSync", "updateCursors", "cursors", "forEach", "discard", "SqlClient", "Effect", "escapeFts5Query", "text", "split", "filter", "Boolean", "map", "term", "replace", "join", "FtsIndex", "migrate", "fn", "sql", "SqlClient", "query", "spaceId", "includeAllQueues", "queueIds", "gen", "trimmed", "trim", "length", "terms", "minTermLength", "Math", "min", "t", "useBm25", "conditions", "sourceConditions", "push", "in", "or", "rows", "and", "row", "rank", "querySnapshotsJSON", "recordIds", "results", "r", "recordId", "rowid", "snapshot", "JSON", "parse", "update", "objects", "forEach", "object", "data", "die", "Error", "stringify", "existing", "discard", "SqlClient", "Effect", "Schema", "ATTR_DELETED", "ATTR_RELATION_SOURCE", "ATTR_RELATION_TARGET", "ATTR_TYPE", "ObjectMeta", "Struct", "recordId", "Number", "objectId", "String", "queueId", "spaceId", "documentId", "entityKind", "typeDxn", "deleted", "Boolean", "source", "NullOr", "target", "version", "ObjectMetaIndex", "migrate", "fn", "sql", "SqlClient", "query", "gen", "rows", "map", "row", "update", "objects", "forEach", "object", "data", "castData", "id", "existing", "result", "v", "ATTR_RELATION_SOURCE", "ATTR_TYPE", "ATTR_DELETED", "ATTR_RELATION_TARGET", "length", "discard", "lookupRecordIds", "die", "Error", "lookupByRecordIds", "recordIds", "placeholders", "join", "unsafe", "SqlClient", "Effect", "Schema", "EncodedReference", "isEncodedReference", "Schema", "invariant", "EscapedPropPath", "String", "annotations", "title", "escape", "path", "map", "p", "toString", "replaceAll", "join", "unescape", "parts", "current", "i", "length", "push", "extractReferences", "data", "refs", "visit", "path", "value", "isEncodedReference", "dxn", "EncodedReference", "toDXN", "echoId", "asEchoDXN", "push", "targetDxn", "toString", "Array", "isArray", "key", "v", "Object", "entries", "i", "length", "String", "ReverseRef", "Struct", "recordId", "Number", "propPath", "ReverseRefIndex", "migrate", "fn", "sql", "SqlClient", "query", "gen", "rows", "update", "objects", "forEach", "object", "die", "Error", "ref", "EscapedPropPath", "escape", "discard", "IndexEngine", "params", "tracker", "IndexTracker", "objectMetaIndex", "ObjectMetaIndex", "ftsIndex", "FtsIndex", "reverseRefIndex", "ReverseRefIndex", "migrate", "gen", "queryText", "query", "queryReverseRef", "querySnapshotsJSON", "recordIds", "queryType", "update", "dataSource", "opts", "updated", "updatedFtsIndex", "done", "doneFtsIndex", "indexName", "spaceId", "limit", "updatedReverseRefIndex", "doneReverseRefIndex", "pipe", "withSpan", "index", "source", "sqlTransaction", "SqlTransaction", "withTransaction", "cursors", "queryCursors", "sourceName", "undefined", "objects", "updatedCursors", "getChangedObjects", "length", "lookupRecordIds", "updateCursors", "map", "_", "resourceId", "cursor"]
7
+ }
@@ -0,0 +1 @@
1
+ {"inputs":{"src/index-tracker.ts":{"bytes":11349,"imports":[{"path":"@effect/sql/SqlClient","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true}],"format":"esm"},"src/indexes/fts-index.ts":{"bytes":22141,"imports":[{"path":"@effect/sql/SqlClient","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true}],"format":"esm"},"src/indexes/object-meta-index.ts":{"bytes":24537,"imports":[{"path":"@effect/sql/SqlClient","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true}],"format":"esm"},"src/utils.ts":{"bytes":4862,"imports":[{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true}],"format":"esm"},"src/indexes/reverse-ref-index.ts":{"bytes":12926,"imports":[{"path":"@effect/sql/SqlClient","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/echo-protocol","kind":"import-statement","external":true},{"path":"src/utils.ts","kind":"import-statement","original":"../utils"}],"format":"esm"},"src/indexes/interface.ts":{"bytes":2404,"imports":[],"format":"esm"},"src/indexes/index.ts":{"bytes":780,"imports":[{"path":"src/indexes/fts-index.ts","kind":"import-statement","original":"./fts-index"},{"path":"src/indexes/object-meta-index.ts","kind":"import-statement","original":"./object-meta-index"},{"path":"src/indexes/reverse-ref-index.ts","kind":"import-statement","original":"./reverse-ref-index"},{"path":"src/indexes/interface.ts","kind":"import-statement","original":"./interface"}],"format":"esm"},"src/index-engine.ts":{"bytes":17543,"imports":[{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/sql-sqlite/SqlTransaction","kind":"import-statement","external":true},{"path":"src/index-tracker.ts","kind":"import-statement","original":"./index-tracker"},{"path":"src/indexes/index.ts","kind":"import-statement","original":"./indexes"}],"format":"esm"},"src/index.ts":{"bytes":1608,"imports":[{"path":"src/index-engine.ts","kind":"import-statement","original":"./index-engine"},{"path":"src/index-tracker.ts","kind":"import-statement","original":"./index-tracker"},{"path":"src/indexes/fts-index.ts","kind":"import-statement","original":"./indexes/fts-index"},{"path":"src/indexes/object-meta-index.ts","kind":"import-statement","original":"./indexes/object-meta-index"},{"path":"src/indexes/reverse-ref-index.ts","kind":"import-statement","original":"./indexes/reverse-ref-index"}],"format":"esm"}},"outputs":{"dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":45770},"dist/lib/node-esm/index.mjs":{"imports":[{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/sql-sqlite/SqlTransaction","kind":"import-statement","external":true},{"path":"@effect/sql/SqlClient","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@effect/sql/SqlClient","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@effect/sql/SqlClient","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@effect/sql/SqlClient","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/echo-protocol","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true}],"exports":["FtsIndex","IndexEngine","IndexTracker","ObjectMetaIndex","ReverseRefIndex"],"entryPoint":"src/index.ts","inputs":{"src/index-engine.ts":{"bytesInOutput":3690},"src/index-tracker.ts":{"bytesInOutput":2850},"src/indexes/fts-index.ts":{"bytesInOutput":3468},"src/indexes/object-meta-index.ts":{"bytesInOutput":5880},"src/indexes/reverse-ref-index.ts":{"bytesInOutput":2763},"src/utils.ts":{"bytesInOutput":1121},"src/index.ts":{"bytesInOutput":0}},"bytes":20221}}}
@@ -0,0 +1,63 @@
1
+ import type * as SqlClient from '@effect/sql/SqlClient';
2
+ import type * as SqlError from '@effect/sql/SqlError';
3
+ import * as Effect from 'effect/Effect';
4
+ import type { SpaceId } from '@dxos/keys';
5
+ import * as SqlTransaction from '@dxos/sql-sqlite/SqlTransaction';
6
+ import { IndexTracker } from './index-tracker';
7
+ import { FtsIndex, type FtsQuery, type FtsQueryResult, type IndexerObject, type ObjectMeta, ObjectMetaIndex, ReverseRefIndex, type ReverseRefQuery } from './indexes';
8
+ /**
9
+ * Cursor into indexable data-source.
10
+ */
11
+ export interface DataSourceCursor {
12
+ spaceId: SpaceId | null;
13
+ /**
14
+ * documentId or queueId.
15
+ */
16
+ resourceId: string | null;
17
+ /**
18
+ * heads or queue position.
19
+ */
20
+ cursor: number | string;
21
+ }
22
+ export interface IndexDataSource {
23
+ readonly sourceName: string;
24
+ getChangedObjects(cursors: DataSourceCursor[], opts?: {
25
+ limit?: number;
26
+ }): Effect.Effect<{
27
+ objects: IndexerObject[];
28
+ cursors: DataSourceCursor[];
29
+ }>;
30
+ }
31
+ export interface IndexEngineParams {
32
+ tracker: IndexTracker;
33
+ objectMetaIndex: ObjectMetaIndex;
34
+ ftsIndex: FtsIndex;
35
+ reverseRefIndex: ReverseRefIndex;
36
+ }
37
+ export declare class IndexEngine {
38
+ #private;
39
+ constructor(params?: IndexEngineParams);
40
+ migrate(): Effect.Effect<void, SqlError.SqlError, SqlClient.SqlClient>;
41
+ /**
42
+ * Query text index and return full object metadata with rank.
43
+ */
44
+ queryText(query: FtsQuery): Effect.Effect<readonly FtsQueryResult[], SqlError.SqlError, SqlClient.SqlClient>;
45
+ queryReverseRef(query: ReverseRefQuery): Effect.Effect<readonly import("./indexes").ReverseRef[], SqlError.SqlError, SqlClient.SqlClient>;
46
+ /**
47
+ * Query snapshots by recordIds.
48
+ * Used to load queue objects from indexed snapshots.
49
+ */
50
+ querySnapshotsJSON(recordIds: number[]): Effect.Effect<readonly {
51
+ recordId: number;
52
+ snapshot: import("@dxos/echo/Obj").JSON;
53
+ }[], SqlError.SqlError, SqlClient.SqlClient>;
54
+ queryType(query: Pick<ObjectMeta, 'spaceId' | 'typeDxn'>): Effect.Effect<readonly ObjectMeta[], SqlError.SqlError, SqlClient.SqlClient>;
55
+ update(dataSource: IndexDataSource, opts: {
56
+ spaceId: SpaceId | null;
57
+ limit?: number;
58
+ }): Effect.Effect<{
59
+ updated: number;
60
+ done: boolean;
61
+ }, SqlError.SqlError, SqlTransaction.SqlTransaction | SqlClient.SqlClient>;
62
+ }
63
+ //# sourceMappingURL=index-engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-engine.d.ts","sourceRoot":"","sources":["../../../src/index-engine.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,SAAS,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,cAAc,MAAM,iCAAiC,CAAC;AAElE,OAAO,EAAoB,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EACL,QAAQ,EACR,KAAK,QAAQ,EACb,KAAK,cAAc,EAEnB,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,eAAe,EACf,eAAe,EACf,KAAK,eAAe,EACrB,MAAM,WAAW,CAAC;AAEnB;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IAExB;;OAEG;IACH,UAAU,EAAE,M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,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,EAClC,QAAQ,CAAC,QAAQ,EACjB,cAAc,CAAC,cAAc,GAAG,SAAS,CAAC,SAAS,CACpD;CAmFF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index-engine.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-engine.test.d.ts","sourceRoot":"","sources":["../../../src/index-engine.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,44 @@
1
+ import * as SqlClient from '@effect/sql/SqlClient';
2
+ import type * as SqlError from '@effect/sql/SqlError';
3
+ import * as Effect from 'effect/Effect';
4
+ import * as Schema from 'effect/Schema';
5
+ import { SpaceId } from '@dxos/keys';
6
+ export declare const IndexCursor: Schema.Struct<{
7
+ /**
8
+ * Name of the index owning this cursor.
9
+ */
10
+ indexName: typeof Schema.String;
11
+ /**
12
+ * Space id.
13
+ */
14
+ spaceId: Schema.NullOr<Schema.Schema<SpaceId, string, never> & {
15
+ byteLength: number;
16
+ encode: (value: Uint8Array) => SpaceId;
17
+ decode: (value: SpaceId) => Uint8Array;
18
+ isValid: (value: unknown) => value is SpaceId;
19
+ make: (value: string) => SpaceId;
20
+ random: () => SpaceId;
21
+ }>;
22
+ /**
23
+ * Source name.
24
+ * 'automerge' / 'queue' / 'index' (for secondary indexes)
25
+ */
26
+ sourceName: typeof Schema.String;
27
+ /**
28
+ * Document id or queue id.
29
+ * doc_id, queue_id, '' <empty string> (if indexing entire namespace)
30
+ */
31
+ resourceId: Schema.NullOr<typeof Schema.String>;
32
+ /**
33
+ * Heads, queue position, version.
34
+ */
35
+ cursor: Schema.Union<[typeof Schema.Number, typeof Schema.String]>;
36
+ }>;
37
+ export interface IndexCursor extends Schema.Schema.Type<typeof IndexCursor> {
38
+ }
39
+ export declare class IndexTracker {
40
+ migrate: () => Effect.Effect<void, SqlError.SqlError, SqlClient.SqlClient>;
41
+ queryCursors: (query: Pick<IndexCursor, "indexName"> & Partial<Pick<IndexCursor, "spaceId" | "sourceName" | "resourceId">>) => Effect.Effect<IndexCursor[], SqlError.SqlError, SqlClient.SqlClient>;
42
+ updateCursors: (cursors: IndexCursor[]) => Effect.Effect<void, SqlError.SqlError, SqlClient.SqlClient>;
43
+ }
44
+ //# sourceMappingURL=index-tracker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-tracker.d.ts","sourceRoot":"","sources":["../../../src/index-tracker.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,SAAS,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,eAAO,MAAM,WAAW;IACtB;;OAEG;;IAEH;;OAEG;;;;;;;;;IAEH;;;OAGG;;IAEH;;;OAGG;;IAEH;;OAEG;;EAEH,CAAC;AACH,MAAM,WAAW,WAAY,SAAQ,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,WAAW,CAAC;CAAG;AAE9E,qBAAa,YAAY;IACvB,OAAO,oEAaJ;IAEH,YAAY,wLA6BV;IAEF,aAAa,0FAkBX;CACH"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index-tracker.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-tracker.test.d.ts","sourceRoot":"","sources":["../../../src/index-tracker.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ export { IndexEngine, type IndexDataSource, type DataSourceCursor, type IndexEngineParams } from './index-engine';
2
+ export { IndexTracker, type IndexCursor } from './index-tracker';
3
+ export { type IndexerObject, type Index } from './indexes/interface';
4
+ export { FtsIndex, type FtsQuery } from './indexes/fts-index';
5
+ export { ObjectMetaIndex, type ObjectMeta } from './indexes/object-meta-index';
6
+ export { ReverseRefIndex, type ReverseRef, type ReverseRefQuery } from './indexes/reverse-ref-index';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,KAAK,eAAe,EAAE,KAAK,gBAAgB,EAAE,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAClH,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,KAAK,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,KAAK,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,6BAA6B,CAAC"}
@@ -0,0 +1,63 @@
1
+ import * as SqlClient from '@effect/sql/SqlClient';
2
+ import type * as SqlError from '@effect/sql/SqlError';
3
+ import * as Effect from 'effect/Effect';
4
+ import type { Obj } from '@dxos/echo';
5
+ import type { ObjectId, SpaceId } from '@dxos/keys';
6
+ import type { Index, IndexerObject } from './interface';
7
+ import type { ObjectMeta } from './object-meta-index';
8
+ /**
9
+ * The space and queue constrains are combined together using a logical OR.
10
+ */
11
+ export interface FtsQuery {
12
+ /**
13
+ * Text to search.
14
+ */
15
+ query: string;
16
+ /**
17
+ * Space ID to search within.
18
+ */
19
+ spaceId: readonly SpaceId[] | null;
20
+ /**
21
+ * If true, include all queues in the spaces specified by `spaceId`.
22
+ */
23
+ includeAllQueues: boolean;
24
+ /**
25
+ * Queue IDs to search within.
26
+ */
27
+ queueIds: readonly ObjectId[] | null;
28
+ }
29
+ /**
30
+ * Result of FTS query including the indexed snapshot data.
31
+ */
32
+ export interface FtsResult extends ObjectMeta {
33
+ /**
34
+ * The indexed snapshot data (JSON string).
35
+ * Used to load queue objects without going through document loading.
36
+ */
37
+ snapshot: string;
38
+ }
39
+ /**
40
+ * Result of FTS query with rank.
41
+ */
42
+ export interface FtsQueryResult extends ObjectMeta {
43
+ /**
44
+ * Relevance rank from FTS5.
45
+ * Higher values indicate better matches.
46
+ * Uses BM25 algorithm when available, falls back to 1 for non-BM25 queries.
47
+ */
48
+ rank: number;
49
+ }
50
+ export declare class FtsIndex implements Index {
51
+ migrate: () => Effect.Effect<void, SqlError.SqlError, SqlClient.SqlClient>;
52
+ query({ query, spaceId, includeAllQueues, queueIds, }: FtsQuery): Effect.Effect<readonly FtsQueryResult[], SqlError.SqlError, SqlClient.SqlClient>;
53
+ /**
54
+ * Query snapshots by recordIds.
55
+ * Returns the parsed JSON snapshots for queue objects.
56
+ */
57
+ querySnapshotsJSON(recordIds: number[]): Effect.Effect<readonly {
58
+ recordId: number;
59
+ snapshot: Obj.JSON;
60
+ }[], SqlError.SqlError, SqlClient.SqlClient>;
61
+ update: (objects: IndexerObject[]) => Effect.Effect<void, SqlError.SqlError, SqlClient.SqlClient>;
62
+ }
63
+ //# sourceMappingURL=fts-index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fts-index.d.ts","sourceRoot":"","sources":["../../../../src/indexes/fts-index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,SAAS,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AAEtD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAEpD,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,OAAO,EAAE,SAAS,OAAO,EAAE,GAAG,IAAI,CAAC;IAEnC;;OAEG;IACH,gBAAgB,EAAE,OAAO,CAAC;IAE1B;;OAEG;IACH,QAAQ,EAAE,SAAS,QAAQ,EAAE,GAAG,IAAI,CAAC;CACtC;AAED;;GAEG;AACH,MAAM,WAAW,SAAU,SAAQ,UAAU;IAC3C;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,UAAU;IAChD;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAC;CACd;AAyBD,qBAAa,QAAS,YAAW,KAAK;IACpC,OAAO,oEAYJ;IAEH,KAAK,CAAC,EACJ,KAAK,EACL,OAAO,EACP,gBAAgB,EAChB,QAAQ,GACT,EAAE,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,cAAc,EAAE,EAAE,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC,SAAS,CAAC;IA0E9F;;;OAGG;IACH,kBAAkB,CAChB,SAAS,EAAE,MAAM,EAAE,GAClB,MAAM,CAAC,MAAM,CAAC,SAAS;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,GAAG,CAAC,IAAI,CAAA;KAAE,EAAE,EAAE,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC,SAAS,CAAC;IAiB7G,MAAM,4FA2BJ;CACH"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=fts-index.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fts-index.test.d.ts","sourceRoot":"","sources":["../../../../src/indexes/fts-index.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=fts5.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fts5.test.d.ts","sourceRoot":"","sources":["../../../../src/indexes/fts5.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ export * from './fts-index';
2
+ export * from './object-meta-index';
3
+ export * from './reverse-ref-index';
4
+ export * from './interface';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/indexes/index.ts"],"names":[],"mappings":"AAIA,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC"}
@@ -0,0 +1,47 @@
1
+ import type * as SqlClient from '@effect/sql/SqlClient';
2
+ import type * as SqlError from '@effect/sql/SqlError';
3
+ import type * as Effect from 'effect/Effect';
4
+ import type { Obj } from '@dxos/echo';
5
+ import type { ObjectId, SpaceId } from '@dxos/keys';
6
+ /**
7
+ * Data describing objects returned from sources to the indexer.
8
+ */
9
+ export interface IndexerObject {
10
+ spaceId: SpaceId;
11
+ /**
12
+ * Queue id if object is from the queue.
13
+ * If null, `documentId` must be set.
14
+ */
15
+ queueId: ObjectId | null;
16
+ /**
17
+ * Document id if object is from the automerge document.
18
+ * If null, `queueId` must be set.
19
+ */
20
+ documentId: string | null;
21
+ /**
22
+ * Record id from the objectMeta index.
23
+ * `Null` before the object is stored in the ObjectMetaIndex.
24
+ * Enriched by the IndexEngine after the object is stored in the ObjectMetaIndex.
25
+ */
26
+ recordId: number | null;
27
+ /**
28
+ * JSON data of the object.
29
+ */
30
+ data: Obj.JSON;
31
+ }
32
+ /**
33
+ * SQLite-based index for storing and querying object data.
34
+ */
35
+ export interface Index {
36
+ /**
37
+ * Runs necessary migrations to the index before it is usable.
38
+ * Idempotent.
39
+ */
40
+ migrate: () => Effect.Effect<void, SqlError.SqlError, SqlClient.SqlClient>;
41
+ /**
42
+ * Updates the index with the given objects.
43
+ * Idempotent.
44
+ */
45
+ update: (objects: IndexerObject[]) => Effect.Effect<void, SqlError.SqlError, SqlClient.SqlClient>;
46
+ }
47
+ //# sourceMappingURL=interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../../src/indexes/interface.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,SAAS,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAE7C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,OAAO,EAAE,QAAQ,GAAG,IAAI,CAAC;IACzB;;;OAGG;IACH,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAE1B;;;;OAIG;IACH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAExB;;OAEG;IACH,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB;;;OAGG;IACH,OAAO,EAAE,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAE3E;;;OAGG;IACH,MAAM,EAAE,CAAC,OAAO,EAAE,aAAa,EAAE,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CACnG"}
@@ -0,0 +1,37 @@
1
+ import * as SqlClient from '@effect/sql/SqlClient';
2
+ import type * as SqlError from '@effect/sql/SqlError';
3
+ import * as Effect from 'effect/Effect';
4
+ import * as Schema from 'effect/Schema';
5
+ import type { IndexerObject } from './interface';
6
+ import type { Index } from './interface';
7
+ export declare const ObjectMeta: Schema.Struct<{
8
+ recordId: typeof Schema.Number;
9
+ objectId: typeof Schema.String;
10
+ queueId: typeof Schema.String;
11
+ spaceId: typeof Schema.String;
12
+ documentId: typeof Schema.String;
13
+ entityKind: typeof Schema.String;
14
+ typeDxn: typeof Schema.String;
15
+ deleted: typeof Schema.Boolean;
16
+ source: Schema.NullOr<typeof Schema.String>;
17
+ target: Schema.NullOr<typeof Schema.String>;
18
+ /** Monotonically increasing sequence number assigned on insert/update for tracking indexing order. */
19
+ version: typeof Schema.Number;
20
+ }>;
21
+ export interface ObjectMeta extends Schema.Schema.Type<typeof ObjectMeta> {
22
+ }
23
+ export declare class ObjectMetaIndex implements Index {
24
+ migrate: () => Effect.Effect<void, SqlError.SqlError, SqlClient.SqlClient>;
25
+ query: (query: Pick<ObjectMeta, "spaceId" | "typeDxn">) => Effect.Effect<readonly ObjectMeta[], SqlError.SqlError, SqlClient.SqlClient>;
26
+ update: (objects: IndexerObject[]) => Effect.Effect<void, SqlError.SqlError, SqlClient.SqlClient>;
27
+ /**
28
+ * Look up `recordIds` for objects that are already stored in the ObjectMetaIndex.
29
+ * Mutates the objects in place.
30
+ */
31
+ lookupRecordIds: (objects: IndexerObject[]) => Effect.Effect<void, SqlError.SqlError, SqlClient.SqlClient>;
32
+ /**
33
+ * Look up object metadata by recordIds.
34
+ */
35
+ lookupByRecordIds: (recordIds: number[]) => Effect.Effect<readonly ObjectMeta[], SqlError.SqlError, SqlClient.SqlClient>;
36
+ }
37
+ //# sourceMappingURL=object-meta-index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object-meta-index.d.ts","sourceRoot":"","sources":["../../../../src/indexes/object-meta-index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,SAAS,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAIxC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEzC,eAAO,MAAM,UAAU;;;;;;;;;;;IAWrB,sGAAsG;;EAEtG,CAAC;AACH,MAAM,WAAW,UAAW,SAAQ,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,UAAU,CAAC;CAAG;AAE5E,qBAAa,eAAgB,YAAW,KAAK;IAC3C,OAAO,oEAoBJ;IAEH,KAAK,mIAcH;IAGF,MAAM,4FAuEJ;IAEF;;;OAGG;IACH,eAAe,4FA+Bb;IAEF;;OAEG;IACH,iBAAiB,wGAmBf;CACH"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=object-meta-index.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object-meta-index.test.d.ts","sourceRoot":"","sources":["../../../../src/indexes/object-meta-index.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,37 @@
1
+ import * as SqlClient from '@effect/sql/SqlClient';
2
+ import type * as SqlError from '@effect/sql/SqlError';
3
+ import * as Effect from 'effect/Effect';
4
+ import * as Schema from 'effect/Schema';
5
+ import type { Index, IndexerObject } from './interface';
6
+ export declare const ReverseRef: Schema.Struct<{
7
+ recordId: typeof Schema.Number;
8
+ targetDxn: typeof Schema.String;
9
+ /**
10
+ * Escaped property path within an object.
11
+ *
12
+ * Escaping rules:
13
+ *
14
+ * - '.' -> '\.'
15
+ * - '\' -> '\\'
16
+ * - contact with .
17
+ */
18
+ propPath: typeof Schema.String;
19
+ }>;
20
+ export interface ReverseRef extends Schema.Schema.Type<typeof ReverseRef> {
21
+ }
22
+ export interface ReverseRefQuery {
23
+ targetDxn: string;
24
+ }
25
+ /**
26
+ * Indexes reverse references - tracks which objects reference which targets.
27
+ * Only indexes references, not relations.
28
+ */
29
+ export declare class ReverseRefIndex implements Index {
30
+ migrate: () => Effect.Effect<void, SqlError.SqlError, SqlClient.SqlClient>;
31
+ /**
32
+ * Query all references pointing to a target DXN.
33
+ */
34
+ query: (args_0: ReverseRefQuery) => Effect.Effect<readonly ReverseRef[], SqlError.SqlError, SqlClient.SqlClient>;
35
+ update: (objects: IndexerObject[]) => Effect.Effect<void, SqlError.SqlError, SqlClient.SqlClient>;
36
+ }
37
+ //# sourceMappingURL=reverse-ref-index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reverse-ref-index.d.ts","sourceRoot":"","sources":["../../../../src/indexes/reverse-ref-index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,SAAS,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAMxC,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AA6BxD,eAAO,MAAM,UAAU;;;IAGrB;;;;;;;;OAQG;;EAEH,CAAC;AACH,MAAM,WAAW,UAAW,SAAQ,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,UAAU,CAAC;CAAG;AAE5E,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;CAEnB;AAED;;;GAGG;AACH,qBAAa,eAAgB,YAAW,KAAK;IAC3C,OAAO,oEAWJ;IAEH;;OAEG;IACH,KAAK,4GAQH;IAEF,MAAM,4FA+BJ;CACH"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=reverse-ref-index.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reverse-ref-index.test.d.ts","sourceRoot":"","sources":["../../../../src/indexes/reverse-ref-index.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,17 @@
1
+ import * as Schema from 'effect/Schema';
2
+ export type ObjectPropPath = (string | number)[];
3
+ /**
4
+ * Escaped property path within an object.
5
+ *
6
+ * Escaping rules:
7
+ *
8
+ * - '.' -> '\.'
9
+ * - '\' -> '\\'
10
+ * - contact with .
11
+ */
12
+ export declare const EscapedPropPath: Schema.SchemaClass<string, string> & {
13
+ escape: (path: ObjectPropPath) => EscapedPropPath;
14
+ unescape: (path: EscapedPropPath) => ObjectPropPath;
15
+ };
16
+ export type EscapedPropPath = Schema.Schema.Type<typeof EscapedPropPath>;
17
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAIxC,MAAM,MAAM,cAAc,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;AAEjD;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG;IACjE,MAAM,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,eAAe,CAAC;IAClD,QAAQ,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,cAAc,CAAC;CA0BrD,CAAC;AACF,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,eAAe,CAAC,CAAC"}