@powersync/service-core 1.21.0 → 1.23.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 +48 -0
- package/dist/api/RouteAPI.d.ts +2 -2
- package/dist/api/diagnostics.d.ts +12 -1
- package/dist/api/diagnostics.js +34 -22
- package/dist/api/diagnostics.js.map +1 -1
- package/dist/auth/RemoteJWKSCollector.js +3 -2
- package/dist/auth/RemoteJWKSCollector.js.map +1 -1
- package/dist/entry/commands/compact-action.js +1 -1
- package/dist/entry/commands/compact-action.js.map +1 -1
- package/dist/modules/AbstractModule.d.ts +6 -2
- package/dist/modules/AbstractModule.js.map +1 -1
- package/dist/replication/AbstractReplicator.d.ts +2 -2
- package/dist/replication/AbstractReplicator.js +24 -23
- package/dist/replication/AbstractReplicator.js.map +1 -1
- package/dist/replication/RelationCache.d.ts +9 -2
- package/dist/replication/RelationCache.js +21 -2
- package/dist/replication/RelationCache.js.map +1 -1
- package/dist/replication/ReplicationModule.d.ts +3 -3
- package/dist/replication/ReplicationModule.js.map +1 -1
- package/dist/routes/configure-fastify.d.ts +12 -12
- package/dist/routes/configure-fastify.js +3 -1
- package/dist/routes/configure-fastify.js.map +1 -1
- package/dist/routes/endpoints/admin.d.ts +24 -24
- package/dist/routes/endpoints/admin.js +49 -35
- package/dist/routes/endpoints/admin.js.map +1 -1
- package/dist/routes/endpoints/checkpointing.js +1 -1
- package/dist/routes/endpoints/checkpointing.js.map +1 -1
- package/dist/routes/endpoints/socket-route.js +1 -1
- package/dist/routes/endpoints/socket-route.js.map +1 -1
- package/dist/routes/endpoints/sync-rules.js +22 -13
- package/dist/routes/endpoints/sync-rules.js.map +1 -1
- package/dist/routes/endpoints/sync-stream.js +1 -1
- package/dist/routes/endpoints/sync-stream.js.map +1 -1
- package/dist/routes/route-register.d.ts +2 -0
- package/dist/routes/route-register.js +65 -3
- package/dist/routes/route-register.js.map +1 -1
- package/dist/runner/teardown.js +8 -8
- package/dist/runner/teardown.js.map +1 -1
- package/dist/storage/BucketStorageBatch.d.ts +29 -6
- package/dist/storage/BucketStorageBatch.js.map +1 -1
- package/dist/storage/BucketStorageFactory.d.ts +26 -27
- package/dist/storage/BucketStorageFactory.js +5 -19
- package/dist/storage/BucketStorageFactory.js.map +1 -1
- package/dist/storage/ParsedSyncConfigSet.d.ts +23 -0
- package/dist/storage/ParsedSyncConfigSet.js +2 -0
- package/dist/storage/ParsedSyncConfigSet.js.map +1 -0
- package/dist/storage/PersistedReplicationStream.d.ts +32 -0
- package/dist/storage/PersistedReplicationStream.js +26 -0
- package/dist/storage/PersistedReplicationStream.js.map +1 -0
- package/dist/storage/PersistedSyncConfigContent.d.ts +60 -0
- package/dist/storage/PersistedSyncConfigContent.js +123 -0
- package/dist/storage/PersistedSyncConfigContent.js.map +1 -0
- package/dist/storage/PersistedSyncConfigStatus.d.ts +13 -0
- package/dist/storage/PersistedSyncConfigStatus.js +2 -0
- package/dist/storage/PersistedSyncConfigStatus.js.map +1 -0
- package/dist/storage/SourceEntity.d.ts +8 -1
- package/dist/storage/SourceTable.d.ts +37 -10
- package/dist/storage/SourceTable.js +50 -14
- package/dist/storage/SourceTable.js.map +1 -1
- package/dist/storage/SyncRulesBucketStorage.d.ts +80 -24
- package/dist/storage/SyncRulesBucketStorage.js.map +1 -1
- package/dist/storage/implementation/BucketDefinitionMapping.d.ts +117 -0
- package/dist/storage/implementation/BucketDefinitionMapping.js +277 -0
- package/dist/storage/implementation/BucketDefinitionMapping.js.map +1 -0
- package/dist/storage/implementation/IncrementalReprocessingCompatibility.d.ts +6 -0
- package/dist/storage/implementation/IncrementalReprocessingCompatibility.js +31 -0
- package/dist/storage/implementation/IncrementalReprocessingCompatibility.js.map +1 -0
- package/dist/storage/implementation/IncrementalReprocessingSyncConfigLog.d.ts +17 -0
- package/dist/storage/implementation/IncrementalReprocessingSyncConfigLog.js +62 -0
- package/dist/storage/implementation/IncrementalReprocessingSyncConfigLog.js.map +1 -0
- package/dist/storage/implementation/ReplicationStreamStorageIds.d.ts +15 -0
- package/dist/storage/implementation/ReplicationStreamStorageIds.js +20 -0
- package/dist/storage/implementation/ReplicationStreamStorageIds.js.map +1 -0
- package/dist/storage/storage-index.d.ts +8 -1
- package/dist/storage/storage-index.js +8 -1
- package/dist/storage/storage-index.js.map +1 -1
- package/dist/sync/BucketChecksumState.d.ts +4 -4
- package/dist/sync/BucketChecksumState.js +1 -1
- package/dist/sync/BucketChecksumState.js.map +1 -1
- package/dist/sync/sync.d.ts +2 -2
- package/dist/sync/sync.js +5 -0
- package/dist/sync/sync.js.map +1 -1
- package/dist/tracing/PerformanceTracer.d.ts +17 -1
- package/dist/tracing/PerformanceTracer.js +3 -0
- package/dist/tracing/PerformanceTracer.js.map +1 -1
- package/dist/util/checkpointing.js +1 -1
- package/dist/util/checkpointing.js.map +1 -1
- package/dist/util/config/types.d.ts +1 -1
- package/dist/util/lsn.d.ts +4 -0
- package/dist/util/lsn.js +10 -0
- package/dist/util/lsn.js.map +1 -1
- package/dist/util/util-index.d.ts +1 -0
- package/dist/util/util-index.js +1 -0
- package/dist/util/util-index.js.map +1 -1
- package/dist/util/utils.d.ts +5 -0
- package/dist/util/utils.js +7 -0
- package/dist/util/utils.js.map +1 -1
- package/package.json +6 -7
- package/src/api/RouteAPI.ts +2 -2
- package/src/api/diagnostics.ts +45 -28
- package/src/auth/RemoteJWKSCollector.ts +3 -1
- package/src/entry/commands/compact-action.ts +1 -1
- package/src/modules/AbstractModule.ts +6 -2
- package/src/replication/AbstractReplicator.ts +27 -26
- package/src/replication/RelationCache.ts +23 -4
- package/src/replication/ReplicationModule.ts +2 -3
- package/src/routes/configure-fastify.ts +8 -1
- package/src/routes/endpoints/admin.ts +75 -49
- package/src/routes/endpoints/checkpointing.ts +1 -1
- package/src/routes/endpoints/socket-route.ts +1 -1
- package/src/routes/endpoints/sync-rules.ts +23 -13
- package/src/routes/endpoints/sync-stream.ts +1 -1
- package/src/routes/route-register.ts +73 -4
- package/src/runner/teardown.ts +8 -8
- package/src/storage/BucketStorageBatch.ts +32 -7
- package/src/storage/BucketStorageFactory.ts +36 -40
- package/src/storage/ParsedSyncConfigSet.ts +25 -0
- package/src/storage/PersistedReplicationStream.ts +55 -0
- package/src/storage/PersistedSyncConfigContent.ts +188 -0
- package/src/storage/PersistedSyncConfigStatus.ts +14 -0
- package/src/storage/SourceEntity.ts +9 -1
- package/src/storage/SourceTable.ts +72 -21
- package/src/storage/SyncRulesBucketStorage.ts +87 -26
- package/src/storage/implementation/BucketDefinitionMapping.ts +436 -0
- package/src/storage/implementation/IncrementalReprocessingCompatibility.ts +41 -0
- package/src/storage/implementation/IncrementalReprocessingSyncConfigLog.ts +109 -0
- package/src/storage/implementation/ReplicationStreamStorageIds.ts +21 -0
- package/src/storage/storage-index.ts +9 -1
- package/src/sync/BucketChecksumState.ts +5 -5
- package/src/sync/sync.ts +8 -3
- package/src/tracing/PerformanceTracer.ts +24 -1
- package/src/util/checkpointing.ts +1 -1
- package/src/util/config/types.ts +1 -1
- package/src/util/lsn.ts +9 -0
- package/src/util/util-index.ts +1 -0
- package/src/util/utils.ts +8 -0
- package/test/src/auth.test.ts +11 -0
- package/test/src/diagnostics.test.ts +64 -33
- package/test/src/module-loader.test.ts +33 -1
- package/test/src/routes/admin.test.ts +180 -18
- package/test/src/routes/error-handler.integration.test.ts +275 -0
- package/test/src/routes/mocks.ts +6 -2
- package/test/src/routes/stream.test.ts +15 -4
- package/test/src/storage/SourceTable.test.ts +89 -0
- package/test/src/sync/BucketChecksumState.test.ts +25 -17
- package/tsconfig.json +1 -4
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/storage/PersistedSyncRulesContent.d.ts +0 -59
- package/dist/storage/PersistedSyncRulesContent.js +0 -100
- package/dist/storage/PersistedSyncRulesContent.js.map +0 -1
- package/src/storage/PersistedSyncRulesContent.ts +0 -174
|
@@ -15,34 +15,39 @@ import {
|
|
|
15
15
|
} from '@/index.js';
|
|
16
16
|
import { JSONBig } from '@powersync/service-jsonbig';
|
|
17
17
|
import {
|
|
18
|
+
nodeSqlite,
|
|
18
19
|
ParameterIndexLookupCreator,
|
|
20
|
+
ParameterLookupDefinitionId,
|
|
19
21
|
ParameterLookupRows,
|
|
22
|
+
ParameterLookupScope,
|
|
20
23
|
ScopedParameterLookup,
|
|
21
|
-
|
|
22
|
-
SqliteRow,
|
|
24
|
+
SourceTableRef,
|
|
23
25
|
SqlSyncRules,
|
|
24
26
|
TablePattern,
|
|
25
27
|
versionedHydrationState
|
|
26
28
|
} from '@powersync/service-sync-rules';
|
|
27
|
-
import
|
|
29
|
+
import * as sqlite from 'node:sqlite';
|
|
28
30
|
import { beforeEach, describe, expect, test } from 'vitest';
|
|
29
31
|
|
|
30
32
|
describe('BucketChecksumState', () => {
|
|
31
33
|
const LOOKUP_SOURCE: ParameterIndexLookupCreator = {
|
|
32
|
-
get
|
|
34
|
+
get sourceId(): ParameterLookupDefinitionId {
|
|
33
35
|
return {
|
|
34
36
|
lookupName: 'lookup',
|
|
35
|
-
queryId: '0'
|
|
36
|
-
source: LOOKUP_SOURCE
|
|
37
|
+
queryId: '0'
|
|
37
38
|
};
|
|
38
39
|
},
|
|
39
40
|
getSourceTables(): Set<TablePattern> {
|
|
40
41
|
return new Set();
|
|
41
42
|
},
|
|
42
|
-
|
|
43
|
-
return
|
|
43
|
+
createEvaluator() {
|
|
44
|
+
return {
|
|
45
|
+
evaluateParameterRow() {
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
};
|
|
44
49
|
},
|
|
45
|
-
tableSyncsParameters(_table:
|
|
50
|
+
tableSyncsParameters(_table: SourceTableRef): boolean {
|
|
46
51
|
return false;
|
|
47
52
|
}
|
|
48
53
|
};
|
|
@@ -60,7 +65,7 @@ bucket_definitions:
|
|
|
60
65
|
data: []
|
|
61
66
|
`,
|
|
62
67
|
{ defaultSchema: 'public' }
|
|
63
|
-
).config.hydrate({ hydrationState: versionedHydrationState(1) });
|
|
68
|
+
).config.hydrate({ hydrationState: versionedHydrationState(1), sqlite: nodeSqlite(sqlite) });
|
|
64
69
|
|
|
65
70
|
// global[1] and global[2]
|
|
66
71
|
const SYNC_RULES_GLOBAL_TWO = SqlSyncRules.fromYaml(
|
|
@@ -73,7 +78,7 @@ bucket_definitions:
|
|
|
73
78
|
data: []
|
|
74
79
|
`,
|
|
75
80
|
{ defaultSchema: 'public' }
|
|
76
|
-
).config.hydrate({ hydrationState: versionedHydrationState(2) });
|
|
81
|
+
).config.hydrate({ hydrationState: versionedHydrationState(2), sqlite: nodeSqlite(sqlite) });
|
|
77
82
|
|
|
78
83
|
// by_project[n]
|
|
79
84
|
const SYNC_RULES_DYNAMIC = SqlSyncRules.fromYaml(
|
|
@@ -84,7 +89,7 @@ bucket_definitions:
|
|
|
84
89
|
data: []
|
|
85
90
|
`,
|
|
86
91
|
{ defaultSchema: 'public' }
|
|
87
|
-
).config.hydrate({ hydrationState: versionedHydrationState(3) });
|
|
92
|
+
).config.hydrate({ hydrationState: versionedHydrationState(3), sqlite: nodeSqlite(sqlite) });
|
|
88
93
|
|
|
89
94
|
const syncContext = new SyncContext({
|
|
90
95
|
maxBuckets: 100,
|
|
@@ -655,7 +660,7 @@ config:
|
|
|
655
660
|
|
|
656
661
|
const rules = SqlSyncRules.fromYaml(source, {
|
|
657
662
|
defaultSchema: 'public'
|
|
658
|
-
}).config.hydrate({ hydrationState: versionedHydrationState(1) });
|
|
663
|
+
}).config.hydrate({ hydrationState: versionedHydrationState(1), sqlite: nodeSqlite(sqlite) });
|
|
659
664
|
|
|
660
665
|
return new BucketChecksumState({
|
|
661
666
|
syncContext,
|
|
@@ -921,7 +926,8 @@ streams:
|
|
|
921
926
|
`,
|
|
922
927
|
{ defaultSchema: 'public' }
|
|
923
928
|
).config.hydrate({
|
|
924
|
-
hydrationState: versionedHydrationState(1)
|
|
929
|
+
hydrationState: versionedHydrationState(1),
|
|
930
|
+
sqlite: nodeSqlite(sqlite)
|
|
925
931
|
});
|
|
926
932
|
|
|
927
933
|
const storage = new MockBucketChecksumStateStorage();
|
|
@@ -1018,7 +1024,8 @@ streams:
|
|
|
1018
1024
|
`,
|
|
1019
1025
|
{ defaultSchema: 'public' }
|
|
1020
1026
|
).config.hydrate({
|
|
1021
|
-
hydrationState: versionedHydrationState(1)
|
|
1027
|
+
hydrationState: versionedHydrationState(1),
|
|
1028
|
+
sqlite: nodeSqlite(sqlite)
|
|
1022
1029
|
});
|
|
1023
1030
|
|
|
1024
1031
|
const storage = new MockBucketChecksumStateStorage();
|
|
@@ -1090,7 +1097,7 @@ streams:
|
|
|
1090
1097
|
query: SELECT id FROM comments WHERE p IN auth.parameter('c')
|
|
1091
1098
|
`,
|
|
1092
1099
|
{ defaultSchema: 'public' }
|
|
1093
|
-
).config.hydrate({ hydrationState: versionedHydrationState(4) });
|
|
1100
|
+
).config.hydrate({ hydrationState: versionedHydrationState(4), sqlite: nodeSqlite(sqlite) });
|
|
1094
1101
|
|
|
1095
1102
|
const storage = new MockBucketChecksumStateStorage();
|
|
1096
1103
|
|
|
@@ -1165,7 +1172,8 @@ streams:
|
|
|
1165
1172
|
}
|
|
1166
1173
|
|
|
1167
1174
|
const SYNC_RULES_MANY = SqlSyncRules.fromYaml(yamlDefinitions, { defaultSchema: 'public' }).config.hydrate({
|
|
1168
|
-
hydrationState: versionedHydrationState(5)
|
|
1175
|
+
hydrationState: versionedHydrationState(5),
|
|
1176
|
+
sqlite: nodeSqlite(sqlite)
|
|
1169
1177
|
});
|
|
1170
1178
|
|
|
1171
1179
|
const storage = new MockBucketChecksumStateStorage();
|
package/tsconfig.json
CHANGED