@powersync/service-core 0.0.0-dev-20250317122913 → 0.0.0-dev-20250325131118
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 +18 -4
- package/dist/api/api-index.d.ts +1 -0
- package/dist/api/api-index.js +1 -0
- package/dist/api/api-index.js.map +1 -1
- package/dist/api/api-metrics.d.ts +11 -0
- package/dist/api/api-metrics.js +30 -0
- package/dist/api/api-metrics.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/metrics/MetricsEngine.d.ts +21 -0
- package/dist/metrics/MetricsEngine.js +79 -0
- package/dist/metrics/MetricsEngine.js.map +1 -0
- package/dist/metrics/metrics-index.d.ts +4 -0
- package/dist/metrics/metrics-index.js +5 -0
- package/dist/metrics/metrics-index.js.map +1 -0
- package/dist/metrics/metrics-interfaces.d.ts +36 -0
- package/dist/metrics/metrics-interfaces.js +6 -0
- package/dist/metrics/metrics-interfaces.js.map +1 -0
- package/dist/metrics/open-telemetry/OpenTelemetryMetricsFactory.d.ts +10 -0
- package/dist/metrics/open-telemetry/OpenTelemetryMetricsFactory.js +51 -0
- package/dist/metrics/open-telemetry/OpenTelemetryMetricsFactory.js.map +1 -0
- package/dist/metrics/open-telemetry/util.d.ts +6 -0
- package/dist/metrics/open-telemetry/util.js +56 -0
- package/dist/metrics/open-telemetry/util.js.map +1 -0
- package/dist/replication/AbstractReplicationJob.d.ts +2 -0
- package/dist/replication/AbstractReplicationJob.js.map +1 -1
- package/dist/replication/AbstractReplicator.d.ts +3 -0
- package/dist/replication/AbstractReplicator.js +3 -0
- package/dist/replication/AbstractReplicator.js.map +1 -1
- package/dist/replication/ReplicationModule.d.ts +7 -0
- package/dist/replication/ReplicationModule.js +1 -0
- package/dist/replication/ReplicationModule.js.map +1 -1
- package/dist/replication/replication-index.d.ts +1 -0
- package/dist/replication/replication-index.js +1 -0
- package/dist/replication/replication-index.js.map +1 -1
- package/dist/replication/replication-metrics.d.ts +11 -0
- package/dist/replication/replication-metrics.js +39 -0
- package/dist/replication/replication-metrics.js.map +1 -0
- package/dist/routes/configure-fastify.d.ts +1 -1
- package/dist/routes/endpoints/probes.d.ts +2 -2
- package/dist/routes/endpoints/probes.js +16 -2
- package/dist/routes/endpoints/probes.js.map +1 -1
- package/dist/routes/endpoints/socket-route.js +5 -5
- package/dist/routes/endpoints/socket-route.js.map +1 -1
- package/dist/routes/endpoints/sync-stream.js +6 -6
- package/dist/routes/endpoints/sync-stream.js.map +1 -1
- package/dist/storage/SyncRulesBucketStorage.d.ts +11 -1
- package/dist/storage/SyncRulesBucketStorage.js +1 -1
- package/dist/storage/SyncRulesBucketStorage.js.map +1 -1
- package/dist/storage/WriteCheckpointAPI.d.ts +0 -2
- package/dist/storage/WriteCheckpointAPI.js.map +1 -1
- package/dist/storage/storage-index.d.ts +1 -0
- package/dist/storage/storage-index.js +1 -0
- package/dist/storage/storage-index.js.map +1 -1
- package/dist/storage/storage-metrics.d.ts +4 -0
- package/dist/storage/storage-metrics.js +56 -0
- package/dist/storage/storage-metrics.js.map +1 -0
- package/dist/sync/BucketChecksumState.d.ts +4 -2
- package/dist/sync/BucketChecksumState.js +17 -26
- package/dist/sync/BucketChecksumState.js.map +1 -1
- package/dist/sync/RequestTracker.d.ts +3 -0
- package/dist/sync/RequestTracker.js +8 -3
- package/dist/sync/RequestTracker.js.map +1 -1
- package/dist/sync/util.d.ts +10 -2
- package/dist/sync/util.js +25 -6
- package/dist/sync/util.js.map +1 -1
- package/dist/system/ServiceContext.d.ts +3 -3
- package/dist/system/ServiceContext.js +7 -3
- package/dist/system/ServiceContext.js.map +1 -1
- package/package.json +8 -8
- package/src/api/api-index.ts +1 -0
- package/src/api/api-metrics.ts +35 -0
- package/src/index.ts +2 -2
- package/src/metrics/MetricsEngine.ts +98 -0
- package/src/metrics/metrics-index.ts +4 -0
- package/src/metrics/metrics-interfaces.ts +41 -0
- package/src/metrics/open-telemetry/OpenTelemetryMetricsFactory.ts +66 -0
- package/src/metrics/open-telemetry/util.ts +74 -0
- package/src/replication/AbstractReplicationJob.ts +2 -0
- package/src/replication/AbstractReplicator.ts +7 -0
- package/src/replication/ReplicationModule.ts +10 -0
- package/src/replication/replication-index.ts +1 -0
- package/src/replication/replication-metrics.ts +45 -0
- package/src/routes/endpoints/probes.ts +18 -2
- package/src/routes/endpoints/socket-route.ts +6 -5
- package/src/routes/endpoints/sync-stream.ts +7 -6
- package/src/storage/SyncRulesBucketStorage.ts +12 -2
- package/src/storage/WriteCheckpointAPI.ts +0 -2
- package/src/storage/storage-index.ts +1 -0
- package/src/storage/storage-metrics.ts +67 -0
- package/src/sync/BucketChecksumState.ts +25 -41
- package/src/sync/RequestTracker.ts +9 -3
- package/src/sync/util.ts +29 -8
- package/src/system/ServiceContext.ts +9 -4
- package/test/src/routes/probes.integration.test.ts +5 -5
- package/test/src/routes/probes.test.ts +5 -4
- package/test/src/sync/BucketChecksumState.test.ts +5 -5
- package/test/src/util.test.ts +48 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/metrics/Metrics.d.ts +0 -30
- package/dist/metrics/Metrics.js +0 -202
- package/dist/metrics/Metrics.js.map +0 -1
- package/src/metrics/Metrics.ts +0 -255
|
@@ -98,7 +98,7 @@ bucket_definitions:
|
|
|
98
98
|
base: { checkpoint: 2n, lsn: '2' },
|
|
99
99
|
writeCheckpoint: null,
|
|
100
100
|
update: {
|
|
101
|
-
updatedDataBuckets: ['global[]'],
|
|
101
|
+
updatedDataBuckets: new Set(['global[]']),
|
|
102
102
|
invalidateDataBuckets: false,
|
|
103
103
|
updatedParameterLookups: new Set(),
|
|
104
104
|
invalidateParameterBuckets: false
|
|
@@ -201,7 +201,7 @@ bucket_definitions:
|
|
|
201
201
|
writeCheckpoint: null,
|
|
202
202
|
update: {
|
|
203
203
|
...CHECKPOINT_INVALIDATE_ALL,
|
|
204
|
-
updatedDataBuckets: ['global[1]', 'global[2]'],
|
|
204
|
+
updatedDataBuckets: new Set(['global[1]', 'global[2]']),
|
|
205
205
|
invalidateDataBuckets: false
|
|
206
206
|
}
|
|
207
207
|
}))!;
|
|
@@ -294,7 +294,7 @@ bucket_definitions:
|
|
|
294
294
|
// Invalidate the state for global[1] - will only re-check the single bucket.
|
|
295
295
|
// This is essentially inconsistent state, but is the simplest way to test that
|
|
296
296
|
// the filter is working.
|
|
297
|
-
updatedDataBuckets: ['global[1]'],
|
|
297
|
+
updatedDataBuckets: new Set(['global[1]']),
|
|
298
298
|
invalidateDataBuckets: false
|
|
299
299
|
}
|
|
300
300
|
}))!;
|
|
@@ -421,7 +421,7 @@ bucket_definitions:
|
|
|
421
421
|
update: {
|
|
422
422
|
...CHECKPOINT_INVALIDATE_ALL,
|
|
423
423
|
invalidateDataBuckets: false,
|
|
424
|
-
updatedDataBuckets: ['global[1]']
|
|
424
|
+
updatedDataBuckets: new Set(['global[1]'])
|
|
425
425
|
}
|
|
426
426
|
}))!;
|
|
427
427
|
expect(line2.checkpointLine).toEqual({
|
|
@@ -533,7 +533,7 @@ bucket_definitions:
|
|
|
533
533
|
writeCheckpoint: null,
|
|
534
534
|
update: {
|
|
535
535
|
invalidateDataBuckets: false,
|
|
536
|
-
updatedDataBuckets:
|
|
536
|
+
updatedDataBuckets: new Set(),
|
|
537
537
|
updatedParameterLookups: new Set([JSONBig.stringify(['by_project', '1', 'u1'])]),
|
|
538
538
|
invalidateParameterBuckets: false
|
|
539
539
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { getIntersection, hasIntersection } from '@/index.js';
|
|
2
|
+
import { describe, expect, test } from 'vitest';
|
|
3
|
+
|
|
4
|
+
describe('utils', () => {
|
|
5
|
+
function testInstersection(a: Set<any>, b: Set<any>, expected: boolean) {
|
|
6
|
+
expect(hasIntersection(a, b)).toBe(expected);
|
|
7
|
+
expect(hasIntersection(b, a)).toBe(expected);
|
|
8
|
+
const mapA = new Map([...a].map((v) => [v, 1]));
|
|
9
|
+
const mapB = new Map([...b].map((v) => [v, 1]));
|
|
10
|
+
expect(hasIntersection(mapA, b)).toBe(expected);
|
|
11
|
+
expect(hasIntersection(mapB, a)).toBe(expected);
|
|
12
|
+
expect(hasIntersection(mapA, mapB)).toBe(expected);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
test('hasIntersection', async () => {
|
|
16
|
+
testInstersection(new Set(['a']), new Set(['a']), true);
|
|
17
|
+
testInstersection(new Set(['a', 'b', 'c']), new Set(['a', 'b', 'c']), true);
|
|
18
|
+
testInstersection(new Set(['a', 'b', 'c']), new Set(['d', 'e']), false);
|
|
19
|
+
testInstersection(new Set(['a', 'b', 'c']), new Set(['d', 'c', 'e']), true);
|
|
20
|
+
testInstersection(new Set(['a', 'b', 'c']), new Set(['c', 'e']), true);
|
|
21
|
+
testInstersection(new Set(['a', 'b', 'c', 2]), new Set([1, 2, 3]), true);
|
|
22
|
+
testInstersection(new Set(['a', 'b', 'c', 4]), new Set([1, 2, 3]), false);
|
|
23
|
+
testInstersection(new Set([]), new Set([1, 2, 3]), false);
|
|
24
|
+
testInstersection(new Set([]), new Set([]), false);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
function testGetIntersection(a: Set<any>, b: Set<any>, expected: any[]) {
|
|
28
|
+
expect([...getIntersection(a, b)]).toEqual(expected);
|
|
29
|
+
expect([...getIntersection(b, a)]).toEqual(expected);
|
|
30
|
+
const mapA = new Map([...a].map((v) => [v, 1]));
|
|
31
|
+
const mapB = new Map([...b].map((v) => [v, 1]));
|
|
32
|
+
expect([...getIntersection(mapA, b)]).toEqual(expected);
|
|
33
|
+
expect([...getIntersection(mapB, a)]).toEqual(expected);
|
|
34
|
+
expect([...getIntersection(mapA, mapB)]).toEqual(expected);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
test('getIntersection', async () => {
|
|
38
|
+
testGetIntersection(new Set(['a']), new Set(['a']), ['a']);
|
|
39
|
+
testGetIntersection(new Set(['a', 'b', 'c']), new Set(['a', 'b', 'c']), ['a', 'b', 'c']);
|
|
40
|
+
testGetIntersection(new Set(['a', 'b', 'c']), new Set(['d', 'e']), []);
|
|
41
|
+
testGetIntersection(new Set(['a', 'b', 'c']), new Set(['d', 'c', 'e']), ['c']);
|
|
42
|
+
testGetIntersection(new Set(['a', 'b', 'c']), new Set(['c', 'e']), ['c']);
|
|
43
|
+
testGetIntersection(new Set(['a', 'b', 'c', 2]), new Set([1, 2, 3]), [2]);
|
|
44
|
+
testGetIntersection(new Set(['a', 'b', 'c', 4]), new Set([1, 2, 3]), []);
|
|
45
|
+
testGetIntersection(new Set([]), new Set([1, 2, 3]), []);
|
|
46
|
+
testGetIntersection(new Set([]), new Set([]), []);
|
|
47
|
+
});
|
|
48
|
+
});
|