@powersync/service-core 0.0.0-dev-20261005120023 → 0.0.0-dev-20261007110800
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 +22 -11
- package/dist/api/RouteAPI.d.ts +8 -1
- package/dist/api/api-index.d.ts +1 -0
- package/dist/api/api-index.js +1 -0
- package/dist/api/api-index.js.map +1 -1
- package/dist/api/diagnostics.js +28 -14
- package/dist/api/diagnostics.js.map +1 -1
- package/dist/api/source-capabilities.d.ts +12 -0
- package/dist/api/source-capabilities.js +27 -0
- package/dist/api/source-capabilities.js.map +1 -0
- package/dist/replication/AbstractReplicator.d.ts +6 -0
- package/dist/replication/AbstractReplicator.js +12 -2
- package/dist/replication/AbstractReplicator.js.map +1 -1
- package/dist/replication/ReplicationModule.js +10 -2
- package/dist/replication/ReplicationModule.js.map +1 -1
- package/dist/routes/configure-fastify.d.ts +24 -24
- package/dist/routes/endpoints/admin.d.ts +48 -48
- package/dist/routes/endpoints/admin.js +8 -8
- package/dist/routes/endpoints/admin.js.map +1 -1
- package/dist/routes/endpoints/sync-rules.js +51 -14
- package/dist/routes/endpoints/sync-rules.js.map +1 -1
- package/dist/storage/BucketStorageFactory.d.ts +11 -13
- package/dist/storage/BucketStorageFactory.js +21 -11
- package/dist/storage/BucketStorageFactory.js.map +1 -1
- package/dist/storage/PersistedReplicationStream.d.ts +1 -2
- package/dist/storage/PersistedReplicationStream.js.map +1 -1
- package/dist/storage/PersistedSyncConfigContent.d.ts +4 -4
- package/dist/storage/PersistedSyncConfigContent.js +5 -12
- package/dist/storage/PersistedSyncConfigContent.js.map +1 -1
- package/dist/storage/StorageEngine.d.ts +0 -4
- package/dist/storage/StorageEngine.js +1 -7
- package/dist/storage/StorageEngine.js.map +1 -1
- package/dist/storage/StorageProvider.d.ts +1 -6
- package/dist/storage/SyncRulesBucketStorage.d.ts +1 -1
- package/dist/storage/storage-index.d.ts +0 -1
- package/dist/storage/storage-index.js +0 -1
- package/dist/storage/storage-index.js.map +1 -1
- package/dist/system/ServiceContext.d.ts +0 -20
- package/dist/system/ServiceContext.js +1 -29
- package/dist/system/ServiceContext.js.map +1 -1
- package/package.json +11 -11
- package/src/api/RouteAPI.ts +9 -1
- package/src/api/api-index.ts +1 -0
- package/src/api/diagnostics.ts +24 -12
- package/src/api/source-capabilities.ts +31 -0
- package/src/replication/AbstractReplicator.ts +14 -2
- package/src/replication/ReplicationModule.ts +9 -2
- package/src/routes/endpoints/admin.ts +14 -6
- package/src/routes/endpoints/sync-rules.ts +52 -16
- package/src/storage/BucketStorageFactory.ts +21 -19
- package/src/storage/PersistedReplicationStream.ts +1 -2
- package/src/storage/PersistedSyncConfigContent.ts +9 -16
- package/src/storage/StorageEngine.ts +1 -10
- package/src/storage/StorageProvider.ts +1 -6
- package/src/storage/SyncRulesBucketStorage.ts +1 -1
- package/src/storage/storage-index.ts +0 -1
- package/src/system/ServiceContext.ts +1 -47
- package/test/src/AbstractReplicator.test.ts +94 -23
- package/test/src/PersistedSyncConfigContent.test.ts +1 -3
- package/test/src/diagnostics.test.ts +71 -0
- package/test/src/routes/admin.test.ts +205 -11
- package/test/src/routes/mocks.ts +0 -2
- package/test/src/routes/sync-rules.test.ts +76 -0
- package/test/src/source-capabilities.test.ts +42 -0
- package/test/src/source_table_config.test.ts +55 -0
- package/test/src/storage/BucketStorageFactory.test.ts +46 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/storage/SyncConfigParser.d.ts +0 -44
- package/dist/storage/SyncConfigParser.js +0 -73
- package/dist/storage/SyncConfigParser.js.map +0 -1
- package/src/storage/SyncConfigParser.ts +0 -124
- package/test/src/SyncConfigParser.test.ts +0 -309
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseObserver } from '@powersync/lib-services-framework';
|
|
1
|
+
import { BaseObserver, logger } from '@powersync/lib-services-framework';
|
|
2
2
|
import { SerializedSyncPlan as RawSerializedSyncPlan, SerializedCompatibilityContext, SyncConfigWithErrors } from '@powersync/service-sync-rules';
|
|
3
3
|
import { ReplicationError } from '@powersync/service-types';
|
|
4
4
|
import { PersistedReplicationStream } from './PersistedReplicationStream.js';
|
|
@@ -6,14 +6,7 @@ import { PersistedSyncConfigContent } from './PersistedSyncConfigContent.js';
|
|
|
6
6
|
import { ReplicationEventPayload } from './ReplicationEventPayload.js';
|
|
7
7
|
import { ReplicationLock } from './ReplicationLock.js';
|
|
8
8
|
import { ReportStorage } from './ReportStorage.js';
|
|
9
|
-
import { SyncConfigParser } from './SyncConfigParser.js';
|
|
10
9
|
import { SyncRulesBucketStorage } from './SyncRulesBucketStorage.js';
|
|
11
|
-
export interface BucketStorageFactoryOptions {
|
|
12
|
-
/**
|
|
13
|
-
* Service-wide parser assembled before storage startup.
|
|
14
|
-
*/
|
|
15
|
-
syncConfigParser: SyncConfigParser;
|
|
16
|
-
}
|
|
17
10
|
/**
|
|
18
11
|
* Represents a configured storage provider.
|
|
19
12
|
*
|
|
@@ -23,11 +16,6 @@ export interface BucketStorageFactoryOptions {
|
|
|
23
16
|
* Storage APIs for a specific replication stream are provided by the `SyncRulesBucketStorage` instances.
|
|
24
17
|
*/
|
|
25
18
|
export declare abstract class BucketStorageFactory extends BaseObserver<BucketStorageFactoryListener> implements AsyncDisposable {
|
|
26
|
-
readonly syncConfigParser: SyncConfigParser;
|
|
27
|
-
/**
|
|
28
|
-
* Creates a storage factory using the service-wide parser assembled before storage startup.
|
|
29
|
-
*/
|
|
30
|
-
constructor(options: BucketStorageFactoryOptions);
|
|
31
19
|
/**
|
|
32
20
|
* Update sync config from configuration, if changed.
|
|
33
21
|
*/
|
|
@@ -177,6 +165,16 @@ export declare function updateSyncRulesFromYaml(content: string, options?: Omit<
|
|
|
177
165
|
validate?: boolean;
|
|
178
166
|
}): UpdateSyncRulesOptions;
|
|
179
167
|
export declare function updateSyncRulesFromConfig(parsed: SyncConfigWithErrors, options?: Omit<UpdateSyncRulesOptions, 'config'>): UpdateSyncRulesOptions;
|
|
168
|
+
/**
|
|
169
|
+
* Logs the errors and warnings of a parsed sync config
|
|
170
|
+
*
|
|
171
|
+
* Call this where a sync config is loaded or deployed, so that operators see these in the service logs and not only
|
|
172
|
+
* in the diagnostics and validate API responses.
|
|
173
|
+
*
|
|
174
|
+
* Fatal errors usually throw during parsing before this is reached. They can reach this when the sync config is parsed
|
|
175
|
+
* without validation, such as at startup with `exit_on_error: false`.
|
|
176
|
+
*/
|
|
177
|
+
export declare function logSyncConfigErrors(parsed: SyncConfigWithErrors, log?: typeof logger): void;
|
|
180
178
|
export interface GetIntanceOptions {
|
|
181
179
|
/**
|
|
182
180
|
* The job lease, including a lease acquired during initial configuration.
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { BaseObserver, logger } from '@powersync/lib-services-framework';
|
|
2
|
-
import { PrecompiledSyncConfig, serializeSyncPlan } from '@powersync/service-sync-rules';
|
|
2
|
+
import { PrecompiledSyncConfig, serializeSyncPlan, SqlSyncRules } from '@powersync/service-sync-rules';
|
|
3
3
|
import { syncConfigYamlErrorToReplicationError } from '../util/errors.js';
|
|
4
|
-
import { SqlSyncConfigParser } from './SyncConfigParser.js';
|
|
5
4
|
/**
|
|
6
5
|
* Represents a configured storage provider.
|
|
7
6
|
*
|
|
@@ -11,14 +10,6 @@ import { SqlSyncConfigParser } from './SyncConfigParser.js';
|
|
|
11
10
|
* Storage APIs for a specific replication stream are provided by the `SyncRulesBucketStorage` instances.
|
|
12
11
|
*/
|
|
13
12
|
export class BucketStorageFactory extends BaseObserver {
|
|
14
|
-
syncConfigParser;
|
|
15
|
-
/**
|
|
16
|
-
* Creates a storage factory using the service-wide parser assembled before storage startup.
|
|
17
|
-
*/
|
|
18
|
-
constructor(options) {
|
|
19
|
-
super();
|
|
20
|
-
this.syncConfigParser = options.syncConfigParser;
|
|
21
|
-
}
|
|
22
13
|
/**
|
|
23
14
|
* Update sync config from configuration, if changed.
|
|
24
15
|
*/
|
|
@@ -48,7 +39,7 @@ export class BucketStorageFactory extends BaseObserver {
|
|
|
48
39
|
}
|
|
49
40
|
export function updateSyncRulesFromYaml(content, options) {
|
|
50
41
|
const { validate, ...updateOptions } = options ?? {};
|
|
51
|
-
const config =
|
|
42
|
+
const config = SqlSyncRules.fromYaml(content, {
|
|
52
43
|
// No schema-based validation at this point
|
|
53
44
|
schema: undefined,
|
|
54
45
|
defaultSchema: options?.defaultSchema ?? 'not_applicable', // Not needed for validation
|
|
@@ -74,4 +65,23 @@ export function updateSyncRulesFromConfig(parsed, options) {
|
|
|
74
65
|
}
|
|
75
66
|
return { config: { yaml: config.content, plan, parsed }, ...options };
|
|
76
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Logs the errors and warnings of a parsed sync config
|
|
70
|
+
*
|
|
71
|
+
* Call this where a sync config is loaded or deployed, so that operators see these in the service logs and not only
|
|
72
|
+
* in the diagnostics and validate API responses.
|
|
73
|
+
*
|
|
74
|
+
* Fatal errors usually throw during parsing before this is reached. They can reach this when the sync config is parsed
|
|
75
|
+
* without validation, such as at startup with `exit_on_error: false`.
|
|
76
|
+
*/
|
|
77
|
+
export function logSyncConfigErrors(parsed, log = logger) {
|
|
78
|
+
for (const error of parsed.errors) {
|
|
79
|
+
if (error.type == 'warning') {
|
|
80
|
+
log.warn(`Sync config warning: ${error.message}`);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
log.error(`Sync config error: ${error.message}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
77
87
|
//# sourceMappingURL=BucketStorageFactory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BucketStorageFactory.js","sourceRoot":"","sources":["../../src/storage/BucketStorageFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EACL,qBAAqB,EAGrB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"BucketStorageFactory.js","sourceRoot":"","sources":["../../src/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BAAiB,CAAC,MAAM,CAAC,IAAI,CAAC;YACpC,+GAA+G;YAC/G,gBAAgB;YAChB,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,qCAAqC,CAAC,CAAC,CAAC,CAAC;SACpE,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,OAAO,EAAE,CAAC;AACxE,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAA4B,EAAE,MAAqB,MAAM;IAC3F,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAClC,IAAI,KAAK,CAAC,IAAI,IAAI,SAAS,EAAE,CAAC;YAC5B,GAAG,CAAC,IAAI,CAAC,wBAAwB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACpD,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,KAAK,CAAC,sBAAsB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Logger } from 'winston';
|
|
2
2
|
import { SyncRuleState } from './BucketStorage.js';
|
|
3
3
|
import type { ParsedSyncConfigSet } from './ParsedSyncConfigSet.js';
|
|
4
|
-
import type { PersistedSyncConfigContent } from './PersistedSyncConfigContent.js';
|
|
4
|
+
import type { ParseSyncConfigOptions, PersistedSyncConfigContent } from './PersistedSyncConfigContent.js';
|
|
5
5
|
import { ReplicationLock } from './ReplicationLock.js';
|
|
6
6
|
import { StorageVersionConfig } from './StorageVersionConfig.js';
|
|
7
|
-
import type { ParseSyncConfigOptions } from './SyncConfigParser.js';
|
|
8
7
|
export declare abstract class PersistedReplicationStream implements PersistedReplicationStreamData {
|
|
9
8
|
readonly replicationStreamId: number;
|
|
10
9
|
readonly replicationJobId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PersistedReplicationStream.js","sourceRoot":"","sources":["../../src/storage/PersistedReplicationStream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,aAAa,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAMrG,OAAO,EAAE,sBAAsB,EAAwB,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"PersistedReplicationStream.js","sourceRoot":"","sources":["../../src/storage/PersistedReplicationStream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,aAAa,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAMrG,OAAO,EAAE,sBAAsB,EAAwB,MAAM,2BAA2B,CAAC;AAEzF,MAAM,OAAgB,0BAA0B;IACrC,mBAAmB,CAAS;IAC5B,gBAAgB,CAAS;IACzB,qBAAqB,CAAS;IAC9B,KAAK,CAAgB;IACrB,cAAc,CAAS;IACvB,MAAM,CAAS;IAKxB,YAAY,IAAoC;QAC9C,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,mBAAmB,CAAC;QACpD,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,IAAI,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;QAClF,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,qBAAqB,CAAC;QACxD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACxB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;QAC1C,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,IAAI,IAAI,CAAC,qBAAqB,IAAI,EAAE,CAAC,CAAC;IACpF,CAAC;IAED,gBAAgB;QACd,MAAM,aAAa,GAAG,sBAAsB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAClE,IAAI,aAAa,IAAI,IAAI,EAAE,CAAC;YAC1B,MAAM,IAAI,YAAY,CACpB,SAAS,CAAC,WAAW,EACrB,+BAA+B,IAAI,CAAC,cAAc,2BAA2B,IAAI,CAAC,mBAAmB,EAAE,CACxG,CAAC;QACJ,CAAC;QACD,OAAO,aAAa,CAAC;IACvB,CAAC;CAKF"}
|
|
@@ -5,13 +5,11 @@ import { SerializedSyncPlan, UpdateSyncRulesOptions } from './BucketStorageFacto
|
|
|
5
5
|
import { ParsedSyncConfigSet } from './ParsedSyncConfigSet.js';
|
|
6
6
|
import { PersistedSyncConfigStatus } from './PersistedSyncConfigStatus.js';
|
|
7
7
|
import { StorageVersionConfig } from './StorageVersionConfig.js';
|
|
8
|
-
import { ParseSyncConfigOptions, SyncConfigParser } from './SyncConfigParser.js';
|
|
9
8
|
export interface ParsePersistedSyncConfigContentOptions {
|
|
10
9
|
content: string;
|
|
11
10
|
compiledPlan: SerializedSyncPlan | null;
|
|
12
11
|
storageVersion: number;
|
|
13
12
|
parseOptions: ParseSyncConfigOptions;
|
|
14
|
-
syncConfigParser: SyncConfigParser;
|
|
15
13
|
}
|
|
16
14
|
export declare function parsePersistedSyncConfigContent(options: ParsePersistedSyncConfigContentOptions): SyncConfigWithErrors;
|
|
17
15
|
/**
|
|
@@ -22,7 +20,6 @@ export declare function parsePersistedSyncConfigContent(options: ParsePersistedS
|
|
|
22
20
|
* lifecycle concerns such as locking and termination.
|
|
23
21
|
*/
|
|
24
22
|
export declare abstract class PersistedSyncConfigContent implements PersistedSyncConfigContentData {
|
|
25
|
-
private readonly syncConfigParser;
|
|
26
23
|
readonly replicationStreamId: number;
|
|
27
24
|
readonly sync_rules_content: string;
|
|
28
25
|
readonly compiled_plan: SerializedSyncPlan | null;
|
|
@@ -32,7 +29,7 @@ export declare abstract class PersistedSyncConfigContent implements PersistedSyn
|
|
|
32
29
|
readonly syncConfigId: PersistedSyncConfigId | null;
|
|
33
30
|
readonly syncConfigState: SyncRuleState;
|
|
34
31
|
readonly version_label: string | undefined;
|
|
35
|
-
constructor(data: PersistedSyncConfigContentData
|
|
32
|
+
constructor(data: PersistedSyncConfigContentData);
|
|
36
33
|
/**
|
|
37
34
|
* Load the storage config.
|
|
38
35
|
*
|
|
@@ -63,3 +60,6 @@ export interface PersistedSyncConfigContentData {
|
|
|
63
60
|
readonly version_label?: string;
|
|
64
61
|
}
|
|
65
62
|
export type PersistedSyncConfigId = string;
|
|
63
|
+
export interface ParseSyncConfigOptions {
|
|
64
|
+
defaultSchema: string;
|
|
65
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { logger as defaultLogger, ErrorCode, ServiceError } from '@powersync/lib-services-framework';
|
|
2
|
-
import { CompatibilityContext, CompatibilityOption, compileEventDefinitions, DEFAULT_HYDRATION_STATE, deserializeSyncPlan, nodeSqlite, PrecompiledSyncConfig, versionedHydrationState, YamlError } from '@powersync/service-sync-rules';
|
|
2
|
+
import { CompatibilityContext, CompatibilityOption, compileEventDefinitions, DEFAULT_HYDRATION_STATE, deserializeSyncPlan, nodeSqlite, PrecompiledSyncConfig, SqlSyncRules, versionedHydrationState, YamlError } from '@powersync/service-sync-rules';
|
|
3
3
|
import * as sqlite from 'node:sqlite';
|
|
4
4
|
import { STORAGE_VERSION_CONFIG } from './StorageVersionConfig.js';
|
|
5
5
|
export function parsePersistedSyncConfigContent(options) {
|
|
6
|
-
const { content, compiledPlan, storageVersion, parseOptions
|
|
6
|
+
const { content, compiledPlan, storageVersion, parseOptions } = options;
|
|
7
7
|
if (compiledPlan == null) {
|
|
8
8
|
// Fallback: Only parse from YAML if no compiled plan is available.
|
|
9
|
-
return
|
|
9
|
+
return SqlSyncRules.fromYaml(content, parseOptions);
|
|
10
10
|
}
|
|
11
11
|
const plan = deserializeSyncPlan(compiledPlan.plan);
|
|
12
12
|
const compatibility = CompatibilityContext.deserialize(compiledPlan.compatibility);
|
|
@@ -35,10 +35,6 @@ export function parsePersistedSyncConfigContent(options) {
|
|
|
35
35
|
// Note: If the original content did not define a storage version, this will still set the storage version.
|
|
36
36
|
// This means asUpdateOptions will not change the storage version, even if the default changes.
|
|
37
37
|
precompiled.storageVersion = storageVersion;
|
|
38
|
-
errors.push(...syncConfigParser.validatePersisted({
|
|
39
|
-
config: precompiled,
|
|
40
|
-
context: { defaultSchema: parseOptions.defaultSchema }
|
|
41
|
-
}));
|
|
42
38
|
if (compiledPlan.errors) {
|
|
43
39
|
for (const error of compiledPlan.errors) {
|
|
44
40
|
const location = error.location && {
|
|
@@ -60,7 +56,6 @@ export function parsePersistedSyncConfigContent(options) {
|
|
|
60
56
|
* lifecycle concerns such as locking and termination.
|
|
61
57
|
*/
|
|
62
58
|
export class PersistedSyncConfigContent {
|
|
63
|
-
syncConfigParser;
|
|
64
59
|
replicationStreamId;
|
|
65
60
|
sync_rules_content;
|
|
66
61
|
compiled_plan;
|
|
@@ -70,8 +65,7 @@ export class PersistedSyncConfigContent {
|
|
|
70
65
|
syncConfigId;
|
|
71
66
|
syncConfigState;
|
|
72
67
|
version_label;
|
|
73
|
-
constructor(data
|
|
74
|
-
this.syncConfigParser = syncConfigParser;
|
|
68
|
+
constructor(data) {
|
|
75
69
|
this.replicationStreamId = data.replicationStreamId;
|
|
76
70
|
this.sync_rules_content = data.sync_rules_content;
|
|
77
71
|
this.compiled_plan = data.compiled_plan;
|
|
@@ -105,8 +99,7 @@ export class PersistedSyncConfigContent {
|
|
|
105
99
|
content: this.sync_rules_content,
|
|
106
100
|
compiledPlan: this.compiled_plan,
|
|
107
101
|
storageVersion: this.storageVersion,
|
|
108
|
-
parseOptions: options
|
|
109
|
-
syncConfigParser: this.syncConfigParser
|
|
102
|
+
parseOptions: options
|
|
110
103
|
});
|
|
111
104
|
}
|
|
112
105
|
parsed(options) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PersistedSyncConfigContent.js","sourceRoot":"","sources":["../../src/storage/PersistedSyncConfigContent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,aAAa,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACrG,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,uBAAuB,EACvB,uBAAuB,EACvB,mBAAmB,EAInB,UAAU,EACV,qBAAqB,
|
|
1
|
+
{"version":3,"file":"PersistedSyncConfigContent.js","sourceRoot":"","sources":["../../src/storage/PersistedSyncConfigContent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,aAAa,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACrG,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,uBAAuB,EACvB,uBAAuB,EACvB,mBAAmB,EAInB,UAAU,EACV,qBAAqB,EACrB,YAAY,EAEZ,uBAAuB,EACvB,SAAS,EACV,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAMtC,OAAO,EAAE,sBAAsB,EAAwB,MAAM,2BAA2B,CAAC;AASzF,MAAM,UAAU,+BAA+B,CAAC,OAA+C;IAC7F,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IAExE,IAAI,YAAY,IAAI,IAAI,EAAE,CAAC;QACzB,mEAAmE;QACnE,OAAO,YAAY,CAAC,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IACtD,CAAC;IAED,MAAM,IAAI,GAAG,mBAAmB,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IACpD,MAAM,aAAa,GAAG,oBAAoB,CAAC,WAAW,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;IACnF,MAAM,MAAM,GAAgB,EAAE,CAAC;IAC/B,kHAAkH;IAClH,8GAA8G;IAC9G,+GAA+G;IAC/G,IAAI,YAAY,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC;QACrC,MAAM,UAAU,GAAG,uBAAuB,CAAC,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AAO,CAAC,EAAE,cAAc,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;gBACnF,OAAO,QAAQ,CAAC;YAClB,CAAC;SACF,CAAC;IACJ,CAAC;IAED,eAAe,CAAC,OAAgD;QAC9D,4DAA4D;QAC5D,MAAM,MAAM,GAAG,IAAI,CAAC,iBAAiB,CAAC,EAAE,aAAa,EAAE,gBAAgB,EAAE,CAAC,CAAC;QAC3E,OAAO;YACL,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,kBAAkB,EAAE,IAAI,EAAE,IAAI,CAAC,aAAa,EAAE,MAAM,EAAE;YAC3E,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,GAAG,OAAO;SACX,CAAC;IACJ,CAAC;CAMF"}
|
|
@@ -2,10 +2,8 @@ import { BaseObserver, ServiceError } from '@powersync/lib-services-framework';
|
|
|
2
2
|
import { ResolvedPowerSyncConfig } from '../util/util-index.js';
|
|
3
3
|
import { BucketStorageFactory } from './BucketStorageFactory.js';
|
|
4
4
|
import { ActiveStorage, StorageProvider } from './StorageProvider.js';
|
|
5
|
-
import { SyncConfigParser } from './SyncConfigParser.js';
|
|
6
5
|
export type StorageEngineOptions = {
|
|
7
6
|
configuration: ResolvedPowerSyncConfig;
|
|
8
|
-
syncConfigParser: SyncConfigParser;
|
|
9
7
|
};
|
|
10
8
|
export interface StorageEngineListener {
|
|
11
9
|
storageActivated: (storage: BucketStorageFactory) => void;
|
|
@@ -14,12 +12,10 @@ export interface StorageEngineListener {
|
|
|
14
12
|
export declare class StorageEngine extends BaseObserver<StorageEngineListener> {
|
|
15
13
|
private options;
|
|
16
14
|
private storageProviders;
|
|
17
|
-
private startupStarted;
|
|
18
15
|
private currentActiveStorage;
|
|
19
16
|
constructor(options: StorageEngineOptions);
|
|
20
17
|
get activeBucketStorage(): BucketStorageFactory;
|
|
21
18
|
get activeStorage(): ActiveStorage;
|
|
22
|
-
get started(): boolean;
|
|
23
19
|
/**
|
|
24
20
|
* Register a provider which generates a {@link BucketStorageFactory}
|
|
25
21
|
* given the matching config specified in the loaded {@link ResolvedPowerSyncConfig}
|
|
@@ -3,7 +3,6 @@ export class StorageEngine extends BaseObserver {
|
|
|
3
3
|
options;
|
|
4
4
|
// TODO: This will need to revisited when we actually support multiple storage providers.
|
|
5
5
|
storageProviders = new Map();
|
|
6
|
-
startupStarted = false;
|
|
7
6
|
currentActiveStorage = null;
|
|
8
7
|
constructor(options) {
|
|
9
8
|
super();
|
|
@@ -18,9 +17,6 @@ export class StorageEngine extends BaseObserver {
|
|
|
18
17
|
}
|
|
19
18
|
return this.currentActiveStorage;
|
|
20
19
|
}
|
|
21
|
-
get started() {
|
|
22
|
-
return this.startupStarted;
|
|
23
|
-
}
|
|
24
20
|
/**
|
|
25
21
|
* Register a provider which generates a {@link BucketStorageFactory}
|
|
26
22
|
* given the matching config specified in the loaded {@link ResolvedPowerSyncConfig}
|
|
@@ -29,12 +25,10 @@ export class StorageEngine extends BaseObserver {
|
|
|
29
25
|
this.storageProviders.set(provider.type, provider);
|
|
30
26
|
}
|
|
31
27
|
async start() {
|
|
32
|
-
this.startupStarted = true;
|
|
33
28
|
logger.info('Starting Storage Engine...');
|
|
34
29
|
const { configuration } = this.options;
|
|
35
30
|
this.currentActiveStorage = await this.storageProviders.get(configuration.storage.type).getStorage({
|
|
36
|
-
resolvedConfig: configuration
|
|
37
|
-
syncConfigParser: this.options.syncConfigParser
|
|
31
|
+
resolvedConfig: configuration
|
|
38
32
|
});
|
|
39
33
|
this.iterateListeners((cb) => cb.storageActivated?.(this.activeBucketStorage));
|
|
40
34
|
this.currentActiveStorage.onFatalError?.((error) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StorageEngine.js","sourceRoot":"","sources":["../../src/storage/StorageEngine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,EAAgB,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"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C,YAAY,EAAE,CAAC,CAAC,KAAK,EAAE,EAAE;YACjD,IAAI,CAAC,gBAAgB,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,iBAAiB,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;QAC/D,CAAC,CAAC,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,mCAAmC,aAAa,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC;QAC9E,MAAM,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;IACtD,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,QAAQ;QACnB,MAAM,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;QAC/C,MAAM,IAAI,CAAC,oBAAoB,EAAE,QAAQ,EAAE,CAAC;QAC5C,MAAM,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC;IACxD,CAAC;CACF"}
|
|
@@ -2,7 +2,6 @@ import { ServiceError } from '@powersync/lib-services-framework';
|
|
|
2
2
|
import * as util from '../util/util-index.js';
|
|
3
3
|
import { BucketStorageFactory } from './BucketStorageFactory.js';
|
|
4
4
|
import { ReportStorage } from './ReportStorage.js';
|
|
5
|
-
import { SyncConfigParser } from './SyncConfigParser.js';
|
|
6
5
|
export interface ActiveStorage {
|
|
7
6
|
storage: BucketStorageFactory;
|
|
8
7
|
reportStorage: ReportStorage;
|
|
@@ -15,10 +14,6 @@ export interface ActiveStorage {
|
|
|
15
14
|
}
|
|
16
15
|
export interface GetStorageOptions {
|
|
17
16
|
resolvedConfig: util.ResolvedPowerSyncConfig;
|
|
18
|
-
/**
|
|
19
|
-
* Service-wide parser containing every extension registered during module initialization.
|
|
20
|
-
*/
|
|
21
|
-
syncConfigParser: SyncConfigParser;
|
|
22
17
|
}
|
|
23
18
|
/**
|
|
24
19
|
* Represents a provider that can create a storage instance for a specific storage type from configuration.
|
|
@@ -30,7 +25,7 @@ export interface StorageProvider {
|
|
|
30
25
|
*/
|
|
31
26
|
type: string;
|
|
32
27
|
/**
|
|
33
|
-
* Creates active storage during storage-engine startup
|
|
28
|
+
* Creates active storage during storage-engine startup.
|
|
34
29
|
*/
|
|
35
30
|
getStorage(options: GetStorageOptions): Promise<ActiveStorage>;
|
|
36
31
|
}
|
|
@@ -6,11 +6,11 @@ import * as util from '../util/util-index.js';
|
|
|
6
6
|
import { BucketStorageBatch, FlushedResult, SaveUpdate } from './BucketStorageBatch.js';
|
|
7
7
|
import { BucketStorageFactory } from './BucketStorageFactory.js';
|
|
8
8
|
import { ParsedSyncConfigSet } from './ParsedSyncConfigSet.js';
|
|
9
|
+
import type { ParseSyncConfigOptions } from './PersistedSyncConfigContent.js';
|
|
9
10
|
import { SourceEntityDescriptor } from './SourceEntity.js';
|
|
10
11
|
import { SourceTable } from './SourceTable.js';
|
|
11
12
|
import { SourceTableCandidateReconciler } from './SourceTableReconciler.js';
|
|
12
13
|
import { StorageVersionConfig } from './StorageVersionConfig.js';
|
|
13
|
-
import { ParseSyncConfigOptions } from './SyncConfigParser.js';
|
|
14
14
|
import { SyncStorageWriteCheckpointAPI } from './WriteCheckpointAPI.js';
|
|
15
15
|
/**
|
|
16
16
|
* Storage for a specific replication stream.
|
|
@@ -24,4 +24,3 @@ export * from './implementation/BucketDefinitionMapping.js';
|
|
|
24
24
|
export * from './implementation/IncrementalReprocessingCompatibility.js';
|
|
25
25
|
export * from './implementation/IncrementalReprocessingSyncConfigLog.js';
|
|
26
26
|
export * from './implementation/ReplicationStreamStorageIds.js';
|
|
27
|
-
export * from './SyncConfigParser.js';
|
|
@@ -24,5 +24,4 @@ export * from './implementation/BucketDefinitionMapping.js';
|
|
|
24
24
|
export * from './implementation/IncrementalReprocessingCompatibility.js';
|
|
25
25
|
export * from './implementation/IncrementalReprocessingSyncConfigLog.js';
|
|
26
26
|
export * from './implementation/ReplicationStreamStorageIds.js';
|
|
27
|
-
export * from './SyncConfigParser.js';
|
|
28
27
|
//# sourceMappingURL=storage-index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-index.js","sourceRoot":"","sources":["../../src/storage/storage-index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yCAAyC,CAAC;AACxD,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iCAAiC,CAAC;AAChD,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AAExC,cAAc,6CAA6C,CAAC;AAC5D,cAAc,0DAA0D,CAAC;AACzE,cAAc,0DAA0D,CAAC;AACzE,cAAc,iDAAiD,CAAC
|
|
1
|
+
{"version":3,"file":"storage-index.js","sourceRoot":"","sources":["../../src/storage/storage-index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yCAAyC,CAAC;AACxD,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iCAAiC,CAAC;AAChD,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AAExC,cAAc,6CAA6C,CAAC;AAC5D,cAAc,0DAA0D,CAAC;AACzE,cAAc,0DAA0D,CAAC;AACzE,cAAc,iDAAiD,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { LifeCycledSystem, ServiceIdentifier } from '@powersync/lib-services-framework';
|
|
2
|
-
import type { AdditionalSyncConfigParser } from '@powersync/service-sync-rules';
|
|
3
2
|
import { EventsEngine } from '../events/EventsEngine.js';
|
|
4
3
|
import * as metrics from '../metrics/MetricsEngine.js';
|
|
5
4
|
import { PowerSyncMigrationManager } from '../migrations/PowerSyncMigrationManager.js';
|
|
@@ -8,15 +7,6 @@ import * as routes from '../routes/routes-index.js';
|
|
|
8
7
|
import * as storage from '../storage/storage-index.js';
|
|
9
8
|
import { SyncContext } from '../sync/SyncContext.js';
|
|
10
9
|
import * as utils from '../util/util-index.js';
|
|
11
|
-
/**
|
|
12
|
-
* Registration-capable sync-config parser exposed to modules through the service context.
|
|
13
|
-
*/
|
|
14
|
-
export interface ServiceContextSyncConfigParser extends storage.SyncConfigParser {
|
|
15
|
-
/**
|
|
16
|
-
* Registers a deterministic parser extension during module initialization, before storage starts.
|
|
17
|
-
*/
|
|
18
|
-
registerParser(extension: AdditionalSyncConfigParser): void;
|
|
19
|
-
}
|
|
20
10
|
export interface ServiceContext {
|
|
21
11
|
configuration: utils.ResolvedPowerSyncConfig;
|
|
22
12
|
lifeCycleEngine: LifeCycledSystem;
|
|
@@ -29,11 +19,6 @@ export interface ServiceContext {
|
|
|
29
19
|
writeCheckpointBatcher: utils.WriteCheckpointBatcher;
|
|
30
20
|
serviceMode: ServiceContextMode;
|
|
31
21
|
eventsEngine: EventsEngine;
|
|
32
|
-
/**
|
|
33
|
-
* Service-wide parser shared by routes, replication, and storage. Source modules register parser extensions on this
|
|
34
|
-
* instance during module initialization.
|
|
35
|
-
*/
|
|
36
|
-
readonly syncConfigParser: ServiceContextSyncConfigParser;
|
|
37
22
|
}
|
|
38
23
|
export declare enum ServiceContextMode {
|
|
39
24
|
API = "api",
|
|
@@ -54,7 +39,6 @@ export interface ServiceContextOptions {
|
|
|
54
39
|
* This controls registering, initializing and the lifecycle of various services.
|
|
55
40
|
*/
|
|
56
41
|
export declare class ServiceContextContainer implements ServiceContext {
|
|
57
|
-
#private;
|
|
58
42
|
configuration: utils.ResolvedPowerSyncConfig;
|
|
59
43
|
lifeCycleEngine: LifeCycledSystem;
|
|
60
44
|
storageEngine: storage.StorageEngine;
|
|
@@ -65,10 +49,6 @@ export declare class ServiceContextContainer implements ServiceContext {
|
|
|
65
49
|
serviceMode: ServiceContextMode;
|
|
66
50
|
constructor(options: ServiceContextOptions);
|
|
67
51
|
get replicationEngine(): replication.ReplicationEngine | null;
|
|
68
|
-
/**
|
|
69
|
-
* Returns the service-wide parser shared by routes, replication, and storage.
|
|
70
|
-
*/
|
|
71
|
-
get syncConfigParser(): ServiceContextSyncConfigParser;
|
|
72
52
|
get metricsEngine(): metrics.MetricsEngine;
|
|
73
53
|
get migrations(): PowerSyncMigrationManager;
|
|
74
54
|
/**
|
|
@@ -31,16 +31,13 @@ export class ServiceContextContainer {
|
|
|
31
31
|
routerEngine;
|
|
32
32
|
writeCheckpointBatcher;
|
|
33
33
|
serviceMode;
|
|
34
|
-
#syncConfigParser;
|
|
35
34
|
constructor(options) {
|
|
36
35
|
this.serviceMode = options.serviceMode;
|
|
37
36
|
const { configuration } = options;
|
|
38
37
|
this.configuration = configuration;
|
|
39
|
-
this.#syncConfigParser = new ServiceContextSyncConfigParserImpl(() => this.storageEngine.started);
|
|
40
38
|
this.lifeCycleEngine = new LifeCycledSystem();
|
|
41
39
|
this.storageEngine = new storage.StorageEngine({
|
|
42
|
-
configuration
|
|
43
|
-
syncConfigParser: this.#syncConfigParser
|
|
40
|
+
configuration
|
|
44
41
|
});
|
|
45
42
|
this.storageEngine.registerListener({
|
|
46
43
|
storageFatalError: (error) => {
|
|
@@ -79,12 +76,6 @@ export class ServiceContextContainer {
|
|
|
79
76
|
get replicationEngine() {
|
|
80
77
|
return container.getOptional(replication.ReplicationEngine);
|
|
81
78
|
}
|
|
82
|
-
/**
|
|
83
|
-
* Returns the service-wide parser shared by routes, replication, and storage.
|
|
84
|
-
*/
|
|
85
|
-
get syncConfigParser() {
|
|
86
|
-
return this.#syncConfigParser;
|
|
87
|
-
}
|
|
88
79
|
get metricsEngine() {
|
|
89
80
|
return container.getImplementation(metrics.MetricsEngine);
|
|
90
81
|
}
|
|
@@ -105,23 +96,4 @@ export class ServiceContextContainer {
|
|
|
105
96
|
return container.getImplementation(identifier);
|
|
106
97
|
}
|
|
107
98
|
}
|
|
108
|
-
/**
|
|
109
|
-
* Registration-capable parser exposed by the service context during module initialization.
|
|
110
|
-
*/
|
|
111
|
-
class ServiceContextSyncConfigParserImpl extends storage.SqlSyncConfigParser {
|
|
112
|
-
isStorageStarted;
|
|
113
|
-
constructor(isStorageStarted) {
|
|
114
|
-
super();
|
|
115
|
-
this.isStorageStarted = isStorageStarted;
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Registers an extension while preserving one parser definition for the service lifetime.
|
|
119
|
-
*/
|
|
120
|
-
registerParser(extension) {
|
|
121
|
-
if (this.isStorageStarted()) {
|
|
122
|
-
throw new Error('A sync config parser extension cannot be registered after the storage engine has started.');
|
|
123
|
-
}
|
|
124
|
-
super.registerParser(extension);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
99
|
//# sourceMappingURL=ServiceContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceContext.js","sourceRoot":"","sources":["../../src/system/ServiceContext.ts"],"names":[],"mappings":"AAAA,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json
CHANGED
|
@@ -4,18 +4,18 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.0.0-dev-
|
|
7
|
+
"version": "0.0.0-dev-20261007110800",
|
|
8
8
|
"license": "FSL-1.1-ALv2",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"exports": "./dist/index.js",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@js-sdsl/ordered-set": "^4.4.2",
|
|
13
13
|
"@opentelemetry/api": "^1.9.0",
|
|
14
|
-
"@opentelemetry/core": "^2.0
|
|
15
|
-
"@opentelemetry/exporter-metrics-otlp-http": "^0.
|
|
16
|
-
"@opentelemetry/exporter-prometheus": "^0.
|
|
17
|
-
"@opentelemetry/resources": "^2.0
|
|
18
|
-
"@opentelemetry/sdk-metrics": "^2.0
|
|
14
|
+
"@opentelemetry/core": "^2.8.0",
|
|
15
|
+
"@opentelemetry/exporter-metrics-otlp-http": "^0.219.0",
|
|
16
|
+
"@opentelemetry/exporter-prometheus": "^0.219.0",
|
|
17
|
+
"@opentelemetry/resources": "^2.8.0",
|
|
18
|
+
"@opentelemetry/sdk-metrics": "^2.8.0",
|
|
19
19
|
"async": "^3.2.4",
|
|
20
20
|
"async-mutex": "^0.5.0",
|
|
21
21
|
"bson": "^6.10.4",
|
|
@@ -33,17 +33,17 @@
|
|
|
33
33
|
"uuid": "^14.0.0",
|
|
34
34
|
"winston": "^3.13.0",
|
|
35
35
|
"yaml": "^2.8.3",
|
|
36
|
-
"@powersync/lib-services-framework": "0.0.0-dev-
|
|
36
|
+
"@powersync/lib-services-framework": "0.0.0-dev-20261007110800",
|
|
37
37
|
"@powersync/service-jsonbig": "0.17.13",
|
|
38
|
-
"@powersync/service-rsocket-router": "0.0.0-dev-
|
|
39
|
-
"@powersync/service-sync-rules": "0.0.0-dev-
|
|
40
|
-
"@powersync/service-types": "0.
|
|
38
|
+
"@powersync/service-rsocket-router": "0.0.0-dev-20261007110800",
|
|
39
|
+
"@powersync/service-sync-rules": "0.0.0-dev-20261007110800",
|
|
40
|
+
"@powersync/service-types": "0.0.0-dev-20261007110800"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/async": "^3.2.24",
|
|
44
44
|
"@types/lodash": "^4.17.5",
|
|
45
45
|
"@types/negotiator": "^0.6.4",
|
|
46
|
-
"fastify": "^5.
|
|
46
|
+
"fastify": "^5.12.5",
|
|
47
47
|
"fastify-plugin": "^5.0.1"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
package/src/api/RouteAPI.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SyncConfig, TablePattern } from '@powersync/service-sync-rules';
|
|
2
2
|
import * as types from '@powersync/service-types';
|
|
3
|
-
import { ParseSyncConfigOptions
|
|
3
|
+
import type { ParseSyncConfigOptions } from '../storage/PersistedSyncConfigContent.js';
|
|
4
|
+
import { SyncRulesBucketStorage } from '../storage/storage-index.js';
|
|
4
5
|
|
|
5
6
|
export interface PatternResult {
|
|
6
7
|
schema: string;
|
|
@@ -40,6 +41,13 @@ export interface RouteAPI {
|
|
|
40
41
|
*/
|
|
41
42
|
getConnectionStatus(): Promise<types.ConnectionStatusV2>;
|
|
42
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Checks whether the source supports the capabilities required by this sync config.
|
|
46
|
+
* Must not modify the source. Return advisory warnings and fatal validation diagnostics.
|
|
47
|
+
* An empty array means no issues; throw only for unexpected failures.
|
|
48
|
+
*/
|
|
49
|
+
validateSourceCapabilities?(syncConfig: SyncConfig): Promise<types.ValidationDiagnostic[]>;
|
|
50
|
+
|
|
43
51
|
/**
|
|
44
52
|
* Expand sync config table patterns into table metadata from the source connection.
|
|
45
53
|
*
|
package/src/api/api-index.ts
CHANGED