@powersync/service-core-tests 0.15.3 → 0.15.4
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 +13 -0
- package/dist/test-utils/MetricsHelper.js +1 -1
- package/dist/test-utils/MetricsHelper.js.map +1 -1
- package/dist/tests/register-data-storage-data-tests.js +18 -0
- package/dist/tests/register-data-storage-data-tests.js.map +1 -1
- package/dist/tests/register-parameter-compacting-tests.js.map +1 -1
- package/dist/tests/register-sync-tests.js +66 -0
- package/dist/tests/register-sync-tests.js.map +1 -1
- package/dist/tests/tests-index.d.ts +4 -4
- package/dist/tests/tests-index.js +4 -4
- package/dist/tests/tests-index.js.map +1 -1
- package/package.json +3 -3
- package/src/test-utils/MetricsHelper.ts +1 -1
- package/src/tests/register-data-storage-data-tests.ts +22 -0
- package/src/tests/register-parameter-compacting-tests.ts +0 -1
- package/src/tests/register-sync-tests.ts +74 -0
- package/src/tests/tests-index.ts +4 -4
- package/tsconfig.tsbuildinfo +1 -1
package/package.json
CHANGED
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
8
|
-
"version": "0.15.
|
|
8
|
+
"version": "0.15.4",
|
|
9
9
|
"main": "dist/index.js",
|
|
10
10
|
"license": "FSL-1.1-ALv2",
|
|
11
11
|
"type": "module",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@powersync/service-core": "^1.20.
|
|
13
|
+
"@powersync/service-core": "^1.20.5",
|
|
14
14
|
"@powersync/service-jsonbig": "^0.17.12",
|
|
15
|
-
"@powersync/service-sync-rules": "^0.
|
|
15
|
+
"@powersync/service-sync-rules": "^0.35.0"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"vitest": "^4.1.0"
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { MetricsEngine, MetricsFactory, OpenTelemetryMetricsFactory } from '@powersync/service-core';
|
|
2
1
|
import {
|
|
3
2
|
AggregationTemporality,
|
|
4
3
|
InMemoryMetricExporter,
|
|
5
4
|
MeterProvider,
|
|
6
5
|
PeriodicExportingMetricReader
|
|
7
6
|
} from '@opentelemetry/sdk-metrics';
|
|
7
|
+
import { MetricsEngine, MetricsFactory, OpenTelemetryMetricsFactory } from '@powersync/service-core';
|
|
8
8
|
|
|
9
9
|
export class MetricsHelper {
|
|
10
10
|
public factory: MetricsFactory;
|
|
@@ -1742,4 +1742,26 @@ bucket_definitions:
|
|
|
1742
1742
|
expected.sort((a, b) => a.bucket.localeCompare(b.bucket));
|
|
1743
1743
|
expect(checksums).toEqual(expected);
|
|
1744
1744
|
});
|
|
1745
|
+
|
|
1746
|
+
test('persists validation errors for sync plan', async () => {
|
|
1747
|
+
await using factory = await config.factory();
|
|
1748
|
+
const deployed = await factory.updateSyncRules(
|
|
1749
|
+
updateSyncRulesFromYaml(`
|
|
1750
|
+
config:
|
|
1751
|
+
edition: 3
|
|
1752
|
+
|
|
1753
|
+
streams:
|
|
1754
|
+
invalid:
|
|
1755
|
+
query: UPDATE test SET foo = 'bar' RETURNING *
|
|
1756
|
+
`)
|
|
1757
|
+
);
|
|
1758
|
+
|
|
1759
|
+
const { errors } = deployed.parsed({ defaultSchema: 'ignored' }).sync_rules;
|
|
1760
|
+
expect(errors).toHaveLength(1);
|
|
1761
|
+
expect(errors[0].message).toStrictEqual('Expected a SELECT statement');
|
|
1762
|
+
expect(errors[0].location).toStrictEqual({
|
|
1763
|
+
start: 54,
|
|
1764
|
+
end: 93
|
|
1765
|
+
});
|
|
1766
|
+
});
|
|
1745
1767
|
}
|
|
@@ -2,7 +2,6 @@ import { storage, updateSyncRulesFromYaml } from '@powersync/service-core';
|
|
|
2
2
|
import { ScopedParameterLookup } from '@powersync/service-sync-rules';
|
|
3
3
|
import { expect, test } from 'vitest';
|
|
4
4
|
import * as test_utils from '../test-utils/test-utils-index.js';
|
|
5
|
-
import { parameterLookupScope } from './util.js';
|
|
6
5
|
|
|
7
6
|
export function registerParameterCompactTests(config: storage.TestStorageConfig) {
|
|
8
7
|
const generateStorageFactory = config.factory;
|
|
@@ -177,6 +177,80 @@ bucket_definitions:
|
|
|
177
177
|
expect(lines).toMatchSnapshot();
|
|
178
178
|
});
|
|
179
179
|
|
|
180
|
+
test('can override priority when subscribing to stream', async () => {
|
|
181
|
+
await using f = await factory();
|
|
182
|
+
|
|
183
|
+
const syncRules = await updateSyncRules(f, {
|
|
184
|
+
content: `
|
|
185
|
+
config:
|
|
186
|
+
edition: 3
|
|
187
|
+
|
|
188
|
+
streams:
|
|
189
|
+
todos:
|
|
190
|
+
query: SELECT * FROM test WHERE id IN subscription.parameter('test_ids')
|
|
191
|
+
`
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
const bucketStorage = f.getInstance(syncRules);
|
|
195
|
+
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
196
|
+
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
197
|
+
|
|
198
|
+
await writer.markAllSnapshotDone('0/1');
|
|
199
|
+
await writer.save({
|
|
200
|
+
sourceTable: testTable,
|
|
201
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
202
|
+
after: {
|
|
203
|
+
id: 'a',
|
|
204
|
+
description: 'Test 1'
|
|
205
|
+
},
|
|
206
|
+
afterReplicaId: 't1'
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
await writer.save({
|
|
210
|
+
sourceTable: testTable,
|
|
211
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
212
|
+
after: {
|
|
213
|
+
id: 'b',
|
|
214
|
+
description: 'Test 2'
|
|
215
|
+
},
|
|
216
|
+
afterReplicaId: 'earlier'
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
await writer.commit('0/1');
|
|
220
|
+
|
|
221
|
+
const stream = sync.streamResponse({
|
|
222
|
+
syncContext,
|
|
223
|
+
bucketStorage,
|
|
224
|
+
syncRules: bucketStorage.getParsedSyncRules(test_utils.PARSE_OPTIONS),
|
|
225
|
+
params: {
|
|
226
|
+
buckets: [],
|
|
227
|
+
include_checksum: true,
|
|
228
|
+
raw_data: true,
|
|
229
|
+
streams: {
|
|
230
|
+
include_defaults: true,
|
|
231
|
+
subscriptions: [
|
|
232
|
+
{
|
|
233
|
+
stream: 'todos',
|
|
234
|
+
parameters: { test_ids: ['a'] },
|
|
235
|
+
override_priority: 0
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
stream: 'todos',
|
|
239
|
+
parameters: { test_ids: ['a', 'b'] },
|
|
240
|
+
override_priority: null
|
|
241
|
+
}
|
|
242
|
+
]
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
tracker,
|
|
246
|
+
token: new JwtPayload({ sub: '', exp: Date.now() / 1000 + 10 }),
|
|
247
|
+
isEncodingAsBson: false
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
const lines = await consumeCheckpointLines(stream);
|
|
251
|
+
expect(lines).toMatchSnapshot();
|
|
252
|
+
});
|
|
253
|
+
|
|
180
254
|
test('sync interrupts low-priority buckets on new checkpoints', async () => {
|
|
181
255
|
await using f = await factory();
|
|
182
256
|
|
package/src/tests/tests-index.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export * from './register-bucket-validation-tests.js';
|
|
2
2
|
export * from './register-compacting-tests.js';
|
|
3
|
-
export * from './register-parameter-compacting-tests.js';
|
|
4
|
-
export * from './register-data-storage-parameter-tests.js';
|
|
5
|
-
export * from './register-data-storage-data-tests.js';
|
|
6
3
|
export * from './register-data-storage-checkpoint-tests.js';
|
|
4
|
+
export * from './register-data-storage-data-tests.js';
|
|
5
|
+
export * from './register-data-storage-parameter-tests.js';
|
|
7
6
|
export * from './register-migration-tests.js';
|
|
8
|
-
export * from './register-
|
|
7
|
+
export * from './register-parameter-compacting-tests.js';
|
|
9
8
|
export * from './register-report-tests.js';
|
|
9
|
+
export * from './register-sync-tests.js';
|
|
10
10
|
export * from './util.js';
|