@concavejs/docstore-better-sqlite3 0.0.1-alpha.8 → 0.0.1-alpha.9

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 (2) hide show
  1. package/dist/index.js +24 -21
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -4745,6 +4745,7 @@ class AccessLog {
4745
4745
  return this.ranges.getRanges().map(serializeKeyRange);
4746
4746
  }
4747
4747
  }
4748
+
4748
4749
  // ../core/dist/tables/memory-table-registry.js
4749
4750
  init_interface();
4750
4751
 
@@ -4877,7 +4878,6 @@ class KernelContext {
4877
4878
  }
4878
4879
  recordTableRead(tableName) {
4879
4880
  if (this.mutationTransaction) {
4880
- this.mutationTransaction.recordTableScan(stringToHex(tableName), []);
4881
4881
  return;
4882
4882
  }
4883
4883
  this.readLog.addTableScan(tableName);
@@ -4890,8 +4890,6 @@ class KernelContext {
4890
4890
  }
4891
4891
  recordIndexRange(tableName, indexDescriptor, startKey, endKey) {
4892
4892
  if (this.mutationTransaction) {
4893
- const indexId = indexKeyspaceId(tableName, indexDescriptor);
4894
- this.mutationTransaction.recordIndexRangeScan(indexId, startKey, endKey, []);
4895
4893
  return;
4896
4894
  }
4897
4895
  this.readLog.addIndexRange(tableName, indexDescriptor, startKey, endKey);
@@ -5050,11 +5048,12 @@ class BlobStoreGateway {
5050
5048
  if (!latest || latest.ts > this.context.snapshotTimestamp) {
5051
5049
  return;
5052
5050
  }
5053
- await storage2.delete(docId.internalId);
5051
+ const canonicalDocId = latest.value.id;
5052
+ await storage2.delete(canonicalDocId.internalId);
5054
5053
  const timestamp2 = this.docStore.allocateTimestamp();
5055
- const entry = { ts: timestamp2, id: docId, value: null, prev_ts: latest.ts };
5054
+ const entry = { ts: timestamp2, id: canonicalDocId, value: null, prev_ts: latest.ts };
5056
5055
  await this.docStore.applyWrites([entry], new Set, "Error");
5057
- this.context.recordLocalWrite(storageId, "_storage", null, docId);
5056
+ this.context.recordLocalWrite(storageId, "_storage", null, canonicalDocId);
5058
5057
  }
5059
5058
  requireStorage() {
5060
5059
  if (!this.storage) {
@@ -5261,16 +5260,17 @@ class SchedulerGateway {
5261
5260
  if (!latest) {
5262
5261
  throw new Error(`Scheduled job with id ${id} not found.`);
5263
5262
  }
5263
+ const canonicalDocId = latest.value.id;
5264
5264
  const newValue = {
5265
5265
  ...latest.value.value,
5266
5266
  state: state ?? { kind: "canceled" }
5267
5267
  };
5268
- const resolvedDocument = { id: docId, value: newValue };
5268
+ const resolvedDocument = { id: canonicalDocId, value: newValue };
5269
5269
  const timestamp2 = this.docStore.allocateTimestamp();
5270
- const entry = { ts: timestamp2, id: docId, value: resolvedDocument, prev_ts: latest.ts };
5270
+ const entry = { ts: timestamp2, id: canonicalDocId, value: resolvedDocument, prev_ts: latest.ts };
5271
5271
  await this.docStore.applyWrites([entry], new Set, "Error");
5272
- const tableName = await resolveTableName(docId, this.context.tableRegistry);
5273
- this.context.recordLocalWrite(id, tableName, resolvedDocument.value, docId);
5272
+ const tableName = await resolveTableName(canonicalDocId, this.context.tableRegistry);
5273
+ this.context.recordLocalWrite(id, tableName, resolvedDocument.value, canonicalDocId);
5274
5274
  }
5275
5275
  }
5276
5276
 
@@ -5488,13 +5488,14 @@ class DatabaseSyscalls {
5488
5488
  if (!latest) {
5489
5489
  throw new Error(`Document with id ${id} not found.`);
5490
5490
  }
5491
+ const canonicalDocId = latest.value.id;
5491
5492
  const timestamp2 = this.docStore.allocateTimestamp();
5492
- const entry = { ts: timestamp2, id: docId, value: null, prev_ts: latest.ts };
5493
+ const entry = { ts: timestamp2, id: canonicalDocId, value: null, prev_ts: latest.ts };
5493
5494
  const indexes = await this.schemaService.getAllIndexesForTable(bareTableName);
5494
- const indexUpdates = generateIndexUpdates(fullTableName, docId, null, latest.value.value, indexes);
5495
+ const indexUpdates = generateIndexUpdates(fullTableName, canonicalDocId, null, latest.value.value, indexes);
5495
5496
  const indexEntries = new Set(indexUpdates.map((update) => ({ ts: timestamp2, update })));
5496
5497
  await this.docStore.applyWrites([entry], indexEntries, "Error");
5497
- this.context.recordLocalWrite(id, fullTableName, null, docId);
5498
+ this.context.recordLocalWrite(id, fullTableName, null, canonicalDocId);
5498
5499
  return {};
5499
5500
  }
5500
5501
  async handleShallowMerge(args) {
@@ -5520,6 +5521,7 @@ class DatabaseSyscalls {
5520
5521
  if (!latest) {
5521
5522
  throw new Error(`Document with id ${id} not found.`);
5522
5523
  }
5524
+ const canonicalDocId = latest.value.id;
5523
5525
  const existingValue = latest.value.value;
5524
5526
  const newValue = { ...existingValue };
5525
5527
  if (typeof value === "object" && value !== null && "$undefined" in value) {
@@ -5546,14 +5548,14 @@ class DatabaseSyscalls {
5546
5548
  }
5547
5549
  }
5548
5550
  await this.schemaService.validate(bareTableName, newValue);
5549
- const resolvedDocument = { id: docId, value: newValue };
5551
+ const resolvedDocument = { id: canonicalDocId, value: newValue };
5550
5552
  const timestamp2 = this.docStore.allocateTimestamp();
5551
- const entry = { ts: timestamp2, id: docId, value: resolvedDocument, prev_ts: latest.ts };
5553
+ const entry = { ts: timestamp2, id: canonicalDocId, value: resolvedDocument, prev_ts: latest.ts };
5552
5554
  const indexes = await this.schemaService.getAllIndexesForTable(bareTableName);
5553
- const indexUpdates = generateIndexUpdates(fullTableName, docId, resolvedDocument.value, existingValue, indexes);
5555
+ const indexUpdates = generateIndexUpdates(fullTableName, canonicalDocId, resolvedDocument.value, existingValue, indexes);
5554
5556
  const indexEntries = new Set(indexUpdates.map((update) => ({ ts: timestamp2, update })));
5555
5557
  await this.docStore.applyWrites([entry], indexEntries, "Error");
5556
- this.context.recordLocalWrite(id, fullTableName, resolvedDocument.value, docId);
5558
+ this.context.recordLocalWrite(id, fullTableName, resolvedDocument.value, canonicalDocId);
5557
5559
  return {};
5558
5560
  }
5559
5561
  async handleReplace(args) {
@@ -5575,17 +5577,18 @@ class DatabaseSyscalls {
5575
5577
  if (!latest) {
5576
5578
  throw new Error(`Document with id ${id} not found.`);
5577
5579
  }
5580
+ const canonicalDocId = latest.value.id;
5578
5581
  const { _id, _creationTime } = latest.value.value;
5579
5582
  const newValue = { ...replaceValue, _id, _creationTime };
5580
5583
  await this.schemaService.validate(bareTableName, newValue);
5581
- const resolvedDocument = { id: docId, value: newValue };
5584
+ const resolvedDocument = { id: canonicalDocId, value: newValue };
5582
5585
  const timestamp2 = this.docStore.allocateTimestamp();
5583
- const entry = { ts: timestamp2, id: docId, value: resolvedDocument, prev_ts: latest.ts };
5586
+ const entry = { ts: timestamp2, id: canonicalDocId, value: resolvedDocument, prev_ts: latest.ts };
5584
5587
  const indexes = await this.schemaService.getAllIndexesForTable(bareTableName);
5585
- const indexUpdates = generateIndexUpdates(fullTableName, docId, resolvedDocument.value, latest.value.value, indexes);
5588
+ const indexUpdates = generateIndexUpdates(fullTableName, canonicalDocId, resolvedDocument.value, latest.value.value, indexes);
5586
5589
  const indexEntries = new Set(indexUpdates.map((update) => ({ ts: timestamp2, update })));
5587
5590
  await this.docStore.applyWrites([entry], indexEntries, "Error");
5588
- this.context.recordLocalWrite(id, fullTableName, newValue, docId);
5591
+ this.context.recordLocalWrite(id, fullTableName, newValue, canonicalDocId);
5589
5592
  return {};
5590
5593
  }
5591
5594
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@concavejs/docstore-better-sqlite3",
3
- "version": "0.0.1-alpha.8",
3
+ "version": "0.0.1-alpha.9",
4
4
  "license": "FSL-1.1-Apache-2.0",
5
5
  "publishConfig": {
6
6
  "access": "public"