@concavejs/docstore-memory 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 +29 -26
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -4388,11 +4388,6 @@ function parseStorageId(storageId) {
4388
4388
  function isTablePlaceholder(table) {
4389
4389
  return table.startsWith("#");
4390
4390
  }
4391
- // ../core/dist/query/planner.js
4392
- init_interface();
4393
- // ../core/dist/query/actions.js
4394
- init_interface();
4395
-
4396
4391
  // ../core/dist/utils/keyspace.js
4397
4392
  var TABLE_PREFIX = "table";
4398
4393
  var INDEX_PREFIX = "index";
@@ -4435,6 +4430,11 @@ function decodeIndexId(indexId) {
4435
4430
  };
4436
4431
  }
4437
4432
 
4433
+ // ../core/dist/query/planner.js
4434
+ init_interface();
4435
+ // ../core/dist/query/actions.js
4436
+ init_interface();
4437
+
4438
4438
  // ../core/dist/queryengine/indexing/read-write-set.js
4439
4439
  class RangeSet {
4440
4440
  ranges = new Map;
@@ -4569,6 +4569,7 @@ class AccessLog {
4569
4569
  return this.ranges.getRanges().map(serializeKeyRange);
4570
4570
  }
4571
4571
  }
4572
+
4572
4573
  // ../core/dist/tables/memory-table-registry.js
4573
4574
  init_interface();
4574
4575
 
@@ -4701,7 +4702,6 @@ class KernelContext {
4701
4702
  }
4702
4703
  recordTableRead(tableName) {
4703
4704
  if (this.mutationTransaction) {
4704
- this.mutationTransaction.recordTableScan(stringToHex(tableName), []);
4705
4705
  return;
4706
4706
  }
4707
4707
  this.readLog.addTableScan(tableName);
@@ -4714,8 +4714,6 @@ class KernelContext {
4714
4714
  }
4715
4715
  recordIndexRange(tableName, indexDescriptor, startKey, endKey) {
4716
4716
  if (this.mutationTransaction) {
4717
- const indexId = indexKeyspaceId(tableName, indexDescriptor);
4718
- this.mutationTransaction.recordIndexRangeScan(indexId, startKey, endKey, []);
4719
4717
  return;
4720
4718
  }
4721
4719
  this.readLog.addIndexRange(tableName, indexDescriptor, startKey, endKey);
@@ -4874,11 +4872,12 @@ class BlobStoreGateway {
4874
4872
  if (!latest || latest.ts > this.context.snapshotTimestamp) {
4875
4873
  return;
4876
4874
  }
4877
- await storage2.delete(docId.internalId);
4875
+ const canonicalDocId = latest.value.id;
4876
+ await storage2.delete(canonicalDocId.internalId);
4878
4877
  const timestamp = this.docStore.allocateTimestamp();
4879
- const entry = { ts: timestamp, id: docId, value: null, prev_ts: latest.ts };
4878
+ const entry = { ts: timestamp, id: canonicalDocId, value: null, prev_ts: latest.ts };
4880
4879
  await this.docStore.applyWrites([entry], new Set, "Error");
4881
- this.context.recordLocalWrite(storageId, "_storage", null, docId);
4880
+ this.context.recordLocalWrite(storageId, "_storage", null, canonicalDocId);
4882
4881
  }
4883
4882
  requireStorage() {
4884
4883
  if (!this.storage) {
@@ -5085,16 +5084,17 @@ class SchedulerGateway {
5085
5084
  if (!latest) {
5086
5085
  throw new Error(`Scheduled job with id ${id} not found.`);
5087
5086
  }
5087
+ const canonicalDocId = latest.value.id;
5088
5088
  const newValue = {
5089
5089
  ...latest.value.value,
5090
5090
  state: state ?? { kind: "canceled" }
5091
5091
  };
5092
- const resolvedDocument = { id: docId, value: newValue };
5092
+ const resolvedDocument = { id: canonicalDocId, value: newValue };
5093
5093
  const timestamp = this.docStore.allocateTimestamp();
5094
- const entry = { ts: timestamp, id: docId, value: resolvedDocument, prev_ts: latest.ts };
5094
+ const entry = { ts: timestamp, id: canonicalDocId, value: resolvedDocument, prev_ts: latest.ts };
5095
5095
  await this.docStore.applyWrites([entry], new Set, "Error");
5096
- const tableName = await resolveTableName(docId, this.context.tableRegistry);
5097
- this.context.recordLocalWrite(id, tableName, resolvedDocument.value, docId);
5096
+ const tableName = await resolveTableName(canonicalDocId, this.context.tableRegistry);
5097
+ this.context.recordLocalWrite(id, tableName, resolvedDocument.value, canonicalDocId);
5098
5098
  }
5099
5099
  }
5100
5100
 
@@ -5312,13 +5312,14 @@ class DatabaseSyscalls {
5312
5312
  if (!latest) {
5313
5313
  throw new Error(`Document with id ${id} not found.`);
5314
5314
  }
5315
+ const canonicalDocId = latest.value.id;
5315
5316
  const timestamp = this.docStore.allocateTimestamp();
5316
- const entry = { ts: timestamp, id: docId, value: null, prev_ts: latest.ts };
5317
+ const entry = { ts: timestamp, id: canonicalDocId, value: null, prev_ts: latest.ts };
5317
5318
  const indexes = await this.schemaService.getAllIndexesForTable(bareTableName);
5318
- const indexUpdates = generateIndexUpdates(fullTableName, docId, null, latest.value.value, indexes);
5319
+ const indexUpdates = generateIndexUpdates(fullTableName, canonicalDocId, null, latest.value.value, indexes);
5319
5320
  const indexEntries = new Set(indexUpdates.map((update) => ({ ts: timestamp, update })));
5320
5321
  await this.docStore.applyWrites([entry], indexEntries, "Error");
5321
- this.context.recordLocalWrite(id, fullTableName, null, docId);
5322
+ this.context.recordLocalWrite(id, fullTableName, null, canonicalDocId);
5322
5323
  return {};
5323
5324
  }
5324
5325
  async handleShallowMerge(args) {
@@ -5344,6 +5345,7 @@ class DatabaseSyscalls {
5344
5345
  if (!latest) {
5345
5346
  throw new Error(`Document with id ${id} not found.`);
5346
5347
  }
5348
+ const canonicalDocId = latest.value.id;
5347
5349
  const existingValue = latest.value.value;
5348
5350
  const newValue = { ...existingValue };
5349
5351
  if (typeof value === "object" && value !== null && "$undefined" in value) {
@@ -5370,14 +5372,14 @@ class DatabaseSyscalls {
5370
5372
  }
5371
5373
  }
5372
5374
  await this.schemaService.validate(bareTableName, newValue);
5373
- const resolvedDocument = { id: docId, value: newValue };
5375
+ const resolvedDocument = { id: canonicalDocId, value: newValue };
5374
5376
  const timestamp = this.docStore.allocateTimestamp();
5375
- const entry = { ts: timestamp, id: docId, value: resolvedDocument, prev_ts: latest.ts };
5377
+ const entry = { ts: timestamp, id: canonicalDocId, value: resolvedDocument, prev_ts: latest.ts };
5376
5378
  const indexes = await this.schemaService.getAllIndexesForTable(bareTableName);
5377
- const indexUpdates = generateIndexUpdates(fullTableName, docId, resolvedDocument.value, existingValue, indexes);
5379
+ const indexUpdates = generateIndexUpdates(fullTableName, canonicalDocId, resolvedDocument.value, existingValue, indexes);
5378
5380
  const indexEntries = new Set(indexUpdates.map((update) => ({ ts: timestamp, update })));
5379
5381
  await this.docStore.applyWrites([entry], indexEntries, "Error");
5380
- this.context.recordLocalWrite(id, fullTableName, resolvedDocument.value, docId);
5382
+ this.context.recordLocalWrite(id, fullTableName, resolvedDocument.value, canonicalDocId);
5381
5383
  return {};
5382
5384
  }
5383
5385
  async handleReplace(args) {
@@ -5399,17 +5401,18 @@ class DatabaseSyscalls {
5399
5401
  if (!latest) {
5400
5402
  throw new Error(`Document with id ${id} not found.`);
5401
5403
  }
5404
+ const canonicalDocId = latest.value.id;
5402
5405
  const { _id, _creationTime } = latest.value.value;
5403
5406
  const newValue = { ...replaceValue, _id, _creationTime };
5404
5407
  await this.schemaService.validate(bareTableName, newValue);
5405
- const resolvedDocument = { id: docId, value: newValue };
5408
+ const resolvedDocument = { id: canonicalDocId, value: newValue };
5406
5409
  const timestamp = this.docStore.allocateTimestamp();
5407
- const entry = { ts: timestamp, id: docId, value: resolvedDocument, prev_ts: latest.ts };
5410
+ const entry = { ts: timestamp, id: canonicalDocId, value: resolvedDocument, prev_ts: latest.ts };
5408
5411
  const indexes = await this.schemaService.getAllIndexesForTable(bareTableName);
5409
- const indexUpdates = generateIndexUpdates(fullTableName, docId, resolvedDocument.value, latest.value.value, indexes);
5412
+ const indexUpdates = generateIndexUpdates(fullTableName, canonicalDocId, resolvedDocument.value, latest.value.value, indexes);
5410
5413
  const indexEntries = new Set(indexUpdates.map((update) => ({ ts: timestamp, update })));
5411
5414
  await this.docStore.applyWrites([entry], indexEntries, "Error");
5412
- this.context.recordLocalWrite(id, fullTableName, newValue, docId);
5415
+ this.context.recordLocalWrite(id, fullTableName, newValue, canonicalDocId);
5413
5416
  return {};
5414
5417
  }
5415
5418
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@concavejs/docstore-memory",
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"