@powersync/service-core 0.0.0-dev-20260803144812 → 0.0.0-dev-20260929095716
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 +114 -5
- package/dist/api/diagnostics.js +7 -2
- package/dist/api/diagnostics.js.map +1 -1
- package/dist/entry/commands/compact-action.js +29 -25
- package/dist/entry/commands/compact-action.js.map +1 -1
- package/dist/entry/commands/config-command.js +1 -1
- package/dist/entry/commands/config-command.js.map +1 -1
- package/dist/metrics/metrics-interfaces.d.ts +5 -1
- package/dist/metrics/metrics-interfaces.js.map +1 -1
- package/dist/metrics/open-telemetry/MetricAttributeFilteringExporter.d.ts +36 -0
- package/dist/metrics/open-telemetry/MetricAttributeFilteringExporter.js +70 -0
- package/dist/metrics/open-telemetry/MetricAttributeFilteringExporter.js.map +1 -0
- package/dist/metrics/open-telemetry/OpenTelemetryMetricsFactory.js +6 -1
- package/dist/metrics/open-telemetry/OpenTelemetryMetricsFactory.js.map +1 -1
- package/dist/metrics/open-telemetry/util.js +7 -3
- package/dist/metrics/open-telemetry/util.js.map +1 -1
- package/dist/migrations/PowerSyncMigrationManager.js +2 -1
- package/dist/migrations/PowerSyncMigrationManager.js.map +1 -1
- package/dist/replication/AbstractReplicator.d.ts +5 -0
- package/dist/replication/AbstractReplicator.js +31 -13
- package/dist/replication/AbstractReplicator.js.map +1 -1
- package/dist/replication/ReplicationModule.d.ts +0 -7
- package/dist/replication/ReplicationModule.js +0 -1
- package/dist/replication/ReplicationModule.js.map +1 -1
- package/dist/routes/configure-fastify.d.ts +12 -3
- package/dist/routes/endpoints/admin.d.ts +24 -6
- package/dist/routes/endpoints/admin.js +17 -11
- package/dist/routes/endpoints/admin.js.map +1 -1
- package/dist/routes/endpoints/socket-route.js +7 -5
- package/dist/routes/endpoints/socket-route.js.map +1 -1
- package/dist/routes/endpoints/sync-rules.js +18 -10
- package/dist/routes/endpoints/sync-rules.js.map +1 -1
- package/dist/storage/BucketStorageBatch.d.ts +2 -1
- package/dist/storage/BucketStorageBatch.js.map +1 -1
- package/dist/storage/BucketStorageFactory.d.ts +49 -6
- package/dist/storage/BucketStorageFactory.js +25 -8
- package/dist/storage/BucketStorageFactory.js.map +1 -1
- package/dist/storage/PersistedReplicationStream.d.ts +2 -1
- package/dist/storage/PersistedReplicationStream.js.map +1 -1
- package/dist/storage/PersistedSyncConfigContent.d.ts +6 -4
- package/dist/storage/PersistedSyncConfigContent.js +34 -14
- package/dist/storage/PersistedSyncConfigContent.js.map +1 -1
- package/dist/storage/ReplicationEventPayload.d.ts +6 -1
- package/dist/storage/SourceEntity.d.ts +7 -2
- package/dist/storage/SourceTable.d.ts +37 -6
- package/dist/storage/SourceTable.js +42 -10
- package/dist/storage/SourceTable.js.map +1 -1
- package/dist/storage/SourceTableReconciler.d.ts +83 -0
- package/dist/storage/SourceTableReconciler.js +95 -0
- package/dist/storage/SourceTableReconciler.js.map +1 -0
- package/dist/storage/StorageEngine.d.ts +4 -0
- package/dist/storage/StorageEngine.js +7 -1
- package/dist/storage/StorageEngine.js.map +1 -1
- package/dist/storage/StorageProvider.d.ts +8 -0
- package/dist/storage/StorageVersionConfig.d.ts +4 -0
- package/dist/storage/StorageVersionConfig.js +10 -1
- package/dist/storage/StorageVersionConfig.js.map +1 -1
- package/dist/storage/SyncConfigParser.d.ts +44 -0
- package/dist/storage/SyncConfigParser.js +70 -0
- package/dist/storage/SyncConfigParser.js.map +1 -0
- package/dist/storage/SyncRulesBucketStorage.d.ts +48 -8
- package/dist/storage/SyncRulesBucketStorage.js.map +1 -1
- package/dist/storage/WriteCheckpointAPI.d.ts +25 -3
- package/dist/storage/WriteCheckpointAPI.js.map +1 -1
- package/dist/storage/implementation/BucketDefinitionMapping.d.ts +23 -7
- package/dist/storage/implementation/BucketDefinitionMapping.js +88 -14
- package/dist/storage/implementation/BucketDefinitionMapping.js.map +1 -1
- package/dist/storage/implementation/IncrementalReprocessingCompatibility.js +9 -5
- package/dist/storage/implementation/IncrementalReprocessingCompatibility.js.map +1 -1
- package/dist/storage/implementation/IncrementalReprocessingSyncConfigLog.js +9 -1
- package/dist/storage/implementation/IncrementalReprocessingSyncConfigLog.js.map +1 -1
- package/dist/storage/storage-index.d.ts +2 -0
- package/dist/storage/storage-index.js +2 -0
- package/dist/storage/storage-index.js.map +1 -1
- package/dist/storage/storage-metrics.js +120 -4
- package/dist/storage/storage-metrics.js.map +1 -1
- package/dist/sync/BucketChecksumState.d.ts +2 -2
- package/dist/sync/BucketChecksumState.js +5 -4
- package/dist/sync/BucketChecksumState.js.map +1 -1
- package/dist/sync/sync.js +37 -9
- package/dist/sync/sync.js.map +1 -1
- package/dist/sync/util.d.ts +1 -1
- package/dist/sync/util.js +13 -1
- package/dist/sync/util.js.map +1 -1
- package/dist/system/ServiceContext.d.ts +20 -0
- package/dist/system/ServiceContext.js +29 -1
- package/dist/system/ServiceContext.js.map +1 -1
- package/dist/util/config/compound-config-collector.js +5 -0
- package/dist/util/config/compound-config-collector.js.map +1 -1
- 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/sync-rules-provider.d.ts +2 -0
- package/dist/util/config/sync-rules/sync-rules-provider.js +3 -0
- package/dist/util/config/sync-rules/sync-rules-provider.js.map +1 -1
- package/dist/util/config/types.d.ts +1 -0
- package/dist/util/param-logging.d.ts +5 -2
- package/dist/util/param-logging.js +17 -9
- package/dist/util/param-logging.js.map +1 -1
- package/dist/util/protocol-types.d.ts +11 -11
- package/dist/util/protocol-types.js +6 -5
- package/dist/util/protocol-types.js.map +1 -1
- package/dist/util/utils.d.ts +2 -1
- package/dist/util/utils.js +16 -1
- package/dist/util/utils.js.map +1 -1
- package/package.json +6 -5
- package/src/api/diagnostics.ts +8 -2
- package/src/entry/commands/compact-action.ts +33 -25
- package/src/entry/commands/config-command.ts +1 -1
- package/src/metrics/metrics-interfaces.ts +6 -1
- package/src/metrics/open-telemetry/MetricAttributeFilteringExporter.ts +85 -0
- package/src/metrics/open-telemetry/OpenTelemetryMetricsFactory.ts +7 -2
- package/src/metrics/open-telemetry/util.ts +7 -3
- package/src/migrations/PowerSyncMigrationManager.ts +2 -1
- package/src/replication/AbstractReplicator.ts +42 -13
- package/src/replication/ReplicationModule.ts +0 -10
- package/src/routes/endpoints/admin.ts +17 -17
- package/src/routes/endpoints/socket-route.ts +9 -6
- package/src/routes/endpoints/sync-rules.ts +21 -12
- package/src/storage/BucketStorageBatch.ts +2 -1
- package/src/storage/BucketStorageFactory.ts +77 -14
- package/src/storage/PersistedReplicationStream.ts +2 -1
- package/src/storage/PersistedSyncConfigContent.ts +42 -19
- package/src/storage/ReplicationEventPayload.ts +6 -1
- package/src/storage/SourceEntity.ts +6 -2
- package/src/storage/SourceTable.ts +68 -11
- package/src/storage/SourceTableReconciler.ts +188 -0
- package/src/storage/StorageEngine.ts +10 -1
- package/src/storage/StorageProvider.ts +8 -0
- package/src/storage/StorageVersionConfig.ts +11 -1
- package/src/storage/SyncConfigParser.ts +121 -0
- package/src/storage/SyncRulesBucketStorage.ts +56 -8
- package/src/storage/WriteCheckpointAPI.ts +32 -3
- package/src/storage/implementation/BucketDefinitionMapping.ts +120 -17
- package/src/storage/implementation/IncrementalReprocessingCompatibility.ts +14 -5
- package/src/storage/implementation/IncrementalReprocessingSyncConfigLog.ts +22 -5
- package/src/storage/storage-index.ts +2 -0
- package/src/storage/storage-metrics.ts +154 -8
- package/src/sync/BucketChecksumState.ts +8 -5
- package/src/sync/sync.ts +40 -11
- package/src/sync/util.ts +25 -9
- package/src/system/ServiceContext.ts +47 -1
- package/src/util/config/compound-config-collector.ts +6 -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/sync-rules-provider.ts +5 -0
- package/src/util/config/types.ts +1 -0
- package/src/util/param-logging.ts +21 -14
- package/src/util/protocol-types.ts +8 -7
- package/src/util/utils.ts +15 -1
- package/test/src/AbstractReplicator.test.ts +62 -0
- package/test/src/MetricAttributeFilteringExporter.test.ts +96 -0
- package/test/src/PersistedSyncConfigContent.test.ts +154 -0
- package/test/src/SyncConfigParser.test.ts +330 -0
- package/test/src/broadcast_iterable.test.ts +26 -8
- package/test/src/config.test.ts +40 -0
- package/test/src/diagnostics.test.ts +48 -0
- package/test/src/routes/admin.test.ts +30 -2
- package/test/src/routes/mocks.ts +2 -0
- package/test/src/routes/stream.test.ts +123 -2
- package/test/src/source-table-reconciler.test.ts +244 -0
- package/test/src/storage/SourceTable.test.ts +4 -1
- package/test/src/storage-metrics.test.ts +148 -0
- package/test/src/sync/BucketChecksumState.test.ts +195 -6
- package/test/src/sync/util.test.ts +34 -0
- package/test/src/util/param-logging.test.ts +59 -0
- package/test/src/util/utils.test.ts +23 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import { BucketDataSource, BucketDefinitionId, ParameterIndexId, ParameterIndexLookupCreator, SourceTableRef } from '@powersync/service-sync-rules';
|
|
1
|
+
import { BucketDataSource, BucketDefinitionId, EventDefinitionId, ParameterIndexId, ParameterIndexLookupCreator, SourceTableRef } from '@powersync/service-sync-rules';
|
|
2
2
|
import { bson } from '../index.js';
|
|
3
|
-
import { ColumnDescriptor } from './SourceEntity.js';
|
|
3
|
+
import { ColumnDescriptor, JsonValue } from './SourceEntity.js';
|
|
4
4
|
/**
|
|
5
5
|
* Format of the id depends on the bucket storage module. It should be consistent within the module.
|
|
6
6
|
*/
|
|
7
7
|
export type SourceTableId = string | bson.ObjectId;
|
|
8
|
+
/**
|
|
9
|
+
* Compare source-table ids without coercing between storage-specific types.
|
|
10
|
+
*/
|
|
11
|
+
export declare function sourceTableIdEquals(left: SourceTableId, right: SourceTableId): boolean;
|
|
8
12
|
export interface SourceTableOptions {
|
|
9
13
|
id: SourceTableId;
|
|
10
14
|
ref: SourceTableRef;
|
|
@@ -15,6 +19,17 @@ export interface SourceTableOptions {
|
|
|
15
19
|
parameterLookupSources: ParameterIndexLookupCreator[];
|
|
16
20
|
bucketDataSourceIds?: Set<BucketDefinitionId>;
|
|
17
21
|
parameterLookupSourceIds?: Set<ParameterIndexId>;
|
|
22
|
+
/**
|
|
23
|
+
* Compiled event definitions assigned to this persisted source-table record.
|
|
24
|
+
*
|
|
25
|
+
* Undefined is the legacy/non-incremental representation where event selection is
|
|
26
|
+
* based on the table ref. V3 incremental storage always supplies this set.
|
|
27
|
+
*/
|
|
28
|
+
eventDefinitionIds?: Set<EventDefinitionId>;
|
|
29
|
+
/**
|
|
30
|
+
* Source-specific metadata. Null when no metadata has been recorded.
|
|
31
|
+
*/
|
|
32
|
+
sourceMetadata?: JsonValue;
|
|
18
33
|
}
|
|
19
34
|
export interface TableSnapshotStatus {
|
|
20
35
|
totalEstimatedCount: number;
|
|
@@ -47,11 +62,11 @@ export declare class SourceTable {
|
|
|
47
62
|
*/
|
|
48
63
|
syncParameters: boolean;
|
|
49
64
|
/**
|
|
50
|
-
* True if this table should
|
|
65
|
+
* True if this table should evaluate event definitions for row changes.
|
|
51
66
|
*
|
|
52
|
-
* This value is resolved externally, and cached here.
|
|
53
|
-
*
|
|
54
|
-
*
|
|
67
|
+
* This value is resolved externally, and cached here. V3 storage assigns disjoint
|
|
68
|
+
* event-definition ids to SourceTables for the same physical table. Multiple records
|
|
69
|
+
* may evaluate different events, but each event id is evaluated through at most one record.
|
|
55
70
|
*
|
|
56
71
|
* Defaults to true for tests.
|
|
57
72
|
*/
|
|
@@ -86,6 +101,10 @@ export declare class SourceTable {
|
|
|
86
101
|
get parameterLookupSources(): ParameterIndexLookupCreator[];
|
|
87
102
|
get bucketDataSourceIds(): Set<string> | undefined;
|
|
88
103
|
get parameterLookupSourceIds(): Set<string> | undefined;
|
|
104
|
+
get eventDefinitionIds(): Set<string> | undefined;
|
|
105
|
+
get sourceMetadata(): string | number | boolean | JsonValue[] | {
|
|
106
|
+
[key: string]: JsonValue;
|
|
107
|
+
} | null;
|
|
89
108
|
/**
|
|
90
109
|
* Sanitized name of the entity in the format of "{schema}.{entity name}".
|
|
91
110
|
* Suitable for safe use in Postgres queries.
|
|
@@ -96,5 +115,17 @@ export declare class SourceTable {
|
|
|
96
115
|
* In-memory clone of the table status.
|
|
97
116
|
*/
|
|
98
117
|
clone(): SourceTable;
|
|
118
|
+
/**
|
|
119
|
+
* Copy this table with different source metadata, preserving its resolved state.
|
|
120
|
+
*/
|
|
121
|
+
withSourceMetadata(sourceMetadata: JsonValue): SourceTable;
|
|
122
|
+
private copyWithSourceMetadata;
|
|
99
123
|
formatSnapshotProgress(): string;
|
|
100
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* A cloned SourceTable exposed to reconciliation with public fields typed as read-only.
|
|
127
|
+
* `options` is omitted so callers cannot mutate the underlying option bag without an explicit cast.
|
|
128
|
+
*/
|
|
129
|
+
export type SourceTableCandidate = Omit<Readonly<SourceTable>, 'options' | 'withSourceMetadata'> & {
|
|
130
|
+
withSourceMetadata(sourceMetadata: JsonValue): SourceTableCandidate;
|
|
131
|
+
};
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { DEFAULT_TAG } from '@powersync/service-sync-rules';
|
|
2
2
|
import * as util from '../util/util-index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Compare source-table ids without coercing between storage-specific types.
|
|
5
|
+
*/
|
|
6
|
+
export function sourceTableIdEquals(left, right) {
|
|
7
|
+
if (typeof left === 'string' || typeof right === 'string') {
|
|
8
|
+
return typeof left === 'string' && typeof right === 'string' && left === right;
|
|
9
|
+
}
|
|
10
|
+
return left.equals(right);
|
|
11
|
+
}
|
|
3
12
|
/**
|
|
4
13
|
* Represents a resolved source table.
|
|
5
14
|
*
|
|
@@ -26,11 +35,11 @@ export class SourceTable {
|
|
|
26
35
|
*/
|
|
27
36
|
syncParameters = true;
|
|
28
37
|
/**
|
|
29
|
-
* True if this table should
|
|
38
|
+
* True if this table should evaluate event definitions for row changes.
|
|
30
39
|
*
|
|
31
|
-
* This value is resolved externally, and cached here.
|
|
32
|
-
*
|
|
33
|
-
*
|
|
40
|
+
* This value is resolved externally, and cached here. V3 storage assigns disjoint
|
|
41
|
+
* event-definition ids to SourceTables for the same physical table. Multiple records
|
|
42
|
+
* may evaluate different events, but each event id is evaluated through at most one record.
|
|
34
43
|
*
|
|
35
44
|
* Defaults to true for tests.
|
|
36
45
|
*/
|
|
@@ -88,6 +97,12 @@ export class SourceTable {
|
|
|
88
97
|
get parameterLookupSourceIds() {
|
|
89
98
|
return this.options.parameterLookupSourceIds;
|
|
90
99
|
}
|
|
100
|
+
get eventDefinitionIds() {
|
|
101
|
+
return this.options.eventDefinitionIds;
|
|
102
|
+
}
|
|
103
|
+
get sourceMetadata() {
|
|
104
|
+
return this.options.sourceMetadata ?? null;
|
|
105
|
+
}
|
|
91
106
|
/**
|
|
92
107
|
* Sanitized name of the entity in the format of "{schema}.{entity name}".
|
|
93
108
|
* Suitable for safe use in Postgres queries.
|
|
@@ -102,22 +117,39 @@ export class SourceTable {
|
|
|
102
117
|
* In-memory clone of the table status.
|
|
103
118
|
*/
|
|
104
119
|
clone() {
|
|
120
|
+
return this.copyWithSourceMetadata(this.sourceMetadata);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Copy this table with different source metadata, preserving its resolved state.
|
|
124
|
+
*/
|
|
125
|
+
withSourceMetadata(sourceMetadata) {
|
|
126
|
+
return this.copyWithSourceMetadata(sourceMetadata);
|
|
127
|
+
}
|
|
128
|
+
copyWithSourceMetadata(sourceMetadata) {
|
|
105
129
|
const copy = new SourceTable({
|
|
106
130
|
id: this.id,
|
|
107
|
-
ref: this.options.ref,
|
|
131
|
+
ref: { ...this.options.ref },
|
|
108
132
|
objectId: this.objectId,
|
|
109
|
-
replicaIdColumns: this.replicaIdColumns,
|
|
133
|
+
replicaIdColumns: this.replicaIdColumns.map((column) => ({ ...column })),
|
|
110
134
|
snapshotComplete: this.snapshotComplete,
|
|
111
|
-
bucketDataSources: this.bucketDataSources,
|
|
112
|
-
parameterLookupSources: this.parameterLookupSources,
|
|
135
|
+
bucketDataSources: [...this.bucketDataSources],
|
|
136
|
+
parameterLookupSources: [...this.parameterLookupSources],
|
|
113
137
|
bucketDataSourceIds: this.bucketDataSourceIds == null ? undefined : new Set(this.bucketDataSourceIds),
|
|
114
|
-
parameterLookupSourceIds: this.parameterLookupSourceIds == null ? undefined : new Set(this.parameterLookupSourceIds)
|
|
138
|
+
parameterLookupSourceIds: this.parameterLookupSourceIds == null ? undefined : new Set(this.parameterLookupSourceIds),
|
|
139
|
+
eventDefinitionIds: this.eventDefinitionIds == null ? undefined : new Set(this.eventDefinitionIds),
|
|
140
|
+
sourceMetadata: structuredClone(sourceMetadata)
|
|
115
141
|
});
|
|
116
142
|
copy.syncData = this.syncData;
|
|
117
143
|
copy.syncParameters = this.syncParameters;
|
|
118
144
|
copy.syncEvent = this.syncEvent;
|
|
119
145
|
copy.storeCurrentData = this.storeCurrentData;
|
|
120
|
-
copy.snapshotStatus =
|
|
146
|
+
copy.snapshotStatus =
|
|
147
|
+
this.snapshotStatus == null
|
|
148
|
+
? undefined
|
|
149
|
+
: {
|
|
150
|
+
...this.snapshotStatus,
|
|
151
|
+
lastKey: this.snapshotStatus.lastKey?.slice() ?? null
|
|
152
|
+
};
|
|
121
153
|
return copy;
|
|
122
154
|
}
|
|
123
155
|
formatSnapshotProgress() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SourceTable.js","sourceRoot":"","sources":["../../src/storage/SourceTable.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,WAAW,
|
|
1
|
+
{"version":3,"file":"SourceTable.js","sourceRoot":"","sources":["../../src/storage/SourceTable.ts"],"names":[],"m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AAO,EAAE,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,IAAI;iBACtD,CAAC;QACR,OAAO,IAAI,CAAC;IACd,CAAC;IAED,sBAAsB;QACpB,IAAI,IAAI,CAAC,gBAAgB,IAAI,IAAI,CAAC,cAAc,IAAI,IAAI,EAAE,CAAC;YACzD,oBAAoB;YACpB,OAAO,GAAG,CAAC;QACb,CAAC;aAAM,IAAI,IAAI,CAAC,cAAc,CAAC,mBAAmB,GAAG,CAAC,EAAE,CAAC;YACvD,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC,eAAe,IAAI,CAAC;QACpD,CAAC;aAAM,CAAC;YACN,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC,eAAe,KAAK,IAAI,CAAC,cAAc,CAAC,mBAAmB,EAAE,CAAC;QAC9F,CAAC;IACH,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { JsonValue, SourceEntityDescriptor } from './SourceEntity.js';
|
|
2
|
+
import { SourceTable, SourceTableCandidate, SourceTableId } from './SourceTable.js';
|
|
3
|
+
/**
|
|
4
|
+
* A source connector's classification of overlapping persisted tables.
|
|
5
|
+
*/
|
|
6
|
+
export interface SourceTableCandidateResolution {
|
|
7
|
+
/**
|
|
8
|
+
* Records storage can reuse. Copies may include updated source metadata.
|
|
9
|
+
*/
|
|
10
|
+
compatibleTables: ReadonlyArray<SourceTableCandidate>;
|
|
11
|
+
/**
|
|
12
|
+
* Records that cannot be reused. Every candidate must appear in exactly one result list.
|
|
13
|
+
*/
|
|
14
|
+
incompatibleTables: ReadonlyArray<SourceTableCandidate>;
|
|
15
|
+
/**
|
|
16
|
+
* Values for records storage creates during this resolution.
|
|
17
|
+
*/
|
|
18
|
+
newTableValues: SourceTableCreateValues;
|
|
19
|
+
}
|
|
20
|
+
export interface SourceTableCreateValues {
|
|
21
|
+
/**
|
|
22
|
+
* Source metadata for new records. Null means no metadata.
|
|
23
|
+
*/
|
|
24
|
+
sourceMetadata: JsonValue;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Input to a source-owned reconciliation callback. The callback may run inside a storage
|
|
28
|
+
* transaction, so it must not mutate storage or perform slow external work.
|
|
29
|
+
*/
|
|
30
|
+
export interface SourceTableCandidateReconcilerInput {
|
|
31
|
+
/**
|
|
32
|
+
* Source entity being resolved.
|
|
33
|
+
*/
|
|
34
|
+
source: SourceEntityDescriptor;
|
|
35
|
+
/**
|
|
36
|
+
* Persisted tables overlapping by name or object id.
|
|
37
|
+
*/
|
|
38
|
+
candidates: ReadonlyArray<SourceTableCandidate>;
|
|
39
|
+
}
|
|
40
|
+
export type SourceTableCandidateReconciler = (input: SourceTableCandidateReconcilerInput) => SourceTableCandidateResolution | Promise<SourceTableCandidateResolution>;
|
|
41
|
+
/**
|
|
42
|
+
* Compare replica-id columns in order.
|
|
43
|
+
*/
|
|
44
|
+
export declare function sameReplicaIdColumns(left: SourceTableCandidate['replicaIdColumns'], right: SourceEntityDescriptor): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Compare the shared source-table identity fields.
|
|
47
|
+
*/
|
|
48
|
+
export declare function sourceIdentityCompatible(source: SourceEntityDescriptor, candidate: SourceTableCandidate): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Default identity-based reconciliation for connectors without source-specific metadata.
|
|
51
|
+
*/
|
|
52
|
+
export declare const defaultSourceTableReconciler: SourceTableCandidateReconciler;
|
|
53
|
+
/**
|
|
54
|
+
* Check that every candidate was classified exactly once.
|
|
55
|
+
*/
|
|
56
|
+
export declare function validateSourceTableCandidateResolution(candidates: ReadonlyArray<SourceTableCandidate>, resolution: SourceTableCandidateResolution): void;
|
|
57
|
+
/**
|
|
58
|
+
* A source-metadata update to persist.
|
|
59
|
+
*/
|
|
60
|
+
export interface SourceTableMetadataUpdate {
|
|
61
|
+
id: SourceTableId;
|
|
62
|
+
sourceMetadata: JsonValue;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Rebuild a resolution from storage-owned tables, applying only reconciler-owned metadata to
|
|
66
|
+
* compatible tables. All other mutable table state comes from storage.
|
|
67
|
+
*
|
|
68
|
+
* Reconciler candidates are typed as read-only, but TypeScript types provide no runtime protection:
|
|
69
|
+
* callback code can cast a cloned candidate and mutate it. Rematerializing by id ensures those
|
|
70
|
+
* mutations are not trusted even when the compile-time boundary is bypassed.
|
|
71
|
+
*/
|
|
72
|
+
export declare function materializeSourceTableResolution(tables: ReadonlyArray<SourceTable>, resolution: SourceTableCandidateResolution): MaterializedSourceTableResolution;
|
|
73
|
+
export interface MaterializedSourceTableResolution {
|
|
74
|
+
compatibleTables: SourceTable[];
|
|
75
|
+
incompatibleTables: SourceTable[];
|
|
76
|
+
newTableValues: SourceTableCreateValues;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Return source-metadata changes from compatible candidates, comparing metadata by value against
|
|
80
|
+
* the original storage-owned tables. The reconciler may mutate its isolated candidate clones, so
|
|
81
|
+
* those clones cannot be used as the persisted baseline.
|
|
82
|
+
*/
|
|
83
|
+
export declare function diffSourceTableUpdates(persistedTables: ReadonlyArray<SourceTable>, resolution: SourceTableCandidateResolution): SourceTableMetadataUpdate[];
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { ServiceAssertionError } from '@powersync/lib-services-framework';
|
|
2
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
3
|
+
import { sourceTableIdEquals } from './SourceTable.js';
|
|
4
|
+
/**
|
|
5
|
+
* Compare replica-id columns in order.
|
|
6
|
+
*/
|
|
7
|
+
export function sameReplicaIdColumns(left, right) {
|
|
8
|
+
const target = right.replicaIdColumns;
|
|
9
|
+
return (left.length == target.length &&
|
|
10
|
+
left.every((column, index) => column.name == target[index].name && column.type == target[index].type && column.typeId == target[index].typeId));
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Compare the shared source-table identity fields.
|
|
14
|
+
*/
|
|
15
|
+
export function sourceIdentityCompatible(source, candidate) {
|
|
16
|
+
return (candidate.schema == source.schema &&
|
|
17
|
+
candidate.name == source.name &&
|
|
18
|
+
(source.objectId == null || candidate.objectId == source.objectId) &&
|
|
19
|
+
sameReplicaIdColumns(candidate.replicaIdColumns, source));
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Default identity-based reconciliation for connectors without source-specific metadata.
|
|
23
|
+
*/
|
|
24
|
+
export const defaultSourceTableReconciler = ({ source, candidates }) => {
|
|
25
|
+
const compatibleTables = [];
|
|
26
|
+
const incompatibleTables = [];
|
|
27
|
+
for (const candidate of candidates) {
|
|
28
|
+
if (sourceIdentityCompatible(source, candidate)) {
|
|
29
|
+
compatibleTables.push(candidate);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
incompatibleTables.push(candidate);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return { compatibleTables, incompatibleTables, newTableValues: { sourceMetadata: null } };
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Check that every candidate was classified exactly once.
|
|
39
|
+
*/
|
|
40
|
+
export function validateSourceTableCandidateResolution(candidates, resolution) {
|
|
41
|
+
const classifiedTables = [...resolution.compatibleTables, ...resolution.incompatibleTables];
|
|
42
|
+
for (const candidate of candidates) {
|
|
43
|
+
const classifications = classifiedTables.filter((table) => sourceTableIdEquals(table.id, candidate.id));
|
|
44
|
+
if (classifications.length !== 1) {
|
|
45
|
+
throw new ServiceAssertionError(`Source table candidate ${candidate.id.toString()} must be classified exactly once, got ${classifications.length}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
for (const table of classifiedTables) {
|
|
49
|
+
if (!candidates.some((candidate) => sourceTableIdEquals(candidate.id, table.id))) {
|
|
50
|
+
throw new ServiceAssertionError(`Source table reconciliation returned unknown candidate ${table.id.toString()}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Rebuild a resolution from storage-owned tables, applying only reconciler-owned metadata to
|
|
56
|
+
* compatible tables. All other mutable table state comes from storage.
|
|
57
|
+
*
|
|
58
|
+
* Reconciler candidates are typed as read-only, but TypeScript types provide no runtime protection:
|
|
59
|
+
* callback code can cast a cloned candidate and mutate it. Rematerializing by id ensures those
|
|
60
|
+
* mutations are not trusted even when the compile-time boundary is bypassed.
|
|
61
|
+
*/
|
|
62
|
+
export function materializeSourceTableResolution(tables, resolution) {
|
|
63
|
+
const findTable = (candidate) => {
|
|
64
|
+
const table = tables.find((table) => sourceTableIdEquals(table.id, candidate.id));
|
|
65
|
+
if (table == null) {
|
|
66
|
+
throw new ServiceAssertionError(`Source table candidate ${candidate.id.toString()} was not persisted`);
|
|
67
|
+
}
|
|
68
|
+
return table;
|
|
69
|
+
};
|
|
70
|
+
return {
|
|
71
|
+
compatibleTables: resolution.compatibleTables.map((candidate) => findTable(candidate).withSourceMetadata(candidate.sourceMetadata)),
|
|
72
|
+
incompatibleTables: resolution.incompatibleTables.map(findTable),
|
|
73
|
+
newTableValues: resolution.newTableValues
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Return source-metadata changes from compatible candidates, comparing metadata by value against
|
|
78
|
+
* the original storage-owned tables. The reconciler may mutate its isolated candidate clones, so
|
|
79
|
+
* those clones cannot be used as the persisted baseline.
|
|
80
|
+
*/
|
|
81
|
+
export function diffSourceTableUpdates(persistedTables, resolution) {
|
|
82
|
+
const updates = [];
|
|
83
|
+
for (const resolvedTable of resolution.compatibleTables) {
|
|
84
|
+
const persistedTable = persistedTables.find((table) => sourceTableIdEquals(table.id, resolvedTable.id));
|
|
85
|
+
if (persistedTable == null) {
|
|
86
|
+
throw new ServiceAssertionError(`Source table reconciliation returned unknown candidate ${resolvedTable.id.toString()}`);
|
|
87
|
+
}
|
|
88
|
+
if (isDeepStrictEqual(persistedTable.sourceMetadata, resolvedTable.sourceMetadata)) {
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
updates.push({ id: resolvedTable.id, sourceMetadata: resolvedTable.sourceMetadata });
|
|
92
|
+
}
|
|
93
|
+
return updates;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=SourceTableReconciler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SourceTableReconciler.js","sourceRoot":"","sources":["../../src/storage/SourceTableReconciler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,EAAoD,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAiDzG;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAClC,IAA8C,EAC9C,KAA6B;IAE7B,MAAM,MAAM,GAAG,KAAK,CAAC,gBAAgB,CAAC;IACtC,OAAO,CACL,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM;QAC5B,IAAI,CAAC,KAAK,CACR,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAChB,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,IAAI,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAClH,CACF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,wBAAwB,CAAC,MAA8B,EAAE,SAA+B;IACtG,OAAO,CACL,SAAS,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM;QACjC,SAAS,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI;QAC7B,CAAC,MAAM,CAAC,QAAQ,IAAI,IAAI,IAAI,SAAS,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC;QAClE,oBAAoB,CAAC,SAAS,CAAC,gBAAgB,EAAE,MAAM,CAAC,CACzD,CAAC;AACJ,CAAC;AAED;;G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,EAAE,CAAC,mBAAmB,CAAC,KAAK,CAAC,EAAE,EAAE,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC;QACxG,IAAI,cAAc,IAAI,IAAI,EAAE,CAAC;YAC3B,MAAM,IAAI,qBAAqB,CAC7B,0DAA0D,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,EAAE,CACxF,CAAC;QACJ,CAAC;QACD,IAAI,iBAAiB,CAAC,cAAc,CAAC,cAAc,EAAE,aAAa,CAAC,cAAc,CAAC,EAAE,CAAC;YACnF,SAAS;QACX,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,aAAa,CAAC,EAAE,EAAE,cAAc,EAAE,aAAa,CAAC,cAAc,EAAE,CAAC,CAAC;IACvF,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -2,8 +2,10 @@ import { BaseObserver, ServiceError } from '@powersync/lib-services-framework';
|
|
|
2
2
|
import { ResolvedPowerSyncConfig } from '../util/util-index.js';
|
|
3
3
|
import { BucketStorageFactory } from './BucketStorageFactory.js';
|
|
4
4
|
import { ActiveStorage, StorageProvider } from './StorageProvider.js';
|
|
5
|
+
import { SyncConfigParser } from './SyncConfigParser.js';
|
|
5
6
|
export type StorageEngineOptions = {
|
|
6
7
|
configuration: ResolvedPowerSyncConfig;
|
|
8
|
+
syncConfigParser: SyncConfigParser;
|
|
7
9
|
};
|
|
8
10
|
export interface StorageEngineListener {
|
|
9
11
|
storageActivated: (storage: BucketStorageFactory) => void;
|
|
@@ -12,10 +14,12 @@ export interface StorageEngineListener {
|
|
|
12
14
|
export declare class StorageEngine extends BaseObserver<StorageEngineListener> {
|
|
13
15
|
private options;
|
|
14
16
|
private storageProviders;
|
|
17
|
+
private startupStarted;
|
|
15
18
|
private currentActiveStorage;
|
|
16
19
|
constructor(options: StorageEngineOptions);
|
|
17
20
|
get activeBucketStorage(): BucketStorageFactory;
|
|
18
21
|
get activeStorage(): ActiveStorage;
|
|
22
|
+
get started(): boolean;
|
|
19
23
|
/**
|
|
20
24
|
* Register a provider which generates a {@link BucketStorageFactory}
|
|
21
25
|
* given the matching config specified in the loaded {@link ResolvedPowerSyncConfig}
|
|
@@ -3,6 +3,7 @@ export class StorageEngine extends BaseObserver {
|
|
|
3
3
|
options;
|
|
4
4
|
// TODO: This will need to revisited when we actually support multiple storage providers.
|
|
5
5
|
storageProviders = new Map();
|
|
6
|
+
startupStarted = false;
|
|
6
7
|
currentActiveStorage = null;
|
|
7
8
|
constructor(options) {
|
|
8
9
|
super();
|
|
@@ -17,6 +18,9 @@ export class StorageEngine extends BaseObserver {
|
|
|
17
18
|
}
|
|
18
19
|
return this.currentActiveStorage;
|
|
19
20
|
}
|
|
21
|
+
get started() {
|
|
22
|
+
return this.startupStarted;
|
|
23
|
+
}
|
|
20
24
|
/**
|
|
21
25
|
* Register a provider which generates a {@link BucketStorageFactory}
|
|
22
26
|
* given the matching config specified in the loaded {@link ResolvedPowerSyncConfig}
|
|
@@ -25,10 +29,12 @@ export class StorageEngine extends BaseObserver {
|
|
|
25
29
|
this.storageProviders.set(provider.type, provider);
|
|
26
30
|
}
|
|
27
31
|
async start() {
|
|
32
|
+
this.startupStarted = true;
|
|
28
33
|
logger.info('Starting Storage Engine...');
|
|
29
34
|
const { configuration } = this.options;
|
|
30
35
|
this.currentActiveStorage = await this.storageProviders.get(configuration.storage.type).getStorage({
|
|
31
|
-
resolvedConfig: configuration
|
|
36
|
+
resolvedConfig: configuration,
|
|
37
|
+
syncConfigParser: this.options.syncConfigParser
|
|
32
38
|
});
|
|
33
39
|
this.iterateListeners((cb) => cb.storageActivated?.(this.activeBucketStorage));
|
|
34
40
|
this.currentActiveStorage.onFatalError?.((error) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StorageEngine.js","sourceRoot":"","sources":["../../src/storage/StorageEngine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,EAAgB,MAAM,mCAAmC,CA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EAAE,IAAI,CAAC,OAAO,CAAC,gBAAgB;SAChD,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,IAAI,CAAC,oBAAoB,CAAC,YAAY,EAAE,CAAC,CAAC,KAAK,EAAE,EAAE;YACjD,IAAI,CAAC,gBAAgB,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,iBAAiB,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;QAC/D,CAAC,CAAC,CAAC;QACH,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"}
|
|
@@ -2,6 +2,7 @@ import { ServiceError } from '@powersync/lib-services-framework';
|
|
|
2
2
|
import * as util from '../util/util-index.js';
|
|
3
3
|
import { BucketStorageFactory } from './BucketStorageFactory.js';
|
|
4
4
|
import { ReportStorage } from './ReportStorage.js';
|
|
5
|
+
import { SyncConfigParser } from './SyncConfigParser.js';
|
|
5
6
|
export interface ActiveStorage {
|
|
6
7
|
storage: BucketStorageFactory;
|
|
7
8
|
reportStorage: ReportStorage;
|
|
@@ -14,6 +15,10 @@ export interface ActiveStorage {
|
|
|
14
15
|
}
|
|
15
16
|
export interface GetStorageOptions {
|
|
16
17
|
resolvedConfig: util.ResolvedPowerSyncConfig;
|
|
18
|
+
/**
|
|
19
|
+
* Service-wide parser containing every extension registered during module initialization.
|
|
20
|
+
*/
|
|
21
|
+
syncConfigParser: SyncConfigParser;
|
|
17
22
|
}
|
|
18
23
|
/**
|
|
19
24
|
* Represents a provider that can create a storage instance for a specific storage type from configuration.
|
|
@@ -24,5 +29,8 @@ export interface StorageProvider {
|
|
|
24
29
|
* The type should match the `type` field in the config.
|
|
25
30
|
*/
|
|
26
31
|
type: string;
|
|
32
|
+
/**
|
|
33
|
+
* Creates active storage during storage-engine startup using the fully assembled service parser.
|
|
34
|
+
*/
|
|
27
35
|
getStorage(options: GetStorageOptions): Promise<ActiveStorage>;
|
|
28
36
|
}
|
|
@@ -33,6 +33,10 @@ export declare const STORAGE_VERSION_2 = 2;
|
|
|
33
33
|
* This is used to build towards incremental reprocessing.
|
|
34
34
|
*/
|
|
35
35
|
export declare const STORAGE_VERSION_3 = 3;
|
|
36
|
+
/**
|
|
37
|
+
* Same as version 3, but marked as stable.
|
|
38
|
+
*/
|
|
39
|
+
export declare const STORAGE_VERSION_4 = 4;
|
|
36
40
|
/**
|
|
37
41
|
* Oldest supported storage version.
|
|
38
42
|
*/
|
|
@@ -16,6 +16,10 @@ export const STORAGE_VERSION_2 = 2;
|
|
|
16
16
|
* This is used to build towards incremental reprocessing.
|
|
17
17
|
*/
|
|
18
18
|
export const STORAGE_VERSION_3 = 3;
|
|
19
|
+
/**
|
|
20
|
+
* Same as version 3, but marked as stable.
|
|
21
|
+
*/
|
|
22
|
+
export const STORAGE_VERSION_4 = 4;
|
|
19
23
|
/**
|
|
20
24
|
* Oldest supported storage version.
|
|
21
25
|
*/
|
|
@@ -29,7 +33,7 @@ export const CURRENT_STORAGE_VERSION = STORAGE_VERSION_2;
|
|
|
29
33
|
*
|
|
30
34
|
* This includes unstable versions.
|
|
31
35
|
*/
|
|
32
|
-
export const SUPPORTED_STORAGE_VERSIONS = [STORAGE_VERSION_1, STORAGE_VERSION_2, STORAGE_VERSION_3];
|
|
36
|
+
export const SUPPORTED_STORAGE_VERSIONS = [STORAGE_VERSION_1, STORAGE_VERSION_2, STORAGE_VERSION_3, STORAGE_VERSION_4];
|
|
33
37
|
/**
|
|
34
38
|
* Shared storage-version behavior across storage implementations.
|
|
35
39
|
*/
|
|
@@ -48,6 +52,11 @@ export const STORAGE_VERSION_CONFIG = {
|
|
|
48
52
|
version: STORAGE_VERSION_3,
|
|
49
53
|
versionedBuckets: true,
|
|
50
54
|
softDeleteCurrentData: true
|
|
55
|
+
},
|
|
56
|
+
[STORAGE_VERSION_4]: {
|
|
57
|
+
version: STORAGE_VERSION_4,
|
|
58
|
+
versionedBuckets: true,
|
|
59
|
+
softDeleteCurrentData: true
|
|
51
60
|
}
|
|
52
61
|
};
|
|
53
62
|
//# sourceMappingURL=StorageVersionConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StorageVersionConfig.js","sourceRoot":"","sources":["../../src/storage/StorageVersionConfig.ts"],"names":[],"mappings":"AAoBA;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAEnC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAEnC;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAEnC;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,iBAAiB,CAAC;AAExD;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,iBAAiB,CAAC;AAEzD;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,iBAAiB,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"StorageVersionConfig.js","sourceRoot":"","sources":["../../src/storage/StorageVersionConfig.ts"],"names":[],"mappings":"AAoBA;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAEnC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAEnC;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAEnC;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAEnC;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,iBAAiB,CAAC;AAExD;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,iBAAiB,CAAC;AAEzD;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,iBAAiB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;AAEvH;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAqD;IACtF,CAAC,iBAAiB,CAAC,EAAE;QACnB,OAAO,EAAE,iBAAiB;QAC1B,gBAAgB,EAAE,KAAK;QACvB,qBAAqB,EAAE,KAAK;KAC7B;IACD,CAAC,iBAAiB,CAAC,EAAE;QACnB,OAAO,EAAE,iBAAiB;QAC1B,gBAAgB,EAAE,IAAI;QACtB,qBAAqB,EAAE,KAAK;KAC7B;IACD,CAAC,iBAAiB,CAAC,EAAE;QACnB,OAAO,EAAE,iBAAiB;QAC1B,gBAAgB,EAAE,IAAI;QACtB,qBAAqB,EAAE,IAAI;KAC5B;IACD,CAAC,iBAAiB,CAAC,EAAE;QACnB,OAAO,EAAE,iBAAiB;QAC1B,gBAAgB,EAAE,IAAI;QACtB,qBAAqB,EAAE,IAAI;KAC5B;CACF,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { AdditionalSyncConfigParser, JsonObject, SyncConfig, SyncConfigWithErrors, SyncRulesOptions, YamlError } from '@powersync/service-sync-rules';
|
|
2
|
+
export type ParseSyncConfigOptions = Omit<SyncRulesOptions, 'parsers' | 'schemaValidator'>;
|
|
3
|
+
/**
|
|
4
|
+
* Shared by service routes, deployment, replication and persisted storage; only initialization can register hooks.
|
|
5
|
+
*/
|
|
6
|
+
export interface SyncConfigParser {
|
|
7
|
+
/**
|
|
8
|
+
* A JSON schema which can be used to validate the format of a supplied sync config.
|
|
9
|
+
*/
|
|
10
|
+
readonly jsonSchema: JsonObject;
|
|
11
|
+
/**
|
|
12
|
+
* Parses string content.
|
|
13
|
+
*
|
|
14
|
+
* @returns The parsed {@link SyncConfigWithErrors}
|
|
15
|
+
*/
|
|
16
|
+
parseContent(content: string, options: ParseSyncConfigOptions): SyncConfigWithErrors;
|
|
17
|
+
/**
|
|
18
|
+
* Validates a persisted/parsed sync config.
|
|
19
|
+
*
|
|
20
|
+
* @returns Any errors detected.
|
|
21
|
+
*/
|
|
22
|
+
validatePersisted(options: {
|
|
23
|
+
config: SyncConfig;
|
|
24
|
+
context: {
|
|
25
|
+
defaultSchema: string;
|
|
26
|
+
};
|
|
27
|
+
}): YamlError[];
|
|
28
|
+
}
|
|
29
|
+
export declare class SqlSyncConfigParser implements SyncConfigParser {
|
|
30
|
+
#private;
|
|
31
|
+
constructor(parsers?: readonly AdditionalSyncConfigParser[]);
|
|
32
|
+
get jsonSchema(): JsonObject;
|
|
33
|
+
/**
|
|
34
|
+
* Validate the candidate composition before mutating the registry.
|
|
35
|
+
*/
|
|
36
|
+
registerParser(parser: AdditionalSyncConfigParser): void;
|
|
37
|
+
parseContent(content: string, options: ParseSyncConfigOptions): SyncConfigWithErrors;
|
|
38
|
+
validatePersisted({ config, context }: {
|
|
39
|
+
config: SyncConfig;
|
|
40
|
+
context: {
|
|
41
|
+
defaultSchema: string;
|
|
42
|
+
};
|
|
43
|
+
}): YamlError[];
|
|
44
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { compileSyncRulesSchemaValidator, createSyncRulesSchema, PrecompiledSyncConfig, SqlSyncRules, SyncRulesErrors, validateAdditionalSyncConfigParsers, YamlError } from '@powersync/service-sync-rules';
|
|
2
|
+
export class SqlSyncConfigParser {
|
|
3
|
+
#parsers;
|
|
4
|
+
#jsonSchema;
|
|
5
|
+
#schemaValidator;
|
|
6
|
+
constructor(parsers = []) {
|
|
7
|
+
validateAdditionalSyncConfigParsers(parsers);
|
|
8
|
+
this.#parsers = [...parsers];
|
|
9
|
+
this.#jsonSchema = createSyncRulesSchema(parsers);
|
|
10
|
+
this.#schemaValidator = compileSyncRulesSchemaValidator(this.#jsonSchema);
|
|
11
|
+
}
|
|
12
|
+
get jsonSchema() {
|
|
13
|
+
// Tooling can customize its copy without changing validation for the running service.
|
|
14
|
+
return structuredClone(this.#jsonSchema);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Validate the candidate composition before mutating the registry.
|
|
18
|
+
*/
|
|
19
|
+
registerParser(parser) {
|
|
20
|
+
const parsers = [...this.#parsers, parser];
|
|
21
|
+
validateAdditionalSyncConfigParsers(parsers);
|
|
22
|
+
const schema = createSyncRulesSchema(parsers);
|
|
23
|
+
const validator = compileSyncRulesSchemaValidator(schema);
|
|
24
|
+
this.#parsers.push(parser);
|
|
25
|
+
this.#jsonSchema = schema;
|
|
26
|
+
this.#schemaValidator = validator;
|
|
27
|
+
}
|
|
28
|
+
parseContent(content, options) {
|
|
29
|
+
return SqlSyncRules.fromYaml(content, {
|
|
30
|
+
...options,
|
|
31
|
+
parsers: this.#parsers,
|
|
32
|
+
schemaValidator: this.#schemaValidator
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
validatePersisted({ config, context }) {
|
|
36
|
+
/**
|
|
37
|
+
* Ensure that all modules which created a persisted SyncConfig
|
|
38
|
+
* are currently loaded.
|
|
39
|
+
* This prevents a case for a SyncConfig with missing external modules to be loaded.
|
|
40
|
+
*/
|
|
41
|
+
const requiredIds = new Set(config instanceof PrecompiledSyncConfig ? Object.keys(config.plan.moduleData ?? {}) : []);
|
|
42
|
+
const registeredIds = new Set(this.#parsers.map((parser) => parser.id));
|
|
43
|
+
const missingIds = [...requiredIds].filter((id) => !registeredIds.has(id));
|
|
44
|
+
if (missingIds.length != 0) {
|
|
45
|
+
throw new Error(`Missing required sync config parsers: ${missingIds.join(', ')}`);
|
|
46
|
+
}
|
|
47
|
+
const errors = [];
|
|
48
|
+
const reportDiagnostic = (diagnostic) => {
|
|
49
|
+
const location = diagnostic.location;
|
|
50
|
+
const error = new YamlError(new Error(diagnostic.message), location && {
|
|
51
|
+
start: location.start_offset,
|
|
52
|
+
end: location.end_offset
|
|
53
|
+
});
|
|
54
|
+
error.type = diagnostic.level;
|
|
55
|
+
errors.push(error);
|
|
56
|
+
};
|
|
57
|
+
for (const parser of this.#parsers) {
|
|
58
|
+
if (!requiredIds.has(parser.id))
|
|
59
|
+
continue;
|
|
60
|
+
/**
|
|
61
|
+
* This allows additional validation of module specific semantics
|
|
62
|
+
*/
|
|
63
|
+
parser.validatePersisted?.({ config, context: { ...context, reportDiagnostic } });
|
|
64
|
+
}
|
|
65
|
+
if (errors.some((error) => error.type == 'fatal'))
|
|
66
|
+
throw new SyncRulesErrors(errors);
|
|
67
|
+
return errors;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=SyncConfigParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SyncConfigParser.js","sourceRoot":"","sources":["../../src/storage/SyncConfigParser.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,+BAA+B,EAC/B,qBAAqB,EAErB,qBAAqB,EACrB,YAAY,EAIZ,eAAe,EAGf,mCAAmC,EACnC,SAAS,EACV,MAAM,+BAA+B,CAAC;AA4BvC,MAAM,OAAO,mBAAmB;IACrB,QAAQ,CAA+B;IAChD,WAAW,CAAa;IACxB,gBAAgB,CAA2B;IAE3C,YAAY,UAAiD,EAAE;QAC7D,mCAAmC,CAAC,OAAO,CAAC,CAAC;QAC7C,IAAI,CAAC,QAAQ,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC;QAClD,IAAI,CAAC,gBAAgB,GAAG,+BAA+B,CAAC,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