@powersync/service-core 1.30.0 → 1.31.0-dev-20261204084200
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 +16 -0
- package/dist/modules/RustModule.d.ts +5 -2
- package/dist/modules/RustModule.js +5 -5
- package/dist/modules/RustModule.js.map +1 -1
- package/dist/storage/BucketStorageBatch.d.ts +21 -0
- package/dist/storage/BucketStorageBatch.js.map +1 -1
- package/dist/storage/SourceTable.d.ts +6 -1
- package/dist/storage/SourceTable.js +7 -1
- package/dist/storage/SourceTable.js.map +1 -1
- package/package.json +5 -5
- package/src/modules/RustModule.ts +10 -7
- package/src/storage/BucketStorageBatch.ts +26 -0
- package/src/storage/SourceTable.ts +10 -1
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @powersync/service-core
|
|
2
2
|
|
|
3
|
+
## 1.31.0-dev-20261204084200
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 8f8a5b7: Add `rust_evaluation` option to MongoDB storage configurations. When set to `force`, replicated rows are processed through an experimental Rust implementation of Sync Streams.
|
|
8
|
+
|
|
9
|
+
Note that the option required incremental reprocessing and `edition: 3` Sync Streams, doesn't support most SQL functions and expressions yet and only works for MongoDB source databases.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [8f8a5b7]
|
|
14
|
+
- @powersync/service-rust-types@0.1.1-dev-20261204084200
|
|
15
|
+
- @powersync/service-sync-rules@0.45.3-dev-20261204084200
|
|
16
|
+
- @powersync/lib-services-framework@0.10.8-dev-20261204084200
|
|
17
|
+
- @powersync/service-rsocket-router@0.3.3-dev-20261204084200
|
|
18
|
+
|
|
3
19
|
## 1.30.0
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { RustAddon } from '@powersync/service-rust-types';
|
|
2
|
+
import { ServiceIdentifier } from '@powersync/lib-services-framework';
|
|
2
3
|
import { ServiceContextContainer } from '../system/ServiceContext.js';
|
|
3
4
|
import { AbstractModule, AbstractModuleOptions, TearDownOptions } from './AbstractModule.js';
|
|
5
|
+
export type { RustAddon };
|
|
4
6
|
export interface RustModuleOptions extends AbstractModuleOptions {
|
|
5
7
|
addonPath: string;
|
|
6
8
|
}
|
|
@@ -12,7 +14,8 @@ export interface RustModuleOptions extends AbstractModuleOptions {
|
|
|
12
14
|
export declare class RustModule extends AbstractModule {
|
|
13
15
|
#private;
|
|
14
16
|
constructor(options: RustModuleOptions);
|
|
15
|
-
initialize(
|
|
16
|
-
loadRust(): Promise<RustAddon.InitializedRustModule>;
|
|
17
|
+
initialize(context: ServiceContextContainer): Promise<void>;
|
|
18
|
+
loadRust(): Promise<[typeof RustAddon, RustAddon.InitializedRustModule]>;
|
|
17
19
|
teardown(_options: TearDownOptions): Promise<void>;
|
|
20
|
+
static readonly id: ServiceIdentifier<typeof RustAddon>;
|
|
18
21
|
}
|
|
@@ -11,15 +11,15 @@ export class RustModule extends AbstractModule {
|
|
|
11
11
|
super(options);
|
|
12
12
|
this.#addonPath = options.addonPath;
|
|
13
13
|
}
|
|
14
|
-
async initialize(
|
|
15
|
-
await this.loadRust();
|
|
16
|
-
|
|
17
|
-
// implementations on the service container.
|
|
14
|
+
async initialize(context) {
|
|
15
|
+
const [addon, _] = await this.loadRust();
|
|
16
|
+
context.register(RustModule.id, addon);
|
|
18
17
|
}
|
|
19
18
|
async loadRust() {
|
|
20
19
|
const addon = loadRustAddon(this.#addonPath);
|
|
21
|
-
return addon.initializeRust({ logger: this.logger });
|
|
20
|
+
return [addon, addon.initializeRust({ logger: this.logger })];
|
|
22
21
|
}
|
|
23
22
|
async teardown(_options) { }
|
|
23
|
+
static id = 'rust-addon';
|
|
24
24
|
}
|
|
25
25
|
//# sourceMappingURL=RustModule.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RustModule.js","sourceRoot":"","sources":["../../src/modules/RustModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAa,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"RustModule.js","sourceRoot":"","sources":["../../src/modules/RustModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAa,MAAM,+BAA+B,CAAC;AAIzE,OAAO,EAAE,cAAc,EAA0C,MAAM,qBAAqB,CAAC;AAQ7F;;;;GAIG;AACH,MAAM,OAAO,UAAW,SAAQ,cAAc;IACnC,UAAU,CAAS;IAE5B,YAAY,OAA0B;QACpC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC;IACtC,CAAC;IAEe,KAAK,CAAC,UAAU,CAAC,OAAgC;QAC/D,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,GAAG,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;QACzC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,MAAM,KAAK,GAAG,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC7C,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAChE,CAAC;IAEe,KAAK,CAAC,QAAQ,CAAC,QAAyB,IAAkB,CAAC;IAE3E,MAAM,CAAU,EAAE,GAAwC,YAAY,CAAC"}
|
|
@@ -39,6 +39,17 @@ export interface BucketStorageBatch extends ObserverClient<BucketBatchStorageLis
|
|
|
39
39
|
* by itself.
|
|
40
40
|
*/
|
|
41
41
|
save(record: SaveOptions): Promise<FlushedResult | null>;
|
|
42
|
+
/**
|
|
43
|
+
* Returns a function implementing {@link BucketStorageBatch.save} for undecoded inputs.
|
|
44
|
+
*
|
|
45
|
+
* While `save` processes rows as decoded SQLite values, some batch implementations can decode and evaluate in one
|
|
46
|
+
* step without the intermediate {@link SqliteRow} format. This is the case for MongoDB bucket storage with an option
|
|
47
|
+
* enabling a Sync Stream evaluator written in Rust.
|
|
48
|
+
*
|
|
49
|
+
* @param format A tag describing the bytes passed to the returned function, e.g. `'bson'`. If the storage
|
|
50
|
+
* implementation doesn't understand the format, it returns undefined.
|
|
51
|
+
*/
|
|
52
|
+
prepareUndecodedSave?(format: unknown): ProcessUndecodedDocument | undefined;
|
|
42
53
|
/**
|
|
43
54
|
* Replicate a truncate operation by removing all currently replicated rows
|
|
44
55
|
* for the specified source tables.
|
|
@@ -160,6 +171,7 @@ export interface BucketStorageBatch extends ObserverClient<BucketBatchStorageLis
|
|
|
160
171
|
*/
|
|
161
172
|
addCustomWriteCheckpoint(checkpoint: BatchedCustomWriteCheckpointOptions): void;
|
|
162
173
|
}
|
|
174
|
+
export type ProcessUndecodedDocument = (save: SaveUndecodedOptions) => Promise<FlushedResult | null>;
|
|
163
175
|
/**
|
|
164
176
|
* Replica id uniquely identifying a row on the source database.
|
|
165
177
|
*
|
|
@@ -219,6 +231,15 @@ export interface SaveDelete {
|
|
|
219
231
|
after?: undefined;
|
|
220
232
|
afterReplicaId?: undefined;
|
|
221
233
|
}
|
|
234
|
+
export type SaveUndecodedOptions = SaveUndecodedInsertOrUpdate | SaveDelete;
|
|
235
|
+
export interface SaveUndecodedInsertOrUpdate {
|
|
236
|
+
tag: SaveOperationTag.INSERT | SaveOperationTag.UPDATE;
|
|
237
|
+
sourceTable: SourceTable;
|
|
238
|
+
before?: undefined;
|
|
239
|
+
beforeReplicaId?: undefined;
|
|
240
|
+
after: Uint8Array;
|
|
241
|
+
afterReplicaId: ReplicaId;
|
|
242
|
+
}
|
|
222
243
|
export interface CheckpointResult {
|
|
223
244
|
/**
|
|
224
245
|
* True if any of these are true:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BucketStorageBatch.js","sourceRoot":"","sources":["../../src/storage/BucketStorageBatch.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,MAAM,mCAAmC,GAAqC;IACnF,sBAAsB,EAAE,IAAI;IAC5B,uBAAuB,EAAE,IAAI;CAC9B,CAAC;
|
|
1
|
+
{"version":3,"file":"BucketStorageBatch.js","sourceRoot":"","sources":["../../src/storage/BucketStorageBatch.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,MAAM,mCAAmC,GAAqC;IACnF,sBAAsB,EAAE,IAAI;IAC5B,uBAAuB,EAAE,IAAI;CAC9B,CAAC;AAsNF,MAAM,CAAN,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC1B,qCAAiB,CAAA;IACjB,qCAAiB,CAAA;IACjB,qCAAiB,CAAA;AACnB,CAAC,EAJW,gBAAgB,KAAhB,gBAAgB,QAI3B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BucketDataSource, BucketDefinitionId, EventDefinitionId, ParameterIndexId, ParameterIndexLookupCreator, SourceTableRef } from '@powersync/service-sync-rules';
|
|
1
|
+
import { BucketDataSource, BucketDefinitionId, EventDefinitionId, ParameterIndexId, ParameterIndexLookupCreator, RustSourceTable, SourceTableRef } from '@powersync/service-sync-rules';
|
|
2
2
|
import { bson } from '../index.js';
|
|
3
3
|
import { ColumnDescriptor, JsonValue } from './SourceEntity.js';
|
|
4
4
|
/**
|
|
@@ -30,6 +30,7 @@ export interface SourceTableOptions {
|
|
|
30
30
|
* Source-specific metadata. Null when no metadata has been recorded.
|
|
31
31
|
*/
|
|
32
32
|
sourceMetadata?: JsonValue;
|
|
33
|
+
rustSourceTable?: RustSourceTable;
|
|
33
34
|
}
|
|
34
35
|
export interface TableSnapshotStatus {
|
|
35
36
|
totalEstimatedCount: number;
|
|
@@ -89,6 +90,10 @@ export declare class SourceTable {
|
|
|
89
90
|
* May be set if snapshotComplete = false.
|
|
90
91
|
*/
|
|
91
92
|
snapshotStatus: TableSnapshotStatus | undefined;
|
|
93
|
+
/**
|
|
94
|
+
* If this table is intended to be processed by the Rust addon, prepared data and parameter sources for Rust.
|
|
95
|
+
*/
|
|
96
|
+
readonly rustSourceTable: RustSourceTable | undefined;
|
|
92
97
|
snapshotComplete: boolean;
|
|
93
98
|
constructor(options: SourceTableOptions);
|
|
94
99
|
get id(): SourceTableId;
|
|
@@ -62,10 +62,15 @@ export class SourceTable {
|
|
|
62
62
|
* May be set if snapshotComplete = false.
|
|
63
63
|
*/
|
|
64
64
|
snapshotStatus = undefined;
|
|
65
|
+
/**
|
|
66
|
+
* If this table is intended to be processed by the Rust addon, prepared data and parameter sources for Rust.
|
|
67
|
+
*/
|
|
68
|
+
rustSourceTable = undefined;
|
|
65
69
|
snapshotComplete;
|
|
66
70
|
constructor(options) {
|
|
67
71
|
this.options = options;
|
|
68
72
|
this.snapshotComplete = options.snapshotComplete;
|
|
73
|
+
this.rustSourceTable = options.rustSourceTable;
|
|
69
74
|
}
|
|
70
75
|
get id() {
|
|
71
76
|
return this.options.id;
|
|
@@ -137,7 +142,8 @@ export class SourceTable {
|
|
|
137
142
|
bucketDataSourceIds: this.bucketDataSourceIds == null ? undefined : new Set(this.bucketDataSourceIds),
|
|
138
143
|
parameterLookupSourceIds: this.parameterLookupSourceIds == null ? undefined : new Set(this.parameterLookupSourceIds),
|
|
139
144
|
eventDefinitionIds: this.eventDefinitionIds == null ? undefined : new Set(this.eventDefinitionIds),
|
|
140
|
-
sourceMetadata: structuredClone(sourceMetadata)
|
|
145
|
+
sourceMetadata: structuredClone(sourceMetadata),
|
|
146
|
+
rustSourceTable: this.rustSourceTable
|
|
141
147
|
});
|
|
142
148
|
copy.syncData = this.syncData;
|
|
143
149
|
copy.syncParameters = this.syncParameters;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SourceTable.js","sourceRoot":"","sources":["../../src/storage/SourceTable.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,WAAW,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,SAAS,CAAC;QAChC,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC;QAC9C,IAAI,CAAC,cAAc;YACjB,IAAI,CAAC,cAAc,IAAI,IAAI;gBACzB,CAAC,CAAC,SAAS;gBACX,CAAC,CAAC;oBACE,GAAG,IAAI,CAAC,cAAc;oBACtB,OAAO,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"}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "1.
|
|
7
|
+
"version": "1.31.0-dev-20261204084200",
|
|
8
8
|
"license": "Apache-2.0",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"exports": "./dist/index.js",
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
"uuid": "^14.0.0",
|
|
33
33
|
"winston": "^3.13.0",
|
|
34
34
|
"yaml": "^2.8.3",
|
|
35
|
-
"@powersync/lib-services-framework": "0.10.
|
|
35
|
+
"@powersync/lib-services-framework": "0.10.8-dev-20261204084200",
|
|
36
36
|
"@powersync/service-jsonbig": "0.18.0",
|
|
37
|
-
"@powersync/service-rsocket-router": "0.3.
|
|
38
|
-
"@powersync/service-rust-types": "0.1.
|
|
39
|
-
"@powersync/service-sync-rules": "0.45.
|
|
37
|
+
"@powersync/service-rsocket-router": "0.3.3-dev-20261204084200",
|
|
38
|
+
"@powersync/service-rust-types": "0.1.1-dev-20261204084200",
|
|
39
|
+
"@powersync/service-sync-rules": "0.45.3-dev-20261204084200",
|
|
40
40
|
"@powersync/service-types": "0.21.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { loadRustAddon, RustAddon } from '@powersync/service-rust-types';
|
|
2
2
|
|
|
3
|
+
import { ServiceIdentifier } from '@powersync/lib-services-framework';
|
|
3
4
|
import { ServiceContextContainer } from '../system/ServiceContext.js';
|
|
4
5
|
import { AbstractModule, AbstractModuleOptions, TearDownOptions } from './AbstractModule.js';
|
|
5
6
|
|
|
7
|
+
export type { RustAddon };
|
|
8
|
+
|
|
6
9
|
export interface RustModuleOptions extends AbstractModuleOptions {
|
|
7
10
|
addonPath: string;
|
|
8
11
|
}
|
|
@@ -20,17 +23,17 @@ export class RustModule extends AbstractModule {
|
|
|
20
23
|
this.#addonPath = options.addonPath;
|
|
21
24
|
}
|
|
22
25
|
|
|
23
|
-
public override async initialize(
|
|
24
|
-
await this.loadRust();
|
|
25
|
-
|
|
26
|
-
// Currently, we just initialize the module for testing purposes. In the future, we'd register Rust-backed
|
|
27
|
-
// implementations on the service container.
|
|
26
|
+
public override async initialize(context: ServiceContextContainer): Promise<void> {
|
|
27
|
+
const [addon, _] = await this.loadRust();
|
|
28
|
+
context.register(RustModule.id, addon);
|
|
28
29
|
}
|
|
29
30
|
|
|
30
|
-
async loadRust(): Promise<RustAddon.InitializedRustModule> {
|
|
31
|
+
async loadRust(): Promise<[typeof RustAddon, RustAddon.InitializedRustModule]> {
|
|
31
32
|
const addon = loadRustAddon(this.#addonPath);
|
|
32
|
-
return addon.initializeRust({ logger: this.logger });
|
|
33
|
+
return [addon, addon.initializeRust({ logger: this.logger })];
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
public override async teardown(_options: TearDownOptions): Promise<void> {}
|
|
37
|
+
|
|
38
|
+
static readonly id: ServiceIdentifier<typeof RustAddon> = 'rust-addon';
|
|
36
39
|
}
|
|
@@ -48,6 +48,18 @@ export interface BucketStorageBatch extends ObserverClient<BucketBatchStorageLis
|
|
|
48
48
|
*/
|
|
49
49
|
save(record: SaveOptions): Promise<FlushedResult | null>;
|
|
50
50
|
|
|
51
|
+
/**
|
|
52
|
+
* Returns a function implementing {@link BucketStorageBatch.save} for undecoded inputs.
|
|
53
|
+
*
|
|
54
|
+
* While `save` processes rows as decoded SQLite values, some batch implementations can decode and evaluate in one
|
|
55
|
+
* step without the intermediate {@link SqliteRow} format. This is the case for MongoDB bucket storage with an option
|
|
56
|
+
* enabling a Sync Stream evaluator written in Rust.
|
|
57
|
+
*
|
|
58
|
+
* @param format A tag describing the bytes passed to the returned function, e.g. `'bson'`. If the storage
|
|
59
|
+
* implementation doesn't understand the format, it returns undefined.
|
|
60
|
+
*/
|
|
61
|
+
prepareUndecodedSave?(format: unknown): ProcessUndecodedDocument | undefined;
|
|
62
|
+
|
|
51
63
|
/**
|
|
52
64
|
* Replicate a truncate operation by removing all currently replicated rows
|
|
53
65
|
* for the specified source tables.
|
|
@@ -182,6 +194,8 @@ export interface BucketStorageBatch extends ObserverClient<BucketBatchStorageLis
|
|
|
182
194
|
addCustomWriteCheckpoint(checkpoint: BatchedCustomWriteCheckpointOptions): void;
|
|
183
195
|
}
|
|
184
196
|
|
|
197
|
+
export type ProcessUndecodedDocument = (save: SaveUndecodedOptions) => Promise<FlushedResult | null>;
|
|
198
|
+
|
|
185
199
|
/**
|
|
186
200
|
* Replica id uniquely identifying a row on the source database.
|
|
187
201
|
*
|
|
@@ -253,6 +267,18 @@ export interface SaveDelete {
|
|
|
253
267
|
afterReplicaId?: undefined;
|
|
254
268
|
}
|
|
255
269
|
|
|
270
|
+
export type SaveUndecodedOptions = SaveUndecodedInsertOrUpdate | SaveDelete;
|
|
271
|
+
|
|
272
|
+
export interface SaveUndecodedInsertOrUpdate {
|
|
273
|
+
tag: SaveOperationTag.INSERT | SaveOperationTag.UPDATE;
|
|
274
|
+
sourceTable: SourceTable;
|
|
275
|
+
before?: undefined;
|
|
276
|
+
beforeReplicaId?: undefined;
|
|
277
|
+
after: Uint8Array;
|
|
278
|
+
afterReplicaId: ReplicaId;
|
|
279
|
+
// Note that we currently don't support TOAST values in undecoded writes
|
|
280
|
+
}
|
|
281
|
+
|
|
256
282
|
export interface CheckpointResult {
|
|
257
283
|
/**
|
|
258
284
|
* True if any of these are true:
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
EventDefinitionId,
|
|
6
6
|
ParameterIndexId,
|
|
7
7
|
ParameterIndexLookupCreator,
|
|
8
|
+
RustSourceTable,
|
|
8
9
|
SourceTableRef
|
|
9
10
|
} from '@powersync/service-sync-rules';
|
|
10
11
|
import { bson } from '../index.js';
|
|
@@ -47,6 +48,7 @@ export interface SourceTableOptions {
|
|
|
47
48
|
* Source-specific metadata. Null when no metadata has been recorded.
|
|
48
49
|
*/
|
|
49
50
|
sourceMetadata?: JsonValue;
|
|
51
|
+
rustSourceTable?: RustSourceTable;
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
export interface TableSnapshotStatus {
|
|
@@ -113,10 +115,16 @@ export class SourceTable {
|
|
|
113
115
|
*/
|
|
114
116
|
public snapshotStatus: TableSnapshotStatus | undefined = undefined;
|
|
115
117
|
|
|
118
|
+
/**
|
|
119
|
+
* If this table is intended to be processed by the Rust addon, prepared data and parameter sources for Rust.
|
|
120
|
+
*/
|
|
121
|
+
public readonly rustSourceTable: RustSourceTable | undefined = undefined;
|
|
122
|
+
|
|
116
123
|
public snapshotComplete: boolean;
|
|
117
124
|
|
|
118
125
|
constructor(public readonly options: SourceTableOptions) {
|
|
119
126
|
this.snapshotComplete = options.snapshotComplete;
|
|
127
|
+
this.rustSourceTable = options.rustSourceTable;
|
|
120
128
|
}
|
|
121
129
|
|
|
122
130
|
get id() {
|
|
@@ -205,7 +213,8 @@ export class SourceTable {
|
|
|
205
213
|
parameterLookupSourceIds:
|
|
206
214
|
this.parameterLookupSourceIds == null ? undefined : new Set(this.parameterLookupSourceIds),
|
|
207
215
|
eventDefinitionIds: this.eventDefinitionIds == null ? undefined : new Set(this.eventDefinitionIds),
|
|
208
|
-
sourceMetadata: structuredClone(sourceMetadata)
|
|
216
|
+
sourceMetadata: structuredClone(sourceMetadata),
|
|
217
|
+
rustSourceTable: this.rustSourceTable
|
|
209
218
|
});
|
|
210
219
|
copy.syncData = this.syncData;
|
|
211
220
|
copy.syncParameters = this.syncParameters;
|