@powersync/service-core 0.13.0 → 0.15.0
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/CHANGELOG.md +31 -0
- package/dist/entry/commands/compact-action.js +14 -14
- package/dist/entry/commands/compact-action.js.map +1 -1
- package/dist/entry/commands/migrate-action.js +15 -4
- package/dist/entry/commands/migrate-action.js.map +1 -1
- package/dist/index.d.ts +1 -3
- package/dist/index.js +1 -3
- package/dist/index.js.map +1 -1
- package/dist/migrations/PowerSyncMigrationManager.d.ts +17 -0
- package/dist/migrations/PowerSyncMigrationManager.js +21 -0
- package/dist/migrations/PowerSyncMigrationManager.js.map +1 -0
- package/dist/migrations/ensure-automatic-migrations.d.ts +4 -0
- package/dist/migrations/ensure-automatic-migrations.js +14 -0
- package/dist/migrations/ensure-automatic-migrations.js.map +1 -0
- package/dist/migrations/migrations-index.d.ts +2 -3
- package/dist/migrations/migrations-index.js +2 -3
- package/dist/migrations/migrations-index.js.map +1 -1
- package/dist/routes/configure-fastify.d.ts +12 -12
- package/dist/routes/endpoints/admin.d.ts +24 -24
- package/dist/storage/BucketStorage.d.ts +51 -3
- package/dist/storage/BucketStorage.js +26 -0
- package/dist/storage/BucketStorage.js.map +1 -1
- package/dist/storage/bson.d.ts +24 -0
- package/dist/storage/bson.js +73 -0
- package/dist/storage/bson.js.map +1 -0
- package/dist/storage/storage-index.d.ts +3 -14
- package/dist/storage/storage-index.js +3 -14
- package/dist/storage/storage-index.js.map +1 -1
- package/dist/sync/sync.js +3 -1
- package/dist/sync/sync.js.map +1 -1
- package/dist/system/ServiceContext.d.ts +3 -0
- package/dist/system/ServiceContext.js +11 -3
- package/dist/system/ServiceContext.js.map +1 -1
- package/dist/util/config/types.d.ts +2 -2
- package/dist/util/utils.d.ts +17 -1
- package/dist/util/utils.js +49 -1
- package/dist/util/utils.js.map +1 -1
- package/package.json +7 -8
- package/src/entry/commands/compact-action.ts +19 -14
- package/src/entry/commands/migrate-action.ts +17 -4
- package/src/index.ts +1 -4
- package/src/migrations/PowerSyncMigrationManager.ts +42 -0
- package/src/migrations/ensure-automatic-migrations.ts +15 -0
- package/src/migrations/migrations-index.ts +2 -3
- package/src/storage/BucketStorage.ts +59 -3
- package/src/storage/bson.ts +78 -0
- package/src/storage/storage-index.ts +3 -15
- package/src/sync/sync.ts +3 -1
- package/src/system/ServiceContext.ts +17 -4
- package/src/util/config/types.ts +2 -2
- package/src/util/utils.ts +47 -1
- package/test/src/env.ts +0 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/db/db-index.d.ts +0 -1
- package/dist/db/db-index.js +0 -2
- package/dist/db/db-index.js.map +0 -1
- package/dist/db/mongo.d.ts +0 -35
- package/dist/db/mongo.js +0 -73
- package/dist/db/mongo.js.map +0 -1
- package/dist/locks/LockManager.d.ts +0 -10
- package/dist/locks/LockManager.js +0 -7
- package/dist/locks/LockManager.js.map +0 -1
- package/dist/locks/MongoLocks.d.ts +0 -36
- package/dist/locks/MongoLocks.js +0 -81
- package/dist/locks/MongoLocks.js.map +0 -1
- package/dist/locks/locks-index.d.ts +0 -2
- package/dist/locks/locks-index.js +0 -3
- package/dist/locks/locks-index.js.map +0 -1
- package/dist/migrations/db/migrations/1684951997326-init.d.ts +0 -3
- package/dist/migrations/db/migrations/1684951997326-init.js +0 -33
- package/dist/migrations/db/migrations/1684951997326-init.js.map +0 -1
- package/dist/migrations/db/migrations/1688556755264-initial-sync-rules.d.ts +0 -2
- package/dist/migrations/db/migrations/1688556755264-initial-sync-rules.js +0 -5
- package/dist/migrations/db/migrations/1688556755264-initial-sync-rules.js.map +0 -1
- package/dist/migrations/db/migrations/1702295701188-sync-rule-state.d.ts +0 -3
- package/dist/migrations/db/migrations/1702295701188-sync-rule-state.js +0 -56
- package/dist/migrations/db/migrations/1702295701188-sync-rule-state.js.map +0 -1
- package/dist/migrations/db/migrations/1711543888062-write-checkpoint-index.d.ts +0 -3
- package/dist/migrations/db/migrations/1711543888062-write-checkpoint-index.js +0 -29
- package/dist/migrations/db/migrations/1711543888062-write-checkpoint-index.js.map +0 -1
- package/dist/migrations/db/migrations/1727099539247-custom-write-checkpoint-index.d.ts +0 -3
- package/dist/migrations/db/migrations/1727099539247-custom-write-checkpoint-index.js +0 -31
- package/dist/migrations/db/migrations/1727099539247-custom-write-checkpoint-index.js.map +0 -1
- package/dist/migrations/definitions.d.ts +0 -18
- package/dist/migrations/definitions.js +0 -6
- package/dist/migrations/definitions.js.map +0 -1
- package/dist/migrations/executor.d.ts +0 -16
- package/dist/migrations/executor.js +0 -64
- package/dist/migrations/executor.js.map +0 -1
- package/dist/migrations/migrations.d.ts +0 -18
- package/dist/migrations/migrations.js +0 -110
- package/dist/migrations/migrations.js.map +0 -1
- package/dist/migrations/store/migration-store.d.ts +0 -11
- package/dist/migrations/store/migration-store.js +0 -46
- package/dist/migrations/store/migration-store.js.map +0 -1
- package/dist/storage/MongoBucketStorage.d.ts +0 -48
- package/dist/storage/MongoBucketStorage.js +0 -427
- package/dist/storage/MongoBucketStorage.js.map +0 -1
- package/dist/storage/mongo/MongoBucketBatch.d.ts +0 -74
- package/dist/storage/mongo/MongoBucketBatch.js +0 -683
- package/dist/storage/mongo/MongoBucketBatch.js.map +0 -1
- package/dist/storage/mongo/MongoCompactor.d.ts +0 -40
- package/dist/storage/mongo/MongoCompactor.js +0 -310
- package/dist/storage/mongo/MongoCompactor.js.map +0 -1
- package/dist/storage/mongo/MongoIdSequence.d.ts +0 -12
- package/dist/storage/mongo/MongoIdSequence.js +0 -21
- package/dist/storage/mongo/MongoIdSequence.js.map +0 -1
- package/dist/storage/mongo/MongoPersistedSyncRules.d.ts +0 -9
- package/dist/storage/mongo/MongoPersistedSyncRules.js +0 -9
- package/dist/storage/mongo/MongoPersistedSyncRules.js.map +0 -1
- package/dist/storage/mongo/MongoPersistedSyncRulesContent.d.ts +0 -20
- package/dist/storage/mongo/MongoPersistedSyncRulesContent.js +0 -26
- package/dist/storage/mongo/MongoPersistedSyncRulesContent.js.map +0 -1
- package/dist/storage/mongo/MongoStorageProvider.d.ts +0 -5
- package/dist/storage/mongo/MongoStorageProvider.js +0 -26
- package/dist/storage/mongo/MongoStorageProvider.js.map +0 -1
- package/dist/storage/mongo/MongoSyncBucketStorage.d.ts +0 -38
- package/dist/storage/mongo/MongoSyncBucketStorage.js +0 -534
- package/dist/storage/mongo/MongoSyncBucketStorage.js.map +0 -1
- package/dist/storage/mongo/MongoSyncRulesLock.d.ts +0 -16
- package/dist/storage/mongo/MongoSyncRulesLock.js +0 -65
- package/dist/storage/mongo/MongoSyncRulesLock.js.map +0 -1
- package/dist/storage/mongo/MongoWriteCheckpointAPI.d.ts +0 -20
- package/dist/storage/mongo/MongoWriteCheckpointAPI.js +0 -104
- package/dist/storage/mongo/MongoWriteCheckpointAPI.js.map +0 -1
- package/dist/storage/mongo/OperationBatch.d.ts +0 -35
- package/dist/storage/mongo/OperationBatch.js +0 -119
- package/dist/storage/mongo/OperationBatch.js.map +0 -1
- package/dist/storage/mongo/PersistedBatch.d.ts +0 -46
- package/dist/storage/mongo/PersistedBatch.js +0 -223
- package/dist/storage/mongo/PersistedBatch.js.map +0 -1
- package/dist/storage/mongo/config.d.ts +0 -19
- package/dist/storage/mongo/config.js +0 -26
- package/dist/storage/mongo/config.js.map +0 -1
- package/dist/storage/mongo/db.d.ts +0 -36
- package/dist/storage/mongo/db.js +0 -47
- package/dist/storage/mongo/db.js.map +0 -1
- package/dist/storage/mongo/models.d.ts +0 -163
- package/dist/storage/mongo/models.js +0 -27
- package/dist/storage/mongo/models.js.map +0 -1
- package/dist/storage/mongo/util.d.ts +0 -54
- package/dist/storage/mongo/util.js +0 -190
- package/dist/storage/mongo/util.js.map +0 -1
- package/src/db/db-index.ts +0 -1
- package/src/db/mongo.ts +0 -81
- package/src/locks/LockManager.ts +0 -16
- package/src/locks/MongoLocks.ts +0 -142
- package/src/locks/locks-index.ts +0 -2
- package/src/migrations/db/migrations/1684951997326-init.ts +0 -38
- package/src/migrations/db/migrations/1688556755264-initial-sync-rules.ts +0 -5
- package/src/migrations/db/migrations/1702295701188-sync-rule-state.ts +0 -102
- package/src/migrations/db/migrations/1711543888062-write-checkpoint-index.ts +0 -34
- package/src/migrations/db/migrations/1727099539247-custom-write-checkpoint-index.ts +0 -37
- package/src/migrations/definitions.ts +0 -21
- package/src/migrations/executor.ts +0 -87
- package/src/migrations/migrations.ts +0 -142
- package/src/migrations/store/migration-store.ts +0 -63
- package/src/storage/MongoBucketStorage.ts +0 -541
- package/src/storage/mongo/MongoBucketBatch.ts +0 -900
- package/src/storage/mongo/MongoCompactor.ts +0 -393
- package/src/storage/mongo/MongoIdSequence.ts +0 -24
- package/src/storage/mongo/MongoPersistedSyncRules.ts +0 -16
- package/src/storage/mongo/MongoPersistedSyncRulesContent.ts +0 -50
- package/src/storage/mongo/MongoStorageProvider.ts +0 -31
- package/src/storage/mongo/MongoSyncBucketStorage.ts +0 -640
- package/src/storage/mongo/MongoSyncRulesLock.ts +0 -85
- package/src/storage/mongo/MongoWriteCheckpointAPI.ts +0 -154
- package/src/storage/mongo/OperationBatch.ts +0 -131
- package/src/storage/mongo/PersistedBatch.ts +0 -285
- package/src/storage/mongo/config.ts +0 -40
- package/src/storage/mongo/db.ts +0 -88
- package/src/storage/mongo/models.ts +0 -187
- package/src/storage/mongo/util.ts +0 -203
- package/test/src/__snapshots__/sync.test.ts.snap +0 -332
- package/test/src/bucket_validation.test.ts +0 -143
- package/test/src/bucket_validation.ts +0 -60
- package/test/src/compacting.test.ts +0 -295
- package/test/src/data_storage.test.ts +0 -1569
- package/test/src/stream_utils.ts +0 -42
- package/test/src/sync.test.ts +0 -511
- package/test/src/util.ts +0 -150
|
@@ -1,295 +0,0 @@
|
|
|
1
|
-
import { SaveOperationTag } from '@/storage/BucketStorage.js';
|
|
2
|
-
import { MongoCompactOptions } from '@/storage/mongo/MongoCompactor.js';
|
|
3
|
-
import { describe, expect, test } from 'vitest';
|
|
4
|
-
import { validateCompactedBucket } from './bucket_validation.js';
|
|
5
|
-
import { oneFromAsync } from './stream_utils.js';
|
|
6
|
-
import { BATCH_OPTIONS, makeTestTable, MONGO_STORAGE_FACTORY, rid, testRules } from './util.js';
|
|
7
|
-
|
|
8
|
-
const TEST_TABLE = makeTestTable('test', ['id']);
|
|
9
|
-
|
|
10
|
-
// Test with the default options - large batch sizes
|
|
11
|
-
describe('compacting buckets - default options', () => compactTests({}));
|
|
12
|
-
|
|
13
|
-
// Also test with the miniumum batch sizes, forcing usage of multiple batches internally
|
|
14
|
-
describe('compacting buckets - batched', () =>
|
|
15
|
-
compactTests({ clearBatchLimit: 2, moveBatchLimit: 1, moveBatchQueryLimit: 1 }));
|
|
16
|
-
|
|
17
|
-
function compactTests(compactOptions: MongoCompactOptions) {
|
|
18
|
-
const factory = MONGO_STORAGE_FACTORY;
|
|
19
|
-
|
|
20
|
-
test('compacting (1)', async () => {
|
|
21
|
-
const sync_rules = testRules(`
|
|
22
|
-
bucket_definitions:
|
|
23
|
-
global:
|
|
24
|
-
data: [select * from test]
|
|
25
|
-
`);
|
|
26
|
-
|
|
27
|
-
const storage = (await factory()).getInstance(sync_rules);
|
|
28
|
-
|
|
29
|
-
const result = await storage.startBatch(BATCH_OPTIONS, async (batch) => {
|
|
30
|
-
await batch.save({
|
|
31
|
-
sourceTable: TEST_TABLE,
|
|
32
|
-
tag: SaveOperationTag.INSERT,
|
|
33
|
-
after: {
|
|
34
|
-
id: 't1'
|
|
35
|
-
},
|
|
36
|
-
afterReplicaId: rid('t1')
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
await batch.save({
|
|
40
|
-
sourceTable: TEST_TABLE,
|
|
41
|
-
tag: SaveOperationTag.INSERT,
|
|
42
|
-
after: {
|
|
43
|
-
id: 't2'
|
|
44
|
-
},
|
|
45
|
-
afterReplicaId: rid('t2')
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
await batch.save({
|
|
49
|
-
sourceTable: TEST_TABLE,
|
|
50
|
-
tag: SaveOperationTag.UPDATE,
|
|
51
|
-
after: {
|
|
52
|
-
id: 't2'
|
|
53
|
-
},
|
|
54
|
-
afterReplicaId: rid('t2')
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
const checkpoint = result!.flushed_op;
|
|
59
|
-
|
|
60
|
-
const batchBefore = await oneFromAsync(storage.getBucketDataBatch(checkpoint, new Map([['global[]', '0']])));
|
|
61
|
-
const dataBefore = batchBefore.batch.data;
|
|
62
|
-
const checksumBefore = await storage.getChecksums(checkpoint, ['global[]']);
|
|
63
|
-
|
|
64
|
-
expect(dataBefore).toMatchObject([
|
|
65
|
-
{
|
|
66
|
-
checksum: 2634521662,
|
|
67
|
-
object_id: 't1',
|
|
68
|
-
op: 'PUT',
|
|
69
|
-
op_id: '1'
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
checksum: 4243212114,
|
|
73
|
-
object_id: 't2',
|
|
74
|
-
op: 'PUT',
|
|
75
|
-
op_id: '2'
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
checksum: 4243212114,
|
|
79
|
-
object_id: 't2',
|
|
80
|
-
op: 'PUT',
|
|
81
|
-
op_id: '3'
|
|
82
|
-
}
|
|
83
|
-
]);
|
|
84
|
-
|
|
85
|
-
await storage.compact(compactOptions);
|
|
86
|
-
|
|
87
|
-
const batchAfter = await oneFromAsync(storage.getBucketDataBatch(checkpoint, new Map([['global[]', '0']])));
|
|
88
|
-
const dataAfter = batchAfter.batch.data;
|
|
89
|
-
const checksumAfter = await storage.getChecksums(checkpoint, ['global[]']);
|
|
90
|
-
|
|
91
|
-
expect(batchAfter.targetOp).toEqual(3n);
|
|
92
|
-
expect(dataAfter).toMatchObject([
|
|
93
|
-
{
|
|
94
|
-
checksum: 2634521662,
|
|
95
|
-
object_id: 't1',
|
|
96
|
-
op: 'PUT',
|
|
97
|
-
op_id: '1'
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
checksum: 4243212114,
|
|
101
|
-
op: 'MOVE',
|
|
102
|
-
op_id: '2'
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
checksum: 4243212114,
|
|
106
|
-
object_id: 't2',
|
|
107
|
-
op: 'PUT',
|
|
108
|
-
op_id: '3'
|
|
109
|
-
}
|
|
110
|
-
]);
|
|
111
|
-
|
|
112
|
-
expect(checksumBefore.get('global[]')).toEqual(checksumAfter.get('global[]'));
|
|
113
|
-
|
|
114
|
-
validateCompactedBucket(dataBefore, dataAfter);
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
test('compacting (2)', async () => {
|
|
118
|
-
const sync_rules = testRules(`
|
|
119
|
-
bucket_definitions:
|
|
120
|
-
global:
|
|
121
|
-
data: [select * from test]
|
|
122
|
-
`);
|
|
123
|
-
|
|
124
|
-
const storage = (await factory()).getInstance(sync_rules);
|
|
125
|
-
|
|
126
|
-
const result = await storage.startBatch(BATCH_OPTIONS, async (batch) => {
|
|
127
|
-
await batch.save({
|
|
128
|
-
sourceTable: TEST_TABLE,
|
|
129
|
-
tag: SaveOperationTag.INSERT,
|
|
130
|
-
after: {
|
|
131
|
-
id: 't1'
|
|
132
|
-
},
|
|
133
|
-
afterReplicaId: rid('t1')
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
await batch.save({
|
|
137
|
-
sourceTable: TEST_TABLE,
|
|
138
|
-
tag: SaveOperationTag.INSERT,
|
|
139
|
-
after: {
|
|
140
|
-
id: 't2'
|
|
141
|
-
},
|
|
142
|
-
afterReplicaId: rid('t2')
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
await batch.save({
|
|
146
|
-
sourceTable: TEST_TABLE,
|
|
147
|
-
tag: SaveOperationTag.DELETE,
|
|
148
|
-
before: {
|
|
149
|
-
id: 't1'
|
|
150
|
-
},
|
|
151
|
-
beforeReplicaId: rid('t1')
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
await batch.save({
|
|
155
|
-
sourceTable: TEST_TABLE,
|
|
156
|
-
tag: SaveOperationTag.UPDATE,
|
|
157
|
-
after: {
|
|
158
|
-
id: 't2'
|
|
159
|
-
},
|
|
160
|
-
afterReplicaId: rid('t2')
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
const checkpoint = result!.flushed_op;
|
|
165
|
-
|
|
166
|
-
const batchBefore = await oneFromAsync(storage.getBucketDataBatch(checkpoint, new Map([['global[]', '0']])));
|
|
167
|
-
const dataBefore = batchBefore.batch.data;
|
|
168
|
-
const checksumBefore = await storage.getChecksums(checkpoint, ['global[]']);
|
|
169
|
-
|
|
170
|
-
expect(dataBefore).toMatchObject([
|
|
171
|
-
{
|
|
172
|
-
checksum: 2634521662,
|
|
173
|
-
object_id: 't1',
|
|
174
|
-
op: 'PUT',
|
|
175
|
-
op_id: '1'
|
|
176
|
-
},
|
|
177
|
-
{
|
|
178
|
-
checksum: 4243212114,
|
|
179
|
-
object_id: 't2',
|
|
180
|
-
op: 'PUT',
|
|
181
|
-
op_id: '2'
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
checksum: 4228978084,
|
|
185
|
-
object_id: 't1',
|
|
186
|
-
op: 'REMOVE',
|
|
187
|
-
op_id: '3'
|
|
188
|
-
},
|
|
189
|
-
{
|
|
190
|
-
checksum: 4243212114,
|
|
191
|
-
object_id: 't2',
|
|
192
|
-
op: 'PUT',
|
|
193
|
-
op_id: '4'
|
|
194
|
-
}
|
|
195
|
-
]);
|
|
196
|
-
|
|
197
|
-
await storage.compact(compactOptions);
|
|
198
|
-
|
|
199
|
-
const batchAfter = await oneFromAsync(storage.getBucketDataBatch(checkpoint, new Map([['global[]', '0']])));
|
|
200
|
-
const dataAfter = batchAfter.batch.data;
|
|
201
|
-
const checksumAfter = await storage.getChecksums(checkpoint, ['global[]']);
|
|
202
|
-
|
|
203
|
-
expect(batchAfter.targetOp).toEqual(4n);
|
|
204
|
-
expect(dataAfter).toMatchObject([
|
|
205
|
-
{
|
|
206
|
-
checksum: -1778190028,
|
|
207
|
-
op: 'CLEAR',
|
|
208
|
-
op_id: '3'
|
|
209
|
-
},
|
|
210
|
-
{
|
|
211
|
-
checksum: 4243212114,
|
|
212
|
-
object_id: 't2',
|
|
213
|
-
op: 'PUT',
|
|
214
|
-
op_id: '4'
|
|
215
|
-
}
|
|
216
|
-
]);
|
|
217
|
-
expect(checksumBefore.get('global[]')).toEqual(checksumAfter.get('global[]'));
|
|
218
|
-
|
|
219
|
-
validateCompactedBucket(dataBefore, dataAfter);
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
test('compacting (3)', async () => {
|
|
223
|
-
const sync_rules = testRules(`
|
|
224
|
-
bucket_definitions:
|
|
225
|
-
global:
|
|
226
|
-
data: [select * from test]
|
|
227
|
-
`);
|
|
228
|
-
|
|
229
|
-
const storage = (await factory()).getInstance(sync_rules);
|
|
230
|
-
|
|
231
|
-
const result = await storage.startBatch(BATCH_OPTIONS, async (batch) => {
|
|
232
|
-
await batch.save({
|
|
233
|
-
sourceTable: TEST_TABLE,
|
|
234
|
-
tag: SaveOperationTag.INSERT,
|
|
235
|
-
after: {
|
|
236
|
-
id: 't1'
|
|
237
|
-
},
|
|
238
|
-
afterReplicaId: 't1'
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
await batch.save({
|
|
242
|
-
sourceTable: TEST_TABLE,
|
|
243
|
-
tag: SaveOperationTag.INSERT,
|
|
244
|
-
after: {
|
|
245
|
-
id: 't2'
|
|
246
|
-
},
|
|
247
|
-
afterReplicaId: 't2'
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
await batch.save({
|
|
251
|
-
sourceTable: TEST_TABLE,
|
|
252
|
-
tag: SaveOperationTag.DELETE,
|
|
253
|
-
before: {
|
|
254
|
-
id: 't1'
|
|
255
|
-
},
|
|
256
|
-
beforeReplicaId: 't1'
|
|
257
|
-
});
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
const checkpoint1 = result!.flushed_op;
|
|
261
|
-
const checksumBefore = await storage.getChecksums(checkpoint1, ['global[]']);
|
|
262
|
-
|
|
263
|
-
const result2 = await storage.startBatch(BATCH_OPTIONS, async (batch) => {
|
|
264
|
-
await batch.save({
|
|
265
|
-
sourceTable: TEST_TABLE,
|
|
266
|
-
tag: SaveOperationTag.DELETE,
|
|
267
|
-
before: {
|
|
268
|
-
id: 't2'
|
|
269
|
-
},
|
|
270
|
-
beforeReplicaId: 't2'
|
|
271
|
-
});
|
|
272
|
-
});
|
|
273
|
-
const checkpoint2 = result2!.flushed_op;
|
|
274
|
-
|
|
275
|
-
await storage.compact(compactOptions);
|
|
276
|
-
|
|
277
|
-
const batchAfter = await oneFromAsync(storage.getBucketDataBatch(checkpoint2, new Map([['global[]', '0']])));
|
|
278
|
-
const dataAfter = batchAfter.batch.data;
|
|
279
|
-
const checksumAfter = await storage.getChecksums(checkpoint2, ['global[]']);
|
|
280
|
-
|
|
281
|
-
expect(batchAfter.targetOp).toEqual(4n);
|
|
282
|
-
expect(dataAfter).toMatchObject([
|
|
283
|
-
{
|
|
284
|
-
checksum: 1874612650,
|
|
285
|
-
op: 'CLEAR',
|
|
286
|
-
op_id: '4'
|
|
287
|
-
}
|
|
288
|
-
]);
|
|
289
|
-
expect(checksumAfter.get('global[]')).toEqual({
|
|
290
|
-
bucket: 'global[]',
|
|
291
|
-
count: 1,
|
|
292
|
-
checksum: 1874612650
|
|
293
|
-
});
|
|
294
|
-
});
|
|
295
|
-
}
|