@powersync/service-module-postgres-storage 0.13.0 → 0.13.1

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.
@@ -104,7 +104,7 @@ exports[`sync - postgres > storage v1 > compacting data - invalidate checkpoint
104
104
  ]
105
105
  `;
106
106
 
107
- exports[`sync - postgres > storage v1 > encodes sync rules id in buckes for streams 1`] = `
107
+ exports[`sync - postgres > storage v1 > encodes sync rules id in buckets for streams 1`] = `
108
108
  [
109
109
  {
110
110
  "checkpoint": {
@@ -159,13 +159,13 @@ exports[`sync - postgres > storage v1 > encodes sync rules id in buckes for stre
159
159
  ]
160
160
  `;
161
161
 
162
- exports[`sync - postgres > storage v1 > encodes sync rules id in buckes for streams 2`] = `
162
+ exports[`sync - postgres > storage v1 > encodes sync rules id in buckets for streams 2`] = `
163
163
  [
164
164
  {
165
165
  "checkpoint": {
166
166
  "buckets": [
167
167
  {
168
- "bucket": "2#test|0[]",
168
+ "bucket": "2#test2|0[]",
169
169
  "checksum": 920318466,
170
170
  "count": 1,
171
171
  "priority": 3,
@@ -181,7 +181,7 @@ exports[`sync - postgres > storage v1 > encodes sync rules id in buckes for stre
181
181
  {
182
182
  "errors": [],
183
183
  "is_default": true,
184
- "name": "test",
184
+ "name": "test2",
185
185
  },
186
186
  ],
187
187
  "write_checkpoint": undefined,
@@ -190,7 +190,7 @@ exports[`sync - postgres > storage v1 > encodes sync rules id in buckes for stre
190
190
  {
191
191
  "data": {
192
192
  "after": "0",
193
- "bucket": "2#test|0[]",
193
+ "bucket": "2#test2|0[]",
194
194
  "data": [
195
195
  {
196
196
  "checksum": 920318466,
@@ -199,7 +199,7 @@ exports[`sync - postgres > storage v1 > encodes sync rules id in buckes for stre
199
199
  "object_type": "test",
200
200
  "op": "PUT",
201
201
  "op_id": "2",
202
- "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
202
+ "subkey": "8a5f3fdd-3f59-5153-92ae-ac115c458441",
203
203
  },
204
204
  ],
205
205
  "has_more": false,
@@ -819,7 +819,7 @@ exports[`sync - postgres > storage v1 > sync updates to data query only 2`] = `
819
819
  "object_type": "lists",
820
820
  "op": "PUT",
821
821
  "op_id": "2",
822
- "subkey": "5ad0aa14-3d5e-5428-ad5b-2c33927d991c",
822
+ "subkey": "b9f16d58-e6f5-55b5-9622-7bc360dba34f",
823
823
  },
824
824
  ],
825
825
  "has_more": false,
@@ -1026,7 +1026,7 @@ exports[`sync - postgres > storage v1 > sync updates to parameter query + data 2
1026
1026
  "object_type": "lists",
1027
1027
  "op": "PUT",
1028
1028
  "op_id": "1",
1029
- "subkey": "5ad0aa14-3d5e-5428-ad5b-2c33927d991c",
1029
+ "subkey": "b9f16d58-e6f5-55b5-9622-7bc360dba34f",
1030
1030
  },
1031
1031
  ],
1032
1032
  "has_more": false,
@@ -1199,7 +1199,7 @@ exports[`sync - postgres > storage v2 > compacting data - invalidate checkpoint
1199
1199
  ]
1200
1200
  `;
1201
1201
 
1202
- exports[`sync - postgres > storage v2 > encodes sync rules id in buckes for streams 1`] = `
1202
+ exports[`sync - postgres > storage v2 > encodes sync rules id in buckets for streams 1`] = `
1203
1203
  [
1204
1204
  {
1205
1205
  "checkpoint": {
@@ -1254,13 +1254,13 @@ exports[`sync - postgres > storage v2 > encodes sync rules id in buckes for stre
1254
1254
  ]
1255
1255
  `;
1256
1256
 
1257
- exports[`sync - postgres > storage v2 > encodes sync rules id in buckes for streams 2`] = `
1257
+ exports[`sync - postgres > storage v2 > encodes sync rules id in buckets for streams 2`] = `
1258
1258
  [
1259
1259
  {
1260
1260
  "checkpoint": {
1261
1261
  "buckets": [
1262
1262
  {
1263
- "bucket": "2#test|0[]",
1263
+ "bucket": "2#test2|0[]",
1264
1264
  "checksum": 920318466,
1265
1265
  "count": 1,
1266
1266
  "priority": 3,
@@ -1276,7 +1276,7 @@ exports[`sync - postgres > storage v2 > encodes sync rules id in buckes for stre
1276
1276
  {
1277
1277
  "errors": [],
1278
1278
  "is_default": true,
1279
- "name": "test",
1279
+ "name": "test2",
1280
1280
  },
1281
1281
  ],
1282
1282
  "write_checkpoint": undefined,
@@ -1285,7 +1285,7 @@ exports[`sync - postgres > storage v2 > encodes sync rules id in buckes for stre
1285
1285
  {
1286
1286
  "data": {
1287
1287
  "after": "0",
1288
- "bucket": "2#test|0[]",
1288
+ "bucket": "2#test2|0[]",
1289
1289
  "data": [
1290
1290
  {
1291
1291
  "checksum": 920318466,
@@ -1294,7 +1294,7 @@ exports[`sync - postgres > storage v2 > encodes sync rules id in buckes for stre
1294
1294
  "object_type": "test",
1295
1295
  "op": "PUT",
1296
1296
  "op_id": "2",
1297
- "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
1297
+ "subkey": "8a5f3fdd-3f59-5153-92ae-ac115c458441",
1298
1298
  },
1299
1299
  ],
1300
1300
  "has_more": false,
@@ -1914,7 +1914,7 @@ exports[`sync - postgres > storage v2 > sync updates to data query only 2`] = `
1914
1914
  "object_type": "lists",
1915
1915
  "op": "PUT",
1916
1916
  "op_id": "2",
1917
- "subkey": "5ad0aa14-3d5e-5428-ad5b-2c33927d991c",
1917
+ "subkey": "b9f16d58-e6f5-55b5-9622-7bc360dba34f",
1918
1918
  },
1919
1919
  ],
1920
1920
  "has_more": false,
@@ -2121,7 +2121,7 @@ exports[`sync - postgres > storage v2 > sync updates to parameter query + data 2
2121
2121
  "object_type": "lists",
2122
2122
  "op": "PUT",
2123
2123
  "op_id": "1",
2124
- "subkey": "5ad0aa14-3d5e-5428-ad5b-2c33927d991c",
2124
+ "subkey": "b9f16d58-e6f5-55b5-9622-7bc360dba34f",
2125
2125
  },
2126
2126
  ],
2127
2127
  "has_more": false,
@@ -2294,7 +2294,7 @@ exports[`sync - postgres > storage v3 > compacting data - invalidate checkpoint
2294
2294
  ]
2295
2295
  `;
2296
2296
 
2297
- exports[`sync - postgres > storage v3 > encodes sync rules id in buckes for streams 1`] = `
2297
+ exports[`sync - postgres > storage v3 > encodes sync rules id in buckets for streams 1`] = `
2298
2298
  [
2299
2299
  {
2300
2300
  "checkpoint": {
@@ -2349,13 +2349,13 @@ exports[`sync - postgres > storage v3 > encodes sync rules id in buckes for stre
2349
2349
  ]
2350
2350
  `;
2351
2351
 
2352
- exports[`sync - postgres > storage v3 > encodes sync rules id in buckes for streams 2`] = `
2352
+ exports[`sync - postgres > storage v3 > encodes sync rules id in buckets for streams 2`] = `
2353
2353
  [
2354
2354
  {
2355
2355
  "checkpoint": {
2356
2356
  "buckets": [
2357
2357
  {
2358
- "bucket": "2#test|0[]",
2358
+ "bucket": "2#test2|0[]",
2359
2359
  "checksum": 920318466,
2360
2360
  "count": 1,
2361
2361
  "priority": 3,
@@ -2371,7 +2371,7 @@ exports[`sync - postgres > storage v3 > encodes sync rules id in buckes for stre
2371
2371
  {
2372
2372
  "errors": [],
2373
2373
  "is_default": true,
2374
- "name": "test",
2374
+ "name": "test2",
2375
2375
  },
2376
2376
  ],
2377
2377
  "write_checkpoint": undefined,
@@ -2380,7 +2380,7 @@ exports[`sync - postgres > storage v3 > encodes sync rules id in buckes for stre
2380
2380
  {
2381
2381
  "data": {
2382
2382
  "after": "0",
2383
- "bucket": "2#test|0[]",
2383
+ "bucket": "2#test2|0[]",
2384
2384
  "data": [
2385
2385
  {
2386
2386
  "checksum": 920318466,
@@ -2389,7 +2389,7 @@ exports[`sync - postgres > storage v3 > encodes sync rules id in buckes for stre
2389
2389
  "object_type": "test",
2390
2390
  "op": "PUT",
2391
2391
  "op_id": "2",
2392
- "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
2392
+ "subkey": "8a5f3fdd-3f59-5153-92ae-ac115c458441",
2393
2393
  },
2394
2394
  ],
2395
2395
  "has_more": false,
@@ -3009,7 +3009,7 @@ exports[`sync - postgres > storage v3 > sync updates to data query only 2`] = `
3009
3009
  "object_type": "lists",
3010
3010
  "op": "PUT",
3011
3011
  "op_id": "2",
3012
- "subkey": "5ad0aa14-3d5e-5428-ad5b-2c33927d991c",
3012
+ "subkey": "b9f16d58-e6f5-55b5-9622-7bc360dba34f",
3013
3013
  },
3014
3014
  ],
3015
3015
  "has_more": false,
@@ -3216,7 +3216,7 @@ exports[`sync - postgres > storage v3 > sync updates to parameter query + data 2
3216
3216
  "object_type": "lists",
3217
3217
  "op": "PUT",
3218
3218
  "op_id": "1",
3219
- "subkey": "5ad0aa14-3d5e-5428-ad5b-2c33927d991c",
3219
+ "subkey": "b9f16d58-e6f5-55b5-9622-7bc360dba34f",
3220
3220
  },
3221
3221
  ],
3222
3222
  "has_more": false,
package/test/src/env.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { utils } from '@powersync/lib-services-framework';
2
2
 
3
3
  export const env = utils.collectEnvironmentVariables({
4
- PG_STORAGE_TEST_URL: utils.type.string.default('postgres://postgres:postgres@localhost:5431/powersync_storage_test'),
4
+ PG_STORAGE_TEST_URL: utils.type.string.default('postgres://postgres:postgres@localhost:5432/powersync_storage_test'),
5
5
  CI: utils.type.boolean.default('false')
6
6
  });
@@ -1,5 +1,5 @@
1
1
  import { storage, updateSyncRulesFromYaml } from '@powersync/service-core';
2
- import { bucketRequestMap, register, test_utils } from '@powersync/service-core-tests';
2
+ import { bucketRequest, register, test_utils } from '@powersync/service-core-tests';
3
3
  import { describe, expect, test } from 'vitest';
4
4
  import { POSTGRES_STORAGE_FACTORY, TEST_STORAGE_VERSIONS } from './util.js';
5
5
 
@@ -39,13 +39,15 @@ for (let storageVersion of TEST_STORAGE_VERSIONS) {
39
39
  )
40
40
  );
41
41
  const bucketStorage = factory.getInstance(syncRules);
42
+ const globalBucket = bucketRequest(syncRules, 'global[]');
42
43
 
43
- const result = await bucketStorage.startBatch(test_utils.BATCH_OPTIONS, async (batch) => {
44
- const sourceTable = test_utils.makeTestTable('test', ['id'], POSTGRES_STORAGE_FACTORY);
44
+ const result = await (async () => {
45
+ await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
46
+ const sourceTable = await test_utils.resolveTestTable(writer, 'test', ['id'], POSTGRES_STORAGE_FACTORY);
45
47
 
46
48
  const largeDescription = '0123456789'.repeat(2_000_00);
47
49
 
48
- await batch.save({
50
+ await writer.save({
49
51
  sourceTable,
50
52
  tag: storage.SaveOperationTag.INSERT,
51
53
  after: {
@@ -55,7 +57,7 @@ for (let storageVersion of TEST_STORAGE_VERSIONS) {
55
57
  afterReplicaId: test_utils.rid('test1')
56
58
  });
57
59
 
58
- await batch.save({
60
+ await writer.save({
59
61
  sourceTable,
60
62
  tag: storage.SaveOperationTag.INSERT,
61
63
  after: {
@@ -66,7 +68,7 @@ for (let storageVersion of TEST_STORAGE_VERSIONS) {
66
68
  });
67
69
 
68
70
  // Large enough to split the returned batch
69
- await batch.save({
71
+ await writer.save({
70
72
  sourceTable,
71
73
  tag: storage.SaveOperationTag.INSERT,
72
74
  after: {
@@ -76,7 +78,7 @@ for (let storageVersion of TEST_STORAGE_VERSIONS) {
76
78
  afterReplicaId: test_utils.rid('large2')
77
79
  });
78
80
 
79
- await batch.save({
81
+ await writer.save({
80
82
  sourceTable,
81
83
  tag: storage.SaveOperationTag.INSERT,
82
84
  after: {
@@ -85,15 +87,14 @@ for (let storageVersion of TEST_STORAGE_VERSIONS) {
85
87
  },
86
88
  afterReplicaId: test_utils.rid('test3')
87
89
  });
88
- });
90
+ return writer.flush();
91
+ })();
89
92
 
90
93
  const checkpoint = result!.flushed_op;
91
94
 
92
95
  const options: storage.BucketDataBatchOptions = {};
93
96
 
94
- const batch1 = await test_utils.fromAsync(
95
- bucketStorage.getBucketDataBatch(checkpoint, bucketRequestMap(syncRules, [['global[]', 0n]]), options)
96
- );
97
+ const batch1 = await test_utils.fromAsync(bucketStorage.getBucketDataBatch(checkpoint, [globalBucket], options));
97
98
  expect(test_utils.getBatchData(batch1)).toEqual([
98
99
  { op_id: '1', op: 'PUT', object_id: 'test1', checksum: 2871785649 }
99
100
  ]);
@@ -106,7 +107,7 @@ for (let storageVersion of TEST_STORAGE_VERSIONS) {
106
107
  const batch2 = await test_utils.fromAsync(
107
108
  bucketStorage.getBucketDataBatch(
108
109
  checkpoint,
109
- bucketRequestMap(syncRules, [['global[]', BigInt(batch1[0].chunkData.next_after)]]),
110
+ [{ ...globalBucket, start: BigInt(batch1[0].chunkData.next_after) }],
110
111
  options
111
112
  )
112
113
  );
@@ -122,7 +123,7 @@ for (let storageVersion of TEST_STORAGE_VERSIONS) {
122
123
  const batch3 = await test_utils.fromAsync(
123
124
  bucketStorage.getBucketDataBatch(
124
125
  checkpoint,
125
- bucketRequestMap(syncRules, [['global[]', BigInt(batch2[0].chunkData.next_after)]]),
126
+ [{ ...globalBucket, start: BigInt(batch2[0].chunkData.next_after) }],
126
127
  options
127
128
  )
128
129
  );
@@ -138,7 +139,7 @@ for (let storageVersion of TEST_STORAGE_VERSIONS) {
138
139
  const batch4 = await test_utils.fromAsync(
139
140
  bucketStorage.getBucketDataBatch(
140
141
  checkpoint,
141
- bucketRequestMap(syncRules, [['global[]', BigInt(batch3[0].chunkData.next_after)]]),
142
+ [{ ...globalBucket, start: BigInt(batch3[0].chunkData.next_after) }],
142
143
  options
143
144
  )
144
145
  );
@@ -1,5 +1,5 @@
1
1
  import { storage, updateSyncRulesFromYaml } from '@powersync/service-core';
2
- import { bucketRequest, bucketRequestMap, register, test_utils } from '@powersync/service-core-tests';
2
+ import { bucketRequest, register, test_utils } from '@powersync/service-core-tests';
3
3
  import { describe, expect, test } from 'vitest';
4
4
  import { PostgresCompactor } from '../../src/storage/PostgresCompactor.js';
5
5
  import { POSTGRES_STORAGE_FACTORY } from './util.js';
@@ -7,7 +7,6 @@ import { POSTGRES_STORAGE_FACTORY } from './util.js';
7
7
  describe('Postgres Sync Bucket Storage Compact', () => register.registerCompactTests(POSTGRES_STORAGE_FACTORY));
8
8
 
9
9
  describe('Postgres Compact - explicit bucket name', () => {
10
- const TEST_TABLE = test_utils.makeTestTable('test', ['id'], POSTGRES_STORAGE_FACTORY);
11
10
  test('compacts a specific bucket by exact name', async () => {
12
11
  await using factory = await POSTGRES_STORAGE_FACTORY.factory();
13
12
  const syncRules = await factory.updateSyncRules(
@@ -19,22 +18,26 @@ bucket_definitions:
19
18
  );
20
19
  const bucketStorage = factory.getInstance(syncRules);
21
20
 
22
- const result = await bucketStorage.startBatch(test_utils.BATCH_OPTIONS, async (batch) => {
23
- await batch.save({
24
- sourceTable: TEST_TABLE,
21
+ const result = await (async () => {
22
+ await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
23
+ const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], POSTGRES_STORAGE_FACTORY);
24
+ await writer.save({
25
+ sourceTable: testTable,
25
26
  tag: storage.SaveOperationTag.INSERT,
26
27
  after: { id: 't1' },
27
28
  afterReplicaId: test_utils.rid('t1')
28
29
  });
29
- await batch.save({
30
- sourceTable: TEST_TABLE,
30
+ await writer.save({
31
+ sourceTable: testTable,
31
32
  tag: storage.SaveOperationTag.UPDATE,
32
33
  after: { id: 't1' },
33
34
  afterReplicaId: test_utils.rid('t1')
34
35
  });
35
- await batch.markAllSnapshotDone('1/1');
36
- await batch.commit('1/1');
37
- });
36
+ await writer.markAllSnapshotDone('1/1');
37
+ const flushed = await writer.flush();
38
+ await writer.commit('1/1');
39
+ return flushed;
40
+ })();
38
41
 
39
42
  const checkpoint = result!.flushed_op;
40
43
 
@@ -46,7 +49,7 @@ bucket_definitions:
46
49
  });
47
50
 
48
51
  const batch = await test_utils.oneFromAsync(
49
- bucketStorage.getBucketDataBatch(checkpoint, bucketRequestMap(syncRules, [['global[]', 0n]]))
52
+ bucketStorage.getBucketDataBatch(checkpoint, [bucketRequest(syncRules, 'global[]', 0n)])
50
53
  );
51
54
 
52
55
  expect(batch.chunkData.data).toMatchObject([
@@ -69,34 +72,38 @@ bucket_definitions:
69
72
  const bucketStorage = factory.getInstance(syncRules);
70
73
  const request = bucketRequest(syncRules, 'global[]');
71
74
 
72
- const result = await bucketStorage.startBatch(test_utils.BATCH_OPTIONS, async (batch) => {
73
- await batch.markAllSnapshotDone('1/1');
74
- await batch.save({
75
- sourceTable: TEST_TABLE,
75
+ const result = await (async () => {
76
+ await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
77
+ const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], POSTGRES_STORAGE_FACTORY);
78
+ await writer.markAllSnapshotDone('1/1');
79
+ await writer.save({
80
+ sourceTable: testTable,
76
81
  tag: storage.SaveOperationTag.INSERT,
77
82
  after: { id: 't1' },
78
83
  afterReplicaId: test_utils.rid('t1')
79
84
  });
80
- await batch.save({
81
- sourceTable: TEST_TABLE,
85
+ await writer.save({
86
+ sourceTable: testTable,
82
87
  tag: storage.SaveOperationTag.DELETE,
83
88
  before: { id: 't1' },
84
89
  beforeReplicaId: test_utils.rid('t1')
85
90
  });
86
- await batch.save({
87
- sourceTable: TEST_TABLE,
91
+ await writer.save({
92
+ sourceTable: testTable,
88
93
  tag: storage.SaveOperationTag.INSERT,
89
94
  after: { id: 't2' },
90
95
  afterReplicaId: test_utils.rid('t2')
91
96
  });
92
- await batch.save({
93
- sourceTable: TEST_TABLE,
97
+ await writer.save({
98
+ sourceTable: testTable,
94
99
  tag: storage.SaveOperationTag.DELETE,
95
100
  before: { id: 't2' },
96
101
  beforeReplicaId: test_utils.rid('t2')
97
102
  });
98
- await batch.commit('1/1');
99
- });
103
+ const flushed = await writer.flush();
104
+ await writer.commit('1/1');
105
+ return flushed;
106
+ })();
100
107
 
101
108
  const checkpoint = result!.flushed_op;
102
109
  const rowsBefore = await test_utils.oneFromAsync(bucketStorage.getBucketDataBatch(checkpoint, [request]));
@@ -1,5 +1,5 @@
1
1
  import { storage, updateSyncRulesFromYaml } from '@powersync/service-core';
2
- import { bucketRequest, register, test_utils } from '@powersync/service-core-tests';
2
+ import { bucketRequest, register, resolveTestTable, test_utils } from '@powersync/service-core-tests';
3
3
  import { describe, expect, test } from 'vitest';
4
4
  import { POSTGRES_STORAGE_FACTORY, TEST_STORAGE_VERSIONS } from './util.js';
5
5
 
@@ -11,7 +11,6 @@ import { POSTGRES_STORAGE_FACTORY, TEST_STORAGE_VERSIONS } from './util.js';
11
11
  function registerStorageVersionTests(storageVersion: number) {
12
12
  describe(`storage v${storageVersion}`, () => {
13
13
  const storageFactory = POSTGRES_STORAGE_FACTORY;
14
- const TEST_TABLE = test_utils.makeTestTable('test', ['id'], storageFactory);
15
14
 
16
15
  register.registerSyncTests(storageFactory.factory, {
17
16
  storageVersion,
@@ -37,53 +36,55 @@ function registerStorageVersionTests(storageVersion: number) {
37
36
  const bucketStorage = factory.getInstance(syncRules);
38
37
  const globalBucket = bucketRequest(syncRules, 'global[]');
39
38
 
40
- const result = await bucketStorage.startBatch(test_utils.BATCH_OPTIONS, async (batch) => {
41
- const sourceTable = TEST_TABLE;
42
-
43
- const largeDescription = '0123456789'.repeat(2_000_00);
44
-
45
- await batch.save({
46
- sourceTable,
47
- tag: storage.SaveOperationTag.INSERT,
48
- after: {
49
- id: 'test1',
50
- description: 'test1'
51
- },
52
- afterReplicaId: test_utils.rid('test1')
53
- });
54
-
55
- await batch.save({
56
- sourceTable,
57
- tag: storage.SaveOperationTag.INSERT,
58
- after: {
59
- id: 'large1',
60
- description: largeDescription
61
- },
62
- afterReplicaId: test_utils.rid('large1')
63
- });
64
-
65
- // Large enough to split the returned batch
66
- await batch.save({
67
- sourceTable,
68
- tag: storage.SaveOperationTag.INSERT,
69
- after: {
70
- id: 'large2',
71
- description: largeDescription
72
- },
73
- afterReplicaId: test_utils.rid('large2')
74
- });
75
-
76
- await batch.save({
77
- sourceTable,
78
- tag: storage.SaveOperationTag.INSERT,
79
- after: {
80
- id: 'test3',
81
- description: 'test3'
82
- },
83
- afterReplicaId: test_utils.rid('test3')
84
- });
39
+ await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
40
+
41
+ const sourceTable = await resolveTestTable(writer, 'test', ['id'], storageFactory);
42
+
43
+ const largeDescription = '0123456789'.repeat(2_000_00);
44
+
45
+ await writer.save({
46
+ sourceTable,
47
+ tag: storage.SaveOperationTag.INSERT,
48
+ after: {
49
+ id: 'test1',
50
+ description: 'test1'
51
+ },
52
+ afterReplicaId: test_utils.rid('test1')
53
+ });
54
+
55
+ await writer.save({
56
+ sourceTable,
57
+ tag: storage.SaveOperationTag.INSERT,
58
+ after: {
59
+ id: 'large1',
60
+ description: largeDescription
61
+ },
62
+ afterReplicaId: test_utils.rid('large1')
85
63
  });
86
64
 
65
+ // Large enough to split the returned batch
66
+ await writer.save({
67
+ sourceTable,
68
+ tag: storage.SaveOperationTag.INSERT,
69
+ after: {
70
+ id: 'large2',
71
+ description: largeDescription
72
+ },
73
+ afterReplicaId: test_utils.rid('large2')
74
+ });
75
+
76
+ await writer.save({
77
+ sourceTable,
78
+ tag: storage.SaveOperationTag.INSERT,
79
+ after: {
80
+ id: 'test3',
81
+ description: 'test3'
82
+ },
83
+ afterReplicaId: test_utils.rid('test3')
84
+ });
85
+
86
+ const result = await writer.flush();
87
+
87
88
  const checkpoint = result!.flushed_op;
88
89
 
89
90
  const options: storage.BucketDataBatchOptions = {};