@powersync/service-core 1.20.4 → 1.20.5

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 (151) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/api/RouteAPI.d.ts +14 -0
  3. package/dist/api/api-index.d.ts +1 -1
  4. package/dist/api/api-index.js +1 -1
  5. package/dist/api/api-index.js.map +1 -1
  6. package/dist/api/api-metrics.js.map +1 -1
  7. package/dist/api/diagnostics.js +16 -14
  8. package/dist/api/diagnostics.js.map +1 -1
  9. package/dist/auth/CachedKeyCollector.js +1 -1
  10. package/dist/auth/CachedKeyCollector.js.map +1 -1
  11. package/dist/auth/CompoundKeyCollector.js.map +1 -1
  12. package/dist/auth/KeyStore.js.map +1 -1
  13. package/dist/auth/RemoteJWKSCollector.js.map +1 -1
  14. package/dist/auth/StaticKeyCollector.d.ts +1 -1
  15. package/dist/auth/StaticKeyCollector.js.map +1 -1
  16. package/dist/auth/StaticSupabaseKeyCollector.d.ts +1 -1
  17. package/dist/auth/StaticSupabaseKeyCollector.js.map +1 -1
  18. package/dist/entry/commands/teardown-action.js +1 -1
  19. package/dist/entry/commands/teardown-action.js.map +1 -1
  20. package/dist/entry/entry-index.d.ts +1 -1
  21. package/dist/entry/entry-index.js +1 -1
  22. package/dist/entry/entry-index.js.map +1 -1
  23. package/dist/events/EventsEngine.js +1 -1
  24. package/dist/events/EventsEngine.js.map +1 -1
  25. package/dist/metrics/MetricsEngine.d.ts +1 -1
  26. package/dist/metrics/metrics-index.d.ts +3 -3
  27. package/dist/metrics/metrics-index.js +3 -3
  28. package/dist/metrics/metrics-index.js.map +1 -1
  29. package/dist/metrics/open-telemetry/util.js +1 -1
  30. package/dist/metrics/open-telemetry/util.js.map +1 -1
  31. package/dist/metrics/register-metrics.js +2 -2
  32. package/dist/metrics/register-metrics.js.map +1 -1
  33. package/dist/modules/AbstractModule.d.ts +1 -1
  34. package/dist/modules/AbstractModule.js.map +1 -1
  35. package/dist/modules/modules-index.d.ts +1 -1
  36. package/dist/modules/modules-index.js +1 -1
  37. package/dist/modules/modules-index.js.map +1 -1
  38. package/dist/replication/AbstractReplicationJob.d.ts +1 -1
  39. package/dist/replication/replication-index.d.ts +3 -3
  40. package/dist/replication/replication-index.js +3 -3
  41. package/dist/replication/replication-index.js.map +1 -1
  42. package/dist/replication/replication-metrics.js.map +1 -1
  43. package/dist/routes/configure-fastify.d.ts +59 -32
  44. package/dist/routes/endpoints/admin.d.ts +108 -54
  45. package/dist/routes/endpoints/sync-rules.js +3 -3
  46. package/dist/routes/endpoints/sync-rules.js.map +1 -1
  47. package/dist/routes/endpoints/sync-stream.d.ts +10 -10
  48. package/dist/routes/hooks.js +1 -1
  49. package/dist/routes/hooks.js.map +1 -1
  50. package/dist/routes/route-register.js.map +1 -1
  51. package/dist/storage/BucketStorageBatch.d.ts +1 -1
  52. package/dist/storage/BucketStorageFactory.d.ts +5 -3
  53. package/dist/storage/BucketStorageFactory.js +10 -8
  54. package/dist/storage/BucketStorageFactory.js.map +1 -1
  55. package/dist/storage/ChecksumCache.js.map +1 -1
  56. package/dist/storage/PersistedSyncRulesContent.js +14 -2
  57. package/dist/storage/PersistedSyncRulesContent.js.map +1 -1
  58. package/dist/storage/ReplicationEventPayload.d.ts +1 -1
  59. package/dist/storage/SourceTable.d.ts +1 -1
  60. package/dist/storage/SourceTable.js.map +1 -1
  61. package/dist/storage/storage-index.d.ts +8 -8
  62. package/dist/storage/storage-index.js +8 -8
  63. package/dist/storage/storage-index.js.map +1 -1
  64. package/dist/storage/storage-metrics.js.map +1 -1
  65. package/dist/streams/streams-index.d.ts +2 -2
  66. package/dist/streams/streams-index.js +2 -2
  67. package/dist/streams/streams-index.js.map +1 -1
  68. package/dist/sync/BucketChecksumState.js +4 -19
  69. package/dist/sync/BucketChecksumState.js.map +1 -1
  70. package/dist/sync/RequestTracker.js +1 -1
  71. package/dist/sync/RequestTracker.js.map +1 -1
  72. package/dist/sync/sync-index.d.ts +2 -2
  73. package/dist/sync/sync-index.js +2 -2
  74. package/dist/sync/sync-index.js.map +1 -1
  75. package/dist/sync/sync.js.map +1 -1
  76. package/dist/sync/util.js.map +1 -1
  77. package/dist/system/ServiceContext.d.ts +1 -1
  78. package/dist/system/ServiceContext.js +1 -1
  79. package/dist/system/ServiceContext.js.map +1 -1
  80. package/dist/util/config/collectors/impl/base64-config-collector.d.ts +1 -1
  81. package/dist/util/config/collectors/impl/base64-config-collector.js.map +1 -1
  82. package/dist/util/config/collectors/impl/filesystem-config-collector.d.ts +1 -1
  83. package/dist/util/config/collectors/impl/filesystem-config-collector.js +1 -1
  84. package/dist/util/config/collectors/impl/filesystem-config-collector.js.map +1 -1
  85. package/dist/util/config/sync-rules/sync-rules-provider.js.map +1 -1
  86. package/dist/util/config.js +1 -1
  87. package/dist/util/config.js.map +1 -1
  88. package/dist/util/errors.d.ts +3 -0
  89. package/dist/util/errors.js +15 -0
  90. package/dist/util/errors.js.map +1 -0
  91. package/dist/util/protocol-types.d.ts +2 -2
  92. package/dist/util/util-index.d.ts +1 -1
  93. package/dist/util/util-index.js +1 -1
  94. package/dist/util/util-index.js.map +1 -1
  95. package/dist/util/utils.d.ts +1 -1
  96. package/package.json +5 -5
  97. package/src/api/RouteAPI.ts +17 -0
  98. package/src/api/api-index.ts +1 -1
  99. package/src/api/api-metrics.ts +1 -1
  100. package/src/api/diagnostics.ts +18 -19
  101. package/src/auth/CachedKeyCollector.ts +2 -3
  102. package/src/auth/CompoundKeyCollector.ts +2 -3
  103. package/src/auth/KeyStore.ts +1 -1
  104. package/src/auth/RemoteJWKSCollector.ts +0 -1
  105. package/src/auth/StaticKeyCollector.ts +1 -1
  106. package/src/auth/StaticSupabaseKeyCollector.ts +1 -1
  107. package/src/entry/commands/teardown-action.ts +1 -1
  108. package/src/entry/entry-index.ts +1 -1
  109. package/src/events/EventsEngine.ts +1 -1
  110. package/src/metrics/MetricsEngine.ts +1 -1
  111. package/src/metrics/metrics-index.ts +3 -3
  112. package/src/metrics/open-telemetry/util.ts +1 -1
  113. package/src/metrics/register-metrics.ts +3 -3
  114. package/src/modules/AbstractModule.ts +1 -1
  115. package/src/modules/modules-index.ts +1 -1
  116. package/src/replication/AbstractReplicationJob.ts +1 -1
  117. package/src/replication/replication-index.ts +3 -3
  118. package/src/replication/replication-metrics.ts +1 -1
  119. package/src/routes/endpoints/sync-rules.ts +3 -5
  120. package/src/routes/hooks.ts +2 -2
  121. package/src/routes/route-register.ts +2 -10
  122. package/src/storage/BucketStorageBatch.ts +1 -1
  123. package/src/storage/BucketStorageFactory.ts +18 -14
  124. package/src/storage/ChecksumCache.ts +1 -1
  125. package/src/storage/PersistedSyncRulesContent.ts +18 -2
  126. package/src/storage/ReplicationEventPayload.ts +1 -1
  127. package/src/storage/SourceTable.ts +1 -1
  128. package/src/storage/storage-index.ts +8 -8
  129. package/src/storage/storage-metrics.ts +2 -2
  130. package/src/streams/streams-index.ts +2 -2
  131. package/src/sync/BucketChecksumState.ts +5 -21
  132. package/src/sync/RequestTracker.ts +1 -1
  133. package/src/sync/sync-index.ts +2 -2
  134. package/src/sync/sync.ts +1 -7
  135. package/src/sync/util.ts +1 -1
  136. package/src/system/ServiceContext.ts +1 -1
  137. package/src/util/config/collectors/impl/base64-config-collector.ts +1 -1
  138. package/src/util/config/collectors/impl/filesystem-config-collector.ts +2 -2
  139. package/src/util/config/sync-rules/sync-rules-provider.ts +1 -1
  140. package/src/util/config.ts +1 -1
  141. package/src/util/errors.ts +21 -0
  142. package/src/util/util-index.ts +1 -1
  143. package/src/util/utils.ts +1 -1
  144. package/test/src/auth.test.ts +7 -7
  145. package/test/src/module-loader.test.ts +1 -1
  146. package/test/src/routes/mocks.ts +1 -1
  147. package/test/src/routes/stream.test.ts +1 -2
  148. package/test/src/sync/BucketChecksumState.test.ts +2 -2
  149. package/test/src/util/protocol_types.test.ts +1 -1
  150. package/tsconfig.tsbuildinfo +1 -1
  151. package/vitest.config.ts +1 -1
@@ -1,16 +1,18 @@
1
1
  import { BaseObserver, logger } from '@powersync/lib-services-framework';
2
- import { ParseSyncRulesOptions, PersistedSyncRules, PersistedSyncRulesContent } from './PersistedSyncRulesContent.js';
3
- import { ReplicationEventPayload } from './ReplicationEventPayload.js';
4
- import { ReplicationLock } from './ReplicationLock.js';
5
- import { SyncRulesBucketStorage } from './SyncRulesBucketStorage.js';
6
- import { ReportStorage } from './ReportStorage.js';
7
2
  import {
8
3
  PrecompiledSyncConfig,
9
4
  SerializedCompatibilityContext,
10
5
  serializeSyncPlan,
11
6
  SqlSyncRules,
12
- SyncConfig
7
+ SyncConfigWithErrors
13
8
  } from '@powersync/service-sync-rules';
9
+ import { ReplicationError } from '@powersync/service-types';
10
+ import { syncConfigYamlErrorToReplicationError } from '../util/errors.js';
11
+ import { ParseSyncRulesOptions, PersistedSyncRules, PersistedSyncRulesContent } from './PersistedSyncRulesContent.js';
12
+ import { ReplicationEventPayload } from './ReplicationEventPayload.js';
13
+ import { ReplicationLock } from './ReplicationLock.js';
14
+ import { ReportStorage } from './ReportStorage.js';
15
+ import { SyncRulesBucketStorage } from './SyncRulesBucketStorage.js';
14
16
 
15
17
  /**
16
18
  * Represents a configured storage provider.
@@ -178,13 +180,14 @@ export interface SerializedSyncPlan {
178
180
  * them.
179
181
  */
180
182
  eventDescriptors: Record<string, string[]>;
183
+ errors?: ReplicationError[];
181
184
  }
182
185
 
183
186
  export function updateSyncRulesFromYaml(
184
187
  content: string,
185
188
  options?: Omit<UpdateSyncRulesOptions, 'config'> & { validate?: boolean }
186
189
  ): UpdateSyncRulesOptions {
187
- const { config } = SqlSyncRules.fromYaml(content, {
190
+ const config = SqlSyncRules.fromYaml(content, {
188
191
  // No schema-based validation at this point
189
192
  schema: undefined,
190
193
  defaultSchema: 'not_applicable', // Not needed for validation
@@ -195,24 +198,25 @@ export function updateSyncRulesFromYaml(
195
198
  }
196
199
 
197
200
  export function updateSyncRulesFromConfig(
198
- parsed: SyncConfig,
201
+ { config, errors }: SyncConfigWithErrors,
199
202
  options?: Omit<UpdateSyncRulesOptions, 'config'>
200
203
  ): UpdateSyncRulesOptions {
201
204
  let plan: SerializedSyncPlan | null = null;
202
- if (parsed instanceof PrecompiledSyncConfig) {
205
+ if (config instanceof PrecompiledSyncConfig) {
203
206
  const eventDescriptors: Record<string, string[]> = {};
204
- for (const event of parsed.eventDescriptors) {
207
+ for (const event of config.eventDescriptors) {
205
208
  eventDescriptors[event.name] = event.sourceQueries.map((q) => q.sql);
206
209
  }
207
210
 
208
211
  plan = {
209
- compatibility: parsed.compatibility.serialize(),
210
- plan: serializeSyncPlan(parsed.plan),
211
- eventDescriptors
212
+ compatibility: config.compatibility.serialize(),
213
+ plan: serializeSyncPlan(config.plan),
214
+ eventDescriptors,
215
+ errors: errors.map((e) => syncConfigYamlErrorToReplicationError(e))
212
216
  };
213
217
  }
214
218
 
215
- return { config: { yaml: parsed.content, plan }, ...options };
219
+ return { config: { yaml: config.content, plan }, ...options };
216
220
  }
217
221
 
218
222
  export interface GetIntanceOptions {
@@ -1,6 +1,6 @@
1
1
  import { OrderedSet } from '@js-sdsl/ordered-set';
2
- import { LRUCache } from 'lru-cache/min';
3
2
  import { BucketDataSource } from '@powersync/service-sync-rules';
3
+ import { LRUCache } from 'lru-cache/min';
4
4
  import { BucketChecksum } from '../util/protocol-types.js';
5
5
  import { addBucketChecksums, ChecksumMap, InternalOpId, PartialChecksum } from '../util/utils.js';
6
6
  import { BucketChecksumRequest } from './SyncRulesBucketStorage.js';
@@ -4,6 +4,7 @@ import {
4
4
  CompatibilityOption,
5
5
  DEFAULT_HYDRATION_STATE,
6
6
  deserializeSyncPlan,
7
+ ErrorLocation,
7
8
  HydratedSyncRules,
8
9
  HydrationState,
9
10
  javaScriptExpressionEngine,
@@ -11,7 +12,8 @@ import {
11
12
  SqlEventDescriptor,
12
13
  SqlSyncRules,
13
14
  SyncConfigWithErrors,
14
- versionedHydrationState
15
+ versionedHydrationState,
16
+ YamlError
15
17
  } from '@powersync/service-sync-rules';
16
18
  import { SerializedSyncPlan, UpdateSyncRulesOptions } from './BucketStorageFactory.js';
17
19
  import { ReplicationLock } from './ReplicationLock.js';
@@ -101,7 +103,21 @@ export abstract class PersistedSyncRulesContent implements PersistedSyncRulesCon
101
103
  sourceText: this.sync_rules_content
102
104
  });
103
105
 
104
- config = { config: precompiled, errors: [] };
106
+ const errors: YamlError[] = [];
107
+ if (this.compiled_plan.errors) {
108
+ for (const error of this.compiled_plan.errors) {
109
+ const location: ErrorLocation | undefined = error.location && {
110
+ start: error.location.start_offset,
111
+ end: error.location.end_offset
112
+ };
113
+ const asYamlError = new YamlError(new Error(error.message), location);
114
+ asYamlError.type = error.level;
115
+
116
+ errors.push(asYamlError);
117
+ }
118
+ }
119
+
120
+ config = { config: precompiled, errors };
105
121
  } else {
106
122
  config = SqlSyncRules.fromYaml(this.sync_rules_content, options);
107
123
  }
@@ -1,6 +1,6 @@
1
1
  import * as sync_rules from '@powersync/service-sync-rules';
2
- import { SourceTable } from './SourceTable.js';
3
2
  import { BucketStorageBatch, SaveOp } from './BucketStorageBatch.js';
3
+ import { SourceTable } from './SourceTable.js';
4
4
 
5
5
  export type EventData = {
6
6
  op: SaveOp;
@@ -1,7 +1,7 @@
1
1
  import { DEFAULT_TAG } from '@powersync/service-sync-rules';
2
+ import { bson } from '../index.js';
2
3
  import * as util from '../util/util-index.js';
3
4
  import { ColumnDescriptor, SourceEntityDescriptor } from './SourceEntity.js';
4
- import { bson } from '../index.js';
5
5
 
6
6
  /**
7
7
  * Format of the id depends on the bucket storage module. It should be consistent within the module.
@@ -1,17 +1,17 @@
1
1
  export * from './bson.js';
2
2
  export * from './BucketStorage.js';
3
+ export * from './BucketStorageBatch.js';
4
+ export * from './BucketStorageFactory.js';
3
5
  export * from './ChecksumCache.js';
6
+ export * from './PersistedSyncRulesContent.js';
4
7
  export * from './ReplicationEventPayload.js';
8
+ export * from './ReplicationLock.js';
9
+ export * from './ReportStorage.js';
5
10
  export * from './SourceEntity.js';
6
11
  export * from './SourceTable.js';
12
+ export * from './storage-metrics.js';
7
13
  export * from './StorageEngine.js';
8
14
  export * from './StorageProvider.js';
9
- export * from './storage-metrics.js';
10
- export * from './WriteCheckpointAPI.js';
11
- export * from './BucketStorageFactory.js';
12
- export * from './BucketStorageBatch.js';
13
- export * from './SyncRulesBucketStorage.js';
14
- export * from './PersistedSyncRulesContent.js';
15
- export * from './ReplicationLock.js';
16
- export * from './ReportStorage.js';
17
15
  export * from './StorageVersionConfig.js';
16
+ export * from './SyncRulesBucketStorage.js';
17
+ export * from './WriteCheckpointAPI.js';
@@ -1,7 +1,7 @@
1
- import { MetricsEngine } from '../metrics/MetricsEngine.js';
2
1
  import { logger } from '@powersync/lib-services-framework';
3
- import { BucketStorageFactory, StorageMetrics } from './BucketStorageFactory.js';
4
2
  import { StorageMetric } from '@powersync/service-types';
3
+ import { MetricsEngine } from '../metrics/MetricsEngine.js';
4
+ import { BucketStorageFactory, StorageMetrics } from './BucketStorageFactory.js';
5
5
 
6
6
  export function createCoreStorageMetrics(engine: MetricsEngine): void {
7
7
  engine.createObservableGauge({
@@ -1,3 +1,3 @@
1
- export * from './merge.js';
2
- export * from './LastValueSink.js';
3
1
  export * from './BroadcastIterable.js';
2
+ export * from './LastValueSink.js';
3
+ export * from './merge.js';
@@ -1,14 +1,13 @@
1
1
  import {
2
- BucketDescription,
3
2
  BucketParameterQuerier,
4
3
  BucketPriority,
5
4
  BucketSource,
6
5
  HydratedSyncRules,
6
+ mergeBuckets,
7
7
  QuerierError,
8
8
  RequestedStream,
9
9
  RequestParameters,
10
- ResolvedBucket,
11
- mergeBuckets
10
+ ResolvedBucket
12
11
  } from '@powersync/service-sync-rules';
13
12
 
14
13
  import * as storage from '../storage/storage-index.js';
@@ -445,6 +444,7 @@ export class BucketParameterState {
445
444
  const subscription = explicitStreamSubscriptions[i];
446
445
 
447
446
  const syncRuleStream: RequestedStream = {
447
+ priorityOverride: subscription.override_priority as BucketPriority | null,
448
448
  parameters: subscription.parameters ?? {},
449
449
  opaque_id: i
450
450
  };
@@ -480,25 +480,9 @@ export class BucketParameterState {
480
480
  * reference default buckets by their stream index instead of duplicating the name on wire.
481
481
  */
482
482
  translateResolvedBucket(description: ResolvedBucket, lookupIndex: Map<string, number>): util.ClientBucketDescription {
483
- // If the client is overriding the priority of any stream that yields this bucket, sync the bucket with that
484
- // priority.
485
- let priorityOverride: BucketPriority | null = null;
486
- for (const reason of description.inclusion_reasons) {
487
- if (reason != 'default') {
488
- const requestedPriority = this.explicitStreamSubscriptions[reason.subscription]?.override_priority;
489
- if (requestedPriority != null) {
490
- if (priorityOverride == null) {
491
- priorityOverride = requestedPriority as BucketPriority;
492
- } else {
493
- priorityOverride = Math.min(requestedPriority, priorityOverride) as BucketPriority;
494
- }
495
- }
496
- }
497
- }
498
-
499
483
  return {
500
484
  bucket: description.bucket,
501
- priority: priorityOverride ?? description.priority,
485
+ priority: description.priority,
502
486
  subscriptions: description.inclusion_reasons.map((reason) => {
503
487
  if (reason == 'default') {
504
488
  const stream = description.definition;
@@ -533,7 +517,7 @@ export class BucketParameterState {
533
517
 
534
518
  let errorMessage = error.message;
535
519
  const logData: any = {
536
- checkpoint: checkpoint,
520
+ checkpoint: checkpoint.base.checkpoint,
537
521
  user_id: this.syncParams.userId,
538
522
  parameter_query_results: update.buckets.length
539
523
  };
@@ -1,8 +1,8 @@
1
1
  import { MetricsEngine } from '../metrics/MetricsEngine.js';
2
2
 
3
+ import { ServiceAssertionError } from '@powersync/lib-services-framework';
3
4
  import { APIMetric } from '@powersync/service-types';
4
5
  import { SyncBucketData } from '../util/protocol-types.js';
5
- import { ServiceAssertionError } from '@powersync/lib-services-framework';
6
6
 
7
7
  /**
8
8
  * Record sync stats per request stream.
@@ -1,6 +1,6 @@
1
+ export * from './BucketChecksumState.js';
1
2
  export * from './RequestTracker.js';
2
3
  export * from './safeRace.js';
3
4
  export * from './sync.js';
4
- export * from './util.js';
5
- export * from './BucketChecksumState.js';
6
5
  export * from './SyncContext.js';
6
+ export * from './util.js';
package/src/sync/sync.ts CHANGED
@@ -1,11 +1,5 @@
1
1
  import { JSONBig, JsonContainer } from '@powersync/service-jsonbig';
2
- import {
3
- BucketDescription,
4
- BucketPriority,
5
- HydratedSyncRules,
6
- ResolvedBucket,
7
- SqliteJsonValue
8
- } from '@powersync/service-sync-rules';
2
+ import { BucketPriority, HydratedSyncRules, ResolvedBucket, SqliteJsonValue } from '@powersync/service-sync-rules';
9
3
 
10
4
  import { AbortError } from 'ix/aborterror.js';
11
5
 
package/src/sync/util.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as timers from 'timers/promises';
2
2
 
3
3
  import { SemaphoreInterface } from 'async-mutex';
4
+ import { serialize } from 'bson';
4
5
  import * as util from '../util/util-index.js';
5
6
  import { RequestTracker } from './RequestTracker.js';
6
- import { serialize } from 'bson';
7
7
 
8
8
  export type TokenStreamOptions = {
9
9
  /**
@@ -1,5 +1,6 @@
1
1
  import { container, LifeCycledSystem, MigrationManager, ServiceIdentifier } from '@powersync/lib-services-framework';
2
2
 
3
+ import { EventsEngine } from '../events/EventsEngine.js';
3
4
  import { framework } from '../index.js';
4
5
  import * as metrics from '../metrics/MetricsEngine.js';
5
6
  import { PowerSyncMigrationManager } from '../migrations/PowerSyncMigrationManager.js';
@@ -8,7 +9,6 @@ import * as routes from '../routes/routes-index.js';
8
9
  import * as storage from '../storage/storage-index.js';
9
10
  import { SyncContext } from '../sync/SyncContext.js';
10
11
  import * as utils from '../util/util-index.js';
11
- import { EventsEngine } from '../events/EventsEngine.js';
12
12
 
13
13
  export interface ServiceContext {
14
14
  configuration: utils.ResolvedPowerSyncConfig;
@@ -1,5 +1,5 @@
1
- import { ConfigCollector } from '../config-collector.js';
2
1
  import { RunnerConfig } from '../../types.js';
2
+ import { ConfigCollector } from '../config-collector.js';
3
3
 
4
4
  export class Base64ConfigCollector extends ConfigCollector {
5
5
  get name(): string {
@@ -1,9 +1,9 @@
1
1
  import * as fs from 'fs/promises';
2
2
  import * as path from 'path';
3
3
 
4
- import { ConfigCollector, ConfigFileFormat } from '../config-collector.js';
5
- import { RunnerConfig } from '../../types.js';
6
4
  import { logger } from '@powersync/lib-services-framework';
5
+ import { RunnerConfig } from '../../types.js';
6
+ import { ConfigCollector, ConfigFileFormat } from '../config-collector.js';
7
7
 
8
8
  export class FileSystemConfigCollector extends ConfigCollector {
9
9
  get name(): string {
@@ -1,5 +1,5 @@
1
- import { SyncRulesConfig } from '../types.js';
2
1
  import fs from 'fs/promises';
2
+ import { SyncRulesConfig } from '../types.js';
3
3
 
4
4
  export interface SyncRulesProvider {
5
5
  get(): Promise<string | undefined>;
@@ -1,7 +1,7 @@
1
1
  import * as fs from 'fs/promises';
2
2
  import winston from 'winston';
3
3
 
4
- import { container, logger, LogFormat, DEFAULT_LOG_LEVEL, DEFAULT_LOG_FORMAT } from '@powersync/lib-services-framework';
4
+ import { container, DEFAULT_LOG_FORMAT, DEFAULT_LOG_LEVEL, LogFormat, logger } from '@powersync/lib-services-framework';
5
5
  import { configFile } from '@powersync/service-types';
6
6
  import { ResolvedPowerSyncConfig, RunnerConfig } from './config/types.js';
7
7
  import { CompoundConfigCollector } from './util-index.js';
@@ -0,0 +1,21 @@
1
+ import { YamlError } from '@powersync/service-sync-rules';
2
+ import { ReplicationError } from '@powersync/service-types';
3
+
4
+ export function syncConfigYamlErrorToReplicationError(
5
+ { type, message, location }: YamlError,
6
+ ts?: string
7
+ ): ReplicationError {
8
+ const error: ReplicationError = {
9
+ level: type,
10
+ message,
11
+ ts
12
+ };
13
+ if (location != null) {
14
+ error.location = {
15
+ start_offset: location.start,
16
+ end_offset: location.end
17
+ };
18
+ }
19
+
20
+ return error;
21
+ }
@@ -1,4 +1,5 @@
1
1
  export * from './alerting.js';
2
+ export * from './checkpointing.js';
2
3
  export * from './env.js';
3
4
  export * from './lsn.js';
4
5
  export * from './memory-tracking.js';
@@ -6,7 +7,6 @@ export * from './Mutex.js';
6
7
  export * from './protocol-types.js';
7
8
  export * from './secs.js';
8
9
  export * from './utils.js';
9
- export * from './checkpointing.js';
10
10
  export * from './version.js';
11
11
 
12
12
  export * from './config.js';
package/src/util/utils.ts CHANGED
@@ -2,7 +2,7 @@ import * as sync_rules from '@powersync/service-sync-rules';
2
2
  import * as bson from 'bson';
3
3
  import crypto from 'crypto';
4
4
  import * as uuid from 'uuid';
5
- import { BucketChecksum, ProtocolOpId, OplogEntry } from './protocol-types.js';
5
+ import { BucketChecksum, OplogEntry, ProtocolOpId } from './protocol-types.js';
6
6
 
7
7
  import * as storage from '../storage/storage-index.js';
8
8
 
@@ -1,13 +1,13 @@
1
- import { describe, expect, test } from 'vitest';
2
- import { StaticKeyCollector } from '../../src/auth/StaticKeyCollector.js';
1
+ import { StaticSupabaseKeyCollector } from '@/index.js';
3
2
  import * as jose from 'jose';
4
- import { KeyStore } from '../../src/auth/KeyStore.js';
3
+ import { describe, expect, test } from 'vitest';
4
+ import { CachedKeyCollector } from '../../src/auth/CachedKeyCollector.js';
5
+ import { KeyResult } from '../../src/auth/KeyCollector.js';
5
6
  import { KeySpec } from '../../src/auth/KeySpec.js';
7
+ import { KeyStore } from '../../src/auth/KeyStore.js';
6
8
  import { RemoteJWKSCollector } from '../../src/auth/RemoteJWKSCollector.js';
7
- import { KeyResult } from '../../src/auth/KeyCollector.js';
8
- import { CachedKeyCollector } from '../../src/auth/CachedKeyCollector.js';
9
- import { JwtPayload, StaticSupabaseKeyCollector } from '@/index.js';
10
- import { debugKeyNotFound, getSupabaseJwksUrl } from '../../src/auth/utils.js';
9
+ import { StaticKeyCollector } from '../../src/auth/StaticKeyCollector.js';
10
+ import { getSupabaseJwksUrl } from '../../src/auth/utils.js';
11
11
 
12
12
  const publicKeyRSA: jose.JWK = {
13
13
  use: 'sig',
@@ -1,5 +1,5 @@
1
1
  import { AbstractModule, loadModules, ServiceContextContainer, TearDownOptions } from '@/index.js';
2
- import { describe, expect, it, vi } from 'vitest';
2
+ import { describe, expect, it } from 'vitest';
3
3
 
4
4
  interface MockConfig {
5
5
  connections?: { type: string }[];
@@ -1,3 +1,4 @@
1
+ import { EventsEngine } from '@/events/EventsEngine.js';
1
2
  import {
2
3
  BucketStorageFactory,
3
4
  createCoreAPIMetrics,
@@ -11,7 +12,6 @@ import {
11
12
  SyncRulesBucketStorage
12
13
  } from '@/index.js';
13
14
  import { MeterProvider } from '@opentelemetry/sdk-metrics';
14
- import { EventsEngine } from '@/events/EventsEngine.js';
15
15
 
16
16
  export function mockServiceContext(storage: Partial<SyncRulesBucketStorage> | null) {
17
17
  // This is very incomplete - just enough to get the current tests passing.
@@ -1,6 +1,6 @@
1
1
  import { BasicRouterRequest, Context, JwtPayload, SyncRulesBucketStorage } from '@/index.js';
2
2
  import { RouterResponse, ServiceError, logger } from '@powersync/lib-services-framework';
3
- import { SqlSyncRules } from '@powersync/service-sync-rules';
3
+ import { DEFAULT_HYDRATION_STATE, SqlSyncRules } from '@powersync/service-sync-rules';
4
4
  import { Readable, Writable } from 'stream';
5
5
  import { pipeline } from 'stream/promises';
6
6
  import { describe, expect, it } from 'vitest';
@@ -8,7 +8,6 @@ import winston from 'winston';
8
8
  import { syncStreamed } from '../../../src/routes/endpoints/sync-stream.js';
9
9
  import { DEFAULT_PARAM_LOGGING_FORMAT_OPTIONS, limitParamsForLogging } from '../../../src/util/param-logging.js';
10
10
  import { mockServiceContext } from './mocks.js';
11
- import { DEFAULT_HYDRATION_STATE } from '@powersync/service-sync-rules';
12
11
 
13
12
  describe('Stream Route', () => {
14
13
  describe('compressed stream', () => {
@@ -15,13 +15,12 @@ import {
15
15
  import { JSONBig } from '@powersync/service-jsonbig';
16
16
  import {
17
17
  ParameterIndexLookupCreator,
18
- RequestJwtPayload,
19
18
  ScopedParameterLookup,
19
+ SourceTableInterface,
20
20
  SqliteJsonRow,
21
21
  SqliteRow,
22
22
  SqlSyncRules,
23
23
  TablePattern,
24
- SourceTableInterface,
25
24
  versionedHydrationState
26
25
  } from '@powersync/service-sync-rules';
27
26
  import { ParameterLookupScope } from '@powersync/service-sync-rules/src/HydrationState.js';
@@ -986,6 +985,7 @@ bucket_definitions:
986
985
  expect(errorMessages[0]).toContain('tasks: 20');
987
986
  expect(errorMessages[0]).toContain('comments: 10');
988
987
 
988
+ expect(errorData[0].checkpoint).toEqual(1n);
989
989
  expect(errorData[0].parameter_query_results).toBe(60);
990
990
  expect(errorData[0].parameter_query_results_by_definition).toEqual({
991
991
  projects: 30,
@@ -1,6 +1,6 @@
1
1
  import { StreamingSyncRequest } from '@/index.js';
2
2
  import { schema } from '@powersync/lib-services-framework';
3
- import { describe, test, expect, it } from 'vitest';
3
+ import { describe, expect, test } from 'vitest';
4
4
 
5
5
  describe('protocol types', () => {
6
6
  describe('StreamingSyncRequest', () => {