@powersync/service-core 0.0.0-dev-20261005120023 → 0.0.0-dev-20261015071128

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 (74) hide show
  1. package/CHANGELOG.md +23 -12
  2. package/dist/api/RouteAPI.d.ts +8 -1
  3. package/dist/api/api-index.d.ts +1 -0
  4. package/dist/api/api-index.js +1 -0
  5. package/dist/api/api-index.js.map +1 -1
  6. package/dist/api/diagnostics.js +28 -14
  7. package/dist/api/diagnostics.js.map +1 -1
  8. package/dist/api/source-capabilities.d.ts +7 -0
  9. package/dist/api/source-capabilities.js +23 -0
  10. package/dist/api/source-capabilities.js.map +1 -0
  11. package/dist/replication/AbstractReplicationJob.d.ts +4 -6
  12. package/dist/replication/AbstractReplicationJob.js.map +1 -1
  13. package/dist/replication/AbstractReplicator.d.ts +11 -0
  14. package/dist/replication/AbstractReplicator.js +24 -2
  15. package/dist/replication/AbstractReplicator.js.map +1 -1
  16. package/dist/replication/ReplicationModule.js +13 -2
  17. package/dist/replication/ReplicationModule.js.map +1 -1
  18. package/dist/routes/configure-fastify.d.ts +24 -24
  19. package/dist/routes/endpoints/admin.d.ts +48 -48
  20. package/dist/routes/endpoints/admin.js +8 -8
  21. package/dist/routes/endpoints/admin.js.map +1 -1
  22. package/dist/routes/endpoints/sync-rules.js +41 -14
  23. package/dist/routes/endpoints/sync-rules.js.map +1 -1
  24. package/dist/storage/BucketStorageFactory.d.ts +11 -13
  25. package/dist/storage/BucketStorageFactory.js +21 -11
  26. package/dist/storage/BucketStorageFactory.js.map +1 -1
  27. package/dist/storage/PersistedReplicationStream.d.ts +1 -2
  28. package/dist/storage/PersistedReplicationStream.js.map +1 -1
  29. package/dist/storage/PersistedSyncConfigContent.d.ts +6 -5
  30. package/dist/storage/PersistedSyncConfigContent.js +5 -12
  31. package/dist/storage/PersistedSyncConfigContent.js.map +1 -1
  32. package/dist/storage/StorageEngine.d.ts +0 -4
  33. package/dist/storage/StorageEngine.js +1 -7
  34. package/dist/storage/StorageEngine.js.map +1 -1
  35. package/dist/storage/StorageProvider.d.ts +1 -6
  36. package/dist/storage/SyncRulesBucketStorage.d.ts +1 -1
  37. package/dist/storage/storage-index.d.ts +0 -1
  38. package/dist/storage/storage-index.js +0 -1
  39. package/dist/storage/storage-index.js.map +1 -1
  40. package/dist/system/ServiceContext.d.ts +0 -20
  41. package/dist/system/ServiceContext.js +1 -29
  42. package/dist/system/ServiceContext.js.map +1 -1
  43. package/package.json +11 -11
  44. package/src/api/RouteAPI.ts +9 -1
  45. package/src/api/api-index.ts +1 -0
  46. package/src/api/diagnostics.ts +24 -12
  47. package/src/api/source-capabilities.ts +24 -0
  48. package/src/replication/AbstractReplicationJob.ts +2 -4
  49. package/src/replication/AbstractReplicator.ts +32 -2
  50. package/src/replication/ReplicationModule.ts +12 -2
  51. package/src/routes/endpoints/admin.ts +14 -6
  52. package/src/routes/endpoints/sync-rules.ts +42 -16
  53. package/src/storage/BucketStorageFactory.ts +21 -19
  54. package/src/storage/PersistedReplicationStream.ts +1 -2
  55. package/src/storage/PersistedSyncConfigContent.ts +11 -16
  56. package/src/storage/StorageEngine.ts +1 -10
  57. package/src/storage/StorageProvider.ts +1 -6
  58. package/src/storage/SyncRulesBucketStorage.ts +1 -1
  59. package/src/storage/storage-index.ts +0 -1
  60. package/src/system/ServiceContext.ts +1 -47
  61. package/test/src/AbstractReplicator.test.ts +109 -23
  62. package/test/src/PersistedSyncConfigContent.test.ts +1 -3
  63. package/test/src/diagnostics.test.ts +104 -0
  64. package/test/src/routes/admin.test.ts +221 -12
  65. package/test/src/routes/mocks.ts +0 -2
  66. package/test/src/routes/sync-rules.test.ts +124 -0
  67. package/test/src/source_table_config.test.ts +104 -0
  68. package/test/src/storage/BucketStorageFactory.test.ts +46 -0
  69. package/tsconfig.tsbuildinfo +1 -1
  70. package/dist/storage/SyncConfigParser.d.ts +0 -44
  71. package/dist/storage/SyncConfigParser.js +0 -73
  72. package/dist/storage/SyncConfigParser.js.map +0 -1
  73. package/src/storage/SyncConfigParser.ts +0 -124
  74. package/test/src/SyncConfigParser.test.ts +0 -309
@@ -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/ServiceCont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AAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAC5D,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,SAAS,CAAC,iBAAiB,CAAC,SAAS,CAAC,uBAAuB,CAAC,iBAAiB,CAAC,CAAC;IAC1F,CAAC;IAED;;;OAGG;IACH,QAAQ,CAAI,UAAgC,EAAE,cAAiB;QAC7D,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;IACjD,CAAC;IAED;;OAEG;IACH,GAAG,CAAI,UAAgC;QACrC,OAAO,SAAS,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;IACjD,CAAC;CACF"}
package/package.json CHANGED
@@ -4,18 +4,18 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.0.0-dev-20261005120023",
7
+ "version": "0.0.0-dev-20261015071128",
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.1",
15
- "@opentelemetry/exporter-metrics-otlp-http": "^0.203.0",
16
- "@opentelemetry/exporter-prometheus": "^0.203.0",
17
- "@opentelemetry/resources": "^2.0.1",
18
- "@opentelemetry/sdk-metrics": "^2.0.1",
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-20261005120023",
36
+ "@powersync/lib-services-framework": "0.0.0-dev-20261015071128",
37
37
  "@powersync/service-jsonbig": "0.17.13",
38
- "@powersync/service-rsocket-router": "0.0.0-dev-20261005120023",
39
- "@powersync/service-sync-rules": "0.0.0-dev-20261005120023",
40
- "@powersync/service-types": "0.19.0"
38
+ "@powersync/service-rsocket-router": "0.0.0-dev-20261015071128",
39
+ "@powersync/service-sync-rules": "0.0.0-dev-20261015071128",
40
+ "@powersync/service-types": "0.0.0-dev-20261015071128"
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.8.5",
46
+ "fastify": "^5.12.5",
47
47
  "fastify-plugin": "^5.0.1"
48
48
  },
49
49
  "scripts": {
@@ -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, SyncRulesBucketStorage } from '../storage/storage-index.js';
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
  *
@@ -2,3 +2,4 @@ export * from './api-metrics.js';
2
2
  export * from './diagnostics.js';
3
3
  export * from './RouteAPI.js';
4
4
  export * from './schema.js';
5
+ export * from './source-capabilities.js';
@@ -85,20 +85,32 @@ export async function getSyncRulesStatus(
85
85
  let replication_lag_bytes: number | undefined = undefined;
86
86
  let slot_wal_budget: SlotWalBudgetInfo | undefined = undefined;
87
87
 
88
+ const validationErrors: ReplicationError[] = [];
88
89
  let tables_flat: TableInfo[] = [];
89
90
 
90
91
  if (check_connection) {
91
- const source_table_patterns = rules.getSourceTables();
92
- const resolved_tables = await apiHandler.getDebugTablesInfo(source_table_patterns, rules);
93
- tables_flat = resolved_tables.flatMap((info) => {
94
- if (info.table) {
95
- return [info.table];
96
- } else if (info.tables) {
97
- return info.tables;
98
- } else {
99
- return [];
100
- }
101
- });
92
+ try {
93
+ validationErrors.push(...((await apiHandler.validateSourceCapabilities?.(rules)) ?? []));
94
+ } catch (e) {
95
+ validationErrors.push({ level: 'fatal', message: e.message, ts: now });
96
+ }
97
+ // Table inspection is independent of source capability checks. Preserve both failures
98
+ // and continue collecting diagnostics that do not depend on table metadata.
99
+ try {
100
+ const source_table_patterns = rules.getSourceTables();
101
+ const resolved_tables = await apiHandler.getDebugTablesInfo(source_table_patterns, rules);
102
+ tables_flat = resolved_tables.flatMap((info) => {
103
+ if (info.table) {
104
+ return [info.table];
105
+ } else if (info.tables) {
106
+ return info.tables;
107
+ } else {
108
+ return [];
109
+ }
110
+ });
111
+ } catch (e) {
112
+ validationErrors.push({ level: 'fatal', message: e.message, ts: now });
113
+ }
102
114
 
103
115
  if (systemStorage) {
104
116
  try {
@@ -155,7 +167,7 @@ export async function getSyncRulesStatus(
155
167
  });
156
168
  }
157
169
 
158
- const errors = tables_flat.flatMap((info) => info.errors);
170
+ const errors = [...validationErrors, ...tables_flat.flatMap((info) => info.errors)];
159
171
  const statusSource = await syncConfig.getSyncConfigStatus();
160
172
 
161
173
  if (statusSource?.last_fatal_error) {
@@ -0,0 +1,24 @@
1
+ import { ErrorCode, ServiceError } from '@powersync/lib-services-framework';
2
+ import type { SyncConfig } from '@powersync/service-sync-rules';
3
+ import type { RouteAPI } from './RouteAPI.js';
4
+
5
+ /**
6
+ * Blocks deployment and reprocessing on fatal source diagnostics; warnings remain advisory.
7
+ * Capability failures use the same typed 422 error for deployment and reprocessing.
8
+ */
9
+ export async function assertSourceCapabilities(api: RouteAPI, config: SyncConfig): Promise<void> {
10
+ try {
11
+ const diagnostics = (await api.validateSourceCapabilities?.(config)) ?? [];
12
+ const errors = diagnostics.filter((diagnostic) => diagnostic.level === 'fatal');
13
+ if (errors.length > 0) {
14
+ throw new Error(errors.map((error) => error.message).join('\n'));
15
+ }
16
+ } catch (error) {
17
+ throw new ServiceError({
18
+ status: 422,
19
+ code: ErrorCode.PSYNC_R0001,
20
+ description: 'Source capability validation failed',
21
+ details: error.message
22
+ });
23
+ }
24
+ }
@@ -1,14 +1,12 @@
1
1
  import { container, logger } from '@powersync/lib-services-framework';
2
2
  import winston from 'winston';
3
3
  import { MetricsEngine } from '../metrics/MetricsEngine.js';
4
- import * as storage from '../storage/storage-index.js';
4
+ import type { CreateJobOptions } from './AbstractReplicator.js';
5
5
  import { ErrorRateLimiter } from './ErrorRateLimiter.js';
6
6
 
7
- export interface AbstractReplicationJobOptions {
7
+ export interface AbstractReplicationJobOptions extends CreateJobOptions {
8
8
  id: string;
9
- storage: storage.SyncRulesBucketStorage;
10
9
  metrics: MetricsEngine;
11
- lock: storage.ReplicationLock;
12
10
  rateLimiter: ErrorRateLimiter;
13
11
  }
14
12
 
@@ -1,4 +1,5 @@
1
1
  import { container, ErrorCode, logger, ReplicationAbortedError } from '@powersync/lib-services-framework';
2
+ import { DEFAULT_TAG, SqlSyncRules, type SyncConfig } from '@powersync/service-sync-rules';
2
3
  import { ReplicationMetric } from '@powersync/service-types';
3
4
  import { hrtime } from 'node:process';
4
5
  import { setTimeout as sleep } from 'node:timers/promises';
@@ -7,6 +8,7 @@ import { MetricsEngine } from '../metrics/MetricsEngine.js';
7
8
  import * as storage from '../storage/storage-index.js';
8
9
  import { StorageEngine } from '../storage/storage-index.js';
9
10
  import { SyncRulesProvider } from '../util/config/sync-rules/sync-rules-provider.js';
11
+ import type { ResolvedPowerSyncConfig } from '../util/config/types.js';
10
12
  import { AbstractReplicationJob } from './AbstractReplicationJob.js';
11
13
  import { ErrorRateLimiter } from './ErrorRateLimiter.js';
12
14
  import { ConnectionTestResult } from './ReplicationModule.js';
@@ -30,6 +32,10 @@ export interface AbstractReplicatorOptions {
30
32
  storageEngine: StorageEngine;
31
33
  metricsEngine: MetricsEngine;
32
34
  syncRuleProvider: SyncRulesProvider;
35
+ /**
36
+ * Source connection metadata from the service config, used when parsing filesystem-loaded sync configs.
37
+ */
38
+ configuration?: Pick<ResolvedPowerSyncConfig, 'connections'>;
33
39
  /**
34
40
  * This limits the effect of retries when there is a persistent issue.
35
41
  */
@@ -73,6 +79,8 @@ export abstract class AbstractReplicator<T extends AbstractReplicationJob = Abst
73
79
 
74
80
  private abortController: AbortController | undefined;
75
81
 
82
+ private assertSourceCapabilities: ((config: SyncConfig) => Promise<void>) | undefined;
83
+
76
84
  protected constructor(private options: AbstractReplicatorOptions) {
77
85
  this.logger = logger.child({ name: `Replicator:${options.id}` });
78
86
  const heartbeatIntervalSeconds = options.heartbeatIntervalSeconds ?? DEFAULT_HEARTBEAT_INTERVAL_SECONDS;
@@ -124,6 +132,13 @@ export abstract class AbstractReplicator<T extends AbstractReplicationJob = Abst
124
132
  return this.abortController?.signal.aborted;
125
133
  }
126
134
 
135
+ /**
136
+ * Register an assertion that blocks unsupported file-loaded sync configs before replication.
137
+ */
138
+ public registerSourceCapabilitiesAssertion(assertion: (config: SyncConfig) => Promise<void>): void {
139
+ this.assertSourceCapabilities = assertion;
140
+ }
141
+
127
142
  public async start(): Promise<void> {
128
143
  this.abortController = new AbortController();
129
144
  this.runLoop().catch((e) => {
@@ -172,11 +187,27 @@ export abstract class AbstractReplicator<T extends AbstractReplicationJob = Abst
172
187
  // versions before that check was added, so we keep the lock for now - for where te service version and sync config is updated at
173
188
  // the same time.
174
189
 
175
- const parsed = this.storage.syncConfigParser.parseContent(loadedSyncConfig, {
190
+ const parsed = SqlSyncRules.fromYaml(loadedSyncConfig, {
176
191
  schema: undefined,
177
192
  defaultSchema: this.defaultSchema,
193
+ connections:
194
+ this.options.configuration?.connections &&
195
+ Object.fromEntries(
196
+ this.options.configuration.connections.map((connection) => [
197
+ connection.tag ?? DEFAULT_TAG,
198
+ { type: connection.type }
199
+ ])
200
+ ),
178
201
  throwOnError: this.syncRuleProvider.exitOnError
179
202
  });
203
+ storage.logSyncConfigErrors(parsed, this.logger);
204
+ try {
205
+ await this.assertSourceCapabilities?.(parsed.config);
206
+ } catch (error) {
207
+ if (this.syncRuleProvider.exitOnError) throw error;
208
+ // Persist the config for diagnostics; the job-start check will prevent unsafe replication.
209
+ this.logger.error('Source capability validation failed for the sync config', error);
210
+ }
180
211
  const { lock } = await this.storage.configureSyncRules(
181
212
  storage.updateSyncRulesFromConfig(parsed, {
182
213
  lock: true,
@@ -188,7 +219,6 @@ export abstract class AbstractReplicator<T extends AbstractReplicationJob = Abst
188
219
  }
189
220
  } catch (e) {
190
221
  // Log and re-raise to exit.
191
- // Should only reach this due to validation errors if exit_on_error is true.
192
222
  this.logger.error(`Failed to update sync config`, e);
193
223
  throw e;
194
224
  }
@@ -90,8 +90,18 @@ export abstract class ReplicationModule<TConfig extends types.configFile.DataSou
90
90
  // If decoding fails, this will raise a hard error, and stop the service.
91
91
  this.decodeConfig(baseMatchingConfig);
92
92
 
93
- context.replicationEngine?.register(this.createReplicator(context));
94
- context.routerEngine?.registerAPI(this.createRouteAPIAdapter());
93
+ const sourceAPI = this.createRouteAPIAdapter();
94
+ // The router exists even in replication-only mode and owns adapter shutdown through the service lifecycle.
95
+ context.routerEngine.registerAPI(sourceAPI);
96
+ if (context.replicationEngine) {
97
+ const replicator = this.createReplicator(context);
98
+ if (sourceAPI.validateSourceCapabilities != null) {
99
+ // KLUDGE: Reuse the adapter validation for filesystem-loaded configs.
100
+ // A shared validation interface could replace this registration through the route adapter in the future.
101
+ replicator.registerSourceCapabilitiesAssertion((config) => api.assertSourceCapabilities(sourceAPI, config));
102
+ }
103
+ context.replicationEngine.register(replicator);
104
+ }
95
105
  }
96
106
 
97
107
  protected decodeConfig(config: TConfig): void {
@@ -1,7 +1,13 @@
1
1
  import * as sqlite from 'node:sqlite';
2
2
 
3
3
  import { ErrorCode, errors, router, schema } from '@powersync/lib-services-framework';
4
- import { HydratedSyncConfig, nodeSqlite, SourceSchema, StaticSchema } from '@powersync/service-sync-rules';
4
+ import {
5
+ HydratedSyncConfig,
6
+ nodeSqlite,
7
+ SourceSchema,
8
+ SqlSyncRules,
9
+ StaticSchema
10
+ } from '@powersync/service-sync-rules';
5
11
  import { internal_routes } from '@powersync/service-types';
6
12
 
7
13
  import { DEFAULT_HYDRATION_STATE } from '@powersync/service-sync-rules';
@@ -155,13 +161,16 @@ export const reprocess = routeDefinition({
155
161
  // 1. This always re-parses the source YAML. If there are changes to the Sync Streams compiler, that can affect the sync plan.
156
162
  // 2. If the source does not set the storage version, this will update it do the current version.
157
163
  // We can consider tweaking this behavior in the future.
158
- const parsed = service_context.syncConfigParser.parseContent(active.content.sync_rules_content, {
164
+ const parsed = SqlSyncRules.fromYaml(active.content.sync_rules_content, {
159
165
  ...apiHandler.getParseSyncRulesOptions(),
160
166
  schema: undefined,
161
167
  // This sync config already passed validation. But if the config is not valid anymore due
162
168
  // to a service change, we do want to report the error here.
163
169
  throwOnError: true
164
170
  });
171
+ storage.logSyncConfigErrors(parsed);
172
+ await api.assertSourceCapabilities(apiHandler, parsed.config);
173
+
165
174
  const new_rules = await activeBucketStorage.updateSyncRules(
166
175
  storage.updateSyncRulesFromConfig(parsed, {
167
176
  version_label: active.content.version_label,
@@ -186,15 +195,14 @@ export const reprocess = routeDefinition({
186
195
 
187
196
  class FakeSyncRulesContentForValidation extends storage.PersistedSyncConfigContent {
188
197
  constructor(
189
- private readonly validationParser: storage.SyncConfigParser,
190
198
  private readonly schema: SourceSchema,
191
199
  data: storage.PersistedSyncConfigContentData
192
200
  ) {
193
- super(data, validationParser);
201
+ super(data);
194
202
  }
195
203
 
196
204
  parsed(options: storage.ParseSyncConfigOptions): storage.ParsedSyncConfigSet {
197
- const syncConfig = this.validationParser.parseContent(this.sync_rules_content, {
205
+ const syncConfig = SqlSyncRules.fromYaml(this.sync_rules_content, {
198
206
  ...options,
199
207
  schema: this.schema
200
208
  });
@@ -235,7 +243,7 @@ export const validate = routeDefinition({
235
243
  const schemaData = await api.getConnectionsSchema(apiHandler);
236
244
  const schema = new StaticSchema(schemaData.connections);
237
245
 
238
- const sync_rules = new FakeSyncRulesContentForValidation(service_context.syncConfigParser, schema, {
246
+ const sync_rules = new FakeSyncRulesContentForValidation(schema, {
239
247
  // Dummy values
240
248
  replicationStreamId: 0,
241
249
  replicationStreamName: '',
@@ -1,11 +1,11 @@
1
1
  import { ErrorCode, errors, router, schema } from '@powersync/lib-services-framework';
2
- import { SyncConfigWithErrors, SyncRulesErrors } from '@powersync/service-sync-rules';
2
+ import { SqlSyncRules, SyncConfigWithErrors, SyncRulesErrors } from '@powersync/service-sync-rules';
3
3
  import type { FastifyPluginAsync } from 'fastify';
4
4
  import * as t from 'ts-codec';
5
+ import { assertSourceCapabilities } from '../../api/source-capabilities.js';
5
6
 
6
- import { RouteAPI } from '../../api/RouteAPI.js';
7
- import { updateSyncRulesFromConfig } from '../../storage/BucketStorageFactory.js';
8
- import { SyncConfigParser } from '../../storage/SyncConfigParser.js';
7
+ import { PatternResult, RouteAPI } from '../../api/RouteAPI.js';
8
+ import { logSyncConfigErrors, updateSyncRulesFromConfig } from '../../storage/BucketStorageFactory.js';
9
9
  import { authApi } from '../auth.js';
10
10
  import { routeDefinition } from '../router.js';
11
11
 
@@ -56,8 +56,9 @@ export const deploySyncRules = routeDefinition({
56
56
  let syncConfig: SyncConfigWithErrors;
57
57
 
58
58
  try {
59
+ // First ensure the SyncConfig parses correctly
59
60
  const apiHandler = service_context.routerEngine.getAPI();
60
- syncConfig = service_context.syncConfigParser.parseContent(content, {
61
+ syncConfig = SqlSyncRules.fromYaml(content, {
61
62
  ...apiHandler.getParseSyncRulesOptions(),
62
63
  // We don't do any schema-level validation at this point
63
64
  schema: undefined
@@ -71,6 +72,10 @@ export const deploySyncRules = routeDefinition({
71
72
  });
72
73
  }
73
74
 
75
+ logSyncConfigErrors(syncConfig);
76
+ // Validate if the current sources support the configuration specified in the sync config
77
+ await assertSourceCapabilities(service_context.routerEngine.getAPI(), syncConfig.config);
78
+
74
79
  const sync_rules = await storageEngine.activeBucketStorage.updateSyncRules(updateSyncRulesFromConfig(syncConfig));
75
80
 
76
81
  return {
@@ -95,7 +100,7 @@ export const validateSyncRules = routeDefinition({
95
100
  const { service_context } = payload.context;
96
101
  const apiHandler = service_context.routerEngine.getAPI();
97
102
 
98
- const info = await debugSyncRules(apiHandler, content, service_context.syncConfigParser);
103
+ const info = await debugSyncRules(apiHandler, content);
99
104
 
100
105
  return replyPrettyJson(info);
101
106
  }
@@ -122,12 +127,10 @@ export const currentSyncRules = routeDefinition({
122
127
 
123
128
  const sync_rules = active.content;
124
129
  const apiHandler = service_context.routerEngine.getAPI();
125
- const info = await debugSyncRules(apiHandler, sync_rules.sync_rules_content, service_context.syncConfigParser);
130
+ const info = await debugSyncRules(apiHandler, sync_rules.sync_rules_content);
126
131
  const next = await activeBucketStorage.getDeployingSyncConfig();
127
132
 
128
- const next_info = next
129
- ? await debugSyncRules(apiHandler, next.content.sync_rules_content, service_context.syncConfigParser)
130
- : null;
133
+ const next_info = next ? await debugSyncRules(apiHandler, next.content.sync_rules_content) : null;
131
134
 
132
135
  const response = {
133
136
  current: {
@@ -179,13 +182,16 @@ export const reprocessSyncRules = routeDefinition({
179
182
  }
180
183
 
181
184
  const sync_rules = active.content;
182
- const parsed = payload.context.service_context.syncConfigParser.parseContent(sync_rules.sync_rules_content, {
185
+ const parsed = SqlSyncRules.fromYaml(sync_rules.sync_rules_content, {
183
186
  ...payload.context.service_context.routerEngine.getAPI().getParseSyncRulesOptions(),
184
187
  schema: undefined,
185
188
  // This sync config already passed validation. But if the rules are not valid anymore due
186
189
  // to a service change, we do want to report the error here.
187
190
  throwOnError: true
188
191
  });
192
+ logSyncConfigErrors(parsed);
193
+ await assertSourceCapabilities(payload.context.service_context.routerEngine.getAPI(), parsed.config);
194
+
189
195
  const new_rules = await activeBucketStorage.updateSyncRules(
190
196
  updateSyncRulesFromConfig(parsed, {
191
197
  version_label: sync_rules.version_label,
@@ -208,18 +214,38 @@ function replyPrettyJson(payload: any) {
208
214
  });
209
215
  }
210
216
 
211
- async function debugSyncRules(apiHandler: RouteAPI, sync_rules: string, syncConfigParser: SyncConfigParser) {
217
+ async function debugSyncRules(apiHandler: RouteAPI, sync_rules: string) {
212
218
  try {
213
- const rules = syncConfigParser.parseContent(sync_rules, {
219
+ const rules = SqlSyncRules.fromYaml(sync_rules, {
214
220
  ...apiHandler.getParseSyncRulesOptions(),
215
221
  // No schema-based validation at this point
216
222
  schema: undefined
217
223
  });
218
- const source_table_patterns = rules.config.getSourceTables();
219
- const resolved_tables = await apiHandler.getDebugTablesInfo(source_table_patterns, rules.config);
224
+ const errors: string[] = [];
225
+ const warnings = rules.errors.filter((error) => error.type === 'warning').map((error) => error.message);
226
+ const recordError = (error: any) => {
227
+ errors.push(...(error instanceof SyncRulesErrors ? error.errors.map((e) => e.message) : [error.message]));
228
+ };
229
+ try {
230
+ const diagnostics = (await apiHandler.validateSourceCapabilities?.(rules.config)) ?? [];
231
+ for (const diagnostic of diagnostics) {
232
+ (diagnostic.level === 'fatal' ? errors : warnings).push(diagnostic.message);
233
+ }
234
+ } catch (e) {
235
+ recordError(e);
236
+ }
237
+ let resolved_tables: PatternResult[] = [];
238
+ try {
239
+ const source_table_patterns = rules.config.getSourceTables();
240
+ resolved_tables = await apiHandler.getDebugTablesInfo(source_table_patterns, rules.config);
241
+ } catch (e) {
242
+ recordError(e);
243
+ }
220
244
 
221
245
  return {
222
- valid: true,
246
+ valid: errors.length == 0,
247
+ ...(warnings.length > 0 ? { warnings } : {}),
248
+ ...(errors.length > 0 ? { errors } : {}),
223
249
  bucket_definitions: rules.config.debugRepresentation(),
224
250
  source_tables: resolved_tables,
225
251
  data_tables: rules.config.debugGetOutputTables()
@@ -4,6 +4,7 @@ import {
4
4
  SerializedSyncPlan as RawSerializedSyncPlan,
5
5
  SerializedCompatibilityContext,
6
6
  serializeSyncPlan,
7
+ SqlSyncRules,
7
8
  SyncConfigWithErrors
8
9
  } from '@powersync/service-sync-rules';
9
10
  import { ReplicationError } from '@powersync/service-types';
@@ -13,16 +14,8 @@ import { PersistedSyncConfigContent } from './PersistedSyncConfigContent.js';
13
14
  import { ReplicationEventPayload } from './ReplicationEventPayload.js';
14
15
  import { ReplicationLock } from './ReplicationLock.js';
15
16
  import { ReportStorage } from './ReportStorage.js';
16
- import { SqlSyncConfigParser, SyncConfigParser } from './SyncConfigParser.js';
17
17
  import { SyncRulesBucketStorage } from './SyncRulesBucketStorage.js';
18
18
 
19
- export interface BucketStorageFactoryOptions {
20
- /**
21
- * Service-wide parser assembled before storage startup.
22
- */
23
- syncConfigParser: SyncConfigParser;
24
- }
25
-
26
19
  /**
27
20
  * Represents a configured storage provider.
28
21
  *
@@ -35,16 +28,6 @@ export abstract class BucketStorageFactory
35
28
  extends BaseObserver<BucketStorageFactoryListener>
36
29
  implements AsyncDisposable
37
30
  {
38
- readonly syncConfigParser: SyncConfigParser;
39
-
40
- /**
41
- * Creates a storage factory using the service-wide parser assembled before storage startup.
42
- */
43
- constructor(options: BucketStorageFactoryOptions) {
44
- super();
45
- this.syncConfigParser = options.syncConfigParser;
46
- }
47
-
48
31
  /**
49
32
  * Update sync config from configuration, if changed.
50
33
  */
@@ -245,7 +228,7 @@ export function updateSyncRulesFromYaml(
245
228
  options?: Omit<UpdateSyncRulesOptions, 'config'> & { validate?: boolean }
246
229
  ): UpdateSyncRulesOptions {
247
230
  const { validate, ...updateOptions } = options ?? {};
248
- const config = new SqlSyncConfigParser().parseContent(content, {
231
+ const config = SqlSyncRules.fromYaml(content, {
249
232
  // No schema-based validation at this point
250
233
  schema: undefined,
251
234
  defaultSchema: options?.defaultSchema ?? 'not_applicable', // Not needed for validation
@@ -279,6 +262,25 @@ export function updateSyncRulesFromConfig(
279
262
  return { config: { yaml: config.content, plan, parsed }, ...options };
280
263
  }
281
264
 
265
+ /**
266
+ * Logs the errors and warnings of a parsed sync config
267
+ *
268
+ * Call this where a sync config is loaded or deployed, so that operators see these in the service logs and not only
269
+ * in the diagnostics and validate API responses.
270
+ *
271
+ * Fatal errors usually throw during parsing before this is reached. They can reach this when the sync config is parsed
272
+ * without validation, such as at startup with `exit_on_error: false`.
273
+ */
274
+ export function logSyncConfigErrors(parsed: SyncConfigWithErrors, log: typeof logger = logger) {
275
+ for (const error of parsed.errors) {
276
+ if (error.type == 'warning') {
277
+ log.warn(`Sync config warning: ${error.message}`);
278
+ } else {
279
+ log.error(`Sync config error: ${error.message}`);
280
+ }
281
+ }
282
+ }
283
+
282
284
  export interface GetIntanceOptions {
283
285
  /**
284
286
  * The job lease, including a lease acquired during initial configuration.
@@ -2,10 +2,9 @@ import { logger as defaultLogger, ErrorCode, ServiceError } from '@powersync/lib
2
2
  import { Logger } from 'winston';
3
3
  import { SyncRuleState } from './BucketStorage.js';
4
4
  import type { ParsedSyncConfigSet } from './ParsedSyncConfigSet.js';
5
- import type { PersistedSyncConfigContent } from './PersistedSyncConfigContent.js';
5
+ import type { ParseSyncConfigOptions, PersistedSyncConfigContent } from './PersistedSyncConfigContent.js';
6
6
  import { ReplicationLock } from './ReplicationLock.js';
7
7
  import { STORAGE_VERSION_CONFIG, StorageVersionConfig } from './StorageVersionConfig.js';
8
- import type { ParseSyncConfigOptions } from './SyncConfigParser.js';
9
8
 
10
9
  export abstract class PersistedReplicationStream implements PersistedReplicationStreamData {
11
10
  readonly replicationStreamId: number;