@concavejs/docstore-cf-d1 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
|
@@ -4679,6 +4679,7 @@ class AccessLog {
|
|
|
4679
4679
|
return this.ranges.getRanges().map(serializeKeyRange);
|
|
4680
4680
|
}
|
|
4681
4681
|
}
|
|
4682
|
+
|
|
4682
4683
|
// ../core/dist/tables/memory-table-registry.js
|
|
4683
4684
|
init_interface();
|
|
4684
4685
|
|
|
@@ -4811,7 +4812,6 @@ class KernelContext {
|
|
|
4811
4812
|
}
|
|
4812
4813
|
recordTableRead(tableName) {
|
|
4813
4814
|
if (this.mutationTransaction) {
|
|
4814
|
-
this.mutationTransaction.recordTableScan(stringToHex(tableName), []);
|
|
4815
4815
|
return;
|
|
4816
4816
|
}
|
|
4817
4817
|
this.readLog.addTableScan(tableName);
|
|
@@ -4824,8 +4824,6 @@ class KernelContext {
|
|
|
4824
4824
|
}
|
|
4825
4825
|
recordIndexRange(tableName, indexDescriptor, startKey, endKey) {
|
|
4826
4826
|
if (this.mutationTransaction) {
|
|
4827
|
-
const indexId = indexKeyspaceId(tableName, indexDescriptor);
|
|
4828
|
-
this.mutationTransaction.recordIndexRangeScan(indexId, startKey, endKey, []);
|
|
4829
4827
|
return;
|
|
4830
4828
|
}
|
|
4831
4829
|
this.readLog.addIndexRange(tableName, indexDescriptor, startKey, endKey);
|
|
@@ -4984,11 +4982,12 @@ class BlobStoreGateway {
|
|
|
4984
4982
|
if (!latest || latest.ts > this.context.snapshotTimestamp) {
|
|
4985
4983
|
return;
|
|
4986
4984
|
}
|
|
4987
|
-
|
|
4985
|
+
const canonicalDocId = latest.value.id;
|
|
4986
|
+
await storage2.delete(canonicalDocId.internalId);
|
|
4988
4987
|
const timestamp2 = this.docStore.allocateTimestamp();
|
|
4989
|
-
const entry = { ts: timestamp2, id:
|
|
4988
|
+
const entry = { ts: timestamp2, id: canonicalDocId, value: null, prev_ts: latest.ts };
|
|
4990
4989
|
await this.docStore.applyWrites([entry], new Set, "Error");
|
|
4991
|
-
this.context.recordLocalWrite(storageId, "_storage", null,
|
|
4990
|
+
this.context.recordLocalWrite(storageId, "_storage", null, canonicalDocId);
|
|
4992
4991
|
}
|
|
4993
4992
|
requireStorage() {
|
|
4994
4993
|
if (!this.storage) {
|
|
@@ -5195,16 +5194,17 @@ class SchedulerGateway {
|
|
|
5195
5194
|
if (!latest) {
|
|
5196
5195
|
throw new Error(`Scheduled job with id ${id} not found.`);
|
|
5197
5196
|
}
|
|
5197
|
+
const canonicalDocId = latest.value.id;
|
|
5198
5198
|
const newValue = {
|
|
5199
5199
|
...latest.value.value,
|
|
5200
5200
|
state: state ?? { kind: "canceled" }
|
|
5201
5201
|
};
|
|
5202
|
-
const resolvedDocument = { id:
|
|
5202
|
+
const resolvedDocument = { id: canonicalDocId, value: newValue };
|
|
5203
5203
|
const timestamp2 = this.docStore.allocateTimestamp();
|
|
5204
|
-
const entry = { ts: timestamp2, id:
|
|
5204
|
+
const entry = { ts: timestamp2, id: canonicalDocId, value: resolvedDocument, prev_ts: latest.ts };
|
|
5205
5205
|
await this.docStore.applyWrites([entry], new Set, "Error");
|
|
5206
|
-
const tableName = await resolveTableName(
|
|
5207
|
-
this.context.recordLocalWrite(id, tableName, resolvedDocument.value,
|
|
5206
|
+
const tableName = await resolveTableName(canonicalDocId, this.context.tableRegistry);
|
|
5207
|
+
this.context.recordLocalWrite(id, tableName, resolvedDocument.value, canonicalDocId);
|
|
5208
5208
|
}
|
|
5209
5209
|
}
|
|
5210
5210
|
|
|
@@ -5422,13 +5422,14 @@ class DatabaseSyscalls {
|
|
|
5422
5422
|
if (!latest) {
|
|
5423
5423
|
throw new Error(`Document with id ${id} not found.`);
|
|
5424
5424
|
}
|
|
5425
|
+
const canonicalDocId = latest.value.id;
|
|
5425
5426
|
const timestamp2 = this.docStore.allocateTimestamp();
|
|
5426
|
-
const entry = { ts: timestamp2, id:
|
|
5427
|
+
const entry = { ts: timestamp2, id: canonicalDocId, value: null, prev_ts: latest.ts };
|
|
5427
5428
|
const indexes = await this.schemaService.getAllIndexesForTable(bareTableName);
|
|
5428
|
-
const indexUpdates = generateIndexUpdates(fullTableName,
|
|
5429
|
+
const indexUpdates = generateIndexUpdates(fullTableName, canonicalDocId, null, latest.value.value, indexes);
|
|
5429
5430
|
const indexEntries = new Set(indexUpdates.map((update) => ({ ts: timestamp2, update })));
|
|
5430
5431
|
await this.docStore.applyWrites([entry], indexEntries, "Error");
|
|
5431
|
-
this.context.recordLocalWrite(id, fullTableName, null,
|
|
5432
|
+
this.context.recordLocalWrite(id, fullTableName, null, canonicalDocId);
|
|
5432
5433
|
return {};
|
|
5433
5434
|
}
|
|
5434
5435
|
async handleShallowMerge(args) {
|
|
@@ -5454,6 +5455,7 @@ class DatabaseSyscalls {
|
|
|
5454
5455
|
if (!latest) {
|
|
5455
5456
|
throw new Error(`Document with id ${id} not found.`);
|
|
5456
5457
|
}
|
|
5458
|
+
const canonicalDocId = latest.value.id;
|
|
5457
5459
|
const existingValue = latest.value.value;
|
|
5458
5460
|
const newValue = { ...existingValue };
|
|
5459
5461
|
if (typeof value === "object" && value !== null && "$undefined" in value) {
|
|
@@ -5480,14 +5482,14 @@ class DatabaseSyscalls {
|
|
|
5480
5482
|
}
|
|
5481
5483
|
}
|
|
5482
5484
|
await this.schemaService.validate(bareTableName, newValue);
|
|
5483
|
-
const resolvedDocument = { id:
|
|
5485
|
+
const resolvedDocument = { id: canonicalDocId, value: newValue };
|
|
5484
5486
|
const timestamp2 = this.docStore.allocateTimestamp();
|
|
5485
|
-
const entry = { ts: timestamp2, id:
|
|
5487
|
+
const entry = { ts: timestamp2, id: canonicalDocId, value: resolvedDocument, prev_ts: latest.ts };
|
|
5486
5488
|
const indexes = await this.schemaService.getAllIndexesForTable(bareTableName);
|
|
5487
|
-
const indexUpdates = generateIndexUpdates(fullTableName,
|
|
5489
|
+
const indexUpdates = generateIndexUpdates(fullTableName, canonicalDocId, resolvedDocument.value, existingValue, indexes);
|
|
5488
5490
|
const indexEntries = new Set(indexUpdates.map((update) => ({ ts: timestamp2, update })));
|
|
5489
5491
|
await this.docStore.applyWrites([entry], indexEntries, "Error");
|
|
5490
|
-
this.context.recordLocalWrite(id, fullTableName, resolvedDocument.value,
|
|
5492
|
+
this.context.recordLocalWrite(id, fullTableName, resolvedDocument.value, canonicalDocId);
|
|
5491
5493
|
return {};
|
|
5492
5494
|
}
|
|
5493
5495
|
async handleReplace(args) {
|
|
@@ -5509,17 +5511,18 @@ class DatabaseSyscalls {
|
|
|
5509
5511
|
if (!latest) {
|
|
5510
5512
|
throw new Error(`Document with id ${id} not found.`);
|
|
5511
5513
|
}
|
|
5514
|
+
const canonicalDocId = latest.value.id;
|
|
5512
5515
|
const { _id, _creationTime } = latest.value.value;
|
|
5513
5516
|
const newValue = { ...replaceValue, _id, _creationTime };
|
|
5514
5517
|
await this.schemaService.validate(bareTableName, newValue);
|
|
5515
|
-
const resolvedDocument = { id:
|
|
5518
|
+
const resolvedDocument = { id: canonicalDocId, value: newValue };
|
|
5516
5519
|
const timestamp2 = this.docStore.allocateTimestamp();
|
|
5517
|
-
const entry = { ts: timestamp2, id:
|
|
5520
|
+
const entry = { ts: timestamp2, id: canonicalDocId, value: resolvedDocument, prev_ts: latest.ts };
|
|
5518
5521
|
const indexes = await this.schemaService.getAllIndexesForTable(bareTableName);
|
|
5519
|
-
const indexUpdates = generateIndexUpdates(fullTableName,
|
|
5522
|
+
const indexUpdates = generateIndexUpdates(fullTableName, canonicalDocId, resolvedDocument.value, latest.value.value, indexes);
|
|
5520
5523
|
const indexEntries = new Set(indexUpdates.map((update) => ({ ts: timestamp2, update })));
|
|
5521
5524
|
await this.docStore.applyWrites([entry], indexEntries, "Error");
|
|
5522
|
-
this.context.recordLocalWrite(id, fullTableName, newValue,
|
|
5525
|
+
this.context.recordLocalWrite(id, fullTableName, newValue, canonicalDocId);
|
|
5523
5526
|
return {};
|
|
5524
5527
|
}
|
|
5525
5528
|
}
|