@rocicorp/zero 1.12.0-canary.5 → 1.12.0-canary.7

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 (414) hide show
  1. package/out/replicache/src/btree/node.js +1 -1
  2. package/out/replicache/src/deleted-clients.d.ts.map +1 -1
  3. package/out/replicache/src/deleted-clients.js +2 -1
  4. package/out/replicache/src/deleted-clients.js.map +1 -1
  5. package/out/replicache/src/kv/sqlite-store.d.ts.map +1 -1
  6. package/out/replicache/src/kv/sqlite-store.js +7 -3
  7. package/out/replicache/src/kv/sqlite-store.js.map +1 -1
  8. package/out/replicache/src/replicache-impl.d.ts.map +1 -1
  9. package/out/replicache/src/replicache-impl.js +17 -14
  10. package/out/replicache/src/replicache-impl.js.map +1 -1
  11. package/out/z2s/src/compiler.js +3 -3
  12. package/out/z2s/src/compiler.js.map +1 -1
  13. package/out/zero/package.js +11 -11
  14. package/out/zero/package.js.map +1 -1
  15. package/out/zero-cache/src/auth/write-authorizer.js +9 -2
  16. package/out/zero-cache/src/auth/write-authorizer.js.map +1 -1
  17. package/out/zero-cache/src/config/zero-config.js +2 -2
  18. package/out/zero-cache/src/config/zero-config.js.map +1 -1
  19. package/out/zero-cache/src/server/change-streamer.js +33 -9
  20. package/out/zero-cache/src/server/change-streamer.js.map +1 -1
  21. package/out/zero-cache/src/services/change-source/common/replica-restore.js.map +1 -1
  22. package/out/zero-cache/src/services/change-source/pg/change-source-init.js +49 -24
  23. package/out/zero-cache/src/services/change-source/pg/change-source-init.js.map +1 -1
  24. package/out/zero-cache/src/services/change-source/pg/change-source.js +64 -7
  25. package/out/zero-cache/src/services/change-source/pg/change-source.js.map +1 -1
  26. package/out/zero-cache/src/services/change-source/pg/fork-request.js +54 -0
  27. package/out/zero-cache/src/services/change-source/pg/fork-request.js.map +1 -0
  28. package/out/zero-cache/src/services/change-source/pg/replication-slots.js +6 -0
  29. package/out/zero-cache/src/services/change-source/pg/replication-slots.js.map +1 -1
  30. package/out/zero-cache/src/services/change-source/protocol/current/downstream.d.ts +1 -0
  31. package/out/zero-cache/src/services/change-source/protocol/current/downstream.d.ts.map +1 -1
  32. package/out/zero-cache/src/services/change-source/protocol/current/status.d.ts +3 -0
  33. package/out/zero-cache/src/services/change-source/protocol/current/status.d.ts.map +1 -1
  34. package/out/zero-cache/src/services/change-source/protocol/current/status.js +2 -1
  35. package/out/zero-cache/src/services/change-source/protocol/current/status.js.map +1 -1
  36. package/out/zero-cache/src/services/change-source/protocol/current/upstream.d.ts +1 -0
  37. package/out/zero-cache/src/services/change-source/protocol/current/upstream.d.ts.map +1 -1
  38. package/out/zero-cache/src/services/change-streamer/backup-cleanup-monitor-factory.js +6 -6
  39. package/out/zero-cache/src/services/change-streamer/backup-cleanup-monitor-factory.js.map +1 -1
  40. package/out/zero-cache/src/services/change-streamer/backup-monitor.js +55 -20
  41. package/out/zero-cache/src/services/change-streamer/backup-monitor.js.map +1 -1
  42. package/out/zero-cache/src/services/change-streamer/change-streamer-service.js +27 -8
  43. package/out/zero-cache/src/services/change-streamer/change-streamer-service.js.map +1 -1
  44. package/out/zero-cache/src/services/change-streamer/change-streamer.js.map +1 -1
  45. package/out/zero-cache/src/services/change-streamer/litestream-sync-requester.js +80 -11
  46. package/out/zero-cache/src/services/change-streamer/litestream-sync-requester.js.map +1 -1
  47. package/out/zero-cache/src/services/change-streamer/litestream3-prometheus-poller.js.map +1 -1
  48. package/out/zero-cache/src/services/change-streamer/replica-poller.js.map +1 -1
  49. package/out/zero-cache/src/services/change-streamer/server-start-metrics.js +42 -0
  50. package/out/zero-cache/src/services/change-streamer/server-start-metrics.js.map +1 -0
  51. package/out/zero-cache/src/services/change-streamer/subscriber.js +5 -4
  52. package/out/zero-cache/src/services/change-streamer/subscriber.js.map +1 -1
  53. package/out/zero-cache/src/services/mutagen/mutagen.js +1 -2
  54. package/out/zero-cache/src/services/mutagen/mutagen.js.map +1 -1
  55. package/out/zero-cache/src/services/view-syncer/view-syncer.js +19 -2
  56. package/out/zero-cache/src/services/view-syncer/view-syncer.js.map +1 -1
  57. package/out/zero-client/src/client/version.js +1 -1
  58. package/out/zero-protocol/src/ast.d.ts.map +1 -1
  59. package/out/zero-protocol/src/ast.js +2 -1
  60. package/out/zero-protocol/src/ast.js.map +1 -1
  61. package/out/zero-protocol/src/down.d.ts +27 -27
  62. package/out/zero-protocol/src/inspect-down.d.ts +81 -81
  63. package/out/zero-protocol/src/up.d.ts +60 -60
  64. package/package.json +11 -11
  65. package/out/shared/src/cache.d.ts +0 -22
  66. package/out/shared/src/cache.d.ts.map +0 -1
  67. package/out/shared/src/custom-key-map.d.ts +0 -26
  68. package/out/shared/src/custom-key-map.d.ts.map +0 -1
  69. package/out/shared/src/custom-key-set.d.ts +0 -25
  70. package/out/shared/src/custom-key-set.d.ts.map +0 -1
  71. package/out/shared/src/logging-test-utils.d.ts +0 -12
  72. package/out/shared/src/logging-test-utils.d.ts.map +0 -1
  73. package/out/shared/src/queue.d.ts +0 -53
  74. package/out/shared/src/queue.d.ts.map +0 -1
  75. package/out/shared/src/ring-buffer.d.ts +0 -42
  76. package/out/shared/src/ring-buffer.d.ts.map +0 -1
  77. package/out/shared/src/sorted-entries.d.ts +0 -2
  78. package/out/shared/src/sorted-entries.d.ts.map +0 -1
  79. package/out/zero/src/server/change-streamer.d.ts +0 -2
  80. package/out/zero/src/server/change-streamer.d.ts.map +0 -1
  81. package/out/zero/src/server/main.d.ts +0 -2
  82. package/out/zero/src/server/main.d.ts.map +0 -1
  83. package/out/zero/src/server/reaper.d.ts +0 -2
  84. package/out/zero/src/server/reaper.d.ts.map +0 -1
  85. package/out/zero/src/server/replicator.d.ts +0 -2
  86. package/out/zero/src/server/replicator.d.ts.map +0 -1
  87. package/out/zero/src/server/syncer.d.ts +0 -2
  88. package/out/zero/src/server/syncer.d.ts.map +0 -1
  89. package/out/zero-cache/src/auth/jwt.d.ts +0 -12
  90. package/out/zero-cache/src/auth/jwt.d.ts.map +0 -1
  91. package/out/zero-cache/src/auth/load-permissions.d.ts +0 -17
  92. package/out/zero-cache/src/auth/load-permissions.d.ts.map +0 -1
  93. package/out/zero-cache/src/auth/write-authorizer.d.ts +0 -28
  94. package/out/zero-cache/src/auth/write-authorizer.d.ts.map +0 -1
  95. package/out/zero-cache/src/config/server-context.d.ts +0 -16
  96. package/out/zero-cache/src/config/server-context.d.ts.map +0 -1
  97. package/out/zero-cache/src/custom/fetch.d.ts +0 -38
  98. package/out/zero-cache/src/custom/fetch.d.ts.map +0 -1
  99. package/out/zero-cache/src/custom/metrics.d.ts +0 -31
  100. package/out/zero-cache/src/custom/metrics.d.ts.map +0 -1
  101. package/out/zero-cache/src/custom-queries/transform-query.d.ts +0 -68
  102. package/out/zero-cache/src/custom-queries/transform-query.d.ts.map +0 -1
  103. package/out/zero-cache/src/db/create.d.ts +0 -12
  104. package/out/zero-cache/src/db/create.d.ts.map +0 -1
  105. package/out/zero-cache/src/db/delete-lite-db.d.ts +0 -2
  106. package/out/zero-cache/src/db/delete-lite-db.d.ts.map +0 -1
  107. package/out/zero-cache/src/db/index-predicate.d.ts +0 -4
  108. package/out/zero-cache/src/db/index-predicate.d.ts.map +0 -1
  109. package/out/zero-cache/src/db/migration-lite.d.ts +0 -78
  110. package/out/zero-cache/src/db/migration-lite.d.ts.map +0 -1
  111. package/out/zero-cache/src/db/migration.d.ts +0 -80
  112. package/out/zero-cache/src/db/migration.d.ts.map +0 -1
  113. package/out/zero-cache/src/db/pg-copy-binary.d.ts +0 -101
  114. package/out/zero-cache/src/db/pg-copy-binary.d.ts.map +0 -1
  115. package/out/zero-cache/src/db/pg-copy.d.ts +0 -30
  116. package/out/zero-cache/src/db/pg-copy.d.ts.map +0 -1
  117. package/out/zero-cache/src/db/pg-type-parser.d.ts +0 -15
  118. package/out/zero-cache/src/db/pg-type-parser.d.ts.map +0 -1
  119. package/out/zero-cache/src/db/transaction-pool.d.ts +0 -205
  120. package/out/zero-cache/src/db/transaction-pool.d.ts.map +0 -1
  121. package/out/zero-cache/src/db/warmup.d.ts +0 -4
  122. package/out/zero-cache/src/db/warmup.d.ts.map +0 -1
  123. package/out/zero-cache/src/observability/events.d.ts +0 -15
  124. package/out/zero-cache/src/observability/events.d.ts.map +0 -1
  125. package/out/zero-cache/src/observability/log-throttle.d.ts +0 -44
  126. package/out/zero-cache/src/observability/log-throttle.d.ts.map +0 -1
  127. package/out/zero-cache/src/server/anonymous-otel-start.d.ts +0 -21
  128. package/out/zero-cache/src/server/anonymous-otel-start.d.ts.map +0 -1
  129. package/out/zero-cache/src/server/change-streamer.d.ts +0 -3
  130. package/out/zero-cache/src/server/change-streamer.d.ts.map +0 -1
  131. package/out/zero-cache/src/server/inspector-delegate.d.ts +0 -71
  132. package/out/zero-cache/src/server/inspector-delegate.d.ts.map +0 -1
  133. package/out/zero-cache/src/server/main.d.ts +0 -3
  134. package/out/zero-cache/src/server/main.d.ts.map +0 -1
  135. package/out/zero-cache/src/server/otel-diag-logger.d.ts +0 -16
  136. package/out/zero-cache/src/server/otel-diag-logger.d.ts.map +0 -1
  137. package/out/zero-cache/src/server/otel-start.d.ts +0 -3
  138. package/out/zero-cache/src/server/otel-start.d.ts.map +0 -1
  139. package/out/zero-cache/src/server/priority-op.d.ts +0 -8
  140. package/out/zero-cache/src/server/priority-op.d.ts.map +0 -1
  141. package/out/zero-cache/src/server/reaper.d.ts +0 -3
  142. package/out/zero-cache/src/server/reaper.d.ts.map +0 -1
  143. package/out/zero-cache/src/server/replicator.d.ts +0 -10
  144. package/out/zero-cache/src/server/replicator.d.ts.map +0 -1
  145. package/out/zero-cache/src/server/slot-keeper.d.ts +0 -26
  146. package/out/zero-cache/src/server/slot-keeper.d.ts.map +0 -1
  147. package/out/zero-cache/src/server/syncer-assigner.d.ts +0 -14
  148. package/out/zero-cache/src/server/syncer-assigner.d.ts.map +0 -1
  149. package/out/zero-cache/src/server/syncer.d.ts +0 -3
  150. package/out/zero-cache/src/server/syncer.d.ts.map +0 -1
  151. package/out/zero-cache/src/server/worker-dispatcher.d.ts +0 -17
  152. package/out/zero-cache/src/server/worker-dispatcher.d.ts.map +0 -1
  153. package/out/zero-cache/src/services/analyze.d.ts +0 -9
  154. package/out/zero-cache/src/services/analyze.d.ts.map +0 -1
  155. package/out/zero-cache/src/services/change-source/change-source.d.ts +0 -32
  156. package/out/zero-cache/src/services/change-source/change-source.d.ts.map +0 -1
  157. package/out/zero-cache/src/services/change-source/common/backfill-manager.d.ts +0 -57
  158. package/out/zero-cache/src/services/change-source/common/backfill-manager.d.ts.map +0 -1
  159. package/out/zero-cache/src/services/change-source/common/change-stream-multiplexer.d.ts +0 -55
  160. package/out/zero-cache/src/services/change-source/common/change-stream-multiplexer.d.ts.map +0 -1
  161. package/out/zero-cache/src/services/change-source/common/init-cleanup.d.ts +0 -24
  162. package/out/zero-cache/src/services/change-source/common/init-cleanup.d.ts.map +0 -1
  163. package/out/zero-cache/src/services/change-source/common/replica-restore.d.ts +0 -115
  164. package/out/zero-cache/src/services/change-source/common/replica-restore.d.ts.map +0 -1
  165. package/out/zero-cache/src/services/change-source/common/replica-schema.d.ts +0 -14
  166. package/out/zero-cache/src/services/change-source/common/replica-schema.d.ts.map +0 -1
  167. package/out/zero-cache/src/services/change-source/custom/change-source.d.ts +0 -25
  168. package/out/zero-cache/src/services/change-source/custom/change-source.d.ts.map +0 -1
  169. package/out/zero-cache/src/services/change-source/pg/backfill-metadata.d.ts +0 -14
  170. package/out/zero-cache/src/services/change-source/pg/backfill-metadata.d.ts.map +0 -1
  171. package/out/zero-cache/src/services/change-source/pg/backfill-stream.d.ts +0 -36
  172. package/out/zero-cache/src/services/change-source/pg/backfill-stream.d.ts.map +0 -1
  173. package/out/zero-cache/src/services/change-source/pg/change-source-init.d.ts +0 -65
  174. package/out/zero-cache/src/services/change-source/pg/change-source-init.d.ts.map +0 -1
  175. package/out/zero-cache/src/services/change-source/pg/change-source.d.ts +0 -115
  176. package/out/zero-cache/src/services/change-source/pg/change-source.d.ts.map +0 -1
  177. package/out/zero-cache/src/services/change-source/pg/initial-sync.d.ts +0 -155
  178. package/out/zero-cache/src/services/change-source/pg/initial-sync.d.ts.map +0 -1
  179. package/out/zero-cache/src/services/change-source/pg/logical-replication/binary-reader.d.ts +0 -17
  180. package/out/zero-cache/src/services/change-source/pg/logical-replication/binary-reader.d.ts.map +0 -1
  181. package/out/zero-cache/src/services/change-source/pg/logical-replication/pgoutput-parser.d.ts +0 -28
  182. package/out/zero-cache/src/services/change-source/pg/logical-replication/pgoutput-parser.d.ts.map +0 -1
  183. package/out/zero-cache/src/services/change-source/pg/logical-replication/pgoutput.types.d.ts +0 -76
  184. package/out/zero-cache/src/services/change-source/pg/logical-replication/pgoutput.types.d.ts.map +0 -1
  185. package/out/zero-cache/src/services/change-source/pg/logical-replication/stream.d.ts +0 -169
  186. package/out/zero-cache/src/services/change-source/pg/logical-replication/stream.d.ts.map +0 -1
  187. package/out/zero-cache/src/services/change-source/pg/replication-slot-cleanup-monitor.d.ts +0 -16
  188. package/out/zero-cache/src/services/change-source/pg/replication-slot-cleanup-monitor.d.ts.map +0 -1
  189. package/out/zero-cache/src/services/change-source/pg/replication-slot-health.d.ts +0 -15
  190. package/out/zero-cache/src/services/change-source/pg/replication-slot-health.d.ts.map +0 -1
  191. package/out/zero-cache/src/services/change-source/pg/replication-slots.d.ts +0 -127
  192. package/out/zero-cache/src/services/change-source/pg/replication-slots.d.ts.map +0 -1
  193. package/out/zero-cache/src/services/change-source/pg/schema/init.d.ts +0 -9
  194. package/out/zero-cache/src/services/change-source/pg/schema/init.d.ts.map +0 -1
  195. package/out/zero-cache/src/services/change-source/protocol/backfill-progress.d.ts +0 -68
  196. package/out/zero-cache/src/services/change-source/protocol/backfill-progress.d.ts.map +0 -1
  197. package/out/zero-cache/src/services/change-streamer/backfill-state-tracker.d.ts +0 -72
  198. package/out/zero-cache/src/services/change-streamer/backfill-state-tracker.d.ts.map +0 -1
  199. package/out/zero-cache/src/services/change-streamer/backfill-state.d.ts +0 -50
  200. package/out/zero-cache/src/services/change-streamer/backfill-state.d.ts.map +0 -1
  201. package/out/zero-cache/src/services/change-streamer/backup-cleanup-monitor-factory.d.ts +0 -14
  202. package/out/zero-cache/src/services/change-streamer/backup-cleanup-monitor-factory.d.ts.map +0 -1
  203. package/out/zero-cache/src/services/change-streamer/backup-monitor.d.ts +0 -18
  204. package/out/zero-cache/src/services/change-streamer/backup-monitor.d.ts.map +0 -1
  205. package/out/zero-cache/src/services/change-streamer/broadcast.d.ts +0 -98
  206. package/out/zero-cache/src/services/change-streamer/broadcast.d.ts.map +0 -1
  207. package/out/zero-cache/src/services/change-streamer/change-log-codec.d.ts +0 -34
  208. package/out/zero-cache/src/services/change-streamer/change-log-codec.d.ts.map +0 -1
  209. package/out/zero-cache/src/services/change-streamer/change-log-compare-digest.d.ts +0 -34
  210. package/out/zero-cache/src/services/change-streamer/change-log-compare-digest.d.ts.map +0 -1
  211. package/out/zero-cache/src/services/change-streamer/change-log-initializer.d.ts +0 -158
  212. package/out/zero-cache/src/services/change-streamer/change-log-initializer.d.ts.map +0 -1
  213. package/out/zero-cache/src/services/change-streamer/change-log-transaction-hash.d.ts +0 -19
  214. package/out/zero-cache/src/services/change-streamer/change-log-transaction-hash.d.ts.map +0 -1
  215. package/out/zero-cache/src/services/change-streamer/change-streamer-http.d.ts +0 -78
  216. package/out/zero-cache/src/services/change-streamer/change-streamer-http.d.ts.map +0 -1
  217. package/out/zero-cache/src/services/change-streamer/change-streamer-service.d.ts +0 -143
  218. package/out/zero-cache/src/services/change-streamer/change-streamer-service.d.ts.map +0 -1
  219. package/out/zero-cache/src/services/change-streamer/change-streamer.d.ts +0 -586
  220. package/out/zero-cache/src/services/change-streamer/change-streamer.d.ts.map +0 -1
  221. package/out/zero-cache/src/services/change-streamer/drain-tracker.d.ts +0 -24
  222. package/out/zero-cache/src/services/change-streamer/drain-tracker.d.ts.map +0 -1
  223. package/out/zero-cache/src/services/change-streamer/error-type-enum.d.ts +0 -15
  224. package/out/zero-cache/src/services/change-streamer/error-type-enum.d.ts.map +0 -1
  225. package/out/zero-cache/src/services/change-streamer/forwarder.d.ts +0 -49
  226. package/out/zero-cache/src/services/change-streamer/forwarder.d.ts.map +0 -1
  227. package/out/zero-cache/src/services/change-streamer/litestream-sync-requester.d.ts +0 -53
  228. package/out/zero-cache/src/services/change-streamer/litestream-sync-requester.d.ts.map +0 -1
  229. package/out/zero-cache/src/services/change-streamer/litestream3-prometheus-poller.d.ts +0 -88
  230. package/out/zero-cache/src/services/change-streamer/litestream3-prometheus-poller.d.ts.map +0 -1
  231. package/out/zero-cache/src/services/change-streamer/replica-poller.d.ts +0 -15
  232. package/out/zero-cache/src/services/change-streamer/replica-poller.d.ts.map +0 -1
  233. package/out/zero-cache/src/services/change-streamer/restore-admission.d.ts +0 -243
  234. package/out/zero-cache/src/services/change-streamer/restore-admission.d.ts.map +0 -1
  235. package/out/zero-cache/src/services/change-streamer/schema/init.d.ts +0 -6
  236. package/out/zero-cache/src/services/change-streamer/schema/init.d.ts.map +0 -1
  237. package/out/zero-cache/src/services/change-streamer/schema/tables.d.ts +0 -152
  238. package/out/zero-cache/src/services/change-streamer/schema/tables.d.ts.map +0 -1
  239. package/out/zero-cache/src/services/change-streamer/shard-sampling.d.ts +0 -11
  240. package/out/zero-cache/src/services/change-streamer/shard-sampling.d.ts.map +0 -1
  241. package/out/zero-cache/src/services/change-streamer/snapshot-message.d.ts +0 -92
  242. package/out/zero-cache/src/services/change-streamer/snapshot-message.d.ts.map +0 -1
  243. package/out/zero-cache/src/services/change-streamer/snapshot-reservations.d.ts +0 -36
  244. package/out/zero-cache/src/services/change-streamer/snapshot-reservations.d.ts.map +0 -1
  245. package/out/zero-cache/src/services/change-streamer/snapshot.d.ts +0 -22
  246. package/out/zero-cache/src/services/change-streamer/snapshot.d.ts.map +0 -1
  247. package/out/zero-cache/src/services/change-streamer/sqlite-change-log-catchup.d.ts +0 -99
  248. package/out/zero-cache/src/services/change-streamer/sqlite-change-log-catchup.d.ts.map +0 -1
  249. package/out/zero-cache/src/services/change-streamer/sqlite-change-log-comparator.d.ts +0 -83
  250. package/out/zero-cache/src/services/change-streamer/sqlite-change-log-comparator.d.ts.map +0 -1
  251. package/out/zero-cache/src/services/change-streamer/sqlite-change-log-purge-scheduler.d.ts +0 -121
  252. package/out/zero-cache/src/services/change-streamer/sqlite-change-log-purge-scheduler.d.ts.map +0 -1
  253. package/out/zero-cache/src/services/change-streamer/sqlite-change-log-read-router.d.ts +0 -73
  254. package/out/zero-cache/src/services/change-streamer/sqlite-change-log-read-router.d.ts.map +0 -1
  255. package/out/zero-cache/src/services/change-streamer/sqlite-change-log-reader.d.ts +0 -62
  256. package/out/zero-cache/src/services/change-streamer/sqlite-change-log-reader.d.ts.map +0 -1
  257. package/out/zero-cache/src/services/change-streamer/sqlite-change-log-writer.d.ts +0 -114
  258. package/out/zero-cache/src/services/change-streamer/sqlite-change-log-writer.d.ts.map +0 -1
  259. package/out/zero-cache/src/services/change-streamer/storer.d.ts +0 -276
  260. package/out/zero-cache/src/services/change-streamer/storer.d.ts.map +0 -1
  261. package/out/zero-cache/src/services/change-streamer/subscribe.d.ts +0 -485
  262. package/out/zero-cache/src/services/change-streamer/subscribe.d.ts.map +0 -1
  263. package/out/zero-cache/src/services/change-streamer/subscriber.d.ts +0 -194
  264. package/out/zero-cache/src/services/change-streamer/subscriber.d.ts.map +0 -1
  265. package/out/zero-cache/src/services/change-streamer/upstream-acker.d.ts +0 -52
  266. package/out/zero-cache/src/services/change-streamer/upstream-acker.d.ts.map +0 -1
  267. package/out/zero-cache/src/services/limiter/sliding-window-limiter.d.ts +0 -57
  268. package/out/zero-cache/src/services/limiter/sliding-window-limiter.d.ts.map +0 -1
  269. package/out/zero-cache/src/services/litestream/commands.d.ts +0 -77
  270. package/out/zero-cache/src/services/litestream/commands.d.ts.map +0 -1
  271. package/out/zero-cache/src/services/litestream/litestream-controller.d.ts +0 -78
  272. package/out/zero-cache/src/services/litestream/litestream-controller.d.ts.map +0 -1
  273. package/out/zero-cache/src/services/litestream/metrics.d.ts +0 -31
  274. package/out/zero-cache/src/services/litestream/metrics.d.ts.map +0 -1
  275. package/out/zero-cache/src/services/litestream/restore-progress.d.ts +0 -24
  276. package/out/zero-cache/src/services/litestream/restore-progress.d.ts.map +0 -1
  277. package/out/zero-cache/src/services/mutagen/mutagen.d.ts +0 -40
  278. package/out/zero-cache/src/services/mutagen/mutagen.d.ts.map +0 -1
  279. package/out/zero-cache/src/services/mutagen/pusher.d.ts +0 -63
  280. package/out/zero-cache/src/services/mutagen/pusher.d.ts.map +0 -1
  281. package/out/zero-cache/src/services/replicator/change-log-db.d.ts +0 -368
  282. package/out/zero-cache/src/services/replicator/change-log-db.d.ts.map +0 -1
  283. package/out/zero-cache/src/services/replicator/change-log-stream-writer.d.ts +0 -56
  284. package/out/zero-cache/src/services/replicator/change-log-stream-writer.d.ts.map +0 -1
  285. package/out/zero-cache/src/services/replicator/change-processor.d.ts +0 -37
  286. package/out/zero-cache/src/services/replicator/change-processor.d.ts.map +0 -1
  287. package/out/zero-cache/src/services/replicator/drain-handler.d.ts +0 -82
  288. package/out/zero-cache/src/services/replicator/drain-handler.d.ts.map +0 -1
  289. package/out/zero-cache/src/services/replicator/incremental-sync.d.ts +0 -25
  290. package/out/zero-cache/src/services/replicator/incremental-sync.d.ts.map +0 -1
  291. package/out/zero-cache/src/services/replicator/notifier.d.ts +0 -9
  292. package/out/zero-cache/src/services/replicator/notifier.d.ts.map +0 -1
  293. package/out/zero-cache/src/services/replicator/replication-status.d.ts +0 -71
  294. package/out/zero-cache/src/services/replicator/replication-status.d.ts.map +0 -1
  295. package/out/zero-cache/src/services/replicator/replicator.d.ts +0 -86
  296. package/out/zero-cache/src/services/replicator/replicator.d.ts.map +0 -1
  297. package/out/zero-cache/src/services/replicator/reporter/recorder.d.ts +0 -55
  298. package/out/zero-cache/src/services/replicator/reporter/recorder.d.ts.map +0 -1
  299. package/out/zero-cache/src/services/replicator/sqlite-change-log-observability.d.ts +0 -132
  300. package/out/zero-cache/src/services/replicator/sqlite-change-log-observability.d.ts.map +0 -1
  301. package/out/zero-cache/src/services/replicator/sqlite-change-log-purger.d.ts +0 -120
  302. package/out/zero-cache/src/services/replicator/sqlite-change-log-purger.d.ts.map +0 -1
  303. package/out/zero-cache/src/services/replicator/write-worker-client.d.ts +0 -111
  304. package/out/zero-cache/src/services/replicator/write-worker-client.d.ts.map +0 -1
  305. package/out/zero-cache/src/services/run-ast.d.ts +0 -39
  306. package/out/zero-cache/src/services/run-ast.d.ts.map +0 -1
  307. package/out/zero-cache/src/services/runner.d.ts +0 -19
  308. package/out/zero-cache/src/services/runner.d.ts.map +0 -1
  309. package/out/zero-cache/src/services/view-syncer/active-users-gauge.d.ts +0 -17
  310. package/out/zero-cache/src/services/view-syncer/active-users-gauge.d.ts.map +0 -1
  311. package/out/zero-cache/src/services/view-syncer/advancement-metrics.d.ts +0 -26
  312. package/out/zero-cache/src/services/view-syncer/advancement-metrics.d.ts.map +0 -1
  313. package/out/zero-cache/src/services/view-syncer/batch-pacer.d.ts +0 -79
  314. package/out/zero-cache/src/services/view-syncer/batch-pacer.d.ts.map +0 -1
  315. package/out/zero-cache/src/services/view-syncer/client-handler.d.ts +0 -97
  316. package/out/zero-cache/src/services/view-syncer/client-handler.d.ts.map +0 -1
  317. package/out/zero-cache/src/services/view-syncer/client-schema.d.ts +0 -18
  318. package/out/zero-cache/src/services/view-syncer/client-schema.d.ts.map +0 -1
  319. package/out/zero-cache/src/services/view-syncer/connection-context-manager.d.ts +0 -184
  320. package/out/zero-cache/src/services/view-syncer/connection-context-manager.d.ts.map +0 -1
  321. package/out/zero-cache/src/services/view-syncer/cvr-purger.d.ts +0 -22
  322. package/out/zero-cache/src/services/view-syncer/cvr-purger.d.ts.map +0 -1
  323. package/out/zero-cache/src/services/view-syncer/cvr-store.d.ts +0 -128
  324. package/out/zero-cache/src/services/view-syncer/cvr-store.d.ts.map +0 -1
  325. package/out/zero-cache/src/services/view-syncer/cvr.d.ts +0 -294
  326. package/out/zero-cache/src/services/view-syncer/cvr.d.ts.map +0 -1
  327. package/out/zero-cache/src/services/view-syncer/deferred-writes-budget.d.ts +0 -81
  328. package/out/zero-cache/src/services/view-syncer/deferred-writes-budget.d.ts.map +0 -1
  329. package/out/zero-cache/src/services/view-syncer/drain-coordinator.d.ts +0 -45
  330. package/out/zero-cache/src/services/view-syncer/drain-coordinator.d.ts.map +0 -1
  331. package/out/zero-cache/src/services/view-syncer/e2e-serving-lag.d.ts +0 -53
  332. package/out/zero-cache/src/services/view-syncer/e2e-serving-lag.d.ts.map +0 -1
  333. package/out/zero-cache/src/services/view-syncer/hydration-budget.d.ts +0 -33
  334. package/out/zero-cache/src/services/view-syncer/hydration-budget.d.ts.map +0 -1
  335. package/out/zero-cache/src/services/view-syncer/hydration-circuit-breaker.d.ts +0 -51
  336. package/out/zero-cache/src/services/view-syncer/hydration-circuit-breaker.d.ts.map +0 -1
  337. package/out/zero-cache/src/services/view-syncer/inspect-handler.d.ts +0 -34
  338. package/out/zero-cache/src/services/view-syncer/inspect-handler.d.ts.map +0 -1
  339. package/out/zero-cache/src/services/view-syncer/pipeline-driver.d.ts +0 -296
  340. package/out/zero-cache/src/services/view-syncer/pipeline-driver.d.ts.map +0 -1
  341. package/out/zero-cache/src/services/view-syncer/plan-warnings.d.ts +0 -7
  342. package/out/zero-cache/src/services/view-syncer/plan-warnings.d.ts.map +0 -1
  343. package/out/zero-cache/src/services/view-syncer/push-cost.d.ts +0 -132
  344. package/out/zero-cache/src/services/view-syncer/push-cost.d.ts.map +0 -1
  345. package/out/zero-cache/src/services/view-syncer/push-cutoff.d.ts +0 -55
  346. package/out/zero-cache/src/services/view-syncer/push-cutoff.d.ts.map +0 -1
  347. package/out/zero-cache/src/services/view-syncer/query-covering.d.ts +0 -28
  348. package/out/zero-cache/src/services/view-syncer/query-covering.d.ts.map +0 -1
  349. package/out/zero-cache/src/services/view-syncer/query-shape.d.ts +0 -25
  350. package/out/zero-cache/src/services/view-syncer/query-shape.d.ts.map +0 -1
  351. package/out/zero-cache/src/services/view-syncer/query-stats.d.ts +0 -89
  352. package/out/zero-cache/src/services/view-syncer/query-stats.d.ts.map +0 -1
  353. package/out/zero-cache/src/services/view-syncer/row-record-cache.d.ts +0 -90
  354. package/out/zero-cache/src/services/view-syncer/row-record-cache.d.ts.map +0 -1
  355. package/out/zero-cache/src/services/view-syncer/row-set-signature.d.ts +0 -17
  356. package/out/zero-cache/src/services/view-syncer/row-set-signature.d.ts.map +0 -1
  357. package/out/zero-cache/src/services/view-syncer/schema/cvr.d.ts +0 -86
  358. package/out/zero-cache/src/services/view-syncer/schema/cvr.d.ts.map +0 -1
  359. package/out/zero-cache/src/services/view-syncer/schema/init.d.ts +0 -5
  360. package/out/zero-cache/src/services/view-syncer/schema/init.d.ts.map +0 -1
  361. package/out/zero-cache/src/services/view-syncer/schema/types.d.ts +0 -563
  362. package/out/zero-cache/src/services/view-syncer/schema/types.d.ts.map +0 -1
  363. package/out/zero-cache/src/services/view-syncer/snapshot-row-cache.d.ts +0 -95
  364. package/out/zero-cache/src/services/view-syncer/snapshot-row-cache.d.ts.map +0 -1
  365. package/out/zero-cache/src/services/view-syncer/snapshotter.d.ts +0 -420
  366. package/out/zero-cache/src/services/view-syncer/snapshotter.d.ts.map +0 -1
  367. package/out/zero-cache/src/services/view-syncer/tracer.d.ts +0 -2
  368. package/out/zero-cache/src/services/view-syncer/tracer.d.ts.map +0 -1
  369. package/out/zero-cache/src/services/view-syncer/ttl-clock.d.ts +0 -10
  370. package/out/zero-cache/src/services/view-syncer/ttl-clock.d.ts.map +0 -1
  371. package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts +0 -133
  372. package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts.map +0 -1
  373. package/out/zero-cache/src/types/downstream.d.ts +0 -11
  374. package/out/zero-cache/src/types/downstream.d.ts.map +0 -1
  375. package/out/zero-cache/src/types/error-with-level.d.ts +0 -9
  376. package/out/zero-cache/src/types/error-with-level.d.ts.map +0 -1
  377. package/out/zero-cache/src/types/pg-patch.d.ts +0 -21
  378. package/out/zero-cache/src/types/pg-patch.d.ts.map +0 -1
  379. package/out/zero-cache/src/types/pg-versions.d.ts +0 -3
  380. package/out/zero-cache/src/types/pg-versions.d.ts.map +0 -1
  381. package/out/zero-cache/src/types/poke-chunk.d.ts +0 -18
  382. package/out/zero-cache/src/types/poke-chunk.d.ts.map +0 -1
  383. package/out/zero-cache/src/types/streams.d.ts +0 -115
  384. package/out/zero-cache/src/types/streams.d.ts.map +0 -1
  385. package/out/zero-cache/src/types/subscription.d.ts +0 -197
  386. package/out/zero-cache/src/types/subscription.d.ts.map +0 -1
  387. package/out/zero-cache/src/workers/connect-params.d.ts +0 -28
  388. package/out/zero-cache/src/workers/connect-params.d.ts.map +0 -1
  389. package/out/zero-cache/src/workers/connection.d.ts +0 -77
  390. package/out/zero-cache/src/workers/connection.d.ts.map +0 -1
  391. package/out/zero-cache/src/workers/replicator.d.ts +0 -57
  392. package/out/zero-cache/src/workers/replicator.d.ts.map +0 -1
  393. package/out/zero-cache/src/workers/syncer-ws-message-handler.d.ts +0 -14
  394. package/out/zero-cache/src/workers/syncer-ws-message-handler.d.ts.map +0 -1
  395. package/out/zero-cache/src/workers/syncer.d.ts +0 -67
  396. package/out/zero-cache/src/workers/syncer.d.ts.map +0 -1
  397. package/out/zero-events/src/index.d.ts +0 -27
  398. package/out/zero-events/src/index.d.ts.map +0 -1
  399. package/out/zero-events/src/json.d.ts +0 -20
  400. package/out/zero-events/src/json.d.ts.map +0 -1
  401. package/out/zero-events/src/status.d.ts +0 -144
  402. package/out/zero-events/src/status.d.ts.map +0 -1
  403. package/out/zqlite/src/database-storage.d.ts +0 -43
  404. package/out/zqlite/src/database-storage.d.ts.map +0 -1
  405. package/out/zqlite/src/explain-queries.d.ts +0 -4
  406. package/out/zqlite/src/explain-queries.d.ts.map +0 -1
  407. package/out/zqlite/src/internal/sql-inline.d.ts +0 -13
  408. package/out/zqlite/src/internal/sql-inline.d.ts.map +0 -1
  409. package/out/zqlite/src/resolve-scalar-subqueries.d.ts +0 -72
  410. package/out/zqlite/src/resolve-scalar-subqueries.d.ts.map +0 -1
  411. package/out/zqlite/src/sqlite-cost-model.d.ts +0 -17
  412. package/out/zqlite/src/sqlite-cost-model.d.ts.map +0 -1
  413. package/out/zqlite/src/sqlite-stat-fanout.d.ts +0 -121
  414. package/out/zqlite/src/sqlite-stat-fanout.d.ts.map +0 -1
@@ -1,420 +0,0 @@
1
- import type { LogContext } from '@rocicorp/logger';
2
- import { type JSONValue } from '../../../../shared/src/bigint-json.ts';
3
- import type { Row } from '../../../../zero-protocol/src/data.ts';
4
- import type { PrimaryKey } from '../../../../zero-types/src/schema.ts';
5
- import { type SQLiteRow } from '../../../../zqlite/src/table-source.ts';
6
- import type { LiteAndZqlSpec, LiteTableSpecWithKeysAndVersion } from '../../db/specs.ts';
7
- import { StatementRunner } from '../../db/statements.ts';
8
- import { type RowKey } from '../../types/row-key.ts';
9
- import type { AppID } from '../../types/shards.ts';
10
- import type { SnapshotRowCache } from './snapshot-row-cache.ts';
11
- /**
12
- * A `Snapshotter` manages the progression of database snapshots for a
13
- * ViewSyncer.
14
- *
15
- * The Replicator and ViewSyncers operate on the same SQLite file, with the
16
- * Replicator being the sole writer to the database. The IVM logic in
17
- * ViewSyncers, however, rely on incrementally applying changes to the DB to
18
- * update the state of its pipelines.
19
- *
20
- * To avoid coupling the progress of the Replicator and all IVM pipelines on
21
- * each other, ViewSyncers operate on ephemeral forks of the database by holding
22
- * [concurrent](https://sqlite.org/src/doc/begin-concurrent/doc/begin_concurrent.md)
23
- * snapshots of the database and simulating (but ultimately rolling back)
24
- * mutations on these snapshots.
25
- *
26
- * Example:
27
- * 1. ViewSyncer takes `snapshot_a` at version `t1` of the database and
28
- * hydrates its pipeline(s).
29
- * 2. Replicator applies a new transaction to the database and notifies
30
- * subscribers.
31
- * 3. ViewSyncer takes `snapshot_b` at `t2`, and queries the `ChangeLog` at
32
- * that snapshot for changes since `t1`.
33
- * 4. ViewSyncer applies those changes to `snapshot_a` for IVM, but does not
34
- * commit them. (Recall that the Replicator is the sole writer to the db, so
35
- * the ViewSyncer never commits any writes.)
36
- * 5. Replicator applies the next transaction and advances the database to `t3`.
37
- * 6. ViewSyncer rolls back `snapshot_a` and opens `snapshot_c` at `t3`, using
38
- * `snapshot_b` to simulate changes from `t2` to `t3`.
39
- *
40
- * ```
41
- * Replicator: t1 --------------> t2 --------------> t3 --------------->
42
- * ViewSyncer: [snapshot_a] ----> [snapshot_b] ----> [snapshot_c]
43
- * ```
44
- *
45
- * Note that the Replicator (and ViewSyncers) do not wait on the progress of
46
- * other ViewSyncers. If a ViewSyncer is busy hydrating at `t1`, the Replicator
47
- * and other ViewSyncers can progress through `t2`, `t3`, etc. independently,
48
- * as the busy ViewSyncer simply takes its own snapshot when it is ready.
49
- *
50
- * ```
51
- * Replicator: t1 --------------> t2 --------------> t3 --------------->
52
- * ViewSyncer1: [snapshot_a] ----> [snapshot_b] ----> [snapshot_c]
53
- * ViewSyncer2: [.......... snapshot_a ..........] ----> [snapshot_b]
54
- * ```
55
- *
56
- * To minimize Database connections (and statement preparation, etc.), the
57
- * Snapshotter reuses the connection from the previous (rolled back)
58
- * snapshot when opening the new one.
59
- *
60
- * ```
61
- * Replicator: t1 --------------> t2 --------------> t3 --------------->
62
- * ViewSyncer: [snapshot_a] ----> [snapshot_b] ----> [snapshot_c]
63
- * (conn_1) (conn_2) (conn_1)
64
- * ```
65
- *
66
- * In this manner, each ViewSyncer uses two connections that continually
67
- * "leapfrog" each other to replay the timeline of changes in isolation from
68
- * the Replicator and other ViewSyncers.
69
- */
70
- export declare class Snapshotter {
71
- #private;
72
- /**
73
- * @param rowCache An optional worker-wide {@link SnapshotRowCache} through
74
- * which the row reads performed when iterating over a
75
- * {@link SnapshotDiff} are shared with the other Snapshotters
76
- * (i.e. client groups) on the worker.
77
- */
78
- constructor(lc: LogContext, dbFile: string, { appID }: AppID, pageCacheSizeKib?: number, rowCache?: SnapshotRowCache);
79
- /**
80
- * Initializes the snapshot to the current head of the database. This must be
81
- * only be called once. The state of whether a Snapshotter has been initialized
82
- * can be determined by calling {@link initialized()}.
83
- */
84
- init(): this;
85
- initialized(): boolean;
86
- /** Returns the current snapshot. Asserts if {@link initialized()} is false. */
87
- current(): Snapshot;
88
- /**
89
- * Advances to the head of the Database, returning a diff between the
90
- * previously current Snapshot and a new Snapshot at head. This is called
91
- * in response to a notification from a Replicator subscription. Subsequent
92
- * calls to {@link current()} return the new Snapshot. Note that the Snapshotter
93
- * must be initialized before advancing.
94
- *
95
- * The returned {@link SnapshotDiff} contains snapshots at the endpoints
96
- * of the database timeline. Iterating over the diff generates a sequence
97
- * of {@link Change}s between the two snapshots.
98
- *
99
- * Note that this sequence is not chronological; rather, the sequence is
100
- * ordered by `<table, row-key>`, such that a row can appear at most once
101
- * in the common case, or twice if its table is `TRUNCATE`'d and a new value
102
- * is subsequently `INSERT`'ed. This results in dropping most intermediate
103
- * changes to a row and bounds the amount of work needed to catch up;
104
- * however, as a consequence, a consistent database state is only guaranteed
105
- * when the sequence has been fully consumed.
106
- *
107
- * Note that Change generation relies on the state of the underlying
108
- * database connections, and because the connection for the previous snapshot
109
- * is reused to produce the next snapshot, the diff object is only valid
110
- * until the next call to `advance()`.
111
- *
112
- * It is okay for the caller to apply `Change`s to the `prev` snapshot
113
- * during the iteration (e.g. this is necessary for IVM); the remainder
114
- * of the iteration is not affected because a given row can appear at most
115
- * once in the sequence (with the exception being TRUNCATE, after which the
116
- * deleted rows can be re-inserted, but this will also behave correctly if
117
- * the changes are applied).
118
- *
119
- * Once the changes have been applied, however, a _subsequent_ iteration
120
- * will not produce the correct results. In order to perform multiple
121
- * change-applying iterations, the caller must (1) create a save point
122
- * on `prev` before each iteration, and (2) rollback to the save point after
123
- * the iteration.
124
- *
125
- * @param prevWrites How the caller writes to `prev` during the iteration,
126
- * which determines which `prev` reads can be shared through the
127
- * {@link SnapshotRowCache}. See {@link PrevWrites}.
128
- */
129
- advance(syncableTables: Map<string, LiteAndZqlSpec>, allTableNames: Set<string>, observedTables?: TableFilter | undefined, prevWrites?: PrevWrites): SnapshotDiff;
130
- /**
131
- * The diff between the two snapshots of the last
132
- * {@link advanceWithoutDiff()}, as {@link advance()} returns it.
133
- *
134
- * @param counts The counts of the change log entries between the two
135
- * snapshots, if the caller has counted them already (see
136
- * `Snapshot.countChangesSince()`). The diff then does not count
137
- * them again.
138
- * @param readTables If set, only the change log entries of these tables
139
- * (and of the permissions table) are read, along with the
140
- * table-wide ops of every table, where `observedTables` reads the
141
- * entries of every table and skips those it does not have. For a
142
- * caller that does not need the changes of the other tables, this
143
- * saves reading and parsing their entries. This requires `counts`.
144
- * If they show that there is no entry of these tables and no
145
- * table-wide op, the change log is not read at all, and the
146
- * diff's `changes` is 0.
147
- */
148
- diff(syncableTables: Map<string, LiteAndZqlSpec>, allTableNames: Set<string>, observedTables?: TableFilter | undefined, prevWrites?: PrevWrites, counts?: ChangeLogCounts | undefined, readTables?: Iterable<string> | undefined): SnapshotDiff;
149
- advanceWithoutDiff(): {
150
- prev: Snapshot;
151
- curr: Snapshot;
152
- };
153
- /**
154
- * The reset of the pipelines that iterating over the changes from the
155
- * previous snapshot to the current one ends in, if it does: the first of
156
- * a schema change, a truncation, and a change of the permissions. It is
157
- * found without iterating, so that a caller that would reset the pipelines
158
- * anyway does not first process the changes that come before it.
159
- *
160
- * If there is none, iterating over a {@link diff()} of the two snapshots
161
- * does not throw a {@link ResetPipelinesSignal}, and can be stopped at any
162
- * point without missing one.
163
- *
164
- * @param counts The changes from the previous snapshot to the current
165
- * one, from which it is known whether there is anything to look
166
- * for.
167
- */
168
- pendingReset(syncableTables: Map<string, LiteAndZqlSpec>, counts: ChangeLogCounts): ResetPipelinesSignal | undefined;
169
- /**
170
- * Releases the previous snapshot, i.e. the `prev` of the last
171
- * {@link advance()} or {@link advanceWithoutDiff()}. It is only read
172
- * while the diff that it is the start of is iterated over, but its read
173
- * transaction otherwise stays open until the next advance, which keeps
174
- * the replica from checkpointing its write-ahead log past it. A diff that
175
- * starts at it can no longer be iterated over.
176
- */
177
- releasePrevious(): void;
178
- /**
179
- * Call this to close the database connections when the Snapshotter is
180
- * no longer needed.
181
- */
182
- destroy(): void;
183
- }
184
- export type Change = {
185
- readonly table: string;
186
- /**
187
- * If this change represents a remove the row to remove,
188
- * if nextValue is not null then all rows that have a unique constraint
189
- * violation with nextValue.
190
- * In both cases these rows should be removed.
191
- */
192
- readonly prevValues: Readonly<Row>[];
193
- readonly nextValue: Readonly<Row> | null;
194
- readonly rowKey: RowKey;
195
- };
196
- /** See `Snapshot.countChangesSince()`. */
197
- /** An entry of {@link Snapshot.changesSince}, in the order of its SELECT. */
198
- type RawChangeLogEntry = readonly [
199
- stateVersion: string,
200
- table: string,
201
- rowKey: string,
202
- op: string
203
- ];
204
- /** Where an entry is in the order that the change log is read in. */
205
- type ChangeLogPosition = {
206
- readonly stateVersion: string;
207
- readonly pos: number;
208
- };
209
- export type ChangeLogCounts = {
210
- /** The number of entries. */
211
- readonly total: number;
212
- /** The number of them that are table-wide ops (a RESET or TRUNCATE). */
213
- readonly tableWideOps: number;
214
- /**
215
- * The number of entries of each table. If {@link sampled}, these are
216
- * estimates, and a table with few entries may be missing.
217
- */
218
- readonly byTable: ReadonlyMap<string, number>;
219
- /** Whether {@link byTable} was estimated from a sample of the entries. */
220
- readonly sampled: boolean;
221
- };
222
- /**
223
- * The most change log entries that are read to count a batch's changes by
224
- * table. Reading an entry costs microseconds, and nothing else runs on the
225
- * sync worker in the meantime, so the cost of counting must not grow with
226
- * the number of changes that a client group has to catch up on.
227
- */
228
- export declare const CHANGE_LOG_SAMPLE_SIZE = 1000;
229
- export interface TableFilter {
230
- has(table: string): boolean;
231
- }
232
- /**
233
- * How the caller of {@link Snapshotter.advance()} writes the changes of a
234
- * {@link SnapshotDiff} to its `prev` snapshot while iterating over it.
235
- *
236
- * A `prev` read for a table with a single unique key (its primary key)
237
- * cannot observe earlier changes of the iteration, since a row key appears
238
- * once in the diff. A read for a table with other unique keys can, because
239
- * the rows it returns may have been displaced or edited by earlier changes.
240
- *
241
- * * `uniform`: every caller applies every change, so such a read depends on
242
- * the `<prev, curr>` versions of the diff, and is shared on that basis.
243
- * * `divergent`: callers apply different subsets of the changes (e.g. the
244
- * pipeline driver skips changes that no pipeline can observe), so such a
245
- * read depends on the caller and is not shared.
246
- * * `none`: the caller does not write to `prev` (e.g. IVM derivation is
247
- * held in memory), so every read depends solely on `prev.version`.
248
- */
249
- export type PrevWrites = 'uniform' | 'divergent' | 'none';
250
- /**
251
- * Represents the difference between two database Snapshots.
252
- * Iterating over the object will produce a sequence of {@link Change}s
253
- * between the two snapshots.
254
- *
255
- * See {@link Snapshotter.advance()} for semantics and usage.
256
- */
257
- export type DiffTimingStats = {
258
- changeLogReadMs: number;
259
- rowReadMs: number;
260
- parseMs: number;
261
- totalDiffMs: number;
262
- };
263
- export interface SnapshotDiff extends Iterable<Change> {
264
- readonly prev: {
265
- readonly db: StatementRunner;
266
- readonly version: string;
267
- };
268
- readonly curr: {
269
- readonly db: StatementRunner;
270
- readonly version: string;
271
- };
272
- /**
273
- * The raw number of ChangeLog entries between the snapshots, before filtering
274
- * out unobserved/non-syncable tables or no-op changes. Progress against this
275
- * total must use {@link changesScanned}, rather than the number of yielded
276
- * changes. Table-wide operations abort iteration and reset the pipelines.
277
- */
278
- readonly changes: number;
279
- /** The number of raw ChangeLog entries read so far, including skipped entries. */
280
- readonly changesScanned: number;
281
- /**
282
- * The raw ChangeLog entries read so far, by table. Like
283
- * {@link changesScanned}, this includes the entries that are not yielded,
284
- * so it counts the same entries as {@link ChangeLogCounts.byTable} does.
285
- */
286
- readonly changesScannedByTable: ReadonlyMap<string, number>;
287
- /** The scanned entries omitted because their table is unobserved/non-syncable or the change is a no-op. */
288
- readonly changesSkipped: number;
289
- /**
290
- * The scanned entries whose rows were looked up in the snapshots. Unlike
291
- * the entries that are yielded, this includes the no-op changes, which are
292
- * only known to be that from their rows.
293
- */
294
- readonly changesLookedUp: number;
295
- /** Timing metrics recorded during diff iteration. */
296
- readonly stats?: DiffTimingStats | undefined;
297
- /**
298
- * Overrides the `prevWrites` passed to {@link Snapshotter.advance()}, for a
299
- * caller that decides how to write to `prev` once it knows the number of
300
- * {@link changes}. Must be called before the diff is iterated, except to
301
- * switch to `divergent`, which can be done between any two changes: it
302
- * shares only the reads that no write to `prev` can affect.
303
- */
304
- setPrevWrites(prevWrites: PrevWrites): void;
305
- }
306
- /**
307
- * Thrown during an iteration of a {@link SnapshotDiff} when a schema
308
- * change or truncate is encountered, which result in aborting the
309
- * advancement and resetting / rehydrating the pipelines.
310
- */
311
- export type ResetPipelinesReason = 'advancement-timeout' | 'scalar-subquery' | 'schema-change' | 'truncation' | 'permissions-change';
312
- export declare class ResetPipelinesSignal extends Error {
313
- readonly name = "ResetPipelinesSignal";
314
- readonly reason: ResetPipelinesReason;
315
- readonly breakdown?: string | undefined;
316
- constructor(msg: string, reason: ResetPipelinesReason, breakdown?: string);
317
- }
318
- declare class Snapshot {
319
- #private;
320
- static create(lc: LogContext, dbFile: string, appID: string, pageCacheSizeKib: number | undefined): Snapshot;
321
- readonly db: StatementRunner;
322
- readonly version: string;
323
- /**
324
- * @param begun Whether `db` is already in a `BEGIN CONCURRENT` transaction
325
- * that has not read anything.
326
- */
327
- constructor(db: StatementRunner, appID: string, begun?: boolean);
328
- numChangesSince(prevVersion: string): any;
329
- /**
330
- * Counts the change log entries after `prevVersion`. The change log keeps
331
- * the latest entry of a row, so these are counts of the rows that changed,
332
- * which is what a diff from `prevVersion` to this snapshot reads.
333
- *
334
- * The total, and the number of table-wide ops (a RESET or TRUNCATE), are
335
- * exact, and are counted from the index alone. The counts by table are
336
- * exact if there are at most `sampleSize` entries. Otherwise they are
337
- * estimated from the newest `sampleSize` entries, so that at most that
338
- * many entries are read however many there are.
339
- */
340
- countChangesSince(prevVersion: string, sampleSize?: number): ChangeLogCounts;
341
- /**
342
- * Whether an entry of `table` was logged after `prevVersion`. This reads
343
- * the table's entries in the change log, however old, so it is for tables
344
- * with few rows.
345
- */
346
- tableChangedSince(table: string, prevVersion: string): boolean;
347
- /**
348
- * Whether a table-wide RESET op (i.e. a schema change) was logged after
349
- * `prevVersion`. Table specs computed at or before `prevVersion` are
350
- * stale with respect to this snapshot if so.
351
- */
352
- schemaChangedSince(prevVersion: string): boolean;
353
- /**
354
- * Whether any table-wide op (i.e. a RESET or TRUNCATE) was logged after
355
- * `prevVersion`. Iterating over a diff ending at this snapshot will
356
- * abort with a {@link ResetPipelinesSignal} if so.
357
- */
358
- hasTableWideOpSince(prevVersion: string): boolean;
359
- /**
360
- * The first table-wide op (a schema change or a truncation) logged after
361
- * `prevVersion`, in the order that {@link changesSince} reads the entries.
362
- */
363
- firstTableWideOpSince(prevVersion: string): ChangeLogPosition & {
364
- table: string;
365
- op: string;
366
- };
367
- /**
368
- * The entries of `table` logged after `prevVersion`, in the order that
369
- * {@link changesSince} reads them. For a table with few rows.
370
- */
371
- entriesSince(table: string, prevVersion: string): (ChangeLogPosition & {
372
- rowKey: string | null;
373
- op: string;
374
- })[];
375
- /**
376
- * @param tables If set, only the entries of these tables, and the
377
- * table-wide ops of every table, are read.
378
- */
379
- changesSince(prevVersion: string, tables?: string | undefined): {
380
- changes: IterableIterator<RawChangeLogEntry>;
381
- cleanup: () => void;
382
- };
383
- /**
384
- * Reads the row with the given `rowKey`, or `undefined` if it does not
385
- * exist.
386
- *
387
- * @param cache An optional {@link SnapshotRowCache} through which to
388
- * perform the read, along with the `tag` that identifies the
389
- * version(s) of the replica that the result depends on.
390
- */
391
- getRow(table: LiteTableSpecWithKeysAndVersion, rowKey: JSONValue, cache?: SnapshotRowCache, tag?: string): Readonly<Record<string, import("../../../../zqlite/src/table-source.ts").SQLiteValue>>;
392
- /**
393
- * Reads the rows that conflict with `row` on any of the given unique
394
- * `keys` (which includes the row with the same primary key, if any).
395
- *
396
- * @param cache An optional {@link SnapshotRowCache} through which to
397
- * perform the read, along with the `tag` that identifies the
398
- * version(s) of the replica that the result depends on.
399
- */
400
- getRows(table: LiteTableSpecWithKeysAndVersion, keys: PrimaryKey[], row: SQLiteRow, cache?: SnapshotRowCache, tag?: string): Readonly<Record<string, import("../../../../zqlite/src/table-source.ts").SQLiteValue>>[];
401
- /**
402
- * Whether the snapshot has been released, or its connection reset to a
403
- * newer snapshot (i.e. via {@link release()} or {@link resetToHead()}),
404
- * after which reads no longer reflect {@link version}.
405
- */
406
- get reset(): boolean;
407
- /**
408
- * Ends the snapshot's read transaction, after which reads no longer
409
- * reflect {@link version}. An open read transaction keeps SQLite from
410
- * checkpointing the write-ahead log past the snapshot, so a snapshot that
411
- * is no longer read should not be left open.
412
- */
413
- release(): void;
414
- resetToHead(): Snapshot;
415
- }
416
- export declare class InvalidDiffError extends Error {
417
- constructor(msg: string);
418
- }
419
- export {};
420
- //# sourceMappingURL=snapshotter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"snapshotter.d.ts","sourceRoot":"","sources":["../../../../../../zero-cache/src/services/view-syncer/snapshotter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAY,KAAK,SAAS,EAAC,MAAM,uCAAuC,CAAC;AAEhF,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,uCAAuC,CAAC;AAC/D,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,sCAAsC,CAAC;AAGrE,OAAO,EAEL,KAAK,SAAS,EACf,MAAM,wCAAwC,CAAC;AAChD,OAAO,KAAK,EACV,cAAc,EACd,+BAA+B,EAChC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAqB,KAAK,MAAM,EAAC,MAAM,wBAAwB,CAAC;AACvE,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,uBAAuB,CAAC;AAYjD,OAAO,KAAK,EAAC,gBAAg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MAAM,GAAG,SAAS;QAczD,OAAO;QASP,OAAO;MAEV;IAED;;;;;;;OAOG;IACH,MAAM,CACJ,KAAK,EAAE,+BAA+B,EACtC,MAAM,EAAE,SAAS,EACjB,KAAK,CAAC,EAAE,gBAAgB,EACxB,GAAG,CAAC,EAAE,MAAM,0FA2Bb;IAED;;;;;;;OAOG;IACH,OAAO,CACL,KAAK,EAAE,+BAA+B,EACtC,IAAI,EAAE,UAAU,EAAE,EAClB,GAAG,EAAE,SAAS,EACd,KAAK,CAAC,EAAE,gBAAgB,EACxB,GAAG,CAAC,EAAE,MAAM,4FAyEb;IAiBD;;;;OAIG;IACH,IAAI,KAAK,IAAI,OAAO,CAEnB;IAED;;;;;OAKG;IACH,OAAO,IAAI,IAAI,CAWd;IAED,WAAW,IAAI,QAAQ,CAGtB;CACF;AAuWD,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,YAAY,GAAG,EAAE,MAAM,EAEtB;CACF"}
@@ -1,2 +0,0 @@
1
- export declare const tracer: import("@opentelemetry/api").Tracer;
2
- //# sourceMappingURL=tracer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tracer.d.ts","sourceRoot":"","sources":["../../../../../../zero-cache/src/services/view-syncer/tracer.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,MAAM,qCAA0C,CAAC"}
@@ -1,10 +0,0 @@
1
- import * as v from '../../../../shared/src/valita.ts';
2
- declare const ttlClockTag: unique symbol;
3
- export type TTLClock = {
4
- [ttlClockTag]: true;
5
- };
6
- export declare const ttlClockSchema: v.Type<TTLClock>;
7
- export declare function ttlClockAsNumber(ttlClock: TTLClock): number;
8
- export declare function ttlClockFromNumber(ttlClock: number): TTLClock;
9
- export {};
10
- //# sourceMappingURL=ttl-clock.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ttl-clock.d.ts","sourceRoot":"","sources":["../../../../../../zero-cache/src/services/view-syncer/ttl-clock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,kCAAkC,CAAC;AAEtD,OAAO,CAAC,MAAM,WAAW,EAAE,OAAO,MAAM,CAAC;AAEzC,MAAM,MAAM,QAAQ,GAAG;IAAC,CAAC,WAAW,CAAC,EAAE,IAAI,CAAA;CAAC,CAAC;AAE7C,eAAO,MAAM,cAAc,EAAoC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAEhF,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAE3D;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAE7D"}
@@ -1,133 +0,0 @@
1
- import type { LogContext } from '@rocicorp/logger';
2
- import type { ChangeDesiredQueriesMessage } from '../../../../zero-protocol/src/change-desired-queries.ts';
3
- import type { InitConnectionMessage } from '../../../../zero-protocol/src/connect.ts';
4
- import type { DeleteClientsMessage } from '../../../../zero-protocol/src/delete-clients.ts';
5
- import type { UnparsedInspectUpMessage } from '../../../../zero-protocol/src/inspect-up.ts';
6
- import type { UpdateAuthMessage } from '../../../../zero-protocol/src/update-auth.ts';
7
- import { type Auth } from '../../auth/auth.ts';
8
- import type { NormalizedZeroConfig } from '../../config/normalize.ts';
9
- import type { CustomQueryTransformer } from '../../custom-queries/transform-query.ts';
10
- import type { InspectorDelegate } from '../../server/inspector-delegate.ts';
11
- import type { ViewSyncerDownstream } from '../../types/downstream.ts';
12
- import type { LexiVersion } from '../../types/lexi-version.ts';
13
- import type { PostgresDB } from '../../types/pg.ts';
14
- import type { ShardID } from '../../types/shards.ts';
15
- import type { Source } from '../../types/streams.ts';
16
- import { Subscription } from '../../types/subscription.ts';
17
- import type { ReplicaState } from '../replicator/replicator.ts';
18
- import type { ActivityBasedService } from '../service.ts';
19
- import type { BatchPacer } from './batch-pacer.ts';
20
- import type { ConnectionContextManager, ConnectionSelector } from './connection-context-manager.ts';
21
- import type { DrainCoordinator } from './drain-coordinator.ts';
22
- import { type MonotonicClock } from './hydration-budget.ts';
23
- import type { PipelineDriver } from './pipeline-driver.ts';
24
- import { type ShouldCutOffPush } from './push-cutoff.ts';
25
- import { type ClientQueryRecord, type CustomQueryRecord, type InternalQueryRecord } from './schema/types.ts';
26
- import { type TTLClock } from './ttl-clock.ts';
27
- export interface ViewSyncer {
28
- initConnection(selector: ConnectionSelector, initConnectionMessage: InitConnectionMessage): Source<ViewSyncerDownstream>;
29
- changeDesiredQueries(selector: ConnectionSelector, msg: ChangeDesiredQueriesMessage): Promise<void>;
30
- deleteClients(selector: ConnectionSelector, msg: DeleteClientsMessage): Promise<string[]>;
31
- inspect(selector: ConnectionSelector, msg: UnparsedInspectUpMessage): Promise<void>;
32
- updateAuth(selector: ConnectionSelector, msg: UpdateAuthMessage, authRevisionChanged: boolean): Promise<void>;
33
- connContextManager: ConnectionContextManager;
34
- readonly queryCount: number;
35
- readonly rowCount: number;
36
- readonly createdAtMs: number;
37
- readonly servedVersion: string | null;
38
- readonly servingLagEligible: boolean;
39
- pipelineHashes(): readonly PipelineHashInfo[];
40
- readonly clientSchemaKey: string | undefined;
41
- }
42
- export type PipelineHashInfo = {
43
- readonly transformationHash: string;
44
- readonly internal: boolean;
45
- readonly queryName: string | undefined;
46
- };
47
- export type SyncContext = ConnectionSelector & {
48
- readonly profileID: string | null;
49
- readonly baseCookie: string | null;
50
- readonly protocolVersion: number;
51
- readonly httpCookie: string | undefined;
52
- readonly origin: string | undefined;
53
- readonly userID: string | undefined;
54
- readonly auth: Auth | undefined;
55
- };
56
- type SetTimeout = (fn: (...args: unknown[]) => void, delay?: number) => ReturnType<typeof setTimeout>;
57
- /**
58
- * We update the ttlClock in flush that writes to the CVR but
59
- * some flushes do not write to the CVR and in those cases we
60
- * use a timer to update the ttlClock every minute.
61
- */
62
- export declare const TTL_CLOCK_INTERVAL = 60000;
63
- /**
64
- * This is some extra time we delay the TTL timer to allow for some
65
- * slack in the timing of the timer. This is to allow multiple evictions
66
- * to happen in a short period of time without having to wait for the
67
- * next tick of the timer.
68
- */
69
- export declare const TTL_TIMER_HYSTERESIS = 50;
70
- export declare class ViewSyncerService implements ViewSyncer, ActivityBasedService {
71
- #private;
72
- readonly id: string;
73
- readonly createdAtMs: number;
74
- readonly connContextManager: ConnectionContextManager;
75
- constructor(config: NormalizedZeroConfig, lc: LogContext, shard: ShardID, taskID: string, clientGroupID: string, cvrDb: PostgresDB, pipelineDriver: PipelineDriver, versionChanges: Subscription<ReplicaState>, drainCoordinator: DrainCoordinator, slowHydrateThreshold: number, inspectorDelegate: InspectorDelegate, connContextManager: ConnectionContextManager, customQueryTransformer: CustomQueryTransformer | undefined, runPriorityOp: <T>(lc: LogContext, description: string, op: () => Promise<T>) => Promise<T>, keepaliveMs?: number, setTimeoutFn?: SetTimeout, now?: MonotonicClock, pushCutoff?: ShouldCutOffPush, pacer?: BatchPacer);
76
- readyState(): Promise<'initialized' | 'draining'>;
77
- run(): Promise<void>;
78
- get queryCount(): number;
79
- pipelineHashes(): readonly PipelineHashInfo[];
80
- get clientSchemaKey(): string | undefined;
81
- get rowCount(): number;
82
- get servedVersion(): LexiVersion | null;
83
- get servingLagEligible(): boolean;
84
- /**
85
- * Guarantees that the ViewSyncer will remain running for at least
86
- * its configured `keepaliveMs`. This is called when establishing a
87
- * new connection to ensure that its associated ViewSyncer isn't
88
- * shutdown before it receives the connection.
89
- *
90
- * @return `true` if the ViewSyncer will stay alive, `false` if the
91
- * ViewSyncer is shutting down.
92
- */
93
- keepalive(): boolean;
94
- initConnection(selector: ConnectionSelector, initConnectionMessage: InitConnectionMessage): Source<ViewSyncerDownstream>;
95
- changeDesiredQueries(selector: ConnectionSelector, msg: ChangeDesiredQueriesMessage): Promise<void>;
96
- updateAuth(selector: ConnectionSelector, msg: UpdateAuthMessage, authRevisionChanged: boolean): Promise<void>;
97
- deleteClients(selector: ConnectionSelector, msg: DeleteClientsMessage): Promise<string[]>;
98
- inspect(selector: ConnectionSelector, msg: UnparsedInspectUpMessage): Promise<void>;
99
- stop(): Promise<void>;
100
- /**
101
- * Test helper: Manually mark initialization as complete.
102
- * This should only be used in tests that don't call initConnection().
103
- */
104
- markInitialized(): void;
105
- }
106
- /**
107
- * Whether a query's TTL has elapsed. A query must be expired for all clients
108
- * in order to be considered expired.
109
- *
110
- * Exported for testing.
111
- */
112
- export declare function expired(ttlClock: TTLClock, q: InternalQueryRecord | ClientQueryRecord | CustomQueryRecord): boolean;
113
- export declare class TimeSliceTimer {
114
- #private;
115
- /**
116
- * @param yieldSlice How the timer yields the process, if not by taking
117
- * turns with the rest of the worker's work (see `yieldProcess()`).
118
- */
119
- constructor(lc: LogContext, yieldSlice?: () => Promise<void>);
120
- start(): Promise<this>;
121
- startWithoutYielding(): this;
122
- yieldProcess(_msgForTesting?: string): Promise<void>;
123
- elapsedLap(): number;
124
- /** @returns the total elapsed time */
125
- stop(): number;
126
- /**
127
- * @returns the elapsed time. This can be called while the Timer is running
128
- * or after it has been stopped.
129
- */
130
- totalElapsed(): number;
131
- }
132
- export {};
133
- //# sourceMappingURL=view-syncer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"view-syncer.d.ts","sourceRoot":"","sources":["../../../../../../zero-cache/src/services/view-syncer/view-syncer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAgBjD,OAAO,KAAK,EAAC,2BAA2B,EAAC,MAAM,yDAAyD,CAAC;AAKzG,OAAO,KAAK,EAEV,qBAAqB,EACtB,MAAM,0CAA0C,CAAC;AAElD,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,iDAAiD,CAAC;AAQ1F,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,6CAA6C,CAAC;AAC1F,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,8CAA8C,CAAC;AAGpF,OAAO,EAAkB,KAAK,IAAI,EAAC,MAAM,oBAAoB,CAAC;AAK9D,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,2BAA2B,CAAC;AACpE,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Q,EAAE,QAAQ,EAClB,CAAC,EAAE,mBAAmB,GAAG,iBAAiB,GAAG,iBAAiB,GAC7D,OAAO,CAuBT;AAkDD,qBAAa,cAAc;;IAMzB;;;OAGG;IACH,YAAY,EAAE,EAAE,UAAU,EAAE,UAAU,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EAG3D;IAEK,KAAK,kBAKV;IAED,oBAAoB,SAInB;IAEK,YAAY,CAAC,cAAc,CAAC,EAAE,MAAM,iBAIzC;IAOD,UAAU,WAGT;IAQD,sCAAsC;IACtC,IAAI,IAAI,MAAM,CAGb;IAED;;;OAGG;IACH,YAAY,IAAI,MAAM,CAIrB;CACF"}
@@ -1,11 +0,0 @@
1
- import type { Downstream } from '../../../zero-protocol/src/down.ts';
2
- /**
3
- * A logical view-syncer message and, when already available, its serialized
4
- * wire representation. Keeping them together lets the connection reuse the
5
- * view-syncer's serialization instead of stringifying large poke parts again.
6
- */
7
- export type ViewSyncerDownstream = {
8
- readonly message: Downstream;
9
- readonly serialized: string | undefined;
10
- };
11
- //# sourceMappingURL=downstream.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"downstream.d.ts","sourceRoot":"","sources":["../../../../../zero-cache/src/types/downstream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,oCAAoC,CAAC;AAEnE;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;CACzC,CAAC"}
@@ -1,9 +0,0 @@
1
- import type { LogLevel } from '@rocicorp/logger';
2
- import { ProtocolError, type ErrorBody } from '../../../zero-protocol/src/error.ts';
3
- export declare class ProtocolErrorWithLevel extends ProtocolError {
4
- readonly logLevel: LogLevel;
5
- constructor(errorBody: ErrorBody, logLevel: LogLevel, options?: ErrorOptions);
6
- }
7
- export declare function getLogLevel(error: unknown): LogLevel;
8
- export declare function wrapWithProtocolError(error: unknown): ProtocolError;
9
- //# sourceMappingURL=error-with-level.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"error-with-level.d.ts","sourceRoot":"","sources":["../../../../../zero-cache/src/types/error-with-level.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAC;AAI/C,OAAO,EAEL,aAAa,EACb,KAAK,SAAS,EACf,MAAM,qCAAqC,CAAC;AAE7C,qBAAa,sBAAuB,SAAQ,aAAa;IACvD,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAE5B,YACE,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,EAClB,OAAO,CAAC,EAAE,YAAY,EAIvB;CACF;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,QAAQ,CAMpD;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,aAAa,CAanE"}
@@ -1,21 +0,0 @@
1
- import type { LogContext } from '@rocicorp/logger';
2
- /**
3
- * Whether the imported postgres.js has Zero's patch
4
- * (`packages/zero/patches/postgres@3.4.7.patch`), which marks itself with
5
- * `Postgres.zeroPatch`. pnpm applies the patch in this repo and in the Docker
6
- * image, but not when `@rocicorp/zero` is installed from npm.
7
- *
8
- * The patch includes the `CopyDone` fix for
9
- * https://github.com/porsager/postgres/issues/499
10
- * (https://github.com/porsager/postgres/pull/1016). Without it, a connection
11
- * can stop responding after a COPY, on any Node version: if the last
12
- * `CopyData` fills the stream's buffer, the socket is paused, and it is never
13
- * resumed once the stream has ended. Node version and OS only change how often
14
- * this happens. Initial sync and backfill only wait for their COPY connections
15
- * to close when this returns `true`.
16
- *
17
- * A later version of the patch can raise the number to mark new fixes.
18
- */
19
- export declare function hasPostgresPatch(): boolean;
20
- export declare function warnIfPostgresUnpatched(lc: LogContext): void;
21
- //# sourceMappingURL=pg-patch.d.ts.map