@powersync/service-core 1.23.3 → 1.25.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 +45 -0
- package/dist/api/RouteAPI.d.ts +17 -3
- package/dist/entry/commands/compact-action.js +4 -0
- package/dist/entry/commands/compact-action.js.map +1 -1
- package/dist/replication/AbstractReplicator.d.ts +9 -4
- package/dist/replication/AbstractReplicator.js +35 -11
- package/dist/replication/AbstractReplicator.js.map +1 -1
- package/dist/routes/configure-fastify.d.ts +31 -0
- package/dist/routes/endpoints/checkpointing.d.ts +62 -0
- package/dist/routes/endpoints/checkpointing.js +63 -3
- package/dist/routes/endpoints/checkpointing.js.map +1 -1
- package/dist/storage/BucketStorageBatch.d.ts +4 -1
- package/dist/storage/BucketStorageBatch.js.map +1 -1
- package/dist/storage/BucketStorageFactory.d.ts +2 -2
- package/dist/storage/CheckpointChecksumInvalidatedError.d.ts +12 -0
- package/dist/storage/CheckpointChecksumInvalidatedError.js +17 -0
- package/dist/storage/CheckpointChecksumInvalidatedError.js.map +1 -0
- package/dist/storage/SourceEntity.d.ts +7 -2
- package/dist/storage/SourceTable.d.ts +24 -1
- package/dist/storage/SourceTable.js +34 -6
- 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/SyncRulesBucketStorage.d.ts +32 -1
- package/dist/storage/SyncRulesBucketStorage.js +3 -0
- package/dist/storage/SyncRulesBucketStorage.js.map +1 -1
- package/dist/storage/WriteCheckpointAPI.d.ts +60 -3
- package/dist/storage/WriteCheckpointAPI.js +33 -0
- package/dist/storage/WriteCheckpointAPI.js.map +1 -1
- package/dist/storage/implementation/BucketDefinitionMapping.d.ts +4 -4
- package/dist/storage/implementation/BucketDefinitionMapping.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/sync/BucketChecksumState.d.ts +7 -0
- package/dist/sync/BucketChecksumState.js +33 -13
- package/dist/sync/BucketChecksumState.js.map +1 -1
- package/dist/sync/sync.js +34 -6
- package/dist/sync/sync.js.map +1 -1
- package/dist/sync/util.d.ts +5 -0
- package/dist/sync/util.js +9 -0
- package/dist/sync/util.js.map +1 -1
- package/dist/util/checkpointing.d.ts +1 -0
- package/dist/util/checkpointing.js +1 -1
- package/dist/util/checkpointing.js.map +1 -1
- package/dist/util/config/compound-config-collector.js +9 -1
- package/dist/util/config/compound-config-collector.js.map +1 -1
- package/dist/util/config/defaults.d.ts +1 -0
- package/dist/util/config/defaults.js +1 -0
- package/dist/util/config/defaults.js.map +1 -1
- package/dist/util/config/types.d.ts +1 -0
- package/dist/util/utils.d.ts +1 -1
- package/dist/util/utils.js +1 -1
- package/dist/util/utils.js.map +1 -1
- package/dist/util/write-checkpoint-batcher.d.ts +1 -1
- package/dist/util/write-checkpoint-batcher.js +18 -8
- package/dist/util/write-checkpoint-batcher.js.map +1 -1
- package/package.json +5 -5
- package/src/api/RouteAPI.ts +18 -3
- package/src/entry/commands/compact-action.ts +6 -0
- package/src/replication/AbstractReplicator.ts +42 -12
- package/src/routes/endpoints/checkpointing.ts +77 -3
- package/src/storage/BucketStorageBatch.ts +4 -1
- package/src/storage/BucketStorageFactory.ts +2 -2
- package/src/storage/CheckpointChecksumInvalidatedError.ts +17 -0
- package/src/storage/SourceEntity.ts +6 -2
- package/src/storage/SourceTable.ts +51 -7
- package/src/storage/SourceTableReconciler.ts +188 -0
- package/src/storage/SyncRulesBucketStorage.ts +38 -1
- package/src/storage/WriteCheckpointAPI.ts +108 -3
- package/src/storage/implementation/BucketDefinitionMapping.ts +4 -4
- package/src/storage/storage-index.ts +2 -0
- package/src/sync/BucketChecksumState.ts +38 -13
- package/src/sync/sync.ts +33 -7
- package/src/sync/util.ts +12 -0
- package/src/util/checkpointing.ts +2 -1
- package/src/util/config/compound-config-collector.ts +12 -0
- package/src/util/config/defaults.ts +1 -0
- package/src/util/config/types.ts +1 -0
- package/src/util/utils.ts +1 -1
- package/src/util/write-checkpoint-batcher.ts +30 -10
- package/test/src/AbstractReplicator.test.ts +147 -0
- package/test/src/config.test.ts +60 -0
- package/test/src/routes/checkpointing.test.ts +54 -0
- package/test/src/source-table-reconciler.test.ts +244 -0
- package/test/src/sync/BucketChecksumState.test.ts +57 -11
- package/test/src/sync/util.test.ts +13 -1
- package/test/src/util/checkpointing.test.ts +99 -20
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { BucketDataSource, BucketDefinitionId, 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,10 @@ export interface SourceTableOptions {
|
|
|
15
19
|
parameterLookupSources: ParameterIndexLookupCreator[];
|
|
16
20
|
bucketDataSourceIds?: Set<BucketDefinitionId>;
|
|
17
21
|
parameterLookupSourceIds?: Set<ParameterIndexId>;
|
|
22
|
+
/**
|
|
23
|
+
* Source-specific metadata. Null when no metadata has been recorded.
|
|
24
|
+
*/
|
|
25
|
+
sourceMetadata?: JsonValue;
|
|
18
26
|
}
|
|
19
27
|
export interface TableSnapshotStatus {
|
|
20
28
|
totalEstimatedCount: number;
|
|
@@ -86,6 +94,9 @@ export declare class SourceTable {
|
|
|
86
94
|
get parameterLookupSources(): ParameterIndexLookupCreator[];
|
|
87
95
|
get bucketDataSourceIds(): Set<string> | undefined;
|
|
88
96
|
get parameterLookupSourceIds(): Set<string> | undefined;
|
|
97
|
+
get sourceMetadata(): string | number | boolean | JsonValue[] | {
|
|
98
|
+
[key: string]: JsonValue;
|
|
99
|
+
} | null;
|
|
89
100
|
/**
|
|
90
101
|
* Sanitized name of the entity in the format of "{schema}.{entity name}".
|
|
91
102
|
* Suitable for safe use in Postgres queries.
|
|
@@ -96,5 +107,17 @@ export declare class SourceTable {
|
|
|
96
107
|
* In-memory clone of the table status.
|
|
97
108
|
*/
|
|
98
109
|
clone(): SourceTable;
|
|
110
|
+
/**
|
|
111
|
+
* Copy this table with different source metadata, preserving its resolved state.
|
|
112
|
+
*/
|
|
113
|
+
withSourceMetadata(sourceMetadata: JsonValue): SourceTable;
|
|
114
|
+
private copyWithSourceMetadata;
|
|
99
115
|
formatSnapshotProgress(): string;
|
|
100
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* A cloned SourceTable exposed to reconciliation with public fields typed as read-only.
|
|
119
|
+
* `options` is omitted so callers cannot mutate the underlying option bag without an explicit cast.
|
|
120
|
+
*/
|
|
121
|
+
export type SourceTableCandidate = Omit<Readonly<SourceTable>, 'options' | 'withSourceMetadata'> & {
|
|
122
|
+
withSourceMetadata(sourceMetadata: JsonValue): SourceTableCandidate;
|
|
123
|
+
};
|
|
@@ -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
|
*
|
|
@@ -88,6 +97,9 @@ export class SourceTable {
|
|
|
88
97
|
get parameterLookupSourceIds() {
|
|
89
98
|
return this.options.parameterLookupSourceIds;
|
|
90
99
|
}
|
|
100
|
+
get sourceMetadata() {
|
|
101
|
+
return this.options.sourceMetadata ?? null;
|
|
102
|
+
}
|
|
91
103
|
/**
|
|
92
104
|
* Sanitized name of the entity in the format of "{schema}.{entity name}".
|
|
93
105
|
* Suitable for safe use in Postgres queries.
|
|
@@ -102,22 +114,38 @@ export class SourceTable {
|
|
|
102
114
|
* In-memory clone of the table status.
|
|
103
115
|
*/
|
|
104
116
|
clone() {
|
|
117
|
+
return this.copyWithSourceMetadata(this.sourceMetadata);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Copy this table with different source metadata, preserving its resolved state.
|
|
121
|
+
*/
|
|
122
|
+
withSourceMetadata(sourceMetadata) {
|
|
123
|
+
return this.copyWithSourceMetadata(sourceMetadata);
|
|
124
|
+
}
|
|
125
|
+
copyWithSourceMetadata(sourceMetadata) {
|
|
105
126
|
const copy = new SourceTable({
|
|
106
127
|
id: this.id,
|
|
107
|
-
ref: this.options.ref,
|
|
128
|
+
ref: { ...this.options.ref },
|
|
108
129
|
objectId: this.objectId,
|
|
109
|
-
replicaIdColumns: this.replicaIdColumns,
|
|
130
|
+
replicaIdColumns: this.replicaIdColumns.map((column) => ({ ...column })),
|
|
110
131
|
snapshotComplete: this.snapshotComplete,
|
|
111
|
-
bucketDataSources: this.bucketDataSources,
|
|
112
|
-
parameterLookupSources: this.parameterLookupSources,
|
|
132
|
+
bucketDataSources: [...this.bucketDataSources],
|
|
133
|
+
parameterLookupSources: [...this.parameterLookupSources],
|
|
113
134
|
bucketDataSourceIds: this.bucketDataSourceIds == null ? undefined : new Set(this.bucketDataSourceIds),
|
|
114
|
-
parameterLookupSourceIds: this.parameterLookupSourceIds == null ? undefined : new Set(this.parameterLookupSourceIds)
|
|
135
|
+
parameterLookupSourceIds: this.parameterLookupSourceIds == null ? undefined : new Set(this.parameterLookupSourceIds),
|
|
136
|
+
sourceMetadata: structuredClone(sourceMetadata)
|
|
115
137
|
});
|
|
116
138
|
copy.syncData = this.syncData;
|
|
117
139
|
copy.syncParameters = this.syncParameters;
|
|
118
140
|
copy.syncEvent = this.syncEvent;
|
|
119
141
|
copy.storeCurrentData = this.storeCurrentData;
|
|
120
|
-
copy.snapshotStatus =
|
|
142
|
+
copy.snapshotStatus =
|
|
143
|
+
this.snapshotStatus == null
|
|
144
|
+
? undefined
|
|
145
|
+
: {
|
|
146
|
+
...this.snapshotStatus,
|
|
147
|
+
lastKey: this.snapshotStatus.lastKey?.slice() ?? null
|
|
148
|
+
};
|
|
121
149
|
return copy;
|
|
122
150
|
}
|
|
123
151
|
formatSnapshotProgress() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SourceTable.js","sourceRoot":"","sources":["../../src/storage/SourceTable.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,WAAW,EAIZ,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,IAAI,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"SourceTable.js","sourceRoot":"","sources":["../../src/storage/SourceTable.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,WAAW,EAIZ,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,IAAI,MAAM,uBAAuB,CAAC;AAQ9C;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAmB,EAAE,KAAoB;IAC3E,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC1D,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,I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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,MAA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yncConfigSet } from './ParsedSyncConfigSet.js';
|
|
|
9
9
|
import { ParseSyncConfigOptions } from './PersistedSyncConfigContent.js';
|
|
10
10
|
import { SourceEntityDescriptor } from './SourceEntity.js';
|
|
11
11
|
import { SourceTable } from './SourceTable.js';
|
|
12
|
+
import { SourceTableCandidateReconciler } from './SourceTableReconciler.js';
|
|
12
13
|
import { StorageVersionConfig } from './StorageVersionConfig.js';
|
|
13
14
|
import { SyncStorageWriteCheckpointAPI } from './WriteCheckpointAPI.js';
|
|
14
15
|
/**
|
|
@@ -105,11 +106,18 @@ export interface SyncRulesBucketStorage extends ObserverClient<SyncRulesBucketSt
|
|
|
105
106
|
* 1. Separate buckets.
|
|
106
107
|
* 2. Limit the size of each individual chunk according to options.batchSizeLimitBytes.
|
|
107
108
|
*
|
|
109
|
+
* The batch may not contain all data for the checkpoint, if the checkpoint is large. The caller must
|
|
110
|
+
* continue querying if either:
|
|
111
|
+
* 1. The last chunk for any bucket has has_more = true.
|
|
112
|
+
* 2. A SyncBucketDataBatchEnd is returned with hasMore = true.
|
|
113
|
+
*
|
|
114
|
+
* The first check can be skipped if a SyncBucketDataBatchEnd is returned with hasMore = false.
|
|
115
|
+
*
|
|
108
116
|
* @param checkpoint the checkpoint
|
|
109
117
|
* @param dataBuckets current bucket states
|
|
110
118
|
* @param options batch size options
|
|
111
119
|
*/
|
|
112
|
-
getBucketDataBatch(checkpoint: ReplicationCheckpoint, dataBuckets: BucketDataRequest[], options?: BucketDataBatchOptions): AsyncIterable<SyncBucketDataChunk>;
|
|
120
|
+
getBucketDataBatch(checkpoint: ReplicationCheckpoint, dataBuckets: BucketDataRequest[], options?: BucketDataBatchOptions): AsyncIterable<SyncBucketDataChunk | SyncBucketDataBatchEnd>;
|
|
113
121
|
/**
|
|
114
122
|
* Compute checksums for a given list of buckets.
|
|
115
123
|
*
|
|
@@ -161,6 +169,11 @@ export interface ResolveTablesOptions {
|
|
|
161
169
|
* Source table or collection metadata discovered during snapshot or streaming.
|
|
162
170
|
*/
|
|
163
171
|
source: SourceEntityDescriptor;
|
|
172
|
+
/**
|
|
173
|
+
* Classifies overlapping persisted tables. Defaults to identity-based reconciliation.
|
|
174
|
+
* This may run inside a storage transaction and must not mutate storage.
|
|
175
|
+
*/
|
|
176
|
+
reconcileSourceTables?: SourceTableCandidateReconciler;
|
|
164
177
|
/**
|
|
165
178
|
* For tests only - custom id generator for stable ids.
|
|
166
179
|
*/
|
|
@@ -251,6 +264,12 @@ export interface CompactOptions {
|
|
|
251
264
|
*/
|
|
252
265
|
compactBuckets?: string[];
|
|
253
266
|
compactParameterData?: boolean;
|
|
267
|
+
/**
|
|
268
|
+
* Delete client-requested write checkpoints created before this time.
|
|
269
|
+
*
|
|
270
|
+
* Generated write checkpoints are not affected.
|
|
271
|
+
*/
|
|
272
|
+
deleteCheckpointRequestsBefore?: Date;
|
|
254
273
|
/** Minimum of 2 */
|
|
255
274
|
clearBatchLimit?: number;
|
|
256
275
|
/** Minimum of 1 */
|
|
@@ -323,6 +342,8 @@ export interface TerminateOptions extends ClearStorageOptions {
|
|
|
323
342
|
}
|
|
324
343
|
export interface BucketDataBatchOptions {
|
|
325
344
|
requestHint?: BucketRequestHint;
|
|
345
|
+
/** Abort any in-progress work for this batch, including object-storage downloads. */
|
|
346
|
+
signal?: AbortSignal;
|
|
326
347
|
/** Limit number of documents returned. Defaults to 1000. */
|
|
327
348
|
limit?: number;
|
|
328
349
|
/**
|
|
@@ -340,6 +361,16 @@ export interface SyncBucketDataChunk {
|
|
|
340
361
|
chunkData: util.SyncBucketData;
|
|
341
362
|
targetOp: util.InternalOpId | null;
|
|
342
363
|
}
|
|
364
|
+
export interface SyncBucketDataBatchEnd {
|
|
365
|
+
/**
|
|
366
|
+
* True if there may be more data for this checkpoint, and the caller should continue querying.
|
|
367
|
+
*
|
|
368
|
+
* This is different from `SyncBucketDataChunk.has_more`, which is per-bucket. This is a global signal for the
|
|
369
|
+
* entire request, and may be true even if there is no returned chunk with has_more: true.
|
|
370
|
+
*/
|
|
371
|
+
hasMore: boolean;
|
|
372
|
+
}
|
|
373
|
+
export declare function isBatchEnd(chunk: SyncBucketDataChunk | SyncBucketDataBatchEnd): chunk is SyncBucketDataBatchEnd;
|
|
343
374
|
export interface ReplicationCheckpoint {
|
|
344
375
|
readonly checkpoint: util.InternalOpId;
|
|
345
376
|
readonly lsn: string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SyncRulesBucketStorage.js","sourceRoot":"","sources":["../../src/storage/SyncRulesBucketStorage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SyncRulesBucketStorage.js","sourceRoot":"","sources":["../../src/storage/SyncRulesBucketStorage.ts"],"names":[],"mappings":"AAmcA,MAAM,UAAU,UAAU,CAAC,KAAmD;IAC5E,OAAQ,KAAgC,CAAC,OAAO,KAAK,SAAS,CAAC;AACjE,CAAC;AAiBD;;;;GAIG;AACH,MAAM,OAAO,8BAA+B,SAAQ,KAAK;IAE5C;IACA;IAFX,YACW,KAAa,EACb,SAAyC;QAElD,KAAK,CAAC,yCAAyC,KAAK,GAAG,CAAC,CAAC;QAHhD,UAAK,GAAL,KAAK,CAAQ;QACb,cAAS,GAAT,SAAS,CAAgC;IAGpD,CAAC;CACF;AAqDD,MAAM,CAAC,MAAM,yBAAyB,GAAsB;IAC1D,kBAAkB,EAAE,IAAI,GAAG,EAAU;IACrC,qBAAqB,EAAE,IAAI;IAC3B,uBAAuB,EAAE,IAAI,GAAG,EAAU;IAC1C,0BAA0B,EAAE,IAAI;CACjC,CAAC"}
|
|
@@ -17,6 +17,17 @@ export interface BaseWriteCheckpointIdentifier {
|
|
|
17
17
|
*/
|
|
18
18
|
user_id: string;
|
|
19
19
|
}
|
|
20
|
+
export interface ClientRequestedCheckpointOptions {
|
|
21
|
+
/**
|
|
22
|
+
* Supplied for client-generated checkpoint requests.
|
|
23
|
+
*
|
|
24
|
+
* If omitted, storage creates or stores a regular write checkpoint.
|
|
25
|
+
* If supplied for managed write checkpoints, storage only uses it when it is
|
|
26
|
+
* greater than the stored id for the user_id. Same or lower supplied ids are
|
|
27
|
+
* no-ops, and storage returns the current stored id.
|
|
28
|
+
*/
|
|
29
|
+
checkpoint_request_id?: bigint;
|
|
30
|
+
}
|
|
20
31
|
export interface CustomWriteCheckpointFilters extends BaseWriteCheckpointIdentifier {
|
|
21
32
|
/**
|
|
22
33
|
* Replication stream which was active when this checkpoint was created.
|
|
@@ -25,9 +36,17 @@ export interface CustomWriteCheckpointFilters extends BaseWriteCheckpointIdentif
|
|
|
25
36
|
}
|
|
26
37
|
export interface BatchedCustomWriteCheckpointOptions extends BaseWriteCheckpointIdentifier {
|
|
27
38
|
/**
|
|
28
|
-
* A supplied incrementing
|
|
39
|
+
* A supplied incrementing checkpoint request id. This is still named
|
|
40
|
+
* "write checkpoint" in storage APIs for backwards compatibility.
|
|
29
41
|
*/
|
|
30
42
|
checkpoint: bigint;
|
|
43
|
+
/**
|
|
44
|
+
* Required when this custom checkpoint was created from a client checkpoint
|
|
45
|
+
* request and should be eligible for checkpoint request retention cleanup.
|
|
46
|
+
* Omit or set to null for persistent custom checkpoints owned by the source
|
|
47
|
+
* or integration.
|
|
48
|
+
*/
|
|
49
|
+
checkpoint_requested_at?: Date | null;
|
|
31
50
|
}
|
|
32
51
|
export interface CustomWriteCheckpointOptions extends BatchedCustomWriteCheckpointOptions {
|
|
33
52
|
/**
|
|
@@ -44,13 +63,51 @@ export interface ManagedWriteCheckpointFilters extends BaseWriteCheckpointIdenti
|
|
|
44
63
|
*/
|
|
45
64
|
heads: Record<string, string>;
|
|
46
65
|
}
|
|
47
|
-
export type ManagedWriteCheckpointOptions = ManagedWriteCheckpointFilters;
|
|
66
|
+
export type ManagedWriteCheckpointOptions = ManagedWriteCheckpointFilters & ClientRequestedCheckpointOptions;
|
|
67
|
+
export interface CreateManagedWriteCheckpointsResult {
|
|
68
|
+
/**
|
|
69
|
+
* Current managed checkpoint id for each full user_id after applying the batch.
|
|
70
|
+
*/
|
|
71
|
+
writeCheckpoints: Map<string, bigint>;
|
|
72
|
+
/**
|
|
73
|
+
* True when the source marker must be forced so replication observes the
|
|
74
|
+
* stored head. Callers use this to advance the source marker once for the
|
|
75
|
+
* whole batch.
|
|
76
|
+
*
|
|
77
|
+
* This must be true whenever a checkpoint in the batch has not yet been
|
|
78
|
+
* processed by replication - both freshly created/advanced checkpoints and
|
|
79
|
+
* existing checkpoints matched by a stale or duplicate request that are still
|
|
80
|
+
* pending. Already-processed checkpoints do not need a new marker.
|
|
81
|
+
*
|
|
82
|
+
* The case this guards against is a lost source marker on a stale retry. The
|
|
83
|
+
* source marker is forced after the checkpoint is persisted, so the two are
|
|
84
|
+
* not atomic (storage and source are usually different databases). Without
|
|
85
|
+
* this flag, the following sequence strands the checkpoint:
|
|
86
|
+
*
|
|
87
|
+
* 1. A client-supplied checkpoint id is persisted (write checkpoint stored,
|
|
88
|
+
* processed_at_lsn null).
|
|
89
|
+
* 2. Forcing the source marker fails, so the request errors and the client
|
|
90
|
+
* retries with the same id.
|
|
91
|
+
* 3. The retry is a no-op for the stored id (monotonic, not greater), so if
|
|
92
|
+
* we only advanced on "a row changed" we would skip the marker.
|
|
93
|
+
* 4. On an idle source nothing else moves replication past the stored head,
|
|
94
|
+
* so the checkpoint never gets acknowledged and the client waits forever.
|
|
95
|
+
*
|
|
96
|
+
* Reporting true while the checkpoint is still pending makes the retry re-force
|
|
97
|
+
* the marker, which resolves the wait.
|
|
98
|
+
*
|
|
99
|
+
* Backends that do not track a per-row processed indicator may conservatively
|
|
100
|
+
* report true whenever any checkpoint was matched.
|
|
101
|
+
*/
|
|
102
|
+
shouldAdvance: boolean;
|
|
103
|
+
}
|
|
104
|
+
export declare function uniqueManagedWriteCheckpoints(checkpoints: ManagedWriteCheckpointOptions[]): ManagedWriteCheckpointOptions[];
|
|
48
105
|
export type SyncStorageLastWriteCheckpointFilters = BaseWriteCheckpointIdentifier | ManagedWriteCheckpointFilters;
|
|
49
106
|
export type LastWriteCheckpointFilters = CustomWriteCheckpointFilters | ManagedWriteCheckpointFilters;
|
|
50
107
|
export interface BaseWriteCheckpointAPI {
|
|
51
108
|
readonly writeCheckpointMode: WriteCheckpointMode;
|
|
52
109
|
setWriteCheckpointMode(mode: WriteCheckpointMode): void;
|
|
53
|
-
createManagedWriteCheckpoints(checkpoints: ManagedWriteCheckpointOptions[]): Promise<
|
|
110
|
+
createManagedWriteCheckpoints(checkpoints: ManagedWriteCheckpointOptions[]): Promise<CreateManagedWriteCheckpointsResult>;
|
|
54
111
|
}
|
|
55
112
|
/**
|
|
56
113
|
* Write Checkpoint API to be used in conjunction with a {@link SyncRulesBucketStorage}.
|
|
@@ -12,5 +12,38 @@ export var WriteCheckpointMode;
|
|
|
12
12
|
*/
|
|
13
13
|
WriteCheckpointMode["MANAGED"] = "managed";
|
|
14
14
|
})(WriteCheckpointMode || (WriteCheckpointMode = {}));
|
|
15
|
+
export function uniqueManagedWriteCheckpoints(checkpoints) {
|
|
16
|
+
const byUser = new Map();
|
|
17
|
+
for (const checkpoint of checkpoints) {
|
|
18
|
+
const existing = byUser.get(checkpoint.user_id);
|
|
19
|
+
// A batch can contain entries for many users, and different users may use
|
|
20
|
+
// different request types (generated vs client-supplied). For a single full
|
|
21
|
+
// user_id, though, all entries should be the same type - a batch can still
|
|
22
|
+
// hold multiple entries for that user (e.g. coalesced requests), so we
|
|
23
|
+
// collapse them to one. For client-supplied ids we keep the greatest
|
|
24
|
+
// requested value, so lower stale ids cannot hide the request that should
|
|
25
|
+
// advance storage. For generated ids the entries are equivalent, so any one
|
|
26
|
+
// is kept.
|
|
27
|
+
//
|
|
28
|
+
// Mixing generated and supplied entries for the same user_id is not expected;
|
|
29
|
+
// shouldReplaceManagedWriteCheckpoint still resolves it deterministically
|
|
30
|
+
// (supplied wins) if that invariant is ever violated.
|
|
31
|
+
if (existing == null || shouldReplaceManagedWriteCheckpoint(existing, checkpoint)) {
|
|
32
|
+
byUser.set(checkpoint.user_id, checkpoint);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return [...byUser.values()];
|
|
36
|
+
}
|
|
37
|
+
function shouldReplaceManagedWriteCheckpoint(existing, candidate) {
|
|
38
|
+
const existingRequestId = existing.checkpoint_request_id;
|
|
39
|
+
const candidateRequestId = candidate.checkpoint_request_id;
|
|
40
|
+
if (candidateRequestId == null) {
|
|
41
|
+
return existingRequestId == null;
|
|
42
|
+
}
|
|
43
|
+
if (existingRequestId == null) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
return candidateRequestId > existingRequestId;
|
|
47
|
+
}
|
|
15
48
|
export const DEFAULT_WRITE_CHECKPOINT_MODE = WriteCheckpointMode.MANAGED;
|
|
16
49
|
//# sourceMappingURL=WriteCheckpointAPI.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WriteCheckpointAPI.js","sourceRoot":"","sources":["../../src/storage/WriteCheckpointAPI.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,mBAYX;AAZD,WAAY,mBAAmB;IAC7B;;;OAGG;IACH,wCAAiB,CAAA;IACjB;;;;OAIG;IACH,0CAAmB,CAAA;AACrB,CAAC,EAZW,mBAAmB,KAAnB,mBAAmB,QAY9B;
|
|
1
|
+
{"version":3,"file":"WriteCheckpointAPI.js","sourceRoot":"","sources":["../../src/storage/WriteCheckpointAPI.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,mBAYX;AAZD,WAAY,mBAAmB;IAC7B;;;OAGG;IACH,wCAAiB,CAAA;IACjB;;;;OAIG;IACH,0CAAmB,CAAA;AACrB,CAAC,EAZW,mBAAmB,KAAnB,mBAAmB,QAY9B;AAoGD,MAAM,UAAU,6BAA6B,CAC3C,WAA4C;IAE5C,MAAM,MAAM,GAAG,IAAI,GAAG,EAAyC,CAAC;IAEhE,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACrC,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAChD,0EAA0E;QAC1E,4EAA4E;QAC5E,2EAA2E;QAC3E,uEAAuE;QACvE,qEAAqE;QACrE,0EAA0E;QAC1E,4EAA4E;QAC5E,WAAW;QACX,EAAE;QACF,8EAA8E;QAC9E,0EAA0E;QAC1E,sDAAsD;QACtD,IAAI,QAAQ,IAAI,IAAI,IAAI,mCAAmC,CAAC,QAAQ,EAAE,UAAU,CAAC,EAAE,CAAC;YAClF,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;AAC9B,CAAC;AAED,SAAS,mCAAmC,CAC1C,QAAuC,EACvC,SAAwC;IAExC,MAAM,iBAAiB,GAAG,QAAQ,CAAC,qBAAqB,CAAC;IACzD,MAAM,kBAAkB,GAAG,SAAS,CAAC,qBAAqB,CAAC;IAE3D,IAAI,kBAAkB,IAAI,IAAI,EAAE,CAAC;QAC/B,OAAO,iBAAiB,IAAI,IAAI,CAAC;IACnC,CAAC;IAED,IAAI,iBAAiB,IAAI,IAAI,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,kBAAkB,GAAG,iBAAiB,CAAC;AAChD,CAAC;AA8BD,MAAM,CAAC,MAAM,6BAA6B,GAAG,mBAAmB,CAAC,OAAO,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BucketDataSource, BucketDefinitionId, ParameterIndexId, ParameterIndexLookupCreator, ParameterLookupDefinitionId,
|
|
1
|
+
import { BucketDataSource, BucketDefinitionId, ParameterIndexId, ParameterIndexLookupCreator, ParameterLookupDefinitionId, SerializedSyncPlan, SourceTableRef, SyncConfigWithErrors } from '@powersync/service-sync-rules';
|
|
2
2
|
export interface SerializedSyncConfigWithMapping {
|
|
3
|
-
plan:
|
|
3
|
+
plan: SerializedSyncPlan;
|
|
4
4
|
mapping: SingleSyncConfigBucketDefinitionMapping;
|
|
5
5
|
}
|
|
6
6
|
export type IncrementalMappingDefinitionType = 'bucket_data' | 'parameter_lookup';
|
|
@@ -76,8 +76,8 @@ export declare class SingleSyncConfigBucketDefinitionMapping implements BucketDe
|
|
|
76
76
|
* @param reservedMappings _all_ mappings used currently and historically for the replication stream; used to construct new ids
|
|
77
77
|
* @returns
|
|
78
78
|
*/
|
|
79
|
-
static constructIncrementalMappingFromSerializedPlans(compatibleConfigs: SerializedSyncConfigWithMapping[], newPlan:
|
|
80
|
-
static constructIncrementalMappingWithChanges(compatibleConfigs: SerializedSyncConfigWithMapping[], newPlan:
|
|
79
|
+
static constructIncrementalMappingFromSerializedPlans(compatibleConfigs: SerializedSyncConfigWithMapping[], newPlan: SerializedSyncPlan, reservedMappings: SingleSyncConfigBucketDefinitionMapping[]): SingleSyncConfigBucketDefinitionMapping;
|
|
80
|
+
static constructIncrementalMappingWithChanges(compatibleConfigs: SerializedSyncConfigWithMapping[], newPlan: SerializedSyncPlan, reservedMappings: SingleSyncConfigBucketDefinitionMapping[]): IncrementalMappingResult;
|
|
81
81
|
constructor(definitions?: Record<string, BucketDefinitionId>, parameterLookupMapping?: Record<string, ParameterIndexId>);
|
|
82
82
|
bucketSourceId(source: BucketDataSource): BucketDefinitionId;
|
|
83
83
|
bucketSourceIdByName(uniqueName: string): BucketDefinitionId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BucketDefinitionMapping.js","sourceRoot":"","sources":["../../../src/storage/implementation/BucketDefinitionMapping.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAGL,OAAO,EAMP,wCAAwC,EACxC,mDAAmD,EAIpD,MAAM,+BAA+B,CAAC;AA6EvC;;;;;;;GAOG;AACH,MAAM,OAAO,uCAAuC;IAoIxC;IACA;IApIV,MAAM,CAAC,oBAAoB,CAAC,OAAm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IAC9D,MAAM,QAAQ,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,GAAG,EAAK,CAAC;IAC9C,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpB,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;AACzB,CAAC;AAED,SAAS,MAAM,CAAI,MAAc,EAAE,MAA+B;IAChE,KAAK,MAAM,KAAK,IAAI,MAAM,IAAI,EAAE,EAAE,CAAC;QACjC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpB,CAAC;AACH,CAAC"}
|
|
@@ -2,6 +2,7 @@ export * from './bson.js';
|
|
|
2
2
|
export * from './BucketStorage.js';
|
|
3
3
|
export * from './BucketStorageBatch.js';
|
|
4
4
|
export * from './BucketStorageFactory.js';
|
|
5
|
+
export * from './CheckpointChecksumInvalidatedError.js';
|
|
5
6
|
export * from './ChecksumCache.js';
|
|
6
7
|
export * from './ParsedSyncConfigSet.js';
|
|
7
8
|
export * from './PersistedReplicationStream.js';
|
|
@@ -12,6 +13,7 @@ export * from './ReplicationLock.js';
|
|
|
12
13
|
export * from './ReportStorage.js';
|
|
13
14
|
export * from './SourceEntity.js';
|
|
14
15
|
export * from './SourceTable.js';
|
|
16
|
+
export * from './SourceTableReconciler.js';
|
|
15
17
|
export * from './storage-metrics.js';
|
|
16
18
|
export * from './StorageEngine.js';
|
|
17
19
|
export * from './StorageProvider.js';
|