@powersync/service-core 0.0.0-dev-20250122110924 → 0.0.0-dev-20250227082606
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 +84 -9
- package/dist/api/RouteAPI.d.ts +9 -1
- package/dist/api/diagnostics.js +107 -169
- package/dist/api/diagnostics.js.map +1 -1
- package/dist/auth/CachedKeyCollector.js +26 -25
- package/dist/auth/CachedKeyCollector.js.map +1 -1
- package/dist/auth/CompoundKeyCollector.js +1 -0
- package/dist/auth/CompoundKeyCollector.js.map +1 -1
- package/dist/auth/KeySpec.js +3 -0
- package/dist/auth/KeySpec.js.map +1 -1
- package/dist/auth/KeyStore.js +4 -0
- package/dist/auth/KeyStore.js.map +1 -1
- package/dist/auth/LeakyBucket.js +5 -0
- package/dist/auth/LeakyBucket.js.map +1 -1
- package/dist/auth/RemoteJWKSCollector.js +4 -1
- package/dist/auth/RemoteJWKSCollector.js.map +1 -1
- package/dist/auth/StaticKeyCollector.js +1 -0
- package/dist/auth/StaticKeyCollector.js.map +1 -1
- package/dist/auth/StaticSupabaseKeyCollector.js +1 -0
- package/dist/auth/StaticSupabaseKeyCollector.js.map +1 -1
- package/dist/entry/commands/compact-action.js +10 -73
- package/dist/entry/commands/compact-action.js.map +1 -1
- package/dist/metrics/Metrics.js +35 -1
- package/dist/metrics/Metrics.js.map +1 -1
- package/dist/modules/AbstractModule.d.ts +1 -1
- package/dist/modules/AbstractModule.js +2 -0
- package/dist/modules/AbstractModule.js.map +1 -1
- package/dist/modules/ModuleManager.js +1 -3
- package/dist/modules/ModuleManager.js.map +1 -1
- package/dist/replication/AbstractReplicationJob.js +4 -2
- package/dist/replication/AbstractReplicationJob.js.map +1 -1
- package/dist/replication/AbstractReplicator.js +26 -88
- package/dist/replication/AbstractReplicator.js.map +1 -1
- package/dist/replication/ReplicationEngine.js +1 -3
- package/dist/replication/ReplicationEngine.js.map +1 -1
- package/dist/replication/ReplicationModule.js +3 -0
- package/dist/replication/ReplicationModule.js.map +1 -1
- package/dist/routes/RouterEngine.js +8 -0
- package/dist/routes/RouterEngine.js.map +1 -1
- package/dist/routes/configure-fastify.d.ts +3 -3
- package/dist/routes/endpoints/admin.d.ts +6 -6
- package/dist/routes/endpoints/admin.js +4 -1
- package/dist/routes/endpoints/admin.js.map +1 -1
- package/dist/routes/endpoints/checkpointing.js +17 -86
- package/dist/routes/endpoints/checkpointing.js.map +1 -1
- package/dist/routes/endpoints/socket-route.js +7 -6
- package/dist/routes/endpoints/socket-route.js.map +1 -1
- package/dist/routes/endpoints/sync-rules.js +7 -2
- package/dist/routes/endpoints/sync-rules.js.map +1 -1
- package/dist/routes/endpoints/sync-stream.js +7 -6
- package/dist/routes/endpoints/sync-stream.js.map +1 -1
- package/dist/runner/teardown.js +5 -67
- package/dist/runner/teardown.js.map +1 -1
- package/dist/storage/BucketStorage.d.ts +8 -414
- package/dist/storage/BucketStorage.js +9 -7
- package/dist/storage/BucketStorage.js.map +1 -1
- package/dist/storage/BucketStorageBatch.d.ts +130 -0
- package/dist/storage/BucketStorageBatch.js +10 -0
- package/dist/storage/BucketStorageBatch.js.map +1 -0
- package/dist/storage/BucketStorageFactory.d.ts +145 -0
- package/dist/storage/BucketStorageFactory.js +2 -0
- package/dist/storage/BucketStorageFactory.js.map +1 -0
- package/dist/storage/ChecksumCache.js +12 -7
- package/dist/storage/ChecksumCache.js.map +1 -1
- package/dist/storage/PersistedSyncRulesContent.d.ts +20 -0
- package/dist/storage/PersistedSyncRulesContent.js +2 -0
- package/dist/storage/PersistedSyncRulesContent.js.map +1 -0
- package/dist/storage/ReplicationEventPayload.d.ts +1 -1
- package/dist/storage/ReplicationLock.d.ts +4 -0
- package/dist/storage/ReplicationLock.js +2 -0
- package/dist/storage/ReplicationLock.js.map +1 -0
- package/dist/storage/SourceEntity.d.ts +6 -2
- package/dist/storage/SourceTable.d.ts +2 -2
- package/dist/storage/SourceTable.js +32 -25
- package/dist/storage/SourceTable.js.map +1 -1
- package/dist/storage/StorageEngine.d.ts +4 -4
- package/dist/storage/StorageEngine.js +6 -5
- package/dist/storage/StorageEngine.js.map +1 -1
- package/dist/storage/StorageProvider.d.ts +4 -1
- package/dist/storage/SyncRulesBucketStorage.d.ts +207 -0
- package/dist/storage/SyncRulesBucketStorage.js +7 -0
- package/dist/storage/SyncRulesBucketStorage.js.map +1 -0
- package/dist/storage/bson.d.ts +19 -6
- package/dist/storage/bson.js +18 -2
- package/dist/storage/bson.js.map +1 -1
- package/dist/storage/storage-index.d.ts +5 -0
- package/dist/storage/storage-index.js +5 -0
- package/dist/storage/storage-index.js.map +1 -1
- package/dist/sync/BroadcastIterable.js +4 -3
- package/dist/sync/BroadcastIterable.js.map +1 -1
- package/dist/sync/BucketChecksumState.d.ts +95 -0
- package/dist/sync/BucketChecksumState.js +321 -0
- package/dist/sync/BucketChecksumState.js.map +1 -0
- package/dist/sync/LastValueSink.js +2 -0
- package/dist/sync/LastValueSink.js.map +1 -1
- package/dist/sync/RequestTracker.js +2 -4
- package/dist/sync/RequestTracker.js.map +1 -1
- package/dist/sync/SyncContext.d.ts +17 -0
- package/dist/sync/SyncContext.js +23 -0
- package/dist/sync/SyncContext.js.map +1 -0
- package/dist/sync/merge.js +4 -0
- package/dist/sync/merge.js.map +1 -1
- package/dist/sync/sync-index.d.ts +2 -0
- package/dist/sync/sync-index.js +2 -0
- package/dist/sync/sync-index.js.map +1 -1
- package/dist/sync/sync.d.ts +10 -4
- package/dist/sync/sync.js +143 -149
- package/dist/sync/sync.js.map +1 -1
- package/dist/sync/util.d.ts +9 -0
- package/dist/sync/util.js +46 -2
- package/dist/sync/util.js.map +1 -1
- package/dist/system/ServiceContext.d.ts +3 -0
- package/dist/system/ServiceContext.js +10 -0
- package/dist/system/ServiceContext.js.map +1 -1
- package/dist/util/Mutex.js +5 -0
- package/dist/util/Mutex.js.map +1 -1
- package/dist/util/checkpointing.d.ts +13 -0
- package/dist/util/checkpointing.js +29 -0
- package/dist/util/checkpointing.js.map +1 -0
- package/dist/util/config/compound-config-collector.js +16 -2
- package/dist/util/config/compound-config-collector.js.map +1 -1
- package/dist/util/config/defaults.d.ts +5 -0
- package/dist/util/config/defaults.js +6 -0
- package/dist/util/config/defaults.js.map +1 -0
- package/dist/util/config/sync-rules/impl/base64-sync-rules-collector.js +1 -0
- package/dist/util/config/sync-rules/impl/base64-sync-rules-collector.js.map +1 -1
- package/dist/util/config/sync-rules/impl/filesystem-sync-rules-collector.js +1 -0
- package/dist/util/config/sync-rules/impl/filesystem-sync-rules-collector.js.map +1 -1
- package/dist/util/config/sync-rules/impl/inline-sync-rules-collector.js +1 -0
- package/dist/util/config/sync-rules/impl/inline-sync-rules-collector.js.map +1 -1
- package/dist/util/config/sync-rules/sync-rules-provider.d.ts +2 -0
- package/dist/util/config/sync-rules/sync-rules-provider.js +4 -0
- package/dist/util/config/sync-rules/sync-rules-provider.js.map +1 -1
- package/dist/util/config/types.d.ts +8 -2
- package/dist/util/config/types.js.map +1 -1
- package/dist/util/memory-tracking.js +1 -1
- package/dist/util/memory-tracking.js.map +1 -1
- package/dist/util/protocol-types.d.ts +13 -4
- 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 +0 -1
- package/dist/util/utils.js +0 -9
- package/dist/util/utils.js.map +1 -1
- package/package.json +6 -6
- package/src/api/RouteAPI.ts +11 -1
- package/src/api/diagnostics.ts +1 -1
- package/src/entry/commands/compact-action.ts +2 -3
- package/src/modules/AbstractModule.ts +1 -1
- package/src/replication/AbstractReplicator.ts +16 -15
- package/src/routes/RouterEngine.ts +1 -0
- package/src/routes/endpoints/admin.ts +4 -1
- package/src/routes/endpoints/checkpointing.ts +11 -22
- package/src/routes/endpoints/socket-route.ts +9 -6
- package/src/routes/endpoints/sync-rules.ts +7 -2
- package/src/routes/endpoints/sync-stream.ts +10 -6
- package/src/runner/teardown.ts +1 -1
- package/src/storage/BucketStorage.ts +8 -515
- package/src/storage/BucketStorageBatch.ts +158 -0
- package/src/storage/BucketStorageFactory.ts +166 -0
- package/src/storage/ChecksumCache.ts +1 -0
- package/src/storage/PersistedSyncRulesContent.ts +26 -0
- package/src/storage/ReplicationEventPayload.ts +1 -1
- package/src/storage/ReplicationLock.ts +5 -0
- package/src/storage/SourceEntity.ts +6 -2
- package/src/storage/SourceTable.ts +1 -1
- package/src/storage/StorageEngine.ts +4 -4
- package/src/storage/StorageProvider.ts +4 -1
- package/src/storage/SyncRulesBucketStorage.ts +265 -0
- package/src/storage/bson.ts +31 -11
- package/src/storage/storage-index.ts +5 -0
- package/src/sync/BucketChecksumState.ts +418 -0
- package/src/sync/SyncContext.ts +36 -0
- package/src/sync/sync-index.ts +2 -0
- package/src/sync/sync.ts +199 -177
- package/src/sync/util.ts +54 -0
- package/src/system/ServiceContext.ts +9 -0
- package/src/util/checkpointing.ts +41 -0
- package/src/util/config/compound-config-collector.ts +26 -2
- package/src/util/config/defaults.ts +5 -0
- package/src/util/config/sync-rules/impl/base64-sync-rules-collector.ts +1 -0
- package/src/util/config/sync-rules/impl/filesystem-sync-rules-collector.ts +1 -0
- package/src/util/config/sync-rules/impl/inline-sync-rules-collector.ts +1 -0
- package/src/util/config/sync-rules/sync-rules-provider.ts +6 -0
- package/src/util/config/types.ts +9 -2
- package/src/util/memory-tracking.ts +2 -2
- package/src/util/protocol-types.ts +16 -4
- package/src/util/util-index.ts +1 -0
- package/src/util/utils.ts +0 -10
- package/test/src/auth.test.ts +5 -5
- package/test/src/sync/BucketChecksumState.test.ts +580 -0
- package/test/src/sync/util.test.ts +34 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { ObserverClient } from '@powersync/lib-services-framework';
|
|
2
|
+
import { ParseSyncRulesOptions, PersistedSyncRules, PersistedSyncRulesContent } from './PersistedSyncRulesContent.js';
|
|
3
|
+
import { ReplicationEventPayload } from './ReplicationEventPayload.js';
|
|
4
|
+
import { ReplicationLock } from './ReplicationLock.js';
|
|
5
|
+
import { SyncRulesBucketStorage } from './SyncRulesBucketStorage.js';
|
|
6
|
+
/**
|
|
7
|
+
* Represents a configured storage provider.
|
|
8
|
+
*
|
|
9
|
+
* The provider can handle multiple copies of sync rules concurrently, each with their own storage.
|
|
10
|
+
* This is to handle replication of a new version of sync rules, while the old version is still active.
|
|
11
|
+
*
|
|
12
|
+
* Storage APIs for a specific copy of sync rules are provided by the `SyncRulesBucketStorage` instances.
|
|
13
|
+
*/
|
|
14
|
+
export interface BucketStorageFactory extends ObserverClient<BucketStorageFactoryListener>, AsyncDisposable {
|
|
15
|
+
/**
|
|
16
|
+
* Update sync rules from configuration, if changed.
|
|
17
|
+
*/
|
|
18
|
+
configureSyncRules(options: UpdateSyncRulesOptions): Promise<{
|
|
19
|
+
updated: boolean;
|
|
20
|
+
persisted_sync_rules?: PersistedSyncRulesContent;
|
|
21
|
+
lock?: ReplicationLock;
|
|
22
|
+
}>;
|
|
23
|
+
/**
|
|
24
|
+
* Get a storage instance to query sync data for specific sync rules.
|
|
25
|
+
*/
|
|
26
|
+
getInstance(syncRules: PersistedSyncRulesContent, options?: GetIntanceOptions): SyncRulesBucketStorage;
|
|
27
|
+
/**
|
|
28
|
+
* Deploy new sync rules.
|
|
29
|
+
*/
|
|
30
|
+
updateSyncRules(options: UpdateSyncRulesOptions): Promise<PersistedSyncRulesContent>;
|
|
31
|
+
/**
|
|
32
|
+
* Indicate that a slot was removed, and we should re-sync by creating
|
|
33
|
+
* a new sync rules instance.
|
|
34
|
+
*
|
|
35
|
+
* This is roughly the same as deploying a new version of the current sync
|
|
36
|
+
* rules, but also accounts for cases where the current sync rules are not
|
|
37
|
+
* the latest ones.
|
|
38
|
+
*
|
|
39
|
+
* Replication should be restarted after this.
|
|
40
|
+
*/
|
|
41
|
+
restartReplication(sync_rules_group_id: number): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Get the sync rules used for querying.
|
|
44
|
+
*/
|
|
45
|
+
getActiveSyncRules(options: ParseSyncRulesOptions): Promise<PersistedSyncRules | null>;
|
|
46
|
+
/**
|
|
47
|
+
* Get the sync rules used for querying.
|
|
48
|
+
*/
|
|
49
|
+
getActiveSyncRulesContent(): Promise<PersistedSyncRulesContent | null>;
|
|
50
|
+
/**
|
|
51
|
+
* Get the sync rules that will be active next once done with initial replicatino.
|
|
52
|
+
*/
|
|
53
|
+
getNextSyncRules(options: ParseSyncRulesOptions): Promise<PersistedSyncRules | null>;
|
|
54
|
+
/**
|
|
55
|
+
* Get the sync rules that will be active next once done with initial replicatino.
|
|
56
|
+
*/
|
|
57
|
+
getNextSyncRulesContent(): Promise<PersistedSyncRulesContent | null>;
|
|
58
|
+
/**
|
|
59
|
+
* Get all sync rules currently replicating. Typically this is the "active" and "next" sync rules.
|
|
60
|
+
*/
|
|
61
|
+
getReplicatingSyncRules(): Promise<PersistedSyncRulesContent[]>;
|
|
62
|
+
/**
|
|
63
|
+
* Get all sync rules stopped but not terminated yet.
|
|
64
|
+
*/
|
|
65
|
+
getStoppedSyncRules(): Promise<PersistedSyncRulesContent[]>;
|
|
66
|
+
/**
|
|
67
|
+
* Get the active storage instance.
|
|
68
|
+
*/
|
|
69
|
+
getActiveStorage(): Promise<SyncRulesBucketStorage | null>;
|
|
70
|
+
/**
|
|
71
|
+
* Get storage size of active sync rules.
|
|
72
|
+
*/
|
|
73
|
+
getStorageMetrics(): Promise<StorageMetrics>;
|
|
74
|
+
/**
|
|
75
|
+
* Get the unique identifier for this instance of Powersync
|
|
76
|
+
*/
|
|
77
|
+
getPowerSyncInstanceId(): Promise<string>;
|
|
78
|
+
/**
|
|
79
|
+
* Get a unique identifier for the system used for storage.
|
|
80
|
+
*/
|
|
81
|
+
getSystemIdentifier(): Promise<BucketStorageSystemIdentifier>;
|
|
82
|
+
}
|
|
83
|
+
export interface BucketStorageFactoryListener {
|
|
84
|
+
syncStorageCreated: (storage: SyncRulesBucketStorage) => void;
|
|
85
|
+
replicationEvent: (event: ReplicationEventPayload) => void;
|
|
86
|
+
}
|
|
87
|
+
export interface StorageMetrics {
|
|
88
|
+
/**
|
|
89
|
+
* Size of operations (bucket_data)
|
|
90
|
+
*/
|
|
91
|
+
operations_size_bytes: number;
|
|
92
|
+
/**
|
|
93
|
+
* Size of parameter storage.
|
|
94
|
+
*
|
|
95
|
+
* Replication storage -> raw data as received from Postgres.
|
|
96
|
+
*/
|
|
97
|
+
parameters_size_bytes: number;
|
|
98
|
+
/**
|
|
99
|
+
* Size of current_data.
|
|
100
|
+
*/
|
|
101
|
+
replication_size_bytes: number;
|
|
102
|
+
}
|
|
103
|
+
export interface UpdateSyncRulesOptions {
|
|
104
|
+
content: string;
|
|
105
|
+
lock?: boolean;
|
|
106
|
+
validate?: boolean;
|
|
107
|
+
}
|
|
108
|
+
export interface GetIntanceOptions {
|
|
109
|
+
/**
|
|
110
|
+
* Set to true to skip trigger any events for creating the instance.
|
|
111
|
+
*
|
|
112
|
+
* This is used when creating the instance only for clearing data.
|
|
113
|
+
*
|
|
114
|
+
* When this is used, note that some functionality such as write checkpoint mode
|
|
115
|
+
* may not be configured correctly.
|
|
116
|
+
*/
|
|
117
|
+
skipLifecycleHooks?: boolean;
|
|
118
|
+
}
|
|
119
|
+
export interface BucketStorageSystemIdentifier {
|
|
120
|
+
/**
|
|
121
|
+
* A unique identifier for the system used for storage.
|
|
122
|
+
* For Postgres this can be the cluster `system_identifier` and database name.
|
|
123
|
+
* For MongoDB this can be the replica set name.
|
|
124
|
+
*/
|
|
125
|
+
id: string;
|
|
126
|
+
/**
|
|
127
|
+
* A unique type for the storage implementation.
|
|
128
|
+
* e.g. `mongodb`, `postgresql`.
|
|
129
|
+
*/
|
|
130
|
+
type: string;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Helper for tests.
|
|
134
|
+
* This is not in the `service-core-tests` package in order for storage modules
|
|
135
|
+
* to provide relevant factories without requiring `service-core-tests` as a direct dependency.
|
|
136
|
+
*/
|
|
137
|
+
export interface TestStorageOptions {
|
|
138
|
+
/**
|
|
139
|
+
* By default, collections are only cleared/
|
|
140
|
+
* Setting this to true will drop the collections completely.
|
|
141
|
+
*/
|
|
142
|
+
dropAll?: boolean;
|
|
143
|
+
doNotClear?: boolean;
|
|
144
|
+
}
|
|
145
|
+
export type TestStorageFactory = (options?: TestStorageOptions) => Promise<BucketStorageFactory>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BucketStorageFactory.js","sourceRoot":"","sources":["../../src/storage/BucketStorageFactory.ts"],"names":[],"mappings":""}
|
|
@@ -2,8 +2,8 @@ import { addBucketChecksums } from '../util/utils.js';
|
|
|
2
2
|
import { LRUCache } from 'lru-cache/min';
|
|
3
3
|
import { OrderedSet } from '@js-sdsl/ordered-set';
|
|
4
4
|
// Approximately 5MB of memory, if we assume 50 bytes per entry
|
|
5
|
-
const DEFAULT_MAX_SIZE =
|
|
6
|
-
const TTL_MS =
|
|
5
|
+
const DEFAULT_MAX_SIZE = 100_000;
|
|
6
|
+
const TTL_MS = 3_600_000;
|
|
7
7
|
/**
|
|
8
8
|
* Implement a LRU cache for checksum requests. Each (bucket, checkpoint) request is cached separately,
|
|
9
9
|
* while the lookups occur in batches.
|
|
@@ -14,11 +14,16 @@ const TTL_MS = 3600000;
|
|
|
14
14
|
* We use the LRUCache fetchMethod to deduplicate in-progress requests.
|
|
15
15
|
*/
|
|
16
16
|
export class ChecksumCache {
|
|
17
|
+
/**
|
|
18
|
+
* The primary checksum cache, with key of `${checkpoint}/${bucket}`.
|
|
19
|
+
*/
|
|
20
|
+
cache;
|
|
21
|
+
/**
|
|
22
|
+
* For each bucket, an ordered set of cached checkpoints.
|
|
23
|
+
*/
|
|
24
|
+
bucketCheckpoints = new Map();
|
|
25
|
+
fetchChecksums;
|
|
17
26
|
constructor(options) {
|
|
18
|
-
/**
|
|
19
|
-
* For each bucket, an ordered set of cached checkpoints.
|
|
20
|
-
*/
|
|
21
|
-
this.bucketCheckpoints = new Map();
|
|
22
27
|
this.fetchChecksums = options.fetchChecksums;
|
|
23
28
|
this.cache = new LRUCache({
|
|
24
29
|
max: options.maxSize ?? DEFAULT_MAX_SIZE,
|
|
@@ -57,7 +62,7 @@ export class ChecksumCache {
|
|
|
57
62
|
// after a compact. This only has effect if the bucket has
|
|
58
63
|
// not been checked in the meantime.
|
|
59
64
|
ttl: TTL_MS,
|
|
60
|
-
ttlResolution:
|
|
65
|
+
ttlResolution: 1_000,
|
|
61
66
|
allowStale: false
|
|
62
67
|
});
|
|
63
68
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChecksumCache.js","sourceRoot":"","sources":["../../src/storage/ChecksumCache.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"ChecksumCache.js","sourceRoot":"","sources":["../../src/storage/ChecksumCache.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAmDlD,+DAA+D;AAC/D,MAAM,gBAAgB,GAAG,OAAO,CAAC;AAEjC,MAAM,MAAM,GAAG,SAAS,CAAC;AAEzB;;;;;;;;GAQG;AACH,MAAM,OAAO,aAAa;IACxB;;OAEG;IACK,KAAK,CAAyD;IACtE;;OAEG;IACK,iBAAiB,GAAG,IAAI,GAAG,EAA8B,CAAC;IAE1D,cAAc,CAAiB;IAEvC,YAAY,OAA6B;QACvC,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;QAE7C,IAAI,CAAC,KAAK,GAAG,IAAI,QAAQ,CAA+C;YACtE,GAAG,EAA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ationLock.js';
|
|
3
|
+
export interface ParseSyncRulesOptions {
|
|
4
|
+
defaultSchema: string;
|
|
5
|
+
}
|
|
6
|
+
export interface PersistedSyncRulesContent {
|
|
7
|
+
readonly id: number;
|
|
8
|
+
readonly sync_rules_content: string;
|
|
9
|
+
readonly slot_name: string;
|
|
10
|
+
readonly last_fatal_error?: string | null;
|
|
11
|
+
readonly last_keepalive_ts?: Date | null;
|
|
12
|
+
readonly last_checkpoint_ts?: Date | null;
|
|
13
|
+
parsed(options: ParseSyncRulesOptions): PersistedSyncRules;
|
|
14
|
+
lock(): Promise<ReplicationLock>;
|
|
15
|
+
}
|
|
16
|
+
export interface PersistedSyncRules {
|
|
17
|
+
readonly id: number;
|
|
18
|
+
readonly sync_rules: SqlSyncRules;
|
|
19
|
+
readonly slot_name: string;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PersistedSyncRulesContent.js","sourceRoot":"","sources":["../../src/storage/PersistedSyncRulesContent.ts"],"names":[],"mappings":""}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as sync_rules from '@powersync/service-sync-rules';
|
|
2
|
-
import { BucketStorageBatch, SaveOp } from './BucketStorage.js';
|
|
3
2
|
import { SourceTable } from './SourceTable.js';
|
|
3
|
+
import { BucketStorageBatch, SaveOp } from './BucketStorageBatch.js';
|
|
4
4
|
export type EventData = {
|
|
5
5
|
op: SaveOp;
|
|
6
6
|
before?: sync_rules.SqliteRow;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReplicationLock.js","sourceRoot":"","sources":["../../src/storage/ReplicationLock.ts"],"names":[],"mappings":""}
|
|
@@ -11,9 +11,13 @@ export interface ColumnDescriptor {
|
|
|
11
11
|
}
|
|
12
12
|
export interface SourceEntityDescriptor {
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* The internal id of the data source structure in the database.
|
|
15
|
+
*
|
|
16
|
+
* If undefined, the schema and name are used as the identifier.
|
|
17
|
+
*
|
|
18
|
+
* If specified, this is specifically used to detect renames.
|
|
15
19
|
*/
|
|
16
|
-
objectId: number | string;
|
|
20
|
+
objectId: number | string | undefined;
|
|
17
21
|
schema: string;
|
|
18
22
|
name: string;
|
|
19
23
|
replicationColumns: ColumnDescriptor[];
|
|
@@ -2,7 +2,7 @@ import { ColumnDescriptor } from './SourceEntity.js';
|
|
|
2
2
|
export declare class SourceTable {
|
|
3
3
|
readonly id: any;
|
|
4
4
|
readonly connectionTag: string;
|
|
5
|
-
readonly objectId: number | string;
|
|
5
|
+
readonly objectId: number | string | undefined;
|
|
6
6
|
readonly schema: string;
|
|
7
7
|
readonly table: string;
|
|
8
8
|
readonly replicaIdColumns: ColumnDescriptor[];
|
|
@@ -32,7 +32,7 @@ export declare class SourceTable {
|
|
|
32
32
|
* Defaults to true for tests.
|
|
33
33
|
*/
|
|
34
34
|
syncEvent: boolean;
|
|
35
|
-
constructor(id: any, connectionTag: string, objectId: number | string, schema: string, table: string, replicaIdColumns: ColumnDescriptor[], snapshotComplete: boolean);
|
|
35
|
+
constructor(id: any, connectionTag: string, objectId: number | string | undefined, schema: string, table: string, replicaIdColumns: ColumnDescriptor[], snapshotComplete: boolean);
|
|
36
36
|
get hasReplicaIdentity(): boolean;
|
|
37
37
|
/**
|
|
38
38
|
* Use for postgres only.
|
|
@@ -1,6 +1,38 @@
|
|
|
1
1
|
import { DEFAULT_TAG } from '@powersync/service-sync-rules';
|
|
2
2
|
import * as util from '../util/util-index.js';
|
|
3
3
|
export class SourceTable {
|
|
4
|
+
id;
|
|
5
|
+
connectionTag;
|
|
6
|
+
objectId;
|
|
7
|
+
schema;
|
|
8
|
+
table;
|
|
9
|
+
replicaIdColumns;
|
|
10
|
+
snapshotComplete;
|
|
11
|
+
static DEFAULT_TAG = DEFAULT_TAG;
|
|
12
|
+
/**
|
|
13
|
+
* True if the table is used in sync rules for data queries.
|
|
14
|
+
*
|
|
15
|
+
* This value is resolved externally, and cached here.
|
|
16
|
+
*
|
|
17
|
+
* Defaults to true for tests.
|
|
18
|
+
*/
|
|
19
|
+
syncData = true;
|
|
20
|
+
/**
|
|
21
|
+
* True if the table is used in sync rules for data queries.
|
|
22
|
+
*
|
|
23
|
+
* This value is resolved externally, and cached here.
|
|
24
|
+
*
|
|
25
|
+
* Defaults to true for tests.
|
|
26
|
+
*/
|
|
27
|
+
syncParameters = true;
|
|
28
|
+
/**
|
|
29
|
+
* True if the table is used in sync rules for events.
|
|
30
|
+
*
|
|
31
|
+
* This value is resolved externally, and cached here.
|
|
32
|
+
*
|
|
33
|
+
* Defaults to true for tests.
|
|
34
|
+
*/
|
|
35
|
+
syncEvent = true;
|
|
4
36
|
constructor(id, connectionTag, objectId, schema, table, replicaIdColumns, snapshotComplete) {
|
|
5
37
|
this.id = id;
|
|
6
38
|
this.connectionTag = connectionTag;
|
|
@@ -9,30 +41,6 @@ export class SourceTable {
|
|
|
9
41
|
this.table = table;
|
|
10
42
|
this.replicaIdColumns = replicaIdColumns;
|
|
11
43
|
this.snapshotComplete = snapshotComplete;
|
|
12
|
-
/**
|
|
13
|
-
* True if the table is used in sync rules for data queries.
|
|
14
|
-
*
|
|
15
|
-
* This value is resolved externally, and cached here.
|
|
16
|
-
*
|
|
17
|
-
* Defaults to true for tests.
|
|
18
|
-
*/
|
|
19
|
-
this.syncData = true;
|
|
20
|
-
/**
|
|
21
|
-
* True if the table is used in sync rules for data queries.
|
|
22
|
-
*
|
|
23
|
-
* This value is resolved externally, and cached here.
|
|
24
|
-
*
|
|
25
|
-
* Defaults to true for tests.
|
|
26
|
-
*/
|
|
27
|
-
this.syncParameters = true;
|
|
28
|
-
/**
|
|
29
|
-
* True if the table is used in sync rules for events.
|
|
30
|
-
*
|
|
31
|
-
* This value is resolved externally, and cached here.
|
|
32
|
-
*
|
|
33
|
-
* Defaults to true for tests.
|
|
34
|
-
*/
|
|
35
|
-
this.syncEvent = true;
|
|
36
44
|
}
|
|
37
45
|
get hasReplicaIdentity() {
|
|
38
46
|
return this.replicaIdColumns.length > 0;
|
|
@@ -57,5 +65,4 @@ export class SourceTable {
|
|
|
57
65
|
return this.syncData || this.syncParameters || this.syncEvent;
|
|
58
66
|
}
|
|
59
67
|
}
|
|
60
|
-
SourceTable.DEFAULT_TAG = DEFAULT_TAG;
|
|
61
68
|
//# sourceMappingURL=SourceTable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SourceTable.js","sourceRoot":"","sources":["../../src/storage/SourceTable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,KAAK,IAAI,MAAM,uBAAuB,CAAC;AAG9C,MAAM,OAAO,WAAW;
|
|
1
|
+
{"version":3,"file":"SourceTable.js","sourceRoot":"","sources":["../../src/storage/SourceTable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,KAAK,IAAI,MAAM,uBAAuB,CAAC;AAG9C,MAAM,OAAO,WAAW;IA+BJ;IACA;IACA;IACA;IACA;IAEA;IACA;IArClB,MAAM,CAAU,WAAW,GAAG,WAAW,CAAC;IAE1C;;;;;;OAMG;IACI,QAAQ,GAAG,IAAI,CAAC;IAEvB;;;;;;OAMG;IACI,cAAc,GAAG,IAAI,CAAC;IAE7B;;;;;;OAMG;IACI,SAAS,GAAG,IAAI,CAAC;IAExB,YACkB,EAAO,EACP,aAAqB,EACrB,QAAqC,EACrC,MAAc,EACd,KAAa,EAEb,gBAAoC,EACpC,gBAAyB;QAPzB,OAAE,GAAF,EAAE,CAAK;QACP,kBAAa,GAAb,aAAa,CAAQ;QACrB,aAAQ,GAAR,QAAQ,CAA6B;QACrC,WAAM,GAAN,MAAM,CAAQ;QACd,UAAK,GAAL,KAAK,CAAQ;QAEb,qBAAgB,GAAhB,gBAAgB,CAAoB;QACpC,qBAAgB,GAAhB,gBAAgB,CAAS;IACxC,CAAC;IAEJ,IAAI,kBAAkB;QACpB,OAAO,IAAI,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC;IAC1C,CAAC;IAED;;;;OAIG;IACH,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAChC,CAAC;IAED;;;;OAIG;IACH,IAAI,iBAAiB;QACnB,OAAO,GAAG,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;IACtF,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,SAAS,CAAC;IAChE,CAAC"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseObserver } from '@powersync/lib-services-framework';
|
|
2
2
|
import { ResolvedPowerSyncConfig } from '../util/util-index.js';
|
|
3
|
-
import { BucketStorageFactory } from './BucketStorage.js';
|
|
4
3
|
import { ActiveStorage, BucketStorageProvider } from './StorageProvider.js';
|
|
4
|
+
import { BucketStorageFactory } from './BucketStorageFactory.js';
|
|
5
5
|
export type StorageEngineOptions = {
|
|
6
6
|
configuration: ResolvedPowerSyncConfig;
|
|
7
7
|
};
|
|
8
|
-
export interface StorageEngineListener
|
|
8
|
+
export interface StorageEngineListener {
|
|
9
9
|
storageActivated: (storage: BucketStorageFactory) => void;
|
|
10
10
|
}
|
|
11
|
-
export declare class StorageEngine extends
|
|
11
|
+
export declare class StorageEngine extends BaseObserver<StorageEngineListener> {
|
|
12
12
|
private options;
|
|
13
13
|
private storageProviders;
|
|
14
14
|
private currentActiveStorage;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export class StorageEngine extends
|
|
1
|
+
import { BaseObserver, logger } from '@powersync/lib-services-framework';
|
|
2
|
+
export class StorageEngine extends BaseObserver {
|
|
3
|
+
options;
|
|
4
|
+
// TODO: This will need to revisited when we actually support multiple storage providers.
|
|
5
|
+
storageProviders = new Map();
|
|
6
|
+
currentActiveStorage = null;
|
|
3
7
|
constructor(options) {
|
|
4
8
|
super();
|
|
5
9
|
this.options = options;
|
|
6
|
-
// TODO: This will need to revisited when we actually support multiple storage providers.
|
|
7
|
-
this.storageProviders = new Map();
|
|
8
|
-
this.currentActiveStorage = null;
|
|
9
10
|
}
|
|
10
11
|
get activeBucketStorage() {
|
|
11
12
|
return this.activeStorage.storage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StorageEngine.js","sourceRoot":"","sources":["../../src/storage/StorageEngine.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"StorageEngine.js","sourceRoot":"","sources":["../../src/storage/StorageEngine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAazE,MAAM,OAAO,aAAc,SAAQ,YAAmC;IAKhD;IAJpB,yFAAyF;IACjF,gBAAgB,GAAuC,IAAI,GAAG,EAAE,CAAC;IACjE,oBAAoB,GAAyB,IAAI,CAAC;IAE1D,YAAoB,OAA6B;QAC/C,KAAK,EAAE,CAAC;QADU,YAAO,GAAP,OAAO,CAAsB;IAEjD,CAAC;IAED,IAAI,mBAAmB;QACrB,OAAO,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;IACpC,CAAC;IAED,IAAI,aAAa;QACf,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;QACnE,CAAC;QAED,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACnC,CAAC;IAED;;;OAGG;IACH,gBAAgB,CAAC,QAA+B;QAC9C,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACrD,CAAC;IAEM,KAAK,CAAC,KAAK;QAChB,MAAM,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;QAC1C,MAAM,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QACvC,IAAI,CAAC,oBAAoB,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAE,CAAC,UAAU,CAAC;YAClG,cAAc,EAAE,aAAa;SAC9B,CAAC,CAAC;QACH,IAAI,CAAC,gBAAgB,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,gBAAgB,EAAE,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC;QAC/E,MAAM,CAAC,IAAI,CAAC,mCAAmC,aAAa,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC;QAC9E,MAAM,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;IACtD,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,QAAQ;QACnB,MAAM,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;QAC/C,MAAM,IAAI,CAAC,oBAAoB,EAAE,QAAQ,EAAE,CAAC;QAC5C,MAAM,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC;IACxD,CAAC;CACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as util from '../util/util-index.js';
|
|
2
|
-
import { BucketStorageFactory } from './
|
|
2
|
+
import { BucketStorageFactory } from './BucketStorageFactory.js';
|
|
3
3
|
export interface ActiveStorage {
|
|
4
4
|
storage: BucketStorageFactory;
|
|
5
5
|
shutDown(): Promise<void>;
|
|
@@ -11,6 +11,9 @@ export interface ActiveStorage {
|
|
|
11
11
|
export interface GetStorageOptions {
|
|
12
12
|
resolvedConfig: util.ResolvedPowerSyncConfig;
|
|
13
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Represents a provider that can create a storage instance for a specific storage type from configuration.
|
|
16
|
+
*/
|
|
14
17
|
export interface BucketStorageProvider {
|
|
15
18
|
/**
|
|
16
19
|
* The storage type that this provider provides.
|