@powersync/service-core 1.20.5 → 1.22.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 +66 -0
- package/dist/api/RouteAPI.d.ts +3 -3
- package/dist/api/diagnostics.d.ts +1 -1
- package/dist/api/diagnostics.js +19 -3
- package/dist/api/diagnostics.js.map +1 -1
- package/dist/auth/RemoteJWKSCollector.js +3 -2
- package/dist/auth/RemoteJWKSCollector.js.map +1 -1
- package/dist/entry/commands/teardown-action.js +1 -1
- package/dist/entry/commands/teardown-action.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/modules/AbstractModule.d.ts +1 -1
- package/dist/replication/AbstractReplicationJob.js +1 -1
- package/dist/replication/AbstractReplicationJob.js.map +1 -1
- package/dist/replication/AbstractReplicator.d.ts +6 -6
- package/dist/replication/AbstractReplicator.js +21 -21
- package/dist/replication/AbstractReplicator.js.map +1 -1
- package/dist/replication/RelationCache.d.ts +9 -2
- package/dist/replication/RelationCache.js +21 -2
- package/dist/replication/RelationCache.js.map +1 -1
- package/dist/routes/configure-fastify.js +3 -1
- package/dist/routes/configure-fastify.js.map +1 -1
- package/dist/routes/endpoints/admin.js +16 -8
- package/dist/routes/endpoints/admin.js.map +1 -1
- package/dist/routes/endpoints/checkpointing.js +1 -1
- package/dist/routes/endpoints/checkpointing.js.map +1 -1
- package/dist/routes/endpoints/socket-route.js +1 -1
- package/dist/routes/endpoints/socket-route.js.map +1 -1
- package/dist/routes/endpoints/sync-rules.js +8 -8
- package/dist/routes/endpoints/sync-rules.js.map +1 -1
- package/dist/routes/endpoints/sync-stream.js +2 -2
- package/dist/routes/endpoints/sync-stream.js.map +1 -1
- package/dist/routes/route-register.d.ts +2 -0
- package/dist/routes/route-register.js +65 -3
- package/dist/routes/route-register.js.map +1 -1
- package/dist/runner/teardown.js +4 -4
- package/dist/runner/teardown.js.map +1 -1
- package/dist/storage/BucketStorage.d.ts +9 -9
- package/dist/storage/BucketStorage.js +9 -9
- package/dist/storage/BucketStorageBatch.d.ts +29 -0
- package/dist/storage/BucketStorageBatch.js.map +1 -1
- package/dist/storage/BucketStorageFactory.d.ts +27 -18
- package/dist/storage/BucketStorageFactory.js +13 -12
- package/dist/storage/BucketStorageFactory.js.map +1 -1
- package/dist/storage/PersistedSyncRulesContent.d.ts +6 -4
- package/dist/storage/PersistedSyncRulesContent.js +15 -8
- package/dist/storage/PersistedSyncRulesContent.js.map +1 -1
- package/dist/storage/SourceEntity.d.ts +8 -1
- package/dist/storage/SourceTable.d.ts +32 -11
- package/dist/storage/SourceTable.js +41 -15
- package/dist/storage/SourceTable.js.map +1 -1
- package/dist/storage/StorageVersionConfig.d.ts +1 -1
- package/dist/storage/StorageVersionConfig.js +1 -1
- package/dist/storage/SyncRulesBucketStorage.d.ts +63 -18
- package/dist/storage/SyncRulesBucketStorage.js +14 -0
- package/dist/storage/SyncRulesBucketStorage.js.map +1 -1
- package/dist/storage/WriteCheckpointAPI.d.ts +6 -6
- package/dist/storage/WriteCheckpointAPI.js +1 -1
- package/dist/storage/bson.d.ts +0 -1
- package/dist/storage/bson.js +0 -4
- package/dist/storage/bson.js.map +1 -1
- package/dist/sync/BucketChecksumState.d.ts +6 -9
- package/dist/sync/BucketChecksumState.js +117 -58
- package/dist/sync/BucketChecksumState.js.map +1 -1
- package/dist/sync/sync.d.ts +2 -2
- package/dist/sync/sync.js.map +1 -1
- package/dist/tracing/PerformanceTracer.d.ts +60 -0
- package/dist/tracing/PerformanceTracer.js +105 -0
- package/dist/tracing/PerformanceTracer.js.map +1 -0
- package/dist/tracing/TraceWriter.d.ts +22 -0
- package/dist/tracing/TraceWriter.js +63 -0
- package/dist/tracing/TraceWriter.js.map +1 -0
- package/dist/util/checkpointing.js +1 -1
- package/dist/util/config/compound-config-collector.d.ts +1 -1
- package/dist/util/config/compound-config-collector.js +2 -2
- package/dist/util/config/compound-config-collector.js.map +1 -1
- package/dist/util/config/sync-rules/impl/filesystem-sync-rules-collector.js +1 -1
- package/dist/util/config/sync-rules/impl/filesystem-sync-rules-collector.js.map +1 -1
- package/dist/util/env.js +1 -1
- package/dist/util/protocol-types.d.ts +1 -1
- package/dist/util/protocol-types.js +1 -1
- package/dist/util/util-index.d.ts +1 -0
- package/dist/util/util-index.js +1 -0
- package/dist/util/util-index.js.map +1 -1
- package/dist/util/utils.d.ts +5 -0
- package/dist/util/utils.js +7 -0
- package/dist/util/utils.js.map +1 -1
- package/package.json +11 -11
- package/src/api/RouteAPI.ts +3 -3
- package/src/api/diagnostics.ts +29 -6
- package/src/auth/RemoteJWKSCollector.ts +3 -1
- package/src/entry/commands/teardown-action.ts +1 -1
- package/src/index.ts +2 -0
- package/src/modules/AbstractModule.ts +1 -1
- package/src/replication/AbstractReplicationJob.ts +1 -1
- package/src/replication/AbstractReplicator.ts +23 -23
- package/src/replication/RelationCache.ts +23 -4
- package/src/routes/configure-fastify.ts +8 -1
- package/src/routes/endpoints/admin.ts +17 -8
- package/src/routes/endpoints/checkpointing.ts +1 -1
- package/src/routes/endpoints/socket-route.ts +1 -1
- package/src/routes/endpoints/sync-rules.ts +8 -8
- package/src/routes/endpoints/sync-stream.ts +2 -2
- package/src/routes/route-register.ts +73 -4
- package/src/runner/teardown.ts +4 -4
- package/src/storage/BucketStorage.ts +9 -9
- package/src/storage/BucketStorageBatch.ts +32 -0
- package/src/storage/BucketStorageFactory.ts +35 -23
- package/src/storage/PersistedSyncRulesContent.ts +20 -12
- package/src/storage/SourceEntity.ts +9 -1
- package/src/storage/SourceTable.ts +56 -22
- package/src/storage/StorageVersionConfig.ts +1 -1
- package/src/storage/SyncRulesBucketStorage.ts +74 -22
- package/src/storage/WriteCheckpointAPI.ts +6 -6
- package/src/storage/bson.ts +0 -5
- package/src/sync/BucketChecksumState.ts +142 -78
- package/src/sync/sync.ts +4 -4
- package/src/tracing/PerformanceTracer.ts +149 -0
- package/src/tracing/TraceWriter.ts +67 -0
- package/src/util/checkpointing.ts +1 -1
- package/src/util/config/compound-config-collector.ts +3 -3
- package/src/util/config/sync-rules/impl/filesystem-sync-rules-collector.ts +1 -1
- package/src/util/env.ts +1 -1
- package/src/util/protocol-types.ts +1 -1
- package/src/util/util-index.ts +1 -0
- package/src/util/utils.ts +8 -0
- package/test/src/auth.test.ts +120 -1
- package/test/src/diagnostics.test.ts +155 -0
- package/test/src/routes/error-handler.integration.test.ts +275 -0
- package/test/src/routes/stream.test.ts +15 -4
- package/test/src/storage/SourceTable.test.ts +89 -0
- package/test/src/sync/BucketChecksumState.test.ts +244 -80
- package/test/tsconfig.json +0 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
BucketDataSource,
|
|
3
|
+
DEFAULT_TAG,
|
|
4
|
+
ParameterIndexLookupCreator,
|
|
5
|
+
SourceTableRef
|
|
6
|
+
} from '@powersync/service-sync-rules';
|
|
2
7
|
import { bson } from '../index.js';
|
|
3
8
|
import * as util from '../util/util-index.js';
|
|
4
|
-
import { ColumnDescriptor
|
|
9
|
+
import { ColumnDescriptor } from './SourceEntity.js';
|
|
5
10
|
|
|
6
11
|
/**
|
|
7
12
|
* Format of the id depends on the bucket storage module. It should be consistent within the module.
|
|
@@ -10,12 +15,12 @@ export type SourceTableId = string | bson.ObjectId;
|
|
|
10
15
|
|
|
11
16
|
export interface SourceTableOptions {
|
|
12
17
|
id: SourceTableId;
|
|
13
|
-
|
|
18
|
+
ref: SourceTableRef;
|
|
14
19
|
objectId: number | string | undefined;
|
|
15
|
-
schema: string;
|
|
16
|
-
name: string;
|
|
17
20
|
replicaIdColumns: ColumnDescriptor[];
|
|
18
21
|
snapshotComplete: boolean;
|
|
22
|
+
bucketDataSources: BucketDataSource[];
|
|
23
|
+
parameterLookupSources: ParameterIndexLookupCreator[];
|
|
19
24
|
}
|
|
20
25
|
|
|
21
26
|
export interface TableSnapshotStatus {
|
|
@@ -24,11 +29,17 @@ export interface TableSnapshotStatus {
|
|
|
24
29
|
lastKey: Uint8Array | null;
|
|
25
30
|
}
|
|
26
31
|
|
|
27
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Represents a resolved source table.
|
|
34
|
+
*
|
|
35
|
+
* There could be multiple of these for the same SourceTableRef.
|
|
36
|
+
* For that reason, we do not implement the SourceTableRef interface, to ensure that the two are not used interchangably.
|
|
37
|
+
*/
|
|
38
|
+
export class SourceTable {
|
|
28
39
|
static readonly DEFAULT_TAG = DEFAULT_TAG;
|
|
29
40
|
|
|
30
41
|
/**
|
|
31
|
-
* True if the table is used in sync
|
|
42
|
+
* True if the table is used in sync config for data queries.
|
|
32
43
|
*
|
|
33
44
|
* This value is resolved externally, and cached here.
|
|
34
45
|
*
|
|
@@ -37,7 +48,7 @@ export class SourceTable implements SourceEntityDescriptor {
|
|
|
37
48
|
public syncData = true;
|
|
38
49
|
|
|
39
50
|
/**
|
|
40
|
-
* True if the table is used in sync
|
|
51
|
+
* True if the table is used in sync config for data queries.
|
|
41
52
|
*
|
|
42
53
|
* This value is resolved externally, and cached here.
|
|
43
54
|
*
|
|
@@ -46,7 +57,7 @@ export class SourceTable implements SourceEntityDescriptor {
|
|
|
46
57
|
public syncParameters = true;
|
|
47
58
|
|
|
48
59
|
/**
|
|
49
|
-
* True if the table is used in sync
|
|
60
|
+
* True if the table is used in sync config for events.
|
|
50
61
|
*
|
|
51
62
|
* This value is resolved externally, and cached here.
|
|
52
63
|
*
|
|
@@ -54,6 +65,19 @@ export class SourceTable implements SourceEntityDescriptor {
|
|
|
54
65
|
*/
|
|
55
66
|
public syncEvent = true;
|
|
56
67
|
|
|
68
|
+
/**
|
|
69
|
+
* True if raw data should be stored in current_data collection.
|
|
70
|
+
*
|
|
71
|
+
* This is needed when the source sends partial row data (e.g. TOAST values).
|
|
72
|
+
* When REPLICA IDENTITY FULL is configured, complete rows are always sent,
|
|
73
|
+
* so we don't need to store raw data.
|
|
74
|
+
*
|
|
75
|
+
* This value is resolved externally based on table configuration.
|
|
76
|
+
*
|
|
77
|
+
* Defaults to true for tests (conservative approach).
|
|
78
|
+
*/
|
|
79
|
+
public storeCurrentData = true;
|
|
80
|
+
|
|
57
81
|
/**
|
|
58
82
|
* Always undefined if snapshotComplete = true.
|
|
59
83
|
*
|
|
@@ -71,31 +95,39 @@ export class SourceTable implements SourceEntityDescriptor {
|
|
|
71
95
|
return this.options.id;
|
|
72
96
|
}
|
|
73
97
|
|
|
74
|
-
get connectionTag() {
|
|
75
|
-
return this.options.connectionTag;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
98
|
get objectId() {
|
|
79
99
|
return this.options.objectId;
|
|
80
100
|
}
|
|
81
101
|
|
|
82
102
|
get schema() {
|
|
83
|
-
return this.options.schema;
|
|
103
|
+
return this.options.ref.schema;
|
|
84
104
|
}
|
|
85
105
|
get name() {
|
|
86
|
-
return this.options.name;
|
|
106
|
+
return this.options.ref.name;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
get ref() {
|
|
110
|
+
return this.options.ref;
|
|
87
111
|
}
|
|
88
112
|
|
|
89
113
|
get replicaIdColumns() {
|
|
90
114
|
return this.options.replicaIdColumns;
|
|
91
115
|
}
|
|
92
116
|
|
|
117
|
+
get bucketDataSources() {
|
|
118
|
+
return this.options.bucketDataSources;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
get parameterLookupSources() {
|
|
122
|
+
return this.options.parameterLookupSources;
|
|
123
|
+
}
|
|
124
|
+
|
|
93
125
|
/**
|
|
94
|
-
*
|
|
95
|
-
*
|
|
126
|
+
* Sanitized name of the entity in the format of "{schema}.{entity name}".
|
|
127
|
+
* Suitable for safe use in Postgres queries.
|
|
96
128
|
*/
|
|
97
129
|
get qualifiedName() {
|
|
98
|
-
return
|
|
130
|
+
return util.qualifiedName(this.ref);
|
|
99
131
|
}
|
|
100
132
|
|
|
101
133
|
get syncAny() {
|
|
@@ -108,15 +140,17 @@ export class SourceTable implements SourceEntityDescriptor {
|
|
|
108
140
|
clone() {
|
|
109
141
|
const copy = new SourceTable({
|
|
110
142
|
id: this.id,
|
|
111
|
-
|
|
143
|
+
ref: this.options.ref,
|
|
112
144
|
objectId: this.objectId,
|
|
113
|
-
schema: this.schema,
|
|
114
|
-
name: this.name,
|
|
115
145
|
replicaIdColumns: this.replicaIdColumns,
|
|
116
|
-
snapshotComplete: this.snapshotComplete
|
|
146
|
+
snapshotComplete: this.snapshotComplete,
|
|
147
|
+
bucketDataSources: this.bucketDataSources,
|
|
148
|
+
parameterLookupSources: this.parameterLookupSources
|
|
117
149
|
});
|
|
118
150
|
copy.syncData = this.syncData;
|
|
119
151
|
copy.syncParameters = this.syncParameters;
|
|
152
|
+
copy.syncEvent = this.syncEvent;
|
|
153
|
+
copy.storeCurrentData = this.storeCurrentData;
|
|
120
154
|
copy.snapshotStatus = this.snapshotStatus;
|
|
121
155
|
return copy;
|
|
122
156
|
}
|
|
@@ -45,7 +45,7 @@ export const STORAGE_VERSION_3 = 3;
|
|
|
45
45
|
export const LEGACY_STORAGE_VERSION = STORAGE_VERSION_1;
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
|
-
* Default storage version for newly persisted
|
|
48
|
+
* Default storage version for newly persisted replication streams.
|
|
49
49
|
*/
|
|
50
50
|
export const CURRENT_STORAGE_VERSION = STORAGE_VERSION_2;
|
|
51
51
|
|
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
import { Logger, ObserverClient } from '@powersync/lib-services-framework';
|
|
2
2
|
import {
|
|
3
3
|
BucketDataSource,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
HydratedSyncConfig,
|
|
5
|
+
ParameterLookupRows,
|
|
6
|
+
ScopedParameterLookup
|
|
7
7
|
} from '@powersync/service-sync-rules';
|
|
8
|
+
import * as bson from 'bson';
|
|
9
|
+
import { PerformanceTracer } from '../tracing/PerformanceTracer.js';
|
|
8
10
|
import * as util from '../util/util-index.js';
|
|
9
11
|
import { BucketStorageBatch, FlushedResult, SaveUpdate } from './BucketStorageBatch.js';
|
|
10
12
|
import { BucketStorageFactory } from './BucketStorageFactory.js';
|
|
11
13
|
import { ParseSyncRulesOptions } from './PersistedSyncRulesContent.js';
|
|
12
14
|
import { SourceEntityDescriptor } from './SourceEntity.js';
|
|
13
15
|
import { SourceTable } from './SourceTable.js';
|
|
16
|
+
import { StorageVersionConfig } from './StorageVersionConfig.js';
|
|
14
17
|
import { SyncStorageWriteCheckpointAPI } from './WriteCheckpointAPI.js';
|
|
15
18
|
|
|
16
19
|
/**
|
|
17
|
-
* Storage for a specific
|
|
20
|
+
* Storage for a specific replication stream.
|
|
18
21
|
*/
|
|
19
22
|
export interface SyncRulesBucketStorage
|
|
20
23
|
extends ObserverClient<SyncRulesBucketStorageListener>,
|
|
21
24
|
SyncStorageWriteCheckpointAPI {
|
|
22
25
|
readonly group_id: number;
|
|
23
26
|
readonly slot_name: string;
|
|
27
|
+
readonly storageConfig: StorageVersionConfig;
|
|
24
28
|
|
|
25
29
|
readonly factory: BucketStorageFactory;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Resolve a table, keeping track of it internally.
|
|
29
|
-
*/
|
|
30
|
-
resolveTable(options: ResolveTableOptions): Promise<ResolveTableResult>;
|
|
30
|
+
readonly logger: Logger;
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Create a new writer.
|
|
@@ -44,14 +44,14 @@ export interface SyncRulesBucketStorage
|
|
|
44
44
|
callback: (batch: BucketStorageBatch) => Promise<void>
|
|
45
45
|
): Promise<FlushedResult | null>;
|
|
46
46
|
|
|
47
|
-
getParsedSyncRules(options: ParseSyncRulesOptions):
|
|
47
|
+
getParsedSyncRules(options: ParseSyncRulesOptions): HydratedSyncConfig;
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
|
-
* Terminate the
|
|
50
|
+
* Terminate the replication stream.
|
|
51
51
|
*
|
|
52
52
|
* This clears the storage, and sets state to TERMINATED.
|
|
53
53
|
*
|
|
54
|
-
* Must only be called on stopped
|
|
54
|
+
* Must only be called on stopped replication streams.
|
|
55
55
|
*/
|
|
56
56
|
terminate(options?: TerminateOptions): Promise<void>;
|
|
57
57
|
|
|
@@ -98,7 +98,7 @@ export interface SyncRulesBucketStorage
|
|
|
98
98
|
/**
|
|
99
99
|
* Yields the latest user write checkpoint whenever the sync checkpoint updates.
|
|
100
100
|
*
|
|
101
|
-
* The stream stops or errors if this is not the active sync
|
|
101
|
+
* The stream stops or errors if this is not the active sync config (anymore).
|
|
102
102
|
*/
|
|
103
103
|
watchCheckpointChanges(options: WatchWriteCheckpointOptions): AsyncIterable<StorageCheckpointUpdate>;
|
|
104
104
|
|
|
@@ -154,18 +154,26 @@ export interface SyncRuleStatus {
|
|
|
154
154
|
active: boolean;
|
|
155
155
|
snapshot_done: boolean;
|
|
156
156
|
snapshot_lsn: string | null;
|
|
157
|
+
/**
|
|
158
|
+
* Last persisted operation that must be included in the next checkpoint once checkpointing is unblocked.
|
|
159
|
+
*/
|
|
160
|
+
keepalive_op: util.InternalOpId | null;
|
|
157
161
|
}
|
|
158
|
-
export interface
|
|
159
|
-
group_id: number;
|
|
162
|
+
export interface ResolveTablesOptions {
|
|
160
163
|
connection_id: number;
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
164
|
+
source: SourceEntityDescriptor;
|
|
165
|
+
/**
|
|
166
|
+
* For tests only - custom id generator for stable ids.
|
|
167
|
+
*/
|
|
168
|
+
idGenerator?: () => string | bson.ObjectId;
|
|
169
|
+
/**
|
|
170
|
+
* For tests only - override the sync rules used.
|
|
171
|
+
*/
|
|
172
|
+
syncRules?: HydratedSyncConfig;
|
|
165
173
|
}
|
|
166
174
|
|
|
167
|
-
export interface
|
|
168
|
-
|
|
175
|
+
export interface ResolveTablesResult {
|
|
176
|
+
tables: SourceTable[];
|
|
169
177
|
dropTables: SourceTable[];
|
|
170
178
|
}
|
|
171
179
|
|
|
@@ -196,9 +204,18 @@ export interface CreateWriterOptions extends ParseSyncRulesOptions {
|
|
|
196
204
|
*/
|
|
197
205
|
markRecordUnavailable?: BucketStorageMarkRecordUnavailable;
|
|
198
206
|
|
|
207
|
+
hooks?: StorageHooks;
|
|
208
|
+
|
|
209
|
+
tracer?: PerformanceTracer<'storage' | 'evaluate'>;
|
|
210
|
+
|
|
199
211
|
logger?: Logger;
|
|
200
212
|
}
|
|
201
213
|
|
|
214
|
+
export interface StorageHooks {
|
|
215
|
+
beforeBatchFlush?: (batch: BucketStorageBatch) => Promise<void>;
|
|
216
|
+
afterBatchFlush?: (batch: BucketStorageBatch) => Promise<void>;
|
|
217
|
+
}
|
|
218
|
+
|
|
202
219
|
/**
|
|
203
220
|
* @deprecated Use `CreateWriterOptions`.
|
|
204
221
|
*/
|
|
@@ -265,6 +282,8 @@ export interface CompactOptions {
|
|
|
265
282
|
compactParameterCacheLimit?: number;
|
|
266
283
|
|
|
267
284
|
signal?: AbortSignal;
|
|
285
|
+
|
|
286
|
+
logger?: Logger;
|
|
268
287
|
}
|
|
269
288
|
|
|
270
289
|
export interface PopulateChecksumCacheOptions {
|
|
@@ -320,8 +339,41 @@ export interface ReplicationCheckpoint {
|
|
|
320
339
|
* Used to resolve "dynamic" parameter queries.
|
|
321
340
|
*
|
|
322
341
|
* This gets parameter sets specific to this checkpoint.
|
|
342
|
+
*
|
|
343
|
+
* @throws {@link ParameterSetLimitExceededError}
|
|
344
|
+
* Thrown if resolved lookups in bucket storage exceed the `limit` parameter.
|
|
345
|
+
*/
|
|
346
|
+
getParameterSets(lookups: ScopedParameterLookup[], limit: number): Promise<ParameterLookupRows[]>;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* An exception thrown by {@link ReplicationCheckpoint} implementations if there are too many parameter results.
|
|
351
|
+
*
|
|
352
|
+
* This is not a suitable exception to show to users, `BucketParameterState` adds additional context.
|
|
353
|
+
*/
|
|
354
|
+
export class ParameterSetLimitExceededError extends Error {
|
|
355
|
+
constructor(
|
|
356
|
+
readonly limit: number,
|
|
357
|
+
readonly breakdown?: ParameterQueryInvocationLog[]
|
|
358
|
+
) {
|
|
359
|
+
super(`Too many parameter results (limit was ${limit})`);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
export interface ParameterQueryInvocationLog {
|
|
364
|
+
/**
|
|
365
|
+
* The definition for which a parameter query was invoked.
|
|
366
|
+
*
|
|
367
|
+
* The exact format of definition is unspecified, it's shown to users to help them debug this failure.
|
|
368
|
+
*/
|
|
369
|
+
definition: string;
|
|
370
|
+
/**
|
|
371
|
+
* If {@link didExceedLimit} is false, the amount of rows returned by the invocation.
|
|
372
|
+
*
|
|
373
|
+
* Otherwise, the maximum amount of rows this invocation was allowed to return.
|
|
323
374
|
*/
|
|
324
|
-
|
|
375
|
+
resultsOrLimit: number;
|
|
376
|
+
didExceedLimit: boolean;
|
|
325
377
|
}
|
|
326
378
|
|
|
327
379
|
export interface WatchWriteCheckpointOptions {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export enum WriteCheckpointMode {
|
|
2
2
|
/**
|
|
3
3
|
* Raw mappings of `user_id` to `write_checkpoint`s should
|
|
4
|
-
* be supplied for each
|
|
4
|
+
* be supplied for each replication stream.
|
|
5
5
|
*/
|
|
6
6
|
CUSTOM = 'custom',
|
|
7
7
|
/**
|
|
@@ -21,7 +21,7 @@ export interface BaseWriteCheckpointIdentifier {
|
|
|
21
21
|
|
|
22
22
|
export interface CustomWriteCheckpointFilters extends BaseWriteCheckpointIdentifier {
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
24
|
+
* Replication stream which was active when this checkpoint was created.
|
|
25
25
|
*/
|
|
26
26
|
sync_rules_id: number;
|
|
27
27
|
}
|
|
@@ -35,7 +35,7 @@ export interface BatchedCustomWriteCheckpointOptions extends BaseWriteCheckpoint
|
|
|
35
35
|
|
|
36
36
|
export interface CustomWriteCheckpointOptions extends BatchedCustomWriteCheckpointOptions {
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
38
|
+
* Replication stream which was active when this checkpoint was created.
|
|
39
39
|
*/
|
|
40
40
|
sync_rules_id: number;
|
|
41
41
|
}
|
|
@@ -63,8 +63,8 @@ export interface BaseWriteCheckpointAPI {
|
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
65
|
* Write Checkpoint API to be used in conjunction with a {@link SyncRulesBucketStorage}.
|
|
66
|
-
* This storage corresponds with a
|
|
67
|
-
*
|
|
66
|
+
* This storage corresponds with a replication stream. These APIs don't require specifying a
|
|
67
|
+
* replication stream id.
|
|
68
68
|
*/
|
|
69
69
|
export interface SyncStorageWriteCheckpointAPI extends BaseWriteCheckpointAPI {
|
|
70
70
|
lastWriteCheckpoint(filters: SyncStorageLastWriteCheckpointFilters): Promise<bigint | null>;
|
|
@@ -72,7 +72,7 @@ export interface SyncStorageWriteCheckpointAPI extends BaseWriteCheckpointAPI {
|
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
74
|
* Write Checkpoint API which is interfaced directly with the storage layer. This requires
|
|
75
|
-
*
|
|
75
|
+
* replication stream identifiers for custom write checkpoints.
|
|
76
76
|
*/
|
|
77
77
|
export interface WriteCheckpointAPI extends BaseWriteCheckpointAPI {
|
|
78
78
|
lastWriteCheckpoint(filters: LastWriteCheckpointFilters): Promise<bigint | null>;
|
package/src/storage/bson.ts
CHANGED
|
@@ -40,11 +40,6 @@ export const deserializeParameterLookup = (lookup: bson.Binary) => {
|
|
|
40
40
|
return parsed;
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
export const getLookupBucketDefinitionName = (lookup: bson.Binary) => {
|
|
44
|
-
const parsed = deserializeParameterLookup(lookup);
|
|
45
|
-
return parsed[0] as string;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
43
|
/**
|
|
49
44
|
* True if this is a bson.UUID.
|
|
50
45
|
*
|