@powersync/service-core 1.22.0 → 1.23.1

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.
Files changed (113) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/api/RouteAPI.d.ts +2 -2
  3. package/dist/api/diagnostics.d.ts +12 -1
  4. package/dist/api/diagnostics.js +34 -22
  5. package/dist/api/diagnostics.js.map +1 -1
  6. package/dist/entry/commands/compact-action.js +1 -1
  7. package/dist/entry/commands/compact-action.js.map +1 -1
  8. package/dist/modules/AbstractModule.d.ts +6 -2
  9. package/dist/modules/AbstractModule.js.map +1 -1
  10. package/dist/replication/AbstractReplicator.d.ts +14 -3
  11. package/dist/replication/AbstractReplicator.js +122 -62
  12. package/dist/replication/AbstractReplicator.js.map +1 -1
  13. package/dist/replication/ReplicationModule.d.ts +3 -3
  14. package/dist/replication/ReplicationModule.js.map +1 -1
  15. package/dist/routes/configure-fastify.d.ts +12 -12
  16. package/dist/routes/endpoints/admin.d.ts +24 -24
  17. package/dist/routes/endpoints/admin.js +46 -35
  18. package/dist/routes/endpoints/admin.js.map +1 -1
  19. package/dist/routes/endpoints/checkpointing.js +1 -1
  20. package/dist/routes/endpoints/checkpointing.js.map +1 -1
  21. package/dist/routes/endpoints/socket-route.js +1 -1
  22. package/dist/routes/endpoints/socket-route.js.map +1 -1
  23. package/dist/routes/endpoints/sync-rules.js +22 -13
  24. package/dist/routes/endpoints/sync-rules.js.map +1 -1
  25. package/dist/routes/endpoints/sync-stream.js +1 -1
  26. package/dist/routes/endpoints/sync-stream.js.map +1 -1
  27. package/dist/runner/teardown.js +8 -8
  28. package/dist/runner/teardown.js.map +1 -1
  29. package/dist/storage/BucketStorageBatch.d.ts +0 -6
  30. package/dist/storage/BucketStorageBatch.js.map +1 -1
  31. package/dist/storage/BucketStorageFactory.d.ts +22 -27
  32. package/dist/storage/BucketStorageFactory.js +4 -18
  33. package/dist/storage/BucketStorageFactory.js.map +1 -1
  34. package/dist/storage/ParsedSyncConfigSet.d.ts +23 -0
  35. package/dist/storage/ParsedSyncConfigSet.js +2 -0
  36. package/dist/storage/ParsedSyncConfigSet.js.map +1 -0
  37. package/dist/storage/PersistedReplicationStream.d.ts +32 -0
  38. package/dist/storage/PersistedReplicationStream.js +26 -0
  39. package/dist/storage/PersistedReplicationStream.js.map +1 -0
  40. package/dist/storage/PersistedSyncConfigContent.d.ts +63 -0
  41. package/dist/storage/PersistedSyncConfigContent.js +125 -0
  42. package/dist/storage/PersistedSyncConfigContent.js.map +1 -0
  43. package/dist/storage/PersistedSyncConfigStatus.d.ts +13 -0
  44. package/dist/storage/PersistedSyncConfigStatus.js +2 -0
  45. package/dist/storage/PersistedSyncConfigStatus.js.map +1 -0
  46. package/dist/storage/SourceTable.d.ts +9 -3
  47. package/dist/storage/SourceTable.js +13 -3
  48. package/dist/storage/SourceTable.js.map +1 -1
  49. package/dist/storage/SyncRulesBucketStorage.d.ts +59 -16
  50. package/dist/storage/SyncRulesBucketStorage.js.map +1 -1
  51. package/dist/storage/implementation/BucketDefinitionMapping.d.ts +117 -0
  52. package/dist/storage/implementation/BucketDefinitionMapping.js +277 -0
  53. package/dist/storage/implementation/BucketDefinitionMapping.js.map +1 -0
  54. package/dist/storage/implementation/IncrementalReprocessingCompatibility.d.ts +6 -0
  55. package/dist/storage/implementation/IncrementalReprocessingCompatibility.js +31 -0
  56. package/dist/storage/implementation/IncrementalReprocessingCompatibility.js.map +1 -0
  57. package/dist/storage/implementation/IncrementalReprocessingSyncConfigLog.d.ts +17 -0
  58. package/dist/storage/implementation/IncrementalReprocessingSyncConfigLog.js +62 -0
  59. package/dist/storage/implementation/IncrementalReprocessingSyncConfigLog.js.map +1 -0
  60. package/dist/storage/implementation/ReplicationStreamStorageIds.d.ts +15 -0
  61. package/dist/storage/implementation/ReplicationStreamStorageIds.js +20 -0
  62. package/dist/storage/implementation/ReplicationStreamStorageIds.js.map +1 -0
  63. package/dist/storage/storage-index.d.ts +8 -1
  64. package/dist/storage/storage-index.js +8 -1
  65. package/dist/storage/storage-index.js.map +1 -1
  66. package/dist/sync/sync.js +5 -0
  67. package/dist/sync/sync.js.map +1 -1
  68. package/dist/util/checkpointing.js +1 -1
  69. package/dist/util/checkpointing.js.map +1 -1
  70. package/dist/util/config/types.d.ts +1 -1
  71. package/dist/util/lsn.d.ts +4 -0
  72. package/dist/util/lsn.js +10 -0
  73. package/dist/util/lsn.js.map +1 -1
  74. package/package.json +6 -7
  75. package/src/api/RouteAPI.ts +2 -2
  76. package/src/api/diagnostics.ts +43 -26
  77. package/src/entry/commands/compact-action.ts +1 -1
  78. package/src/modules/AbstractModule.ts +6 -2
  79. package/src/replication/AbstractReplicator.ts +145 -65
  80. package/src/replication/ReplicationModule.ts +2 -3
  81. package/src/routes/endpoints/admin.ts +72 -50
  82. package/src/routes/endpoints/checkpointing.ts +1 -1
  83. package/src/routes/endpoints/socket-route.ts +1 -1
  84. package/src/routes/endpoints/sync-rules.ts +23 -13
  85. package/src/routes/endpoints/sync-stream.ts +1 -1
  86. package/src/runner/teardown.ts +8 -8
  87. package/src/storage/BucketStorageBatch.ts +0 -7
  88. package/src/storage/BucketStorageFactory.ts +30 -39
  89. package/src/storage/ParsedSyncConfigSet.ts +25 -0
  90. package/src/storage/PersistedReplicationStream.ts +55 -0
  91. package/src/storage/PersistedSyncConfigContent.ts +192 -0
  92. package/src/storage/PersistedSyncConfigStatus.ts +14 -0
  93. package/src/storage/SourceTable.ts +20 -3
  94. package/src/storage/SyncRulesBucketStorage.ts +64 -16
  95. package/src/storage/implementation/BucketDefinitionMapping.ts +436 -0
  96. package/src/storage/implementation/IncrementalReprocessingCompatibility.ts +41 -0
  97. package/src/storage/implementation/IncrementalReprocessingSyncConfigLog.ts +109 -0
  98. package/src/storage/implementation/ReplicationStreamStorageIds.ts +21 -0
  99. package/src/storage/storage-index.ts +9 -1
  100. package/src/sync/sync.ts +5 -0
  101. package/src/util/checkpointing.ts +1 -1
  102. package/src/util/config/types.ts +1 -1
  103. package/src/util/lsn.ts +9 -0
  104. package/test/src/diagnostics.test.ts +62 -34
  105. package/test/src/module-loader.test.ts +33 -1
  106. package/test/src/routes/admin.test.ts +182 -18
  107. package/test/src/routes/mocks.ts +6 -2
  108. package/tsconfig.json +1 -4
  109. package/tsconfig.tsbuildinfo +1 -1
  110. package/dist/storage/PersistedSyncRulesContent.d.ts +0 -59
  111. package/dist/storage/PersistedSyncRulesContent.js +0 -100
  112. package/dist/storage/PersistedSyncRulesContent.js.map +0 -1
  113. package/src/storage/PersistedSyncRulesContent.ts +0 -174
@@ -0,0 +1,192 @@
1
+ import { logger as defaultLogger, ErrorCode, ServiceError } from '@powersync/lib-services-framework';
2
+ import {
3
+ CompatibilityContext,
4
+ CompatibilityOption,
5
+ DEFAULT_HYDRATION_STATE,
6
+ deserializeSyncPlan,
7
+ ErrorLocation,
8
+ HydratedSyncConfig,
9
+ HydrationState,
10
+ nodeSqlite,
11
+ PrecompiledSyncConfig,
12
+ SqlEventDescriptor,
13
+ SqlSyncRules,
14
+ SyncConfigWithErrors,
15
+ versionedHydrationState,
16
+ YamlError
17
+ } from '@powersync/service-sync-rules';
18
+ import * as sqlite from 'node:sqlite';
19
+ import { Logger } from 'winston';
20
+ import { SyncRuleState } from './BucketStorage.js';
21
+ import { SerializedSyncPlan, UpdateSyncRulesOptions } from './BucketStorageFactory.js';
22
+ import { ParsedSyncConfigSet } from './ParsedSyncConfigSet.js';
23
+ import { PersistedSyncConfigStatus } from './PersistedSyncConfigStatus.js';
24
+ import { STORAGE_VERSION_CONFIG, StorageVersionConfig } from './StorageVersionConfig.js';
25
+
26
+ export interface ParsePersistedSyncConfigContentOptions {
27
+ content: string;
28
+ compiledPlan: SerializedSyncPlan | null;
29
+ storageVersion: number;
30
+ parseOptions: ParseSyncConfigOptions;
31
+ }
32
+
33
+ export function parsePersistedSyncConfigContent(options: ParsePersistedSyncConfigContentOptions): SyncConfigWithErrors {
34
+ const { content, compiledPlan, storageVersion, parseOptions } = options;
35
+
36
+ if (compiledPlan == null) {
37
+ // Fallback: Only parse from YAML if no compiled plan is available.
38
+ return SqlSyncRules.fromYaml(content, parseOptions);
39
+ }
40
+
41
+ const plan = deserializeSyncPlan(compiledPlan.plan);
42
+ const compatibility = CompatibilityContext.deserialize(compiledPlan.compatibility);
43
+ const eventDefinitions: SqlEventDescriptor[] = [];
44
+ for (const [name, queries] of Object.entries(compiledPlan.eventDescriptors)) {
45
+ const descriptor = new SqlEventDescriptor(name, compatibility);
46
+ for (const query of queries) {
47
+ descriptor.addSourceQuery(query, parseOptions);
48
+ }
49
+
50
+ eventDefinitions.push(descriptor);
51
+ }
52
+
53
+ const precompiled = new PrecompiledSyncConfig(plan, compatibility, eventDefinitions, {
54
+ defaultSchema: parseOptions.defaultSchema,
55
+ sourceText: content
56
+ });
57
+
58
+ // Note: If the original content did not define a storage version, this will still set the storage version.
59
+ // This means asUpdateOptions will not change the storage version, even if the default changes.
60
+ precompiled.storageVersion = storageVersion;
61
+
62
+ const errors: YamlError[] = [];
63
+ if (compiledPlan.errors) {
64
+ for (const error of compiledPlan.errors) {
65
+ const location: ErrorLocation | undefined = error.location && {
66
+ start: error.location.start_offset,
67
+ end: error.location.end_offset
68
+ };
69
+ const asYamlError = new YamlError(new Error(error.message), location);
70
+ asYamlError.type = error.level;
71
+
72
+ errors.push(asYamlError);
73
+ }
74
+ }
75
+
76
+ return { config: precompiled, errors };
77
+ }
78
+
79
+ /**
80
+ * Immutable sync config content for one sync config inside a replication stream.
81
+ *
82
+ * This represents the persisted config content. Fetch per-config status with
83
+ * {@link getSyncConfigStatus}. Use {@link PersistedReplicationStream} for stream
84
+ * lifecycle concerns such as locking and termination.
85
+ */
86
+
87
+ export abstract class PersistedSyncConfigContent implements PersistedSyncConfigContentData {
88
+ readonly replicationStreamId: number;
89
+ readonly sync_rules_content: string;
90
+ readonly compiled_plan: SerializedSyncPlan | null;
91
+ readonly replicationStreamName: string;
92
+ readonly storageVersion: number;
93
+ readonly logger: Logger;
94
+ readonly syncConfigId: PersistedSyncConfigId | null;
95
+ readonly syncConfigState: SyncRuleState;
96
+
97
+ constructor(data: PersistedSyncConfigContentData) {
98
+ this.replicationStreamId = data.replicationStreamId;
99
+ this.sync_rules_content = data.sync_rules_content;
100
+ this.compiled_plan = data.compiled_plan;
101
+ this.replicationStreamName = data.replicationStreamName;
102
+ this.storageVersion = data.storageVersion;
103
+ this.syncConfigId = data.syncConfigId ?? null;
104
+ this.syncConfigState = data.syncConfigState;
105
+ this.logger = defaultLogger.child({ prefix: `[${this.replicationStreamName}] ` });
106
+ }
107
+
108
+ /**
109
+ * Load the storage config.
110
+ *
111
+ * This may throw if the persisted storage version is not supported.
112
+ */
113
+ getStorageConfig(): StorageVersionConfig {
114
+ const storageConfig = STORAGE_VERSION_CONFIG[this.storageVersion];
115
+ if (storageConfig == null) {
116
+ throw new ServiceError(
117
+ ErrorCode.PSYNC_S1005,
118
+ `Unsupported storage version ${this.storageVersion} for replication stream ${this.replicationStreamId}`
119
+ );
120
+ }
121
+ return storageConfig;
122
+ }
123
+
124
+ /**
125
+ * Parse only this config's content into a single {@link SyncConfigWithErrors}.
126
+ *
127
+ * This does not depend on any other configs in the same replication stream.
128
+ */
129
+ protected parseSingleConfig(options: ParseSyncConfigOptions): SyncConfigWithErrors {
130
+ return parsePersistedSyncConfigContent({
131
+ content: this.sync_rules_content,
132
+ compiledPlan: this.compiled_plan,
133
+ storageVersion: this.storageVersion,
134
+ parseOptions: options
135
+ });
136
+ }
137
+
138
+ parsed(options: ParseSyncConfigOptions): ParsedSyncConfigSet {
139
+ let hydrationState: HydrationState;
140
+ const config = this.parseSingleConfig(options);
141
+
142
+ const storageConfig = this.getStorageConfig();
143
+ if (
144
+ storageConfig.versionedBuckets ||
145
+ config.config.compatibility.isEnabled(CompatibilityOption.versionedBucketIds)
146
+ ) {
147
+ hydrationState = versionedHydrationState(this.replicationStreamId);
148
+ } else {
149
+ hydrationState = DEFAULT_HYDRATION_STATE;
150
+ }
151
+
152
+ let hydrated: HydratedSyncConfig | undefined;
153
+ return {
154
+ replicationStreamId: this.replicationStreamId,
155
+ replicationStreamName: this.replicationStreamName,
156
+ syncConfigs: [config],
157
+ hydrationState,
158
+ get hydratedSyncConfig(): HydratedSyncConfig {
159
+ hydrated ??= config.config.hydrate({ hydrationState, sqlite: nodeSqlite(sqlite) });
160
+ return hydrated;
161
+ }
162
+ };
163
+ }
164
+
165
+ asUpdateOptions(options?: Omit<UpdateSyncRulesOptions, 'config'>): UpdateSyncRulesOptions {
166
+ // defaultSchema is not relevant for the parsed version here
167
+ const parsed = this.parseSingleConfig({ defaultSchema: 'not_applicable' });
168
+ return {
169
+ config: { yaml: this.sync_rules_content, plan: this.compiled_plan, parsed },
170
+ ...options
171
+ };
172
+ }
173
+
174
+ /**
175
+ * Fetch the current persisted state for this exact sync config.
176
+ */
177
+ abstract getSyncConfigStatus(): Promise<PersistedSyncConfigStatus | null>;
178
+ }
179
+ export interface PersistedSyncConfigContentData {
180
+ readonly replicationStreamId: number;
181
+ readonly sync_rules_content: string;
182
+ readonly compiled_plan: SerializedSyncPlan | null;
183
+ readonly replicationStreamName: string;
184
+ readonly storageVersion: number;
185
+
186
+ readonly syncConfigId?: PersistedSyncConfigId | null;
187
+ readonly syncConfigState: SyncRuleState;
188
+ }
189
+ export type PersistedSyncConfigId = string;
190
+ export interface ParseSyncConfigOptions {
191
+ defaultSchema: string;
192
+ }
@@ -0,0 +1,14 @@
1
+ import { SyncRuleState } from './BucketStorage.js';
2
+ import { PersistedSyncConfigId } from './PersistedSyncConfigContent.js';
3
+
4
+ export interface PersistedSyncConfigStatus {
5
+ readonly id: PersistedSyncConfigId;
6
+ readonly replicationStreamId: number;
7
+ readonly state: SyncRuleState;
8
+ readonly snapshot_done?: boolean;
9
+ readonly last_checkpoint_lsn: string | null;
10
+ readonly last_fatal_error?: string | null;
11
+ readonly last_fatal_error_ts?: Date | null;
12
+ readonly last_keepalive_ts?: Date | null;
13
+ readonly last_checkpoint_ts?: Date | null;
14
+ }
@@ -1,6 +1,8 @@
1
1
  import {
2
2
  BucketDataSource,
3
+ BucketDefinitionId,
3
4
  DEFAULT_TAG,
5
+ ParameterIndexId,
4
6
  ParameterIndexLookupCreator,
5
7
  SourceTableRef
6
8
  } from '@powersync/service-sync-rules';
@@ -21,6 +23,8 @@ export interface SourceTableOptions {
21
23
  snapshotComplete: boolean;
22
24
  bucketDataSources: BucketDataSource[];
23
25
  parameterLookupSources: ParameterIndexLookupCreator[];
26
+ bucketDataSourceIds?: Set<BucketDefinitionId>;
27
+ parameterLookupSourceIds?: Set<ParameterIndexId>;
24
28
  }
25
29
 
26
30
  export interface TableSnapshotStatus {
@@ -57,9 +61,11 @@ export class SourceTable {
57
61
  public syncParameters = true;
58
62
 
59
63
  /**
60
- * True if the table is used in sync config for events.
64
+ * True if this table should fire events for row changes.
61
65
  *
62
- * This value is resolved externally, and cached here.
66
+ * This value is resolved externally, and cached here. When multiple SourceTables exist
67
+ * for the same SourceTableRef (v3 storage), resolveTables designates exactly one of them
68
+ * as the event carrier, so that a row change saved once per table fires each event once.
63
69
  *
64
70
  * Defaults to true for tests.
65
71
  */
@@ -122,6 +128,14 @@ export class SourceTable {
122
128
  return this.options.parameterLookupSources;
123
129
  }
124
130
 
131
+ get bucketDataSourceIds() {
132
+ return this.options.bucketDataSourceIds;
133
+ }
134
+
135
+ get parameterLookupSourceIds() {
136
+ return this.options.parameterLookupSourceIds;
137
+ }
138
+
125
139
  /**
126
140
  * Sanitized name of the entity in the format of "{schema}.{entity name}".
127
141
  * Suitable for safe use in Postgres queries.
@@ -145,7 +159,10 @@ export class SourceTable {
145
159
  replicaIdColumns: this.replicaIdColumns,
146
160
  snapshotComplete: this.snapshotComplete,
147
161
  bucketDataSources: this.bucketDataSources,
148
- parameterLookupSources: this.parameterLookupSources
162
+ parameterLookupSources: this.parameterLookupSources,
163
+ bucketDataSourceIds: this.bucketDataSourceIds == null ? undefined : new Set(this.bucketDataSourceIds),
164
+ parameterLookupSourceIds:
165
+ this.parameterLookupSourceIds == null ? undefined : new Set(this.parameterLookupSourceIds)
149
166
  });
150
167
  copy.syncData = this.syncData;
151
168
  copy.syncParameters = this.syncParameters;
@@ -10,7 +10,8 @@ import { PerformanceTracer } from '../tracing/PerformanceTracer.js';
10
10
  import * as util from '../util/util-index.js';
11
11
  import { BucketStorageBatch, FlushedResult, SaveUpdate } from './BucketStorageBatch.js';
12
12
  import { BucketStorageFactory } from './BucketStorageFactory.js';
13
- import { ParseSyncRulesOptions } from './PersistedSyncRulesContent.js';
13
+ import { ParsedSyncConfigSet } from './ParsedSyncConfigSet.js';
14
+ import { ParseSyncConfigOptions } from './PersistedSyncConfigContent.js';
14
15
  import { SourceEntityDescriptor } from './SourceEntity.js';
15
16
  import { SourceTable } from './SourceTable.js';
16
17
  import { StorageVersionConfig } from './StorageVersionConfig.js';
@@ -22,8 +23,8 @@ import { SyncStorageWriteCheckpointAPI } from './WriteCheckpointAPI.js';
22
23
  export interface SyncRulesBucketStorage
23
24
  extends ObserverClient<SyncRulesBucketStorageListener>,
24
25
  SyncStorageWriteCheckpointAPI {
25
- readonly group_id: number;
26
- readonly slot_name: string;
26
+ readonly replicationStreamId: number;
27
+ readonly replicationStreamName: string;
27
28
  readonly storageConfig: StorageVersionConfig;
28
29
 
29
30
  readonly factory: BucketStorageFactory;
@@ -44,7 +45,20 @@ export interface SyncRulesBucketStorage
44
45
  callback: (batch: BucketStorageBatch) => Promise<void>
45
46
  ): Promise<FlushedResult | null>;
46
47
 
47
- getParsedSyncRules(options: ParseSyncRulesOptions): HydratedSyncConfig;
48
+ /**
49
+ * Get the canonical parsed sync config set for the given parse options.
50
+ *
51
+ * Repeated calls with the same options return the same instance for the lifetime of
52
+ * this storage instance. This is the identity boundary for parsed sync config state:
53
+ * all operations against this storage instance must use parsed objects from sets
54
+ * returned here, never from an independent parse of the same content.
55
+ */
56
+ getParsedSyncConfigSet(options: ParseSyncConfigOptions): ParsedSyncConfigSet;
57
+
58
+ /**
59
+ * Shortcut for `getParsedSyncConfigSet(options).hydratedSyncConfig`.
60
+ */
61
+ getParsedSyncRules(options: ParseSyncConfigOptions): HydratedSyncConfig;
48
62
 
49
63
  /**
50
64
  * Terminate the replication stream.
@@ -55,7 +69,7 @@ export interface SyncRulesBucketStorage
55
69
  */
56
70
  terminate(options?: TerminateOptions): Promise<void>;
57
71
 
58
- getStatus(): Promise<SyncRuleStatus>;
72
+ getStatus(): Promise<ReplicationStreamStatus>;
59
73
 
60
74
  /**
61
75
  * Clear the storage, without changing state.
@@ -133,6 +147,12 @@ export interface SyncRulesBucketStorage
133
147
  * Clear checksum cache. Primarily intended for tests.
134
148
  */
135
149
  clearChecksumCache(): void;
150
+
151
+ /**
152
+ * Optional storage-provider cleanup for sync configs that have been stopped
153
+ * inside this replication stream.
154
+ */
155
+ cleanupStoppedSyncConfigs?(options: CleanupStoppedSyncConfigsOptions): Promise<CleanupStoppedSyncConfigsResult>;
136
156
  }
137
157
 
138
158
  export interface SyncRulesBucketStorageListener {
@@ -149,15 +169,15 @@ export interface BucketChecksumRequest {
149
169
  source: BucketDataSource;
150
170
  }
151
171
 
152
- export interface SyncRuleStatus {
153
- checkpoint_lsn: string | null;
154
- active: boolean;
155
- snapshot_done: boolean;
156
- snapshot_lsn: string | null;
172
+ export interface ReplicationStreamStatus {
173
+ /**
174
+ * Source position to resume replication from.
175
+ */
176
+ resumeLsn: string | null;
157
177
  /**
158
- * Last persisted operation that must be included in the next checkpoint once checkpointing is unblocked.
178
+ * True if _every_ active/processing sync config has a client-visible checkpoint.
159
179
  */
160
- keepalive_op: util.InternalOpId | null;
180
+ snapshotDone: boolean;
161
181
  }
162
182
  export interface ResolveTablesOptions {
163
183
  connection_id: number;
@@ -167,9 +187,9 @@ export interface ResolveTablesOptions {
167
187
  */
168
188
  idGenerator?: () => string | bson.ObjectId;
169
189
  /**
170
- * For tests only - override the sync rules used.
190
+ * For tests only - override the parsed sync config set used.
171
191
  */
172
- syncRules?: HydratedSyncConfig;
192
+ parsedSyncConfig?: ParsedSyncConfigSet;
173
193
  }
174
194
 
175
195
  export interface ResolveTablesResult {
@@ -177,7 +197,7 @@ export interface ResolveTablesResult {
177
197
  dropTables: SourceTable[];
178
198
  }
179
199
 
180
- export interface CreateWriterOptions extends ParseSyncRulesOptions {
200
+ export interface CreateWriterOptions extends ParseSyncConfigOptions {
181
201
  zeroLSN: string;
182
202
  /**
183
203
  * Whether or not to store a copy of the current data.
@@ -262,6 +282,9 @@ export interface CompactOptions {
262
282
  /** Minimum of 1 */
263
283
  moveBatchQueryLimit?: number;
264
284
 
285
+ /** Byte cap per read batch for streaming compaction. Default 16MB. */
286
+ moveBatchByteLimit?: number;
287
+
265
288
  /**
266
289
  * Minimum number new operations in a bucket to trigger compaction of that bucket.
267
290
  *
@@ -287,7 +310,14 @@ export interface CompactOptions {
287
310
  }
288
311
 
289
312
  export interface PopulateChecksumCacheOptions {
290
- maxOpId: util.InternalOpId;
313
+ /**
314
+ * Compute checksums up to this op id.
315
+ *
316
+ * Defaults to the highest persisted op id for the replication stream, which covers
317
+ * the common case of populating the cache right after initial replication, before
318
+ * the first checkpoint exists.
319
+ */
320
+ maxOpId?: util.InternalOpId;
291
321
  minBucketChanges?: number;
292
322
  signal?: AbortSignal;
293
323
  }
@@ -303,6 +333,24 @@ export interface ClearStorageOptions {
303
333
  signal?: AbortSignal;
304
334
  }
305
335
 
336
+ export interface CleanupStoppedSyncConfigsOptions {
337
+ signal?: AbortSignal;
338
+ logger?: Logger;
339
+ defaultSchema: string;
340
+ sourceConnectionTag: string;
341
+ }
342
+
343
+ export interface CleanupStoppedSyncConfigsResult {
344
+ stoppedSyncConfigsRemoved: number;
345
+ bucketDataCollectionsDropped: number;
346
+ parameterIndexCollectionsDropped: number;
347
+ /** Best-effort number, not accurate if the operation takes longer than the timeout. */
348
+ bucketStateDocumentsDeleted: number;
349
+ sourceRecordCollectionsDropped: number;
350
+ sourceTablesUpdated: number;
351
+ sourceTablesDeleted: number;
352
+ }
353
+
306
354
  export interface TerminateOptions extends ClearStorageOptions {
307
355
  /**
308
356
  * If true, also clear the storage before terminating.