@powersync/service-core 0.0.0-dev-20260602073133 → 0.0.0-dev-20260803144812

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 (183) hide show
  1. package/CHANGELOG.md +83 -4
  2. package/dist/api/RouteAPI.d.ts +42 -14
  3. package/dist/api/diagnostics.d.ts +12 -1
  4. package/dist/api/diagnostics.js +34 -22
  5. package/dist/api/diagnostics.js.map +1 -1
  6. package/dist/entry/commands/compact-action.js +5 -1
  7. package/dist/entry/commands/compact-action.js.map +1 -1
  8. package/dist/modules/AbstractModule.d.ts +6 -2
  9. package/dist/modules/AbstractModule.js.map +1 -1
  10. package/dist/replication/AbstractReplicator.d.ts +26 -7
  11. package/dist/replication/AbstractReplicator.js +148 -68
  12. package/dist/replication/AbstractReplicator.js.map +1 -1
  13. package/dist/replication/ReplicationModule.d.ts +3 -3
  14. package/dist/replication/ReplicationModule.js.map +1 -1
  15. package/dist/routes/RouterEngine.d.ts +1 -0
  16. package/dist/routes/RouterEngine.js +6 -1
  17. package/dist/routes/RouterEngine.js.map +1 -1
  18. package/dist/routes/configure-fastify.d.ts +95 -56
  19. package/dist/routes/configure-fastify.js +15 -2
  20. package/dist/routes/configure-fastify.js.map +1 -1
  21. package/dist/routes/endpoints/admin.d.ts +24 -24
  22. package/dist/routes/endpoints/admin.js +46 -35
  23. package/dist/routes/endpoints/admin.js.map +1 -1
  24. package/dist/routes/endpoints/checkpointing.d.ts +62 -0
  25. package/dist/routes/endpoints/checkpointing.js +65 -7
  26. package/dist/routes/endpoints/checkpointing.js.map +1 -1
  27. package/dist/routes/endpoints/socket-route.js +3 -2
  28. package/dist/routes/endpoints/socket-route.js.map +1 -1
  29. package/dist/routes/endpoints/sync-rules.js +22 -13
  30. package/dist/routes/endpoints/sync-rules.js.map +1 -1
  31. package/dist/routes/endpoints/sync-stream.js +1 -1
  32. package/dist/routes/endpoints/sync-stream.js.map +1 -1
  33. package/dist/runner/teardown.js +8 -8
  34. package/dist/runner/teardown.js.map +1 -1
  35. package/dist/storage/BucketStorageBatch.d.ts +63 -17
  36. package/dist/storage/BucketStorageBatch.js.map +1 -1
  37. package/dist/storage/BucketStorageFactory.d.ts +22 -27
  38. package/dist/storage/BucketStorageFactory.js +4 -18
  39. package/dist/storage/BucketStorageFactory.js.map +1 -1
  40. package/dist/storage/CheckpointChecksumInvalidatedError.d.ts +12 -0
  41. package/dist/storage/CheckpointChecksumInvalidatedError.js +17 -0
  42. package/dist/storage/CheckpointChecksumInvalidatedError.js.map +1 -0
  43. package/dist/storage/ChecksumCache.d.ts +11 -6
  44. package/dist/storage/ChecksumCache.js +5 -4
  45. package/dist/storage/ChecksumCache.js.map +1 -1
  46. package/dist/storage/ParsedSyncConfigSet.d.ts +23 -0
  47. package/dist/storage/ParsedSyncConfigSet.js +2 -0
  48. package/dist/storage/ParsedSyncConfigSet.js.map +1 -0
  49. package/dist/storage/PersistedReplicationStream.d.ts +32 -0
  50. package/dist/storage/PersistedReplicationStream.js +26 -0
  51. package/dist/storage/PersistedReplicationStream.js.map +1 -0
  52. package/dist/storage/PersistedSyncConfigContent.d.ts +63 -0
  53. package/dist/storage/PersistedSyncConfigContent.js +125 -0
  54. package/dist/storage/PersistedSyncConfigContent.js.map +1 -0
  55. package/dist/storage/PersistedSyncConfigStatus.d.ts +13 -0
  56. package/dist/storage/PersistedSyncConfigStatus.js +2 -0
  57. package/dist/storage/PersistedSyncConfigStatus.js.map +1 -0
  58. package/dist/storage/SourceEntity.d.ts +6 -0
  59. package/dist/storage/SourceTable.d.ts +21 -3
  60. package/dist/storage/SourceTable.js +26 -3
  61. package/dist/storage/SourceTable.js.map +1 -1
  62. package/dist/storage/SyncRulesBucketStorage.d.ts +119 -21
  63. package/dist/storage/SyncRulesBucketStorage.js +3 -0
  64. package/dist/storage/SyncRulesBucketStorage.js.map +1 -1
  65. package/dist/storage/WriteCheckpointAPI.d.ts +60 -3
  66. package/dist/storage/WriteCheckpointAPI.js +33 -0
  67. package/dist/storage/WriteCheckpointAPI.js.map +1 -1
  68. package/dist/storage/implementation/BucketDefinitionMapping.d.ts +117 -0
  69. package/dist/storage/implementation/BucketDefinitionMapping.js +277 -0
  70. package/dist/storage/implementation/BucketDefinitionMapping.js.map +1 -0
  71. package/dist/storage/implementation/IncrementalReprocessingCompatibility.d.ts +6 -0
  72. package/dist/storage/implementation/IncrementalReprocessingCompatibility.js +31 -0
  73. package/dist/storage/implementation/IncrementalReprocessingCompatibility.js.map +1 -0
  74. package/dist/storage/implementation/IncrementalReprocessingSyncConfigLog.d.ts +17 -0
  75. package/dist/storage/implementation/IncrementalReprocessingSyncConfigLog.js +62 -0
  76. package/dist/storage/implementation/IncrementalReprocessingSyncConfigLog.js.map +1 -0
  77. package/dist/storage/implementation/ReplicationStreamStorageIds.d.ts +15 -0
  78. package/dist/storage/implementation/ReplicationStreamStorageIds.js +20 -0
  79. package/dist/storage/implementation/ReplicationStreamStorageIds.js.map +1 -0
  80. package/dist/storage/storage-index.d.ts +9 -1
  81. package/dist/storage/storage-index.js +9 -1
  82. package/dist/storage/storage-index.js.map +1 -1
  83. package/dist/sync/BucketChecksumState.d.ts +12 -2
  84. package/dist/sync/BucketChecksumState.js +69 -21
  85. package/dist/sync/BucketChecksumState.js.map +1 -1
  86. package/dist/sync/RequestTracker.d.ts +7 -0
  87. package/dist/sync/RequestTracker.js +12 -0
  88. package/dist/sync/RequestTracker.js.map +1 -1
  89. package/dist/sync/sync.js +154 -41
  90. package/dist/sync/sync.js.map +1 -1
  91. package/dist/sync/util.d.ts +5 -0
  92. package/dist/sync/util.js +9 -0
  93. package/dist/sync/util.js.map +1 -1
  94. package/dist/system/ServiceContext.d.ts +2 -0
  95. package/dist/system/ServiceContext.js +2 -0
  96. package/dist/system/ServiceContext.js.map +1 -1
  97. package/dist/tracing/PerformanceTracer.d.ts +23 -1
  98. package/dist/tracing/PerformanceTracer.js +11 -0
  99. package/dist/tracing/PerformanceTracer.js.map +1 -1
  100. package/dist/util/checkpointing.d.ts +4 -8
  101. package/dist/util/checkpointing.js +1 -16
  102. package/dist/util/checkpointing.js.map +1 -1
  103. package/dist/util/config/compound-config-collector.js +18 -2
  104. package/dist/util/config/compound-config-collector.js.map +1 -1
  105. package/dist/util/config/defaults.d.ts +2 -0
  106. package/dist/util/config/defaults.js +2 -0
  107. package/dist/util/config/defaults.js.map +1 -1
  108. package/dist/util/config/types.d.ts +3 -1
  109. package/dist/util/lsn.d.ts +4 -0
  110. package/dist/util/lsn.js +10 -0
  111. package/dist/util/lsn.js.map +1 -1
  112. package/dist/util/util-index.d.ts +1 -0
  113. package/dist/util/util-index.js +1 -0
  114. package/dist/util/util-index.js.map +1 -1
  115. package/dist/util/utils.d.ts +1 -1
  116. package/dist/util/utils.js +1 -1
  117. package/dist/util/write-checkpoint-batcher.d.ts +19 -0
  118. package/dist/util/write-checkpoint-batcher.js +100 -0
  119. package/dist/util/write-checkpoint-batcher.js.map +1 -0
  120. package/package.json +6 -7
  121. package/src/api/RouteAPI.ts +43 -14
  122. package/src/api/diagnostics.ts +43 -26
  123. package/src/entry/commands/compact-action.ts +7 -1
  124. package/src/modules/AbstractModule.ts +6 -2
  125. package/src/replication/AbstractReplicator.ts +181 -72
  126. package/src/replication/ReplicationModule.ts +2 -3
  127. package/src/routes/RouterEngine.ts +7 -1
  128. package/src/routes/configure-fastify.ts +25 -2
  129. package/src/routes/endpoints/admin.ts +72 -50
  130. package/src/routes/endpoints/checkpointing.ts +79 -8
  131. package/src/routes/endpoints/socket-route.ts +3 -2
  132. package/src/routes/endpoints/sync-rules.ts +23 -13
  133. package/src/routes/endpoints/sync-stream.ts +1 -1
  134. package/src/runner/teardown.ts +8 -8
  135. package/src/storage/BucketStorageBatch.ts +64 -18
  136. package/src/storage/BucketStorageFactory.ts +30 -39
  137. package/src/storage/CheckpointChecksumInvalidatedError.ts +17 -0
  138. package/src/storage/ChecksumCache.ts +27 -14
  139. package/src/storage/ParsedSyncConfigSet.ts +25 -0
  140. package/src/storage/PersistedReplicationStream.ts +55 -0
  141. package/src/storage/PersistedSyncConfigContent.ts +192 -0
  142. package/src/storage/PersistedSyncConfigStatus.ts +14 -0
  143. package/src/storage/SourceEntity.ts +6 -0
  144. package/src/storage/SourceTable.ts +34 -3
  145. package/src/storage/SyncRulesBucketStorage.ts +138 -22
  146. package/src/storage/WriteCheckpointAPI.ts +108 -3
  147. package/src/storage/implementation/BucketDefinitionMapping.ts +436 -0
  148. package/src/storage/implementation/IncrementalReprocessingCompatibility.ts +41 -0
  149. package/src/storage/implementation/IncrementalReprocessingSyncConfigLog.ts +109 -0
  150. package/src/storage/implementation/ReplicationStreamStorageIds.ts +21 -0
  151. package/src/storage/storage-index.ts +10 -1
  152. package/src/sync/BucketChecksumState.ts +103 -21
  153. package/src/sync/RequestTracker.ts +20 -0
  154. package/src/sync/sync.ts +183 -48
  155. package/src/sync/util.ts +12 -0
  156. package/src/system/ServiceContext.ts +7 -0
  157. package/src/tracing/PerformanceTracer.ts +41 -1
  158. package/src/util/checkpointing.ts +4 -22
  159. package/src/util/config/compound-config-collector.ts +25 -1
  160. package/src/util/config/defaults.ts +2 -0
  161. package/src/util/config/types.ts +3 -1
  162. package/src/util/lsn.ts +9 -0
  163. package/src/util/util-index.ts +1 -0
  164. package/src/util/utils.ts +1 -1
  165. package/src/util/write-checkpoint-batcher.ts +142 -0
  166. package/test/src/AbstractReplicator.test.ts +115 -0
  167. package/test/src/checksum_cache.test.ts +22 -0
  168. package/test/src/config.test.ts +102 -0
  169. package/test/src/diagnostics.test.ts +62 -34
  170. package/test/src/module-loader.test.ts +33 -1
  171. package/test/src/routes/admin.test.ts +182 -18
  172. package/test/src/routes/checkpointing.test.ts +54 -0
  173. package/test/src/routes/mocks.ts +6 -2
  174. package/test/src/storage/SourceTable.test.ts +89 -0
  175. package/test/src/sync/BucketChecksumState.test.ts +98 -12
  176. package/test/src/sync/util.test.ts +13 -1
  177. package/test/src/util/checkpointing.test.ts +249 -0
  178. package/tsconfig.json +1 -4
  179. package/tsconfig.tsbuildinfo +1 -1
  180. package/dist/storage/PersistedSyncRulesContent.d.ts +0 -59
  181. package/dist/storage/PersistedSyncRulesContent.js +0 -100
  182. package/dist/storage/PersistedSyncRulesContent.js.map +0 -1
  183. package/src/storage/PersistedSyncRulesContent.ts +0 -174
@@ -16,6 +16,7 @@ export type RouteRegistrationOptions = {
16
16
  */
17
17
  export type RouteDefinitions = {
18
18
  api?: Partial<RouteRegistrationOptions>;
19
+ checkpointing?: Partial<RouteRegistrationOptions>;
19
20
  sync_stream?: Partial<RouteRegistrationOptions>;
20
21
  };
21
22
  export type FastifyServerConfig = {
@@ -101,8 +102,8 @@ export declare const DEFAULT_ROUTE_OPTIONS: {
101
102
  ts?: string | undefined;
102
103
  }[];
103
104
  id: string;
104
- postgres_uri: string;
105
105
  connected: boolean;
106
+ postgres_uri: string;
106
107
  }[];
107
108
  active_sync_rules?: {
108
109
  errors: {
@@ -204,8 +205,8 @@ export declare const DEFAULT_ROUTE_OPTIONS: {
204
205
  ts?: string | undefined;
205
206
  }[];
206
207
  id: string;
207
- postgres_uri: string;
208
208
  connected: boolean;
209
+ postgres_uri: string;
209
210
  }[];
210
211
  active_sync_rules?: {
211
212
  errors: {
@@ -318,8 +319,8 @@ export declare const DEFAULT_ROUTE_OPTIONS: {
318
319
  ts?: string | undefined;
319
320
  }[];
320
321
  id: string;
321
- postgres_uri: string;
322
322
  connected: boolean;
323
+ postgres_uri: string;
323
324
  }[];
324
325
  active_sync_rules?: {
325
326
  errors: {
@@ -425,8 +426,8 @@ export declare const DEFAULT_ROUTE_OPTIONS: {
425
426
  }[];
426
427
  id?: string | undefined;
427
428
  }[];
428
- defaultConnectionTag: string;
429
429
  defaultSchema: string;
430
+ defaultConnectionTag: string;
430
431
  }, import("./router.js").Context, import("./router.js").RequestEndpointHandlerPayload<{}, import("./router.js").Context, import("./router.js").BasicRouterRequest>, import("@powersync/lib-services-framework").EndpointHandler<import("./router.js").RequestEndpointHandlerPayload<{}, import("./router.js").Context, import("./router.js").BasicRouterRequest>, {
431
432
  connections: {
432
433
  tag: string;
@@ -446,8 +447,8 @@ export declare const DEFAULT_ROUTE_OPTIONS: {
446
447
  }[];
447
448
  id?: string | undefined;
448
449
  }[];
449
- defaultConnectionTag: string;
450
450
  defaultSchema: string;
451
+ defaultConnectionTag: string;
451
452
  }>> & {
452
453
  path: string;
453
454
  method: import("@powersync/lib-services-framework").HTTPMethod.POST;
@@ -478,8 +479,8 @@ export declare const DEFAULT_ROUTE_OPTIONS: {
478
479
  }[];
479
480
  id?: string | undefined;
480
481
  }[];
481
- defaultConnectionTag: string;
482
482
  defaultSchema: string;
483
+ defaultConnectionTag: string;
483
484
  }>;
484
485
  }) | (import("@powersync/lib-services-framework").Endpoint<{}, {
485
486
  connections: {
@@ -526,8 +527,6 @@ export declare const DEFAULT_ROUTE_OPTIONS: {
526
527
  connections: {
527
528
  id: string;
528
529
  tag: string;
529
- slot_name: string;
530
- initial_replication_done: boolean;
531
530
  tables: {
532
531
  name: string;
533
532
  schema: string;
@@ -545,6 +544,8 @@ export declare const DEFAULT_ROUTE_OPTIONS: {
545
544
  }[];
546
545
  pattern?: string | undefined;
547
546
  }[];
547
+ slot_name: string;
548
+ initial_replication_done: boolean;
548
549
  last_lsn?: string | undefined;
549
550
  last_keepalive_ts?: string | undefined;
550
551
  last_checkpoint_ts?: string | undefined;
@@ -571,8 +572,6 @@ export declare const DEFAULT_ROUTE_OPTIONS: {
571
572
  connections: {
572
573
  id: string;
573
574
  tag: string;
574
- slot_name: string;
575
- initial_replication_done: boolean;
576
575
  tables: {
577
576
  name: string;
578
577
  schema: string;
@@ -590,6 +589,8 @@ export declare const DEFAULT_ROUTE_OPTIONS: {
590
589
  }[];
591
590
  pattern?: string | undefined;
592
591
  }[];
592
+ slot_name: string;
593
+ initial_replication_done: boolean;
593
594
  last_lsn?: string | undefined;
594
595
  last_keepalive_ts?: string | undefined;
595
596
  last_checkpoint_ts?: string | undefined;
@@ -627,8 +628,6 @@ export declare const DEFAULT_ROUTE_OPTIONS: {
627
628
  connections: {
628
629
  id: string;
629
630
  tag: string;
630
- slot_name: string;
631
- initial_replication_done: boolean;
632
631
  tables: {
633
632
  name: string;
634
633
  schema: string;
@@ -646,6 +645,8 @@ export declare const DEFAULT_ROUTE_OPTIONS: {
646
645
  }[];
647
646
  pattern?: string | undefined;
648
647
  }[];
648
+ slot_name: string;
649
+ initial_replication_done: boolean;
649
650
  last_lsn?: string | undefined;
650
651
  last_keepalive_ts?: string | undefined;
651
652
  last_checkpoint_ts?: string | undefined;
@@ -656,50 +657,6 @@ export declare const DEFAULT_ROUTE_OPTIONS: {
656
657
  }[];
657
658
  content?: string | undefined;
658
659
  }>;
659
- }) | (import("@powersync/lib-services-framework").Endpoint<{
660
- client_id?: string | undefined;
661
- }, {
662
- checkpoint: bigint;
663
- }, import("./router.js").Context, import("./router.js").RequestEndpointHandlerPayload<{
664
- client_id?: string | undefined;
665
- }, import("./router.js").Context, import("./router.js").BasicRouterRequest>, import("@powersync/lib-services-framework").EndpointHandler<import("./router.js").RequestEndpointHandlerPayload<{
666
- client_id?: string | undefined;
667
- }, import("./router.js").Context, import("./router.js").BasicRouterRequest>, {
668
- checkpoint: bigint;
669
- }>> & {
670
- path: string;
671
- method: import("@powersync/lib-services-framework").HTTPMethod.GET;
672
- authorize: (payload: import("./router.js").RequestEndpointHandlerPayload) => Promise<import("@powersync/lib-services-framework").AuthorizationResponse>;
673
- validator: import("@powersync/lib-services-framework").MicroValidator<{
674
- client_id?: string | undefined;
675
- }, string[]>;
676
- handler: (payload: import("./router.js").RequestEndpointHandlerPayload<{
677
- client_id?: string | undefined;
678
- }, import("./router.js").Context, import("./router.js").BasicRouterRequest>) => Promise<{
679
- checkpoint: bigint;
680
- }>;
681
- }) | (import("@powersync/lib-services-framework").Endpoint<{
682
- client_id?: string | undefined;
683
- }, {
684
- write_checkpoint: string;
685
- }, import("./router.js").Context, import("./router.js").RequestEndpointHandlerPayload<{
686
- client_id?: string | undefined;
687
- }, import("./router.js").Context, import("./router.js").BasicRouterRequest>, import("@powersync/lib-services-framework").EndpointHandler<import("./router.js").RequestEndpointHandlerPayload<{
688
- client_id?: string | undefined;
689
- }, import("./router.js").Context, import("./router.js").BasicRouterRequest>, {
690
- write_checkpoint: string;
691
- }>> & {
692
- path: string;
693
- method: import("@powersync/lib-services-framework").HTTPMethod.GET;
694
- authorize: (payload: import("./router.js").RequestEndpointHandlerPayload) => Promise<import("@powersync/lib-services-framework").AuthorizationResponse>;
695
- validator: import("@powersync/lib-services-framework").MicroValidator<{
696
- client_id?: string | undefined;
697
- }, string[]>;
698
- handler: (payload: import("./router.js").RequestEndpointHandlerPayload<{
699
- client_id?: string | undefined;
700
- }, import("./router.js").Context, import("./router.js").BasicRouterRequest>) => Promise<{
701
- write_checkpoint: string;
702
- }>;
703
660
  }) | (import("@powersync/lib-services-framework").Endpoint<unknown, import("@powersync/lib-services-framework").RouterResponse<{
704
661
  ready: boolean;
705
662
  started: boolean;
@@ -805,6 +762,88 @@ export declare const DEFAULT_ROUTE_OPTIONS: {
805
762
  max_queue_depth: number;
806
763
  };
807
764
  };
765
+ checkpointing: {
766
+ routes: ((import("@powersync/lib-services-framework").Endpoint<{
767
+ client_id?: string | undefined;
768
+ }, {
769
+ checkpoint: bigint;
770
+ }, import("./router.js").Context, import("./router.js").RequestEndpointHandlerPayload<{
771
+ client_id?: string | undefined;
772
+ }, import("./router.js").Context, import("./router.js").BasicRouterRequest>, import("@powersync/lib-services-framework").EndpointHandler<import("./router.js").RequestEndpointHandlerPayload<{
773
+ client_id?: string | undefined;
774
+ }, import("./router.js").Context, import("./router.js").BasicRouterRequest>, {
775
+ checkpoint: bigint;
776
+ }>> & {
777
+ path: string;
778
+ method: import("@powersync/lib-services-framework").HTTPMethod.GET;
779
+ authorize: (payload: import("./router.js").RequestEndpointHandlerPayload) => Promise<import("@powersync/lib-services-framework").AuthorizationResponse>;
780
+ validator: import("@powersync/lib-services-framework").MicroValidator<{
781
+ client_id?: string | undefined;
782
+ }, string[]>;
783
+ handler: (payload: import("./router.js").RequestEndpointHandlerPayload<{
784
+ client_id?: string | undefined;
785
+ }, import("./router.js").Context, import("./router.js").BasicRouterRequest>) => Promise<{
786
+ checkpoint: bigint;
787
+ }>;
788
+ }) | (import("@powersync/lib-services-framework").Endpoint<{
789
+ client_id?: string | undefined;
790
+ }, {
791
+ write_checkpoint: string;
792
+ }, import("./router.js").Context, import("./router.js").RequestEndpointHandlerPayload<{
793
+ client_id?: string | undefined;
794
+ }, import("./router.js").Context, import("./router.js").BasicRouterRequest>, import("@powersync/lib-services-framework").EndpointHandler<import("./router.js").RequestEndpointHandlerPayload<{
795
+ client_id?: string | undefined;
796
+ }, import("./router.js").Context, import("./router.js").BasicRouterRequest>, {
797
+ write_checkpoint: string;
798
+ }>> & {
799
+ path: string;
800
+ method: import("@powersync/lib-services-framework").HTTPMethod.GET;
801
+ authorize: (payload: import("./router.js").RequestEndpointHandlerPayload) => Promise<import("@powersync/lib-services-framework").AuthorizationResponse>;
802
+ validator: import("@powersync/lib-services-framework").MicroValidator<{
803
+ client_id?: string | undefined;
804
+ }, string[]>;
805
+ handler: (payload: import("./router.js").RequestEndpointHandlerPayload<{
806
+ client_id?: string | undefined;
807
+ }, import("./router.js").Context, import("./router.js").BasicRouterRequest>) => Promise<{
808
+ write_checkpoint: string;
809
+ }>;
810
+ }) | (import("@powersync/lib-services-framework").Endpoint<{
811
+ client_id: string;
812
+ checkpoint_request_id: string | number | bigint;
813
+ }, {
814
+ checkpoint_request_id: string;
815
+ }, import("./router.js").Context, import("./router.js").RequestEndpointHandlerPayload<{
816
+ client_id: string;
817
+ checkpoint_request_id: string | number | bigint;
818
+ }, import("./router.js").Context, import("./router.js").BasicRouterRequest>, import("@powersync/lib-services-framework").EndpointHandler<import("./router.js").RequestEndpointHandlerPayload<{
819
+ client_id: string;
820
+ checkpoint_request_id: string | number | bigint;
821
+ }, import("./router.js").Context, import("./router.js").BasicRouterRequest>, {
822
+ checkpoint_request_id: string;
823
+ }>> & {
824
+ path: string;
825
+ method: import("@powersync/lib-services-framework").HTTPMethod.POST;
826
+ authorize: (payload: import("./router.js").RequestEndpointHandlerPayload) => Promise<import("@powersync/lib-services-framework").AuthorizationResponse>;
827
+ validator: {
828
+ validate(params: {
829
+ client_id: string;
830
+ checkpoint_request_id: string | number | bigint;
831
+ }): import("@powersync/lib-services-framework").ValidationLeft<string[]> | {
832
+ valid: true;
833
+ };
834
+ };
835
+ handler: (request: import("./router.js").RequestEndpointHandlerPayload<{
836
+ client_id: string;
837
+ checkpoint_request_id: string | number | bigint;
838
+ }, import("./router.js").Context, import("./router.js").BasicRouterRequest>) => Promise<{
839
+ checkpoint_request_id: string;
840
+ }>;
841
+ }))[];
842
+ queue_options: {
843
+ concurrency: number;
844
+ max_queue_depth: number;
845
+ };
846
+ };
808
847
  sync_stream: {
809
848
  routes: (import("@powersync/lib-services-framework").Endpoint<{
810
849
  parameters?: Record<string, any> | undefined;
@@ -7,12 +7,20 @@ import { SYNC_STREAM_ROUTES } from './endpoints/sync-stream.js';
7
7
  import { createRequestQueueHook } from './hooks.js';
8
8
  export const DEFAULT_ROUTE_OPTIONS = {
9
9
  api: {
10
- routes: [...ADMIN_ROUTES, ...CHECKPOINT_ROUTES, ...SYNC_RULES_ROUTES, ...PROBES_ROUTES],
10
+ routes: [...ADMIN_ROUTES, ...SYNC_RULES_ROUTES, ...PROBES_ROUTES],
11
11
  queue_options: {
12
12
  concurrency: 10,
13
13
  max_queue_depth: 20
14
14
  }
15
15
  },
16
+ checkpointing: {
17
+ routes: [...CHECKPOINT_ROUTES],
18
+ queue_options: {
19
+ // Note that the values here has an effect on WriteCheckpointBatcher
20
+ concurrency: 100,
21
+ max_queue_depth: 100
22
+ }
23
+ },
16
24
  sync_stream: {
17
25
  routes: [...SYNC_STREAM_ROUTES],
18
26
  queue_options: {
@@ -35,6 +43,7 @@ export function configureFastifyServer(server, options) {
35
43
  };
36
44
  // Set on the outer server so both child scopes inherit.
37
45
  registerFastifyErrorHandler(server);
46
+ registerFastifyNotFoundHandler(server);
38
47
  /**
39
48
  * Fastify creates an encapsulated context for each `.register` call.
40
49
  * Creating a separate context here to separate the concurrency limits for Admin APIs
@@ -43,10 +52,14 @@ export function configureFastifyServer(server, options) {
43
52
  */
44
53
  server.register(async function (childContext) {
45
54
  registerFastifyRoutes(childContext, generateContext, routes.api?.routes ?? DEFAULT_ROUTE_OPTIONS.api.routes);
46
- registerFastifyNotFoundHandler(childContext);
47
55
  // Limit the active concurrent requests
48
56
  childContext.addHook('onRequest', createRequestQueueHook(routes.api?.queue_options ?? DEFAULT_ROUTE_OPTIONS.api.queue_options));
49
57
  });
58
+ server.register(async function (childContext) {
59
+ registerFastifyRoutes(childContext, generateContext, routes.checkpointing?.routes ?? DEFAULT_ROUTE_OPTIONS.checkpointing.routes);
60
+ // Limit the active concurrent requests
61
+ childContext.addHook('onRequest', createRequestQueueHook(routes.checkpointing?.queue_options ?? DEFAULT_ROUTE_OPTIONS.checkpointing.queue_options));
62
+ });
50
63
  // Create a separate context for concurrency queueing
51
64
  server.register(async function (childContext) {
52
65
  registerFastifyRoutes(childContext, generateContext, routes.sync_stream?.routes ?? DEFAULT_ROUTE_OPTIONS.sync_stream.routes);
@@ -1 +1 @@
1
- {"version":3,"file":"configure-fastify.js","sourceRoot":"","sources":["../../src/routes/configure-fastify.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,2BAA2B,EAC3B,8BAA8B,EAC9B,qBAAqB,EACtB,MAAM,qBAAqB,CAAC;AAI7B,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,sB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AAC,KAAK,WAAW,YAAY;QAC1C,qBAAqB,CACnB,YAAY,EACZ,eAAe,EACf,MAAM,CAAC,WAAW,EAAE,MAAM,IAAI,qBAAqB,CAAC,WAAW,CAAC,MAAM,CACvE,CAAC;QACF,uCAAuC;QACvC,YAAY,CAAC,OAAO,CAClB,WAAW,EACX,sBAAsB,CAAC,MAAM,CAAC,WAAW,EAAE,aAAa,IAAI,qBAAqB,CAAC,WAAW,CAAC,aAAa,CAAC,CAC7G,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"configure-fastify.js","sourceRoot":"","sources":["../../src/routes/configure-fastify.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,2BAA2B,EAC3B,8BAA8B,EAC9B,qBAAqB,EACtB,MAAM,qBAAqB,CAAC;AAI7B,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAA4B,MAAM,YAAY,CAAC;AA2B9E,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,GAAG,EAAE;QACH,MAAM,EAAE,CAAC,GAAG,YAAY,EAAE,GAAG,iBAAiB,EAAE,GAAG,aAAa,CAAC;QACjE,aAAa,EAAE;YACb,WAAW,EAAE,EAAE;YACf,eAAe,EAAE,EAAE;SACpB;KACF;IACD,aAAa,EAAE;QACb,MAAM,EAAE,CAAC,GAAG,iBAAiB,CAAC;QAC9B,aAAa,EAAE;YACb,oEAAoE;YACpE,WAAW,EAAE,GAAG;YAChB,eAAe,EAAE,GAAG;SACrB;KACF;IACD,WAAW,EAAE;QACX,MAAM,EAAE,CAAC,GAAG,kBAA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AEH,qDAAqD;IACrD,MAAM,CAAC,QAAQ,CAAC,KAAK,WAAW,YAAY;QAC1C,qBAAqB,CACnB,YAAY,EACZ,eAAe,EACf,MAAM,CAAC,WAAW,EAAE,MAAM,IAAI,qBAAqB,CAAC,WAAW,CAAC,MAAM,CACvE,CAAC;QACF,uCAAuC;QACvC,YAAY,CAAC,OAAO,CAClB,WAAW,EACX,sBAAsB,CAAC,MAAM,CAAC,WAAW,EAAE,aAAa,IAAI,qBAAqB,CAAC,WAAW,CAAC,aAAa,CAAC,CAC7G,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -80,8 +80,8 @@ export declare const diagnostics: router.Endpoint<{
80
80
  ts?: string | undefined;
81
81
  }[];
82
82
  id: string;
83
- postgres_uri: string;
84
83
  connected: boolean;
84
+ postgres_uri: string;
85
85
  }[];
86
86
  active_sync_rules?: {
87
87
  errors: {
@@ -183,8 +183,8 @@ export declare const diagnostics: router.Endpoint<{
183
183
  ts?: string | undefined;
184
184
  }[];
185
185
  id: string;
186
- postgres_uri: string;
187
186
  connected: boolean;
187
+ postgres_uri: string;
188
188
  }[];
189
189
  active_sync_rules?: {
190
190
  errors: {
@@ -297,8 +297,8 @@ export declare const diagnostics: router.Endpoint<{
297
297
  ts?: string | undefined;
298
298
  }[];
299
299
  id: string;
300
- postgres_uri: string;
301
300
  connected: boolean;
301
+ postgres_uri: string;
302
302
  }[];
303
303
  active_sync_rules?: {
304
304
  errors: {
@@ -405,8 +405,8 @@ export declare const getSchema: router.Endpoint<{}, {
405
405
  }[];
406
406
  id?: string | undefined;
407
407
  }[];
408
- defaultConnectionTag: string;
409
408
  defaultSchema: string;
409
+ defaultConnectionTag: string;
410
410
  }, import("../router.js").Context, import("../router.js").RequestEndpointHandlerPayload<{}, import("../router.js").Context, import("../router.js").BasicRouterRequest>, router.EndpointHandler<import("../router.js").RequestEndpointHandlerPayload<{}, import("../router.js").Context, import("../router.js").BasicRouterRequest>, {
411
411
  connections: {
412
412
  tag: string;
@@ -426,8 +426,8 @@ export declare const getSchema: router.Endpoint<{}, {
426
426
  }[];
427
427
  id?: string | undefined;
428
428
  }[];
429
- defaultConnectionTag: string;
430
429
  defaultSchema: string;
430
+ defaultConnectionTag: string;
431
431
  }>> & {
432
432
  path: string;
433
433
  method: router.HTTPMethod.POST;
@@ -458,8 +458,8 @@ export declare const getSchema: router.Endpoint<{}, {
458
458
  }[];
459
459
  id?: string | undefined;
460
460
  }[];
461
- defaultConnectionTag: string;
462
461
  defaultSchema: string;
462
+ defaultConnectionTag: string;
463
463
  }>;
464
464
  };
465
465
  export declare const reprocess: router.Endpoint<{}, {
@@ -508,8 +508,6 @@ export declare const validate: router.Endpoint<{
508
508
  connections: {
509
509
  id: string;
510
510
  tag: string;
511
- slot_name: string;
512
- initial_replication_done: boolean;
513
511
  tables: {
514
512
  name: string;
515
513
  schema: string;
@@ -527,6 +525,8 @@ export declare const validate: router.Endpoint<{
527
525
  }[];
528
526
  pattern?: string | undefined;
529
527
  }[];
528
+ slot_name: string;
529
+ initial_replication_done: boolean;
530
530
  last_lsn?: string | undefined;
531
531
  last_keepalive_ts?: string | undefined;
532
532
  last_checkpoint_ts?: string | undefined;
@@ -553,8 +553,6 @@ export declare const validate: router.Endpoint<{
553
553
  connections: {
554
554
  id: string;
555
555
  tag: string;
556
- slot_name: string;
557
- initial_replication_done: boolean;
558
556
  tables: {
559
557
  name: string;
560
558
  schema: string;
@@ -572,6 +570,8 @@ export declare const validate: router.Endpoint<{
572
570
  }[];
573
571
  pattern?: string | undefined;
574
572
  }[];
573
+ slot_name: string;
574
+ initial_replication_done: boolean;
575
575
  last_lsn?: string | undefined;
576
576
  last_keepalive_ts?: string | undefined;
577
577
  last_checkpoint_ts?: string | undefined;
@@ -609,8 +609,6 @@ export declare const validate: router.Endpoint<{
609
609
  connections: {
610
610
  id: string;
611
611
  tag: string;
612
- slot_name: string;
613
- initial_replication_done: boolean;
614
612
  tables: {
615
613
  name: string;
616
614
  schema: string;
@@ -628,6 +626,8 @@ export declare const validate: router.Endpoint<{
628
626
  }[];
629
627
  pattern?: string | undefined;
630
628
  }[];
629
+ slot_name: string;
630
+ initial_replication_done: boolean;
631
631
  last_lsn?: string | undefined;
632
632
  last_keepalive_ts?: string | undefined;
633
633
  last_checkpoint_ts?: string | undefined;
@@ -716,8 +716,8 @@ export declare const ADMIN_ROUTES: ((router.Endpoint<{
716
716
  ts?: string | undefined;
717
717
  }[];
718
718
  id: string;
719
- postgres_uri: string;
720
719
  connected: boolean;
720
+ postgres_uri: string;
721
721
  }[];
722
722
  active_sync_rules?: {
723
723
  errors: {
@@ -819,8 +819,8 @@ export declare const ADMIN_ROUTES: ((router.Endpoint<{
819
819
  ts?: string | undefined;
820
820
  }[];
821
821
  id: string;
822
- postgres_uri: string;
823
822
  connected: boolean;
823
+ postgres_uri: string;
824
824
  }[];
825
825
  active_sync_rules?: {
826
826
  errors: {
@@ -933,8 +933,8 @@ export declare const ADMIN_ROUTES: ((router.Endpoint<{
933
933
  ts?: string | undefined;
934
934
  }[];
935
935
  id: string;
936
- postgres_uri: string;
937
936
  connected: boolean;
937
+ postgres_uri: string;
938
938
  }[];
939
939
  active_sync_rules?: {
940
940
  errors: {
@@ -1040,8 +1040,8 @@ export declare const ADMIN_ROUTES: ((router.Endpoint<{
1040
1040
  }[];
1041
1041
  id?: string | undefined;
1042
1042
  }[];
1043
- defaultConnectionTag: string;
1044
1043
  defaultSchema: string;
1044
+ defaultConnectionTag: string;
1045
1045
  }, import("../router.js").Context, import("../router.js").RequestEndpointHandlerPayload<{}, import("../router.js").Context, import("../router.js").BasicRouterRequest>, router.EndpointHandler<import("../router.js").RequestEndpointHandlerPayload<{}, import("../router.js").Context, import("../router.js").BasicRouterRequest>, {
1046
1046
  connections: {
1047
1047
  tag: string;
@@ -1061,8 +1061,8 @@ export declare const ADMIN_ROUTES: ((router.Endpoint<{
1061
1061
  }[];
1062
1062
  id?: string | undefined;
1063
1063
  }[];
1064
- defaultConnectionTag: string;
1065
1064
  defaultSchema: string;
1065
+ defaultConnectionTag: string;
1066
1066
  }>> & {
1067
1067
  path: string;
1068
1068
  method: router.HTTPMethod.POST;
@@ -1093,8 +1093,8 @@ export declare const ADMIN_ROUTES: ((router.Endpoint<{
1093
1093
  }[];
1094
1094
  id?: string | undefined;
1095
1095
  }[];
1096
- defaultConnectionTag: string;
1097
1096
  defaultSchema: string;
1097
+ defaultConnectionTag: string;
1098
1098
  }>;
1099
1099
  }) | (router.Endpoint<{}, {
1100
1100
  connections: {
@@ -1141,8 +1141,6 @@ export declare const ADMIN_ROUTES: ((router.Endpoint<{
1141
1141
  connections: {
1142
1142
  id: string;
1143
1143
  tag: string;
1144
- slot_name: string;
1145
- initial_replication_done: boolean;
1146
1144
  tables: {
1147
1145
  name: string;
1148
1146
  schema: string;
@@ -1160,6 +1158,8 @@ export declare const ADMIN_ROUTES: ((router.Endpoint<{
1160
1158
  }[];
1161
1159
  pattern?: string | undefined;
1162
1160
  }[];
1161
+ slot_name: string;
1162
+ initial_replication_done: boolean;
1163
1163
  last_lsn?: string | undefined;
1164
1164
  last_keepalive_ts?: string | undefined;
1165
1165
  last_checkpoint_ts?: string | undefined;
@@ -1186,8 +1186,6 @@ export declare const ADMIN_ROUTES: ((router.Endpoint<{
1186
1186
  connections: {
1187
1187
  id: string;
1188
1188
  tag: string;
1189
- slot_name: string;
1190
- initial_replication_done: boolean;
1191
1189
  tables: {
1192
1190
  name: string;
1193
1191
  schema: string;
@@ -1205,6 +1203,8 @@ export declare const ADMIN_ROUTES: ((router.Endpoint<{
1205
1203
  }[];
1206
1204
  pattern?: string | undefined;
1207
1205
  }[];
1206
+ slot_name: string;
1207
+ initial_replication_done: boolean;
1208
1208
  last_lsn?: string | undefined;
1209
1209
  last_keepalive_ts?: string | undefined;
1210
1210
  last_checkpoint_ts?: string | undefined;
@@ -1242,8 +1242,6 @@ export declare const ADMIN_ROUTES: ((router.Endpoint<{
1242
1242
  connections: {
1243
1243
  id: string;
1244
1244
  tag: string;
1245
- slot_name: string;
1246
- initial_replication_done: boolean;
1247
1245
  tables: {
1248
1246
  name: string;
1249
1247
  schema: string;
@@ -1261,6 +1259,8 @@ export declare const ADMIN_ROUTES: ((router.Endpoint<{
1261
1259
  }[];
1262
1260
  pattern?: string | undefined;
1263
1261
  }[];
1262
+ slot_name: string;
1263
+ initial_replication_done: boolean;
1264
1264
  last_lsn?: string | undefined;
1265
1265
  last_keepalive_ts?: string | undefined;
1266
1266
  last_checkpoint_ts?: string | undefined;