@concavejs/docstore-cf-do 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.
- package/dist/index.js +24 -21
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4708,6 +4708,7 @@ class AccessLog {
|
|
|
4708
4708
|
return this.ranges.getRanges().map(serializeKeyRange);
|
|
4709
4709
|
}
|
|
4710
4710
|
}
|
|
4711
|
+
|
|
4711
4712
|
// ../core/dist/tables/memory-table-registry.js
|
|
4712
4713
|
init_interface();
|
|
4713
4714
|
|
|
@@ -4840,7 +4841,6 @@ class KernelContext {
|
|
|
4840
4841
|
}
|
|
4841
4842
|
recordTableRead(tableName) {
|
|
4842
4843
|
if (this.mutationTransaction) {
|
|
4843
|
-
this.mutationTransaction.recordTableScan(stringToHex(tableName), []);
|
|
4844
4844
|
return;
|
|
4845
4845
|
}
|
|
4846
4846
|
this.readLog.addTableScan(tableName);
|
|
@@ -4853,8 +4853,6 @@ class KernelContext {
|
|
|
4853
4853
|
}
|
|
4854
4854
|
recordIndexRange(tableName, indexDescriptor, startKey, endKey) {
|
|
4855
4855
|
if (this.mutationTransaction) {
|
|
4856
|
-
const indexId = indexKeyspaceId(tableName, indexDescriptor);
|
|
4857
|
-
this.mutationTransaction.recordIndexRangeScan(indexId, startKey, endKey, []);
|
|
4858
4856
|
return;
|
|
4859
4857
|
}
|
|
4860
4858
|
this.readLog.addIndexRange(tableName, indexDescriptor, startKey, endKey);
|
|
@@ -5013,11 +5011,12 @@ class BlobStoreGateway {
|
|
|
5013
5011
|
if (!latest || latest.ts > this.context.snapshotTimestamp) {
|
|
5014
5012
|
return;
|
|
5015
5013
|
}
|
|
5016
|
-
|
|
5014
|
+
const canonicalDocId = latest.value.id;
|
|
5015
|
+
await storage2.delete(canonicalDocId.internalId);
|
|
5017
5016
|
const timestamp2 = this.docStore.allocateTimestamp();
|
|
5018
|
-
const entry = { ts: timestamp2, id:
|
|
5017
|
+
const entry = { ts: timestamp2, id: canonicalDocId, value: null, prev_ts: latest.ts };
|
|
5019
5018
|
await this.docStore.applyWrites([entry], new Set, "Error");
|
|
5020
|
-
this.context.recordLocalWrite(storageId, "_storage", null,
|
|
5019
|
+
this.context.recordLocalWrite(storageId, "_storage", null, canonicalDocId);
|
|
5021
5020
|
}
|
|
5022
5021
|
requireStorage() {
|
|
5023
5022
|
if (!this.storage) {
|
|
@@ -5224,16 +5223,17 @@ class SchedulerGateway {
|
|
|
5224
5223
|
if (!latest) {
|
|
5225
5224
|
throw new Error(`Scheduled job with id ${id} not found.`);
|
|
5226
5225
|
}
|
|
5226
|
+
const canonicalDocId = latest.value.id;
|
|
5227
5227
|
const newValue = {
|
|
5228
5228
|
...latest.value.value,
|
|
5229
5229
|
state: state ?? { kind: "canceled" }
|
|
5230
5230
|
};
|
|
5231
|
-
const resolvedDocument = { id:
|
|
5231
|
+
const resolvedDocument = { id: canonicalDocId, value: newValue };
|
|
5232
5232
|
const timestamp2 = this.docStore.allocateTimestamp();
|
|
5233
|
-
const entry = { ts: timestamp2, id:
|
|
5233
|
+
const entry = { ts: timestamp2, id: canonicalDocId, value: resolvedDocument, prev_ts: latest.ts };
|
|
5234
5234
|
await this.docStore.applyWrites([entry], new Set, "Error");
|
|
5235
|
-
const tableName = await resolveTableName(
|
|
5236
|
-
this.context.recordLocalWrite(id, tableName, resolvedDocument.value,
|
|
5235
|
+
const tableName = await resolveTableName(canonicalDocId, this.context.tableRegistry);
|
|
5236
|
+
this.context.recordLocalWrite(id, tableName, resolvedDocument.value, canonicalDocId);
|
|
5237
5237
|
}
|
|
5238
5238
|
}
|
|
5239
5239
|
|
|
@@ -5451,13 +5451,14 @@ class DatabaseSyscalls {
|
|
|
5451
5451
|
if (!latest) {
|
|
5452
5452
|
throw new Error(`Document with id ${id} not found.`);
|
|
5453
5453
|
}
|
|
5454
|
+
const canonicalDocId = latest.value.id;
|
|
5454
5455
|
const timestamp2 = this.docStore.allocateTimestamp();
|
|
5455
|
-
const entry = { ts: timestamp2, id:
|
|
5456
|
+
const entry = { ts: timestamp2, id: canonicalDocId, value: null, prev_ts: latest.ts };
|
|
5456
5457
|
const indexes = await this.schemaService.getAllIndexesForTable(bareTableName);
|
|
5457
|
-
const indexUpdates = generateIndexUpdates(fullTableName,
|
|
5458
|
+
const indexUpdates = generateIndexUpdates(fullTableName, canonicalDocId, null, latest.value.value, indexes);
|
|
5458
5459
|
const indexEntries = new Set(indexUpdates.map((update) => ({ ts: timestamp2, update })));
|
|
5459
5460
|
await this.docStore.applyWrites([entry], indexEntries, "Error");
|
|
5460
|
-
this.context.recordLocalWrite(id, fullTableName, null,
|
|
5461
|
+
this.context.recordLocalWrite(id, fullTableName, null, canonicalDocId);
|
|
5461
5462
|
return {};
|
|
5462
5463
|
}
|
|
5463
5464
|
async handleShallowMerge(args) {
|
|
@@ -5483,6 +5484,7 @@ class DatabaseSyscalls {
|
|
|
5483
5484
|
if (!latest) {
|
|
5484
5485
|
throw new Error(`Document with id ${id} not found.`);
|
|
5485
5486
|
}
|
|
5487
|
+
const canonicalDocId = latest.value.id;
|
|
5486
5488
|
const existingValue = latest.value.value;
|
|
5487
5489
|
const newValue = { ...existingValue };
|
|
5488
5490
|
if (typeof value === "object" && value !== null && "$undefined" in value) {
|
|
@@ -5509,14 +5511,14 @@ class DatabaseSyscalls {
|
|
|
5509
5511
|
}
|
|
5510
5512
|
}
|
|
5511
5513
|
await this.schemaService.validate(bareTableName, newValue);
|
|
5512
|
-
const resolvedDocument = { id:
|
|
5514
|
+
const resolvedDocument = { id: canonicalDocId, value: newValue };
|
|
5513
5515
|
const timestamp2 = this.docStore.allocateTimestamp();
|
|
5514
|
-
const entry = { ts: timestamp2, id:
|
|
5516
|
+
const entry = { ts: timestamp2, id: canonicalDocId, value: resolvedDocument, prev_ts: latest.ts };
|
|
5515
5517
|
const indexes = await this.schemaService.getAllIndexesForTable(bareTableName);
|
|
5516
|
-
const indexUpdates = generateIndexUpdates(fullTableName,
|
|
5518
|
+
const indexUpdates = generateIndexUpdates(fullTableName, canonicalDocId, resolvedDocument.value, existingValue, indexes);
|
|
5517
5519
|
const indexEntries = new Set(indexUpdates.map((update) => ({ ts: timestamp2, update })));
|
|
5518
5520
|
await this.docStore.applyWrites([entry], indexEntries, "Error");
|
|
5519
|
-
this.context.recordLocalWrite(id, fullTableName, resolvedDocument.value,
|
|
5521
|
+
this.context.recordLocalWrite(id, fullTableName, resolvedDocument.value, canonicalDocId);
|
|
5520
5522
|
return {};
|
|
5521
5523
|
}
|
|
5522
5524
|
async handleReplace(args) {
|
|
@@ -5538,17 +5540,18 @@ class DatabaseSyscalls {
|
|
|
5538
5540
|
if (!latest) {
|
|
5539
5541
|
throw new Error(`Document with id ${id} not found.`);
|
|
5540
5542
|
}
|
|
5543
|
+
const canonicalDocId = latest.value.id;
|
|
5541
5544
|
const { _id, _creationTime } = latest.value.value;
|
|
5542
5545
|
const newValue = { ...replaceValue, _id, _creationTime };
|
|
5543
5546
|
await this.schemaService.validate(bareTableName, newValue);
|
|
5544
|
-
const resolvedDocument = { id:
|
|
5547
|
+
const resolvedDocument = { id: canonicalDocId, value: newValue };
|
|
5545
5548
|
const timestamp2 = this.docStore.allocateTimestamp();
|
|
5546
|
-
const entry = { ts: timestamp2, id:
|
|
5549
|
+
const entry = { ts: timestamp2, id: canonicalDocId, value: resolvedDocument, prev_ts: latest.ts };
|
|
5547
5550
|
const indexes = await this.schemaService.getAllIndexesForTable(bareTableName);
|
|
5548
|
-
const indexUpdates = generateIndexUpdates(fullTableName,
|
|
5551
|
+
const indexUpdates = generateIndexUpdates(fullTableName, canonicalDocId, resolvedDocument.value, latest.value.value, indexes);
|
|
5549
5552
|
const indexEntries = new Set(indexUpdates.map((update) => ({ ts: timestamp2, update })));
|
|
5550
5553
|
await this.docStore.applyWrites([entry], indexEntries, "Error");
|
|
5551
|
-
this.context.recordLocalWrite(id, fullTableName, newValue,
|
|
5554
|
+
this.context.recordLocalWrite(id, fullTableName, newValue, canonicalDocId);
|
|
5552
5555
|
return {};
|
|
5553
5556
|
}
|
|
5554
5557
|
}
|