@dxos/index-core 0.8.4-main.9be5663bfe → 0.8.4-main.bc2380dfbc

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.
package/LICENSE CHANGED
@@ -1,8 +1,105 @@
1
- MIT License
2
- Copyright (c) 2022 DXOS
1
+ # Functional Source License, Version 1.1, ALv2 Future License
3
2
 
4
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
3
+ ## Abbreviation
5
4
 
6
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
5
+ FSL-1.1-Apache-2.0
7
6
 
8
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
7
+ ## Notice
8
+
9
+ Copyright 2026 DXOS
10
+
11
+ ## Terms and Conditions
12
+
13
+ ### Licensor ("We")
14
+
15
+ The party offering the Software under these Terms and Conditions.
16
+
17
+ ### The Software
18
+
19
+ The "Software" is each version of the software that we make available under
20
+ these Terms and Conditions, as indicated by our inclusion of these Terms and
21
+ Conditions with the Software.
22
+
23
+ ### License Grant
24
+
25
+ Subject to your compliance with this License Grant and the Patents,
26
+ Redistribution and Trademark clauses below, we hereby grant you the right to
27
+ use, copy, modify, create derivative works, publicly perform, publicly display
28
+ and redistribute the Software for any Permitted Purpose identified below.
29
+
30
+ ### Permitted Purpose
31
+
32
+ A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
33
+ means making the Software available to others in a commercial product or
34
+ service that:
35
+
36
+ 1. substitutes for the Software;
37
+
38
+ 2. substitutes for any other product or service we offer using the Software
39
+ that exists as of the date we make the Software available; or
40
+
41
+ 3. offers the same or substantially similar functionality as the Software.
42
+
43
+ Permitted Purposes specifically include using the Software:
44
+
45
+ 1. for your internal use and access;
46
+
47
+ 2. for non-commercial education;
48
+
49
+ 3. for non-commercial research; and
50
+
51
+ 4. in connection with professional services that you provide to a licensee
52
+ using the Software in accordance with these Terms and Conditions.
53
+
54
+ ### Patents
55
+
56
+ To the extent your use for a Permitted Purpose would necessarily infringe our
57
+ patents, the license grant above includes a license under our patents. If you
58
+ make a claim against any party that the Software infringes or contributes to
59
+ the infringement of any patent, then your patent license to the Software ends
60
+ immediately.
61
+
62
+ ### Redistribution
63
+
64
+ The Terms and Conditions apply to all copies, modifications and derivatives of
65
+ the Software.
66
+
67
+ If you redistribute any copies, modifications or derivatives of the Software,
68
+ you must include a copy of or a link to these Terms and Conditions and not
69
+ remove any copyright notices provided in or with the Software.
70
+
71
+ ### Disclaimer
72
+
73
+ THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
74
+ IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
75
+ PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
76
+
77
+ IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
78
+ SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
79
+ EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
80
+
81
+ ### Trademarks
82
+
83
+ Except for displaying the License Details and identifying us as the origin of
84
+ the Software, you have no right under these Terms and Conditions to use our
85
+ trademarks, trade names, service marks or product names.
86
+
87
+ ## Grant of Future License
88
+
89
+ We hereby irrevocably grant you an additional license to use the Software under
90
+ the Apache License, Version 2.0 that is effective on the second anniversary of
91
+ the date we make the Software available. On or after that date, you may use the
92
+ Software under the Apache License, Version 2.0, in which case the following
93
+ will apply:
94
+
95
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
96
+ this file except in compliance with the License.
97
+
98
+ You may obtain a copy of the License at
99
+
100
+ http://www.apache.org/licenses/LICENSE-2.0
101
+
102
+ Unless required by applicable law or agreed to in writing, software distributed
103
+ under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
104
+ CONDITIONS OF ANY KIND, either express or implied. See the License for the
105
+ specific language governing permissions and limitations under the License.
package/README.md CHANGED
@@ -18,4 +18,4 @@ pnpm i @dxos/index-core
18
18
 
19
19
  Your ideas, issues, and code are most welcome. Please take a look at our [community code of conduct](https://github.com/dxos/dxos/blob/main/CODE_OF_CONDUCT.md), the [issue guide](https://github.com/dxos/dxos/blob/main/CONTRIBUTING.md#submitting-issues), and the [PR contribution guide](https://github.com/dxos/dxos/blob/main/CONTRIBUTING.md#submitting-prs).
20
20
 
21
- License: [MIT](./LICENSE) Copyright 2022 © DXOS
21
+ License: [FSL-1.1-Apache-2.0](./LICENSE) Copyright 2022 © DXOS
@@ -1,5 +1,6 @@
1
1
  // src/index-engine.ts
2
2
  import * as Effect5 from "effect/Effect";
3
+ import { ATTR_TYPE as ATTR_TYPE2 } from "@dxos/echo/internal";
3
4
  import * as SqlTransaction from "@dxos/sql-sqlite/SqlTransaction";
4
5
 
5
6
  // src/index-tracker.ts
@@ -88,6 +89,7 @@ var IndexTracker = class {
88
89
  // src/indexes/fts-index.ts
89
90
  import * as SqlClient3 from "@effect/sql/SqlClient";
90
91
  import * as Effect2 from "effect/Effect";
92
+ var SQL_CHUNK_SIZE = 500;
91
93
  var escapeFts5Query = (text) => {
92
94
  return text.split(/\s+/).filter(Boolean).map((term) => `"${term.replace(/"/g, '""')}"`).join(" ");
93
95
  };
@@ -149,6 +151,7 @@ var FtsIndex = class {
149
151
  /**
150
152
  * Query snapshots by recordIds.
151
153
  * Returns the parsed JSON snapshots for queue objects.
154
+ * RecordIds not present in the FTS index are silently omitted from the result.
152
155
  */
153
156
  querySnapshotsJSON(recordIds) {
154
157
  return Effect2.gen(function* () {
@@ -156,11 +159,21 @@ var FtsIndex = class {
156
159
  return [];
157
160
  }
158
161
  const sql = yield* SqlClient3.SqlClient;
159
- const results = yield* sql`SELECT rowid, snapshot FROM ftsIndex WHERE rowid IN ${sql.in(recordIds)}`;
160
- return results.map((r) => ({
161
- recordId: r.rowid,
162
- snapshot: JSON.parse(r.snapshot)
163
- }));
162
+ const chunks = [];
163
+ for (let i = 0; i < recordIds.length; i += SQL_CHUNK_SIZE) {
164
+ chunks.push(recordIds.slice(i, i + SQL_CHUNK_SIZE));
165
+ }
166
+ const allResults = [];
167
+ for (const chunk of chunks) {
168
+ const rows = yield* sql`SELECT rowid, snapshot FROM ftsIndex WHERE rowid IN ${sql.in(chunk)}`;
169
+ for (const r of rows) {
170
+ allResults.push({
171
+ recordId: r.rowid,
172
+ snapshot: JSON.parse(r.snapshot)
173
+ });
174
+ }
175
+ }
176
+ return allResults;
164
177
  });
165
178
  }
166
179
  update = Effect2.fn("FtsIndex.update")((objects) => Effect2.gen(function* () {
@@ -196,11 +209,13 @@ var ObjectMeta = Schema2.Struct({
196
209
  recordId: Schema2.Number,
197
210
  objectId: Schema2.String,
198
211
  queueId: Schema2.String,
212
+ /** Queue subspace namespace (e.g. 'data', 'trace'). Empty string for non-queue objects. */
213
+ queueNamespace: Schema2.String,
199
214
  spaceId: Schema2.String,
200
215
  documentId: Schema2.String,
201
216
  entityKind: Schema2.String,
202
217
  /** The versioned DXN of the type of the object. */
203
- typeDxn: Schema2.String,
218
+ typeDXN: Schema2.String,
204
219
  deleted: Schema2.Boolean,
205
220
  source: Schema2.NullOr(Schema2.String),
206
221
  target: Schema2.NullOr(Schema2.String),
@@ -237,10 +252,11 @@ var ObjectMetaIndex = class {
237
252
  recordId INTEGER PRIMARY KEY AUTOINCREMENT,
238
253
  objectId TEXT NOT NULL,
239
254
  queueId TEXT NOT NULL DEFAULT '',
255
+ queueNamespace TEXT NOT NULL DEFAULT '',
240
256
  spaceId TEXT NOT NULL,
241
257
  documentId TEXT NOT NULL DEFAULT '',
242
258
  entityKind TEXT NOT NULL,
243
- typeDxn TEXT NOT NULL,
259
+ typeDXN TEXT NOT NULL,
244
260
  deleted INTEGER NOT NULL,
245
261
  source TEXT,
246
262
  target TEXT,
@@ -252,8 +268,9 @@ var ObjectMetaIndex = class {
252
268
  yield* Effect3.catchAll(sql`ALTER TABLE objectMeta ADD COLUMN parent TEXT`, () => Effect3.void);
253
269
  yield* Effect3.catchAll(sql`ALTER TABLE objectMeta ADD COLUMN createdAt INTEGER`, () => Effect3.void);
254
270
  yield* Effect3.catchAll(sql`ALTER TABLE objectMeta ADD COLUMN updatedAt INTEGER`, () => Effect3.void);
271
+ yield* Effect3.catchAll(sql`ALTER TABLE objectMeta ADD COLUMN queueNamespace TEXT NOT NULL DEFAULT ''`, () => Effect3.void);
255
272
  yield* sql`CREATE INDEX IF NOT EXISTS idx_object_index_objectId ON objectMeta(spaceId, objectId)`;
256
- yield* sql`CREATE INDEX IF NOT EXISTS idx_object_index_typeDxn ON objectMeta(spaceId, typeDxn)`;
273
+ yield* sql`CREATE INDEX IF NOT EXISTS idx_object_index_typeDXN ON objectMeta(spaceId, typeDXN)`;
257
274
  yield* sql`CREATE INDEX IF NOT EXISTS idx_object_index_version ON objectMeta(version)`;
258
275
  yield* sql`CREATE INDEX IF NOT EXISTS idx_object_index_parent ON objectMeta(spaceId, parent)`;
259
276
  yield* sql`CREATE INDEX IF NOT EXISTS idx_object_index_updatedAt ON objectMeta(updatedAt)`;
@@ -261,8 +278,8 @@ var ObjectMetaIndex = class {
261
278
  });
262
279
  query = Effect3.fn("ObjectMetaIndex.query")((query) => Effect3.gen(function* () {
263
280
  const sql = yield* SqlClient5.SqlClient;
264
- const parsedType = DXN.tryParse(query.typeDxn)?.asTypeDXN();
265
- const rows = parsedType && parsedType.version === void 0 ? yield* sql`SELECT * FROM objectMeta WHERE spaceId = ${query.spaceId} AND (typeDxn = ${query.typeDxn} OR typeDxn LIKE ${_escapeLikePrefix(query.typeDxn)} ESCAPE '\\')` : yield* sql`SELECT * FROM objectMeta WHERE spaceId = ${query.spaceId} AND typeDxn = ${query.typeDxn}`;
281
+ const parsedType = DXN.tryParse(query.typeDXN)?.asTypeDXN();
282
+ const rows = parsedType && parsedType.version === void 0 ? yield* sql`SELECT * FROM objectMeta WHERE spaceId = ${query.spaceId} AND (typeDXN = ${query.typeDXN} OR typeDXN LIKE ${_escapeLikePrefix(query.typeDXN)} ESCAPE '\\')` : yield* sql`SELECT * FROM objectMeta WHERE spaceId = ${query.spaceId} AND typeDXN = ${query.typeDXN}`;
266
283
  return rows.map((row) => ({
267
284
  ...row,
268
285
  deleted: !!row.deleted
@@ -298,12 +315,12 @@ var ObjectMetaIndex = class {
298
315
  }
299
316
  const sql = yield* SqlClient5.SqlClient;
300
317
  const sourceCondition = buildSourceCondition(sql, spaceIds, includeAllQueues, queueIds);
301
- const typeWhere = sql.or(typeDxns.map((typeDxn) => {
302
- const parsedType = DXN.tryParse(typeDxn)?.asTypeDXN();
318
+ const typeWhere = sql.or(typeDxns.map((typeDXN) => {
319
+ const parsedType = DXN.tryParse(typeDXN)?.asTypeDXN();
303
320
  return parsedType && parsedType.version === void 0 ? sql.or([
304
- sql`typeDxn = ${typeDxn}`,
305
- sql`typeDxn LIKE ${_escapeLikePrefix(typeDxn)} ESCAPE '\\'`
306
- ]) : sql`typeDxn = ${typeDxn}`;
321
+ sql`typeDXN = ${typeDXN}`,
322
+ sql`typeDXN LIKE ${_escapeLikePrefix(typeDXN)} ESCAPE '\\'`
323
+ ]) : sql`typeDXN = ${typeDXN}`;
307
324
  }));
308
325
  const rows = inverted ? yield* sql`SELECT * FROM objectMeta WHERE ${sourceCondition} AND NOT ${typeWhere}` : yield* sql`SELECT * FROM objectMeta WHERE ${sourceCondition} AND ${typeWhere}`;
309
326
  return rows.map((row) => ({
@@ -327,7 +344,7 @@ var ObjectMetaIndex = class {
327
344
  update = Effect3.fn("ObjectMetaIndex.update")((objects) => Effect3.gen(function* () {
328
345
  const sql = yield* SqlClient5.SqlClient;
329
346
  yield* Effect3.forEach(objects, (object) => Effect3.gen(function* () {
330
- const { spaceId, queueId, documentId, data } = object;
347
+ const { spaceId, queueId, queueNamespace, documentId, data } = object;
331
348
  const castData = data;
332
349
  const objectId = castData.id;
333
350
  let existing;
@@ -342,7 +359,7 @@ var ObjectMetaIndex = class {
342
359
  const [{ v }] = result;
343
360
  const version = (v ?? 0) + 1;
344
361
  const entityKind = castData[ATTR_RELATION_SOURCE] ? "relation" : "object";
345
- const typeDxn = castData[ATTR_TYPE] ? String(castData[ATTR_TYPE]) : "type";
362
+ const typeDXN = castData[ATTR_TYPE] ? String(castData[ATTR_TYPE]) : "type";
346
363
  const deleted = castData[ATTR_DELETED] ? 1 : 0;
347
364
  const source = entityKind === "relation" ? castData[ATTR_RELATION_SOURCE] ?? null : null;
348
365
  const target = entityKind === "relation" ? castData[ATTR_RELATION_TARGET] ?? null : null;
@@ -352,8 +369,9 @@ var ObjectMetaIndex = class {
352
369
  yield* sql`
353
370
  UPDATE objectMeta SET
354
371
  version = ${version},
372
+ queueNamespace = ${queueNamespace ?? ""},
355
373
  entityKind = ${entityKind},
356
- typeDxn = ${typeDxn},
374
+ typeDXN = ${typeDXN},
357
375
  deleted = ${deleted},
358
376
  source = ${source},
359
377
  target = ${target},
@@ -364,12 +382,12 @@ var ObjectMetaIndex = class {
364
382
  } else {
365
383
  yield* sql`
366
384
  INSERT INTO objectMeta (
367
- objectId, queueId, spaceId, documentId,
368
- entityKind, typeDxn, deleted, source, target, parent, version,
385
+ objectId, queueId, queueNamespace, spaceId, documentId,
386
+ entityKind, typeDXN, deleted, source, target, parent, version,
369
387
  createdAt, updatedAt
370
388
  ) VALUES (
371
- ${objectId}, ${queueId ?? ""}, ${spaceId}, ${documentId ?? ""},
372
- ${entityKind}, ${typeDxn}, ${deleted},
389
+ ${objectId}, ${queueId ?? ""}, ${queueNamespace ?? ""}, ${spaceId}, ${documentId ?? ""},
390
+ ${entityKind}, ${typeDXN}, ${deleted},
373
391
  ${source}, ${target}, ${parent}, ${version},
374
392
  ${sourceTimestamp}, ${sourceTimestamp}
375
393
  )
@@ -460,13 +478,18 @@ var ObjectMetaIndex = class {
460
478
  }));
461
479
  /**
462
480
  * Query children by parent object ids.
481
+ * Matches both:
482
+ * - Objects whose `parent` field references one of the given parent ids (standard parent/child hierarchy).
483
+ * - Queue items whose `queueId` equals one of the parent ids (e.g. items inside a Feed, since a feed's queue
484
+ * DXN uses the feed's object id as its queue id — see `Feed.getQueueDxn`).
463
485
  */
464
486
  queryChildren = Effect3.fn("ObjectMetaIndex.queryChildren")((query) => Effect3.gen(function* () {
465
487
  if (query.parentIds.length === 0) {
466
488
  return [];
467
489
  }
468
490
  const sql = yield* SqlClient5.SqlClient;
469
- const rows = yield* sql`SELECT * FROM objectMeta WHERE spaceId IN ${sql.in(query.spaceId)} AND parent IN ${sql.in(query.parentIds.map((id) => DXN.fromLocalObjectId(id).toString()))}`;
491
+ const parentDxns = query.parentIds.map((id) => DXN.fromLocalObjectId(id).toString());
492
+ const rows = yield* sql`SELECT * FROM objectMeta WHERE ${sql.in("spaceId", query.spaceId)} AND (${sql.in("parent", parentDxns)} OR ${sql.in("queueId", query.parentIds)})`;
470
493
  return rows.map((row) => ({
471
494
  ...row,
472
495
  deleted: !!row.deleted
@@ -495,15 +518,7 @@ var EscapedPropPath = class extends Schema3.String.annotations({
495
518
  let current = "";
496
519
  for (let i = 0; i < path.length; i++) {
497
520
  if (path[i] === "\\") {
498
- invariant(i + 1 < path.length && (path[i + 1] === "." || path[i + 1] === "\\"), "Malformed escaping.", {
499
- F: __dxlog_file,
500
- L: 34,
501
- S: this,
502
- A: [
503
- "i + 1 < path.length && (path[i + 1] === '.' || path[i + 1] === '\\\\')",
504
- "'Malformed escaping.'"
505
- ]
506
- });
521
+ invariant(i + 1 < path.length && (path[i + 1] === "." || path[i + 1] === "\\"), "Malformed escaping.", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 25, S: this, A: ["i + 1 < path.length && (path[i + 1] === '.' || path[i + 1] === '\\\\')", "'Malformed escaping.'"] });
507
522
  current = current + path[i + 1];
508
523
  i++;
509
524
  } else if (path[i] === ".") {
@@ -530,7 +545,7 @@ var extractReferences = (data) => {
530
545
  }
531
546
  refs.push({
532
547
  path,
533
- targetDxn: dxn.toString()
548
+ targetDXN: dxn.toString()
534
549
  });
535
550
  } else if (typeof value === "object" && value !== null && !Array.isArray(value)) {
536
551
  for (const [key, v] of Object.entries(value)) {
@@ -553,7 +568,7 @@ var extractReferences = (data) => {
553
568
  };
554
569
  var ReverseRef = Schema4.Struct({
555
570
  recordId: Schema4.Number,
556
- targetDxn: Schema4.String,
571
+ targetDXN: Schema4.String,
557
572
  /**
558
573
  * Escaped property path within an object.
559
574
  *
@@ -570,18 +585,18 @@ var ReverseRefIndex = class {
570
585
  const sql = yield* SqlClient7.SqlClient;
571
586
  yield* sql`CREATE TABLE IF NOT EXISTS reverseRef (
572
587
  recordId INTEGER NOT NULL,
573
- targetDxn TEXT NOT NULL,
588
+ targetDXN TEXT NOT NULL,
574
589
  propPath TEXT NOT NULL,
575
- PRIMARY KEY (recordId, targetDxn, propPath)
590
+ PRIMARY KEY (recordId, targetDXN, propPath)
576
591
  )`;
577
- yield* sql`CREATE INDEX IF NOT EXISTS idx_reverse_ref_target ON reverseRef(targetDxn)`;
592
+ yield* sql`CREATE INDEX IF NOT EXISTS idx_reverse_ref_target ON reverseRef(targetDXN)`;
578
593
  });
579
594
  /**
580
595
  * Query all references pointing to a target DXN.
581
596
  */
582
- query = Effect4.fn("ReverseRefIndex.query")(({ targetDxn }) => Effect4.gen(function* () {
597
+ query = Effect4.fn("ReverseRefIndex.query")(({ targetDXN }) => Effect4.gen(function* () {
583
598
  const sql = yield* SqlClient7.SqlClient;
584
- const rows = yield* sql`SELECT * FROM reverseRef WHERE targetDxn = ${targetDxn}`;
599
+ const rows = yield* sql`SELECT * FROM reverseRef WHERE targetDXN = ${targetDXN}`;
585
600
  return rows;
586
601
  }));
587
602
  update = Effect4.fn("ReverseRefIndex.update")((objects) => Effect4.gen(function* () {
@@ -593,7 +608,7 @@ var ReverseRefIndex = class {
593
608
  }
594
609
  yield* sql`DELETE FROM reverseRef WHERE recordId = ${recordId}`;
595
610
  const refs = extractReferences(data);
596
- yield* Effect4.forEach(refs, (ref) => sql`INSERT INTO reverseRef (recordId, targetDxn, propPath) VALUES (${recordId}, ${ref.targetDxn}, ${EscapedPropPath.escape(ref.path)})`, {
611
+ yield* Effect4.forEach(refs, (ref) => sql`INSERT INTO reverseRef (recordId, targetDXN, propPath) VALUES (${recordId}, ${ref.targetDXN}, ${EscapedPropPath.escape(ref.path)})`, {
597
612
  discard: true
598
613
  });
599
614
  }), {
@@ -603,6 +618,33 @@ var ReverseRefIndex = class {
603
618
  };
604
619
 
605
620
  // src/index-engine.ts
621
+ var makeEmptyIndexingResult = () => ({
622
+ updated: 0,
623
+ done: true,
624
+ spaces: /* @__PURE__ */ new Set(),
625
+ queues: /* @__PURE__ */ new Set(),
626
+ documents: /* @__PURE__ */ new Set(),
627
+ types: /* @__PURE__ */ new Set(),
628
+ objects: /* @__PURE__ */ new Set()
629
+ });
630
+ var accumulateIndexingResult = (acc, objects) => {
631
+ for (const obj of objects) {
632
+ acc.spaces.add(obj.spaceId);
633
+ if (obj.queueId) {
634
+ acc.queues.add(obj.queueId);
635
+ }
636
+ if (obj.documentId) {
637
+ acc.documents.add(obj.documentId);
638
+ }
639
+ const t = obj.data[ATTR_TYPE2];
640
+ if (t) {
641
+ acc.types.add(String(t));
642
+ }
643
+ if (obj.data.id) {
644
+ acc.objects.add(obj.data.id);
645
+ }
646
+ }
647
+ };
606
648
  var IndexEngine = class {
607
649
  #tracker;
608
650
  #objectMetaIndex;
@@ -669,26 +711,24 @@ var IndexEngine = class {
669
711
  }
670
712
  update(ctx, dataSource, opts) {
671
713
  return Effect5.gen(this, function* () {
672
- let updated = 0;
673
- let done = true;
674
- const { updated: updatedFtsIndex, done: doneFtsIndex } = yield* this.#update(ctx, this.#ftsIndex, dataSource, {
714
+ const result = makeEmptyIndexingResult();
715
+ const { updated: updatedFtsIndex, done: doneFtsIndex, objects: ftsObjects } = yield* this.#update(ctx, this.#ftsIndex, dataSource, {
675
716
  indexName: "fts5",
676
717
  spaceId: opts.spaceId,
677
718
  limit: opts.limit
678
719
  });
679
- updated += updatedFtsIndex;
680
- done = done && doneFtsIndex;
681
- const { updated: updatedReverseRefIndex, done: doneReverseRefIndex } = yield* this.#update(ctx, this.#reverseRefIndex, dataSource, {
720
+ result.updated += updatedFtsIndex;
721
+ result.done = result.done && doneFtsIndex;
722
+ accumulateIndexingResult(result, ftsObjects);
723
+ const { updated: updatedReverseRefIndex, done: doneReverseRefIndex, objects: reverseRefObjects } = yield* this.#update(ctx, this.#reverseRefIndex, dataSource, {
682
724
  indexName: "reverseRef",
683
725
  spaceId: opts.spaceId,
684
726
  limit: opts.limit
685
727
  });
686
- updated += updatedReverseRefIndex;
687
- done = done && doneReverseRefIndex;
688
- return {
689
- updated,
690
- done
691
- };
728
+ result.updated += updatedReverseRefIndex;
729
+ result.done = result.done && doneReverseRefIndex;
730
+ accumulateIndexingResult(result, reverseRefObjects);
731
+ return result;
692
732
  }).pipe(Effect5.withSpan("IndexEngine.update"));
693
733
  }
694
734
  /**
@@ -716,7 +756,8 @@ var IndexEngine = class {
716
756
  if (objects.length === 0) {
717
757
  return {
718
758
  updated: 0,
719
- done: true
759
+ done: true,
760
+ objects: []
720
761
  };
721
762
  }
722
763
  yield* this.#objectMetaIndex.update(objects);
@@ -731,7 +772,8 @@ var IndexEngine = class {
731
772
  })));
732
773
  return {
733
774
  updated: objects.length,
734
- done: false
775
+ done: false,
776
+ objects
735
777
  };
736
778
  }));
737
779
  }).pipe(Effect5.withSpan("IndexEngine.#update"));