@concavejs/docstore-cf-hyperdrive 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
@@ -27136,11 +27136,6 @@ function parseStorageId(storageId) {
27136
27136
  function isTablePlaceholder(table) {
27137
27137
  return table.startsWith("#");
27138
27138
  }
27139
- // ../core/dist/query/planner.js
27140
- init_interface();
27141
- // ../core/dist/query/actions.js
27142
- init_interface();
27143
-
27144
27139
  // ../core/dist/utils/keyspace.js
27145
27140
  var TABLE_PREFIX = "table";
27146
27141
  var INDEX_PREFIX = "index";
@@ -27183,6 +27178,11 @@ function decodeIndexId(indexId) {
27183
27178
  };
27184
27179
  }
27185
27180
 
27181
+ // ../core/dist/query/planner.js
27182
+ init_interface();
27183
+ // ../core/dist/query/actions.js
27184
+ init_interface();
27185
+
27186
27186
  // ../core/dist/queryengine/indexing/read-write-set.js
27187
27187
  class RangeSet {
27188
27188
  ranges = new Map;
@@ -27317,6 +27317,7 @@ class AccessLog {
27317
27317
  return this.ranges.getRanges().map(serializeKeyRange);
27318
27318
  }
27319
27319
  }
27320
+
27320
27321
  // ../core/dist/tables/memory-table-registry.js
27321
27322
  init_interface();
27322
27323
 
@@ -27449,7 +27450,6 @@ class KernelContext {
27449
27450
  }
27450
27451
  recordTableRead(tableName) {
27451
27452
  if (this.mutationTransaction) {
27452
- this.mutationTransaction.recordTableScan(stringToHex(tableName), []);
27453
27453
  return;
27454
27454
  }
27455
27455
  this.readLog.addTableScan(tableName);
@@ -27462,8 +27462,6 @@ class KernelContext {
27462
27462
  }
27463
27463
  recordIndexRange(tableName, indexDescriptor, startKey, endKey) {
27464
27464
  if (this.mutationTransaction) {
27465
- const indexId = indexKeyspaceId(tableName, indexDescriptor);
27466
- this.mutationTransaction.recordIndexRangeScan(indexId, startKey, endKey, []);
27467
27465
  return;
27468
27466
  }
27469
27467
  this.readLog.addIndexRange(tableName, indexDescriptor, startKey, endKey);
@@ -27622,11 +27620,12 @@ class BlobStoreGateway {
27622
27620
  if (!latest || latest.ts > this.context.snapshotTimestamp) {
27623
27621
  return;
27624
27622
  }
27625
- await storage2.delete(docId.internalId);
27623
+ const canonicalDocId = latest.value.id;
27624
+ await storage2.delete(canonicalDocId.internalId);
27626
27625
  const timestamp = this.docStore.allocateTimestamp();
27627
- const entry = { ts: timestamp, id: docId, value: null, prev_ts: latest.ts };
27626
+ const entry = { ts: timestamp, id: canonicalDocId, value: null, prev_ts: latest.ts };
27628
27627
  await this.docStore.applyWrites([entry], new Set, "Error");
27629
- this.context.recordLocalWrite(storageId, "_storage", null, docId);
27628
+ this.context.recordLocalWrite(storageId, "_storage", null, canonicalDocId);
27630
27629
  }
27631
27630
  requireStorage() {
27632
27631
  if (!this.storage) {
@@ -27833,16 +27832,17 @@ class SchedulerGateway {
27833
27832
  if (!latest) {
27834
27833
  throw new Error(`Scheduled job with id ${id} not found.`);
27835
27834
  }
27835
+ const canonicalDocId = latest.value.id;
27836
27836
  const newValue = {
27837
27837
  ...latest.value.value,
27838
27838
  state: state ?? { kind: "canceled" }
27839
27839
  };
27840
- const resolvedDocument = { id: docId, value: newValue };
27840
+ const resolvedDocument = { id: canonicalDocId, value: newValue };
27841
27841
  const timestamp = this.docStore.allocateTimestamp();
27842
- const entry = { ts: timestamp, id: docId, value: resolvedDocument, prev_ts: latest.ts };
27842
+ const entry = { ts: timestamp, id: canonicalDocId, value: resolvedDocument, prev_ts: latest.ts };
27843
27843
  await this.docStore.applyWrites([entry], new Set, "Error");
27844
- const tableName = await resolveTableName(docId, this.context.tableRegistry);
27845
- this.context.recordLocalWrite(id, tableName, resolvedDocument.value, docId);
27844
+ const tableName = await resolveTableName(canonicalDocId, this.context.tableRegistry);
27845
+ this.context.recordLocalWrite(id, tableName, resolvedDocument.value, canonicalDocId);
27846
27846
  }
27847
27847
  }
27848
27848
 
@@ -28060,13 +28060,14 @@ class DatabaseSyscalls {
28060
28060
  if (!latest) {
28061
28061
  throw new Error(`Document with id ${id} not found.`);
28062
28062
  }
28063
+ const canonicalDocId = latest.value.id;
28063
28064
  const timestamp = this.docStore.allocateTimestamp();
28064
- const entry = { ts: timestamp, id: docId, value: null, prev_ts: latest.ts };
28065
+ const entry = { ts: timestamp, id: canonicalDocId, value: null, prev_ts: latest.ts };
28065
28066
  const indexes = await this.schemaService.getAllIndexesForTable(bareTableName);
28066
- const indexUpdates = generateIndexUpdates(fullTableName, docId, null, latest.value.value, indexes);
28067
+ const indexUpdates = generateIndexUpdates(fullTableName, canonicalDocId, null, latest.value.value, indexes);
28067
28068
  const indexEntries = new Set(indexUpdates.map((update) => ({ ts: timestamp, update })));
28068
28069
  await this.docStore.applyWrites([entry], indexEntries, "Error");
28069
- this.context.recordLocalWrite(id, fullTableName, null, docId);
28070
+ this.context.recordLocalWrite(id, fullTableName, null, canonicalDocId);
28070
28071
  return {};
28071
28072
  }
28072
28073
  async handleShallowMerge(args) {
@@ -28092,6 +28093,7 @@ class DatabaseSyscalls {
28092
28093
  if (!latest) {
28093
28094
  throw new Error(`Document with id ${id} not found.`);
28094
28095
  }
28096
+ const canonicalDocId = latest.value.id;
28095
28097
  const existingValue = latest.value.value;
28096
28098
  const newValue = { ...existingValue };
28097
28099
  if (typeof value === "object" && value !== null && "$undefined" in value) {
@@ -28118,14 +28120,14 @@ class DatabaseSyscalls {
28118
28120
  }
28119
28121
  }
28120
28122
  await this.schemaService.validate(bareTableName, newValue);
28121
- const resolvedDocument = { id: docId, value: newValue };
28123
+ const resolvedDocument = { id: canonicalDocId, value: newValue };
28122
28124
  const timestamp = this.docStore.allocateTimestamp();
28123
- const entry = { ts: timestamp, id: docId, value: resolvedDocument, prev_ts: latest.ts };
28125
+ const entry = { ts: timestamp, id: canonicalDocId, value: resolvedDocument, prev_ts: latest.ts };
28124
28126
  const indexes = await this.schemaService.getAllIndexesForTable(bareTableName);
28125
- const indexUpdates = generateIndexUpdates(fullTableName, docId, resolvedDocument.value, existingValue, indexes);
28127
+ const indexUpdates = generateIndexUpdates(fullTableName, canonicalDocId, resolvedDocument.value, existingValue, indexes);
28126
28128
  const indexEntries = new Set(indexUpdates.map((update) => ({ ts: timestamp, update })));
28127
28129
  await this.docStore.applyWrites([entry], indexEntries, "Error");
28128
- this.context.recordLocalWrite(id, fullTableName, resolvedDocument.value, docId);
28130
+ this.context.recordLocalWrite(id, fullTableName, resolvedDocument.value, canonicalDocId);
28129
28131
  return {};
28130
28132
  }
28131
28133
  async handleReplace(args) {
@@ -28147,17 +28149,18 @@ class DatabaseSyscalls {
28147
28149
  if (!latest) {
28148
28150
  throw new Error(`Document with id ${id} not found.`);
28149
28151
  }
28152
+ const canonicalDocId = latest.value.id;
28150
28153
  const { _id, _creationTime } = latest.value.value;
28151
28154
  const newValue = { ...replaceValue, _id, _creationTime };
28152
28155
  await this.schemaService.validate(bareTableName, newValue);
28153
- const resolvedDocument = { id: docId, value: newValue };
28156
+ const resolvedDocument = { id: canonicalDocId, value: newValue };
28154
28157
  const timestamp = this.docStore.allocateTimestamp();
28155
- const entry = { ts: timestamp, id: docId, value: resolvedDocument, prev_ts: latest.ts };
28158
+ const entry = { ts: timestamp, id: canonicalDocId, value: resolvedDocument, prev_ts: latest.ts };
28156
28159
  const indexes = await this.schemaService.getAllIndexesForTable(bareTableName);
28157
- const indexUpdates = generateIndexUpdates(fullTableName, docId, resolvedDocument.value, latest.value.value, indexes);
28160
+ const indexUpdates = generateIndexUpdates(fullTableName, canonicalDocId, resolvedDocument.value, latest.value.value, indexes);
28158
28161
  const indexEntries = new Set(indexUpdates.map((update) => ({ ts: timestamp, update })));
28159
28162
  await this.docStore.applyWrites([entry], indexEntries, "Error");
28160
- this.context.recordLocalWrite(id, fullTableName, newValue, docId);
28163
+ this.context.recordLocalWrite(id, fullTableName, newValue, canonicalDocId);
28161
28164
  return {};
28162
28165
  }
28163
28166
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@concavejs/docstore-cf-hyperdrive",
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"