@rocicorp/zero 0.25.0-canary.0 → 0.25.0-canary.2

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 (394) hide show
  1. package/out/{chunk-MXPHMVU7.js → chunk-COKJ5W7V.js} +2527 -540
  2. package/out/chunk-COKJ5W7V.js.map +7 -0
  3. package/out/{chunk-4RB4OYLQ.js → chunk-TJFNGO7E.js} +3 -2
  4. package/out/{chunk-BJ2CGCME.js → chunk-YWU2DZ23.js} +20 -4
  5. package/out/chunk-YWU2DZ23.js.map +7 -0
  6. package/out/{lazy-inspector-2SW772W4.js → lazy-inspector-OXIFYSSQ.js} +2 -2
  7. package/out/react.js +59 -28
  8. package/out/react.js.map +4 -4
  9. package/out/replicache/src/dag/lazy-store.d.ts +1 -1
  10. package/out/replicache/src/dag/lazy-store.d.ts.map +1 -1
  11. package/out/replicache/src/log-options.d.ts +1 -1
  12. package/out/replicache/src/log-options.d.ts.map +1 -1
  13. package/out/replicache/src/persist/collect-idb-databases.d.ts +3 -3
  14. package/out/replicache/src/persist/collect-idb-databases.d.ts.map +1 -1
  15. package/out/replicache/src/replicache-options.d.ts +1 -1
  16. package/out/replicache/src/replicache-options.d.ts.map +1 -1
  17. package/out/shared/src/error.d.ts +4 -0
  18. package/out/shared/src/error.d.ts.map +1 -0
  19. package/out/shared/src/error.js +70 -0
  20. package/out/shared/src/error.js.map +1 -0
  21. package/out/shared/src/options.d.ts +1 -1
  22. package/out/shared/src/options.d.ts.map +1 -1
  23. package/out/shared/src/promise-race.d.ts +17 -0
  24. package/out/shared/src/promise-race.d.ts.map +1 -0
  25. package/out/solid.js +61 -22
  26. package/out/solid.js.map +4 -4
  27. package/out/z2s/src/compiler.d.ts +1 -1
  28. package/out/z2s/src/compiler.d.ts.map +1 -1
  29. package/out/z2s/src/compiler.js +1 -1
  30. package/out/z2s/src/compiler.js.map +1 -1
  31. package/out/z2s/src/sql.d.ts.map +1 -1
  32. package/out/z2s/src/sql.js +1 -1
  33. package/out/z2s/src/sql.js.map +1 -1
  34. package/out/zero/package.json +6 -4
  35. package/out/zero/src/zero-out.d.ts +3 -0
  36. package/out/zero/src/zero-out.d.ts.map +1 -0
  37. package/out/zero/src/zero-out.js +13 -0
  38. package/out/zero/src/zero-out.js.map +1 -0
  39. package/out/zero-cache/src/config/zero-config.d.ts +12 -0
  40. package/out/zero-cache/src/config/zero-config.d.ts.map +1 -1
  41. package/out/zero-cache/src/config/zero-config.js +36 -0
  42. package/out/zero-cache/src/config/zero-config.js.map +1 -1
  43. package/out/zero-cache/src/custom/fetch.d.ts +3 -1
  44. package/out/zero-cache/src/custom/fetch.d.ts.map +1 -1
  45. package/out/zero-cache/src/custom/fetch.js +104 -27
  46. package/out/zero-cache/src/custom/fetch.js.map +1 -1
  47. package/out/zero-cache/src/custom-queries/transform-query.d.ts +2 -6
  48. package/out/zero-cache/src/custom-queries/transform-query.d.ts.map +1 -1
  49. package/out/zero-cache/src/custom-queries/transform-query.js +42 -41
  50. package/out/zero-cache/src/custom-queries/transform-query.js.map +1 -1
  51. package/out/zero-cache/src/db/create.d.ts +4 -0
  52. package/out/zero-cache/src/db/create.d.ts.map +1 -1
  53. package/out/zero-cache/src/db/create.js +7 -9
  54. package/out/zero-cache/src/db/create.js.map +1 -1
  55. package/out/zero-cache/src/db/lite-tables.js +2 -2
  56. package/out/zero-cache/src/db/lite-tables.js.map +1 -1
  57. package/out/zero-cache/src/db/pg-to-lite.d.ts.map +1 -1
  58. package/out/zero-cache/src/db/pg-to-lite.js +7 -6
  59. package/out/zero-cache/src/db/pg-to-lite.js.map +1 -1
  60. package/out/zero-cache/src/db/specs.d.ts +12 -12
  61. package/out/zero-cache/src/scripts/decommission.d.ts +50 -0
  62. package/out/zero-cache/src/scripts/decommission.d.ts.map +1 -0
  63. package/out/zero-cache/src/scripts/decommission.js +51 -0
  64. package/out/zero-cache/src/scripts/decommission.js.map +1 -0
  65. package/out/zero-cache/src/server/change-streamer.d.ts.map +1 -1
  66. package/out/zero-cache/src/server/change-streamer.js +1 -1
  67. package/out/zero-cache/src/server/change-streamer.js.map +1 -1
  68. package/out/zero-cache/src/server/inspector-delegate.d.ts.map +1 -1
  69. package/out/zero-cache/src/server/inspector-delegate.js +6 -1
  70. package/out/zero-cache/src/server/inspector-delegate.js.map +1 -1
  71. package/out/zero-cache/src/server/syncer.d.ts.map +1 -1
  72. package/out/zero-cache/src/server/syncer.js +1 -1
  73. package/out/zero-cache/src/server/syncer.js.map +1 -1
  74. package/out/zero-cache/src/services/change-source/pg/change-source.js +1 -0
  75. package/out/zero-cache/src/services/change-source/pg/change-source.js.map +1 -1
  76. package/out/zero-cache/src/services/change-source/pg/logical-replication/binary-reader.d.ts +1 -1
  77. package/out/zero-cache/src/services/change-source/pg/logical-replication/binary-reader.d.ts.map +1 -1
  78. package/out/zero-cache/src/services/change-source/pg/logical-replication/binary-reader.js +1 -1
  79. package/out/zero-cache/src/services/change-source/pg/logical-replication/binary-reader.js.map +1 -1
  80. package/out/zero-cache/src/services/change-source/pg/schema/ddl.d.ts +25 -25
  81. package/out/zero-cache/src/services/change-source/pg/schema/published.d.ts +10 -10
  82. package/out/zero-cache/src/services/change-source/pg/schema/shard.d.ts +5 -5
  83. package/out/zero-cache/src/services/change-source/protocol/current/data.d.ts +16 -16
  84. package/out/zero-cache/src/services/change-source/protocol/current/downstream.d.ts +24 -24
  85. package/out/zero-cache/src/services/change-streamer/change-streamer-http.d.ts +2 -1
  86. package/out/zero-cache/src/services/change-streamer/change-streamer-http.d.ts.map +1 -1
  87. package/out/zero-cache/src/services/change-streamer/change-streamer-http.js +18 -2
  88. package/out/zero-cache/src/services/change-streamer/change-streamer-http.js.map +1 -1
  89. package/out/zero-cache/src/services/change-streamer/change-streamer.d.ts +8 -8
  90. package/out/zero-cache/src/services/mutagen/mutagen.d.ts.map +1 -1
  91. package/out/zero-cache/src/services/mutagen/mutagen.js +9 -7
  92. package/out/zero-cache/src/services/mutagen/mutagen.js.map +1 -1
  93. package/out/zero-cache/src/services/mutagen/pusher.d.ts +21 -25
  94. package/out/zero-cache/src/services/mutagen/pusher.d.ts.map +1 -1
  95. package/out/zero-cache/src/services/mutagen/pusher.js +78 -60
  96. package/out/zero-cache/src/services/mutagen/pusher.js.map +1 -1
  97. package/out/zero-cache/src/services/view-syncer/client-handler.d.ts +3 -1
  98. package/out/zero-cache/src/services/view-syncer/client-handler.d.ts.map +1 -1
  99. package/out/zero-cache/src/services/view-syncer/client-handler.js +10 -6
  100. package/out/zero-cache/src/services/view-syncer/client-handler.js.map +1 -1
  101. package/out/zero-cache/src/services/view-syncer/client-schema.d.ts.map +1 -1
  102. package/out/zero-cache/src/services/view-syncer/client-schema.js +6 -3
  103. package/out/zero-cache/src/services/view-syncer/client-schema.js.map +1 -1
  104. package/out/zero-cache/src/services/view-syncer/cvr-store.d.ts +4 -4
  105. package/out/zero-cache/src/services/view-syncer/cvr-store.d.ts.map +1 -1
  106. package/out/zero-cache/src/services/view-syncer/cvr-store.js +15 -6
  107. package/out/zero-cache/src/services/view-syncer/cvr-store.js.map +1 -1
  108. package/out/zero-cache/src/services/view-syncer/cvr.d.ts.map +1 -1
  109. package/out/zero-cache/src/services/view-syncer/cvr.js +4 -2
  110. package/out/zero-cache/src/services/view-syncer/cvr.js.map +1 -1
  111. package/out/zero-cache/src/services/view-syncer/drain-coordinator.d.ts +1 -0
  112. package/out/zero-cache/src/services/view-syncer/drain-coordinator.d.ts.map +1 -1
  113. package/out/zero-cache/src/services/view-syncer/drain-coordinator.js +5 -0
  114. package/out/zero-cache/src/services/view-syncer/drain-coordinator.js.map +1 -1
  115. package/out/zero-cache/src/services/view-syncer/key-columns.d.ts.map +1 -1
  116. package/out/zero-cache/src/services/view-syncer/key-columns.js +4 -2
  117. package/out/zero-cache/src/services/view-syncer/key-columns.js.map +1 -1
  118. package/out/zero-cache/src/services/view-syncer/pipeline-driver.d.ts +1 -1
  119. package/out/zero-cache/src/services/view-syncer/pipeline-driver.d.ts.map +1 -1
  120. package/out/zero-cache/src/services/view-syncer/pipeline-driver.js +19 -2
  121. package/out/zero-cache/src/services/view-syncer/pipeline-driver.js.map +1 -1
  122. package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts +7 -0
  123. package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts.map +1 -1
  124. package/out/zero-cache/src/services/view-syncer/view-syncer.js +91 -32
  125. package/out/zero-cache/src/services/view-syncer/view-syncer.js.map +1 -1
  126. package/out/zero-cache/src/types/error-with-level.d.ts +9 -0
  127. package/out/zero-cache/src/types/error-with-level.d.ts.map +1 -0
  128. package/out/zero-cache/src/types/error-with-level.js +24 -0
  129. package/out/zero-cache/src/types/error-with-level.js.map +1 -0
  130. package/out/zero-cache/src/types/lite.d.ts +15 -13
  131. package/out/zero-cache/src/types/lite.d.ts.map +1 -1
  132. package/out/zero-cache/src/types/lite.js +17 -5
  133. package/out/zero-cache/src/types/lite.js.map +1 -1
  134. package/out/zero-cache/src/types/pg-data-type.d.ts +73 -0
  135. package/out/zero-cache/src/types/pg-data-type.d.ts.map +1 -0
  136. package/out/zero-cache/src/types/pg-data-type.js +76 -0
  137. package/out/zero-cache/src/types/pg-data-type.js.map +1 -0
  138. package/out/zero-cache/src/types/pg.d.ts +1 -73
  139. package/out/zero-cache/src/types/pg.d.ts.map +1 -1
  140. package/out/zero-cache/src/types/pg.js +0 -77
  141. package/out/zero-cache/src/types/pg.js.map +1 -1
  142. package/out/zero-cache/src/types/processes.d.ts +1 -1
  143. package/out/zero-cache/src/types/processes.d.ts.map +1 -1
  144. package/out/zero-cache/src/types/processes.js.map +1 -1
  145. package/out/zero-cache/src/types/schema-versions.d.ts +7 -3
  146. package/out/zero-cache/src/types/schema-versions.d.ts.map +1 -1
  147. package/out/zero-cache/src/types/schema-versions.js +7 -5
  148. package/out/zero-cache/src/types/schema-versions.js.map +1 -1
  149. package/out/zero-cache/src/types/streams.d.ts +1 -1
  150. package/out/zero-cache/src/types/streams.d.ts.map +1 -1
  151. package/out/zero-cache/src/types/streams.js +19 -9
  152. package/out/zero-cache/src/types/streams.js.map +1 -1
  153. package/out/zero-cache/src/types/subscription.d.ts +17 -2
  154. package/out/zero-cache/src/types/subscription.d.ts.map +1 -1
  155. package/out/zero-cache/src/types/subscription.js +42 -6
  156. package/out/zero-cache/src/types/subscription.js.map +1 -1
  157. package/out/zero-cache/src/types/websocket-handoff.d.ts +3 -3
  158. package/out/zero-cache/src/types/websocket-handoff.d.ts.map +1 -1
  159. package/out/zero-cache/src/types/websocket-handoff.js +6 -4
  160. package/out/zero-cache/src/types/websocket-handoff.js.map +1 -1
  161. package/out/zero-cache/src/workers/connection.d.ts +6 -1
  162. package/out/zero-cache/src/workers/connection.d.ts.map +1 -1
  163. package/out/zero-cache/src/workers/connection.js +26 -9
  164. package/out/zero-cache/src/workers/connection.js.map +1 -1
  165. package/out/zero-cache/src/workers/syncer-ws-message-handler.d.ts.map +1 -1
  166. package/out/zero-cache/src/workers/syncer-ws-message-handler.js +7 -1
  167. package/out/zero-cache/src/workers/syncer-ws-message-handler.js.map +1 -1
  168. package/out/zero-cache/src/workers/syncer.d.ts.map +1 -1
  169. package/out/zero-cache/src/workers/syncer.js +22 -4
  170. package/out/zero-cache/src/workers/syncer.js.map +1 -1
  171. package/out/zero-client/src/client/client-error-kind-enum.d.ts +8 -0
  172. package/out/zero-client/src/client/client-error-kind-enum.d.ts.map +1 -1
  173. package/out/zero-client/src/client/connection-manager.d.ts +82 -14
  174. package/out/zero-client/src/client/connection-manager.d.ts.map +1 -1
  175. package/out/zero-client/src/client/connection-status-enum.d.ts +4 -0
  176. package/out/zero-client/src/client/connection-status-enum.d.ts.map +1 -1
  177. package/out/zero-client/src/client/connection.d.ts +53 -0
  178. package/out/zero-client/src/client/connection.d.ts.map +1 -0
  179. package/out/zero-client/src/client/error.d.ts +51 -24
  180. package/out/zero-client/src/client/error.d.ts.map +1 -1
  181. package/out/zero-client/src/client/ivm-branch.d.ts +2 -2
  182. package/out/zero-client/src/client/ivm-branch.d.ts.map +1 -1
  183. package/out/zero-client/src/client/metrics.d.ts +9 -0
  184. package/out/zero-client/src/client/metrics.d.ts.map +1 -1
  185. package/out/zero-client/src/client/mutation-tracker.d.ts +5 -4
  186. package/out/zero-client/src/client/mutation-tracker.d.ts.map +1 -1
  187. package/out/zero-client/src/client/options.d.ts +15 -18
  188. package/out/zero-client/src/client/options.d.ts.map +1 -1
  189. package/out/zero-client/src/client/query-manager.d.ts +5 -4
  190. package/out/zero-client/src/client/query-manager.d.ts.map +1 -1
  191. package/out/zero-client/src/client/zero-rep.d.ts +3 -1
  192. package/out/zero-client/src/client/zero-rep.d.ts.map +1 -1
  193. package/out/zero-client/src/client/zero.d.ts +27 -5
  194. package/out/zero-client/src/client/zero.d.ts.map +1 -1
  195. package/out/zero-client/src/mod.d.ts +12 -1
  196. package/out/zero-client/src/mod.d.ts.map +1 -1
  197. package/out/zero-client/src/types/query-result.d.ts +23 -0
  198. package/out/zero-client/src/types/query-result.d.ts.map +1 -0
  199. package/out/zero-protocol/src/application-error.d.ts +33 -0
  200. package/out/zero-protocol/src/application-error.d.ts.map +1 -0
  201. package/out/zero-protocol/src/application-error.js +37 -0
  202. package/out/zero-protocol/src/application-error.js.map +1 -0
  203. package/out/zero-protocol/src/custom-queries.d.ts +56 -53
  204. package/out/zero-protocol/src/custom-queries.d.ts.map +1 -1
  205. package/out/zero-protocol/src/custom-queries.js +16 -14
  206. package/out/zero-protocol/src/custom-queries.js.map +1 -1
  207. package/out/zero-protocol/src/down.d.ts +8 -10
  208. package/out/zero-protocol/src/down.d.ts.map +1 -1
  209. package/out/zero-protocol/src/error-kind-enum.d.ts +65 -0
  210. package/out/zero-protocol/src/error-kind-enum.d.ts.map +1 -1
  211. package/out/zero-protocol/src/error-kind-enum.js +2 -0
  212. package/out/zero-protocol/src/error-kind-enum.js.map +1 -1
  213. package/out/zero-protocol/src/error-origin-enum.d.ts +7 -0
  214. package/out/zero-protocol/src/error-origin-enum.d.ts.map +1 -0
  215. package/out/zero-protocol/src/error-origin-enum.js +4 -0
  216. package/out/zero-protocol/src/error-origin-enum.js.map +1 -0
  217. package/out/zero-protocol/src/error-origin.d.ts +5 -0
  218. package/out/zero-protocol/src/error-origin.d.ts.map +1 -0
  219. package/out/zero-protocol/src/error-origin.js +3 -0
  220. package/out/zero-protocol/src/error-origin.js.map +1 -0
  221. package/out/zero-protocol/src/error-reason-enum.d.ts +15 -0
  222. package/out/zero-protocol/src/error-reason-enum.d.ts.map +1 -0
  223. package/out/zero-protocol/src/error-reason-enum.js +8 -0
  224. package/out/zero-protocol/src/error-reason-enum.js.map +1 -0
  225. package/out/zero-protocol/src/error-reason.d.ts +5 -0
  226. package/out/zero-protocol/src/error-reason.d.ts.map +1 -0
  227. package/out/zero-protocol/src/error-reason.js +3 -0
  228. package/out/zero-protocol/src/error-reason.js.map +1 -0
  229. package/out/zero-protocol/src/error.d.ts +181 -1
  230. package/out/zero-protocol/src/error.d.ts.map +1 -1
  231. package/out/zero-protocol/src/error.js +71 -2
  232. package/out/zero-protocol/src/error.js.map +1 -1
  233. package/out/zero-protocol/src/mutation-id.d.ts +7 -0
  234. package/out/zero-protocol/src/mutation-id.d.ts.map +1 -0
  235. package/out/zero-protocol/src/mutation-id.js +6 -0
  236. package/out/zero-protocol/src/mutation-id.js.map +1 -0
  237. package/out/zero-protocol/src/mutations-patch.d.ts +6 -3
  238. package/out/zero-protocol/src/mutations-patch.d.ts.map +1 -1
  239. package/out/zero-protocol/src/mutations-patch.js +2 -1
  240. package/out/zero-protocol/src/mutations-patch.js.map +1 -1
  241. package/out/zero-protocol/src/poke.d.ts +2 -0
  242. package/out/zero-protocol/src/poke.d.ts.map +1 -1
  243. package/out/zero-protocol/src/protocol-version.d.ts +1 -1
  244. package/out/zero-protocol/src/protocol-version.d.ts.map +1 -1
  245. package/out/zero-protocol/src/protocol-version.js +3 -1
  246. package/out/zero-protocol/src/protocol-version.js.map +1 -1
  247. package/out/zero-protocol/src/push.d.ts +145 -13
  248. package/out/zero-protocol/src/push.d.ts.map +1 -1
  249. package/out/zero-protocol/src/push.js +35 -13
  250. package/out/zero-protocol/src/push.js.map +1 -1
  251. package/out/zero-react/src/mod.d.ts +7 -2
  252. package/out/zero-react/src/mod.d.ts.map +1 -1
  253. package/out/zero-react/src/use-query.d.ts +1 -21
  254. package/out/zero-react/src/use-query.d.ts.map +1 -1
  255. package/out/zero-react/src/use-zero-connection-state.d.ts +9 -0
  256. package/out/zero-react/src/use-zero-connection-state.d.ts.map +1 -0
  257. package/out/zero-react/src/use-zero-online.d.ts +2 -0
  258. package/out/zero-react/src/use-zero-online.d.ts.map +1 -1
  259. package/out/zero-react/src/zero-provider.d.ts.map +1 -1
  260. package/out/zero-server/src/mod.d.ts +5 -4
  261. package/out/zero-server/src/mod.d.ts.map +1 -1
  262. package/out/zero-server/src/mod.js +5 -4
  263. package/out/zero-server/src/mod.js.map +1 -1
  264. package/out/zero-server/src/process-mutations.d.ts +3 -3
  265. package/out/zero-server/src/process-mutations.d.ts.map +1 -1
  266. package/out/zero-server/src/process-mutations.js +181 -68
  267. package/out/zero-server/src/process-mutations.js.map +1 -1
  268. package/out/zero-server/src/queries/process-queries.d.ts +4 -3
  269. package/out/zero-server/src/queries/process-queries.d.ts.map +1 -1
  270. package/out/zero-server/src/queries/process-queries.js +85 -19
  271. package/out/zero-server/src/queries/process-queries.js.map +1 -1
  272. package/out/zero-server/src/schema.js +1 -1
  273. package/out/zero-server/src/schema.js.map +1 -1
  274. package/out/zero-server/src/zql-database.d.ts +1 -1
  275. package/out/zero-server/src/zql-database.d.ts.map +1 -1
  276. package/out/zero-server/src/zql-database.js.map +1 -1
  277. package/out/zero-solid/src/mod.d.ts +11 -2
  278. package/out/zero-solid/src/mod.d.ts.map +1 -1
  279. package/out/zero-solid/src/solid-view.d.ts +3 -23
  280. package/out/zero-solid/src/solid-view.d.ts.map +1 -1
  281. package/out/zero-solid/src/use-query.d.ts +1 -1
  282. package/out/zero-solid/src/use-query.d.ts.map +1 -1
  283. package/out/zero-solid/src/use-zero-connection-state.d.ts +10 -0
  284. package/out/zero-solid/src/use-zero-connection-state.d.ts.map +1 -0
  285. package/out/zero-solid/src/use-zero-online.d.ts +1 -7
  286. package/out/zero-solid/src/use-zero-online.d.ts.map +1 -1
  287. package/out/zero-solid/src/use-zero.d.ts +1 -0
  288. package/out/zero-solid/src/use-zero.d.ts.map +1 -1
  289. package/out/zero.js +15 -3
  290. package/out/zql/src/builder/builder.d.ts +2 -1
  291. package/out/zql/src/builder/builder.d.ts.map +1 -1
  292. package/out/zql/src/builder/builder.js +5 -1
  293. package/out/zql/src/builder/builder.js.map +1 -1
  294. package/out/zql/src/ivm/data.d.ts +1 -1
  295. package/out/zql/src/ivm/data.d.ts.map +1 -1
  296. package/out/zql/src/ivm/data.js.map +1 -1
  297. package/out/zql/src/ivm/filter-push.d.ts +1 -1
  298. package/out/zql/src/ivm/filter-push.d.ts.map +1 -1
  299. package/out/zql/src/ivm/filter-push.js.map +1 -1
  300. package/out/zql/src/ivm/memory-source.d.ts +2 -2
  301. package/out/zql/src/ivm/memory-source.d.ts.map +1 -1
  302. package/out/zql/src/ivm/memory-source.js.map +1 -1
  303. package/out/zql/src/ivm/source.d.ts +1 -1
  304. package/out/zql/src/ivm/source.d.ts.map +1 -1
  305. package/out/zql/src/ivm/take.d.ts +1 -1
  306. package/out/zql/src/ivm/take.d.ts.map +1 -1
  307. package/out/zql/src/ivm/take.js.map +1 -1
  308. package/out/zql/src/planner/planner-builder.d.ts +15 -0
  309. package/out/zql/src/planner/planner-builder.d.ts.map +1 -0
  310. package/out/zql/src/planner/planner-builder.js +180 -0
  311. package/out/zql/src/planner/planner-builder.js.map +1 -0
  312. package/out/zql/src/planner/planner-connection.d.ts +125 -0
  313. package/out/zql/src/planner/planner-connection.d.ts.map +1 -0
  314. package/out/zql/src/planner/planner-connection.js +257 -0
  315. package/out/zql/src/planner/planner-connection.js.map +1 -0
  316. package/out/zql/src/planner/planner-constraint.d.ts +14 -0
  317. package/out/zql/src/planner/planner-constraint.d.ts.map +1 -0
  318. package/out/zql/src/planner/planner-constraint.js +12 -0
  319. package/out/zql/src/planner/planner-constraint.js.map +1 -0
  320. package/out/zql/src/planner/planner-debug.d.ts +148 -0
  321. package/out/zql/src/planner/planner-debug.d.ts.map +1 -0
  322. package/out/zql/src/planner/planner-debug.js +176 -0
  323. package/out/zql/src/planner/planner-debug.js.map +1 -0
  324. package/out/zql/src/planner/planner-fan-in.d.ts +39 -0
  325. package/out/zql/src/planner/planner-fan-in.d.ts.map +1 -0
  326. package/out/zql/src/planner/planner-fan-in.js +167 -0
  327. package/out/zql/src/planner/planner-fan-in.js.map +1 -0
  328. package/out/zql/src/planner/planner-fan-out.d.ts +23 -0
  329. package/out/zql/src/planner/planner-fan-out.d.ts.map +1 -0
  330. package/out/zql/src/planner/planner-fan-out.js +62 -0
  331. package/out/zql/src/planner/planner-fan-out.js.map +1 -0
  332. package/out/zql/src/planner/planner-graph.d.ts +103 -0
  333. package/out/zql/src/planner/planner-graph.d.ts.map +1 -0
  334. package/out/zql/src/planner/planner-graph.js +380 -0
  335. package/out/zql/src/planner/planner-graph.js.map +1 -0
  336. package/out/zql/src/planner/planner-join.d.ts +136 -0
  337. package/out/zql/src/planner/planner-join.d.ts.map +1 -0
  338. package/out/zql/src/planner/planner-join.js +329 -0
  339. package/out/zql/src/planner/planner-join.js.map +1 -0
  340. package/out/zql/src/planner/planner-node.d.ts +48 -0
  341. package/out/zql/src/planner/planner-node.d.ts.map +1 -0
  342. package/out/zql/src/planner/planner-node.js +2 -0
  343. package/out/zql/src/planner/planner-node.js.map +1 -0
  344. package/out/zql/src/planner/planner-source.d.ts +11 -0
  345. package/out/zql/src/planner/planner-source.d.ts.map +1 -0
  346. package/out/zql/src/planner/planner-source.js +13 -0
  347. package/out/zql/src/planner/planner-source.js.map +1 -0
  348. package/out/zql/src/planner/planner-terminus.d.ts +17 -0
  349. package/out/zql/src/planner/planner-terminus.d.ts.map +1 -0
  350. package/out/zql/src/planner/planner-terminus.js +28 -0
  351. package/out/zql/src/planner/planner-terminus.js.map +1 -0
  352. package/out/zql/src/query/error.d.ts +4 -0
  353. package/out/zql/src/query/error.d.ts.map +1 -0
  354. package/out/zql/src/query/error.js +9 -0
  355. package/out/zql/src/query/error.js.map +1 -0
  356. package/out/zql/src/query/expression.d.ts +2 -2
  357. package/out/zql/src/query/expression.d.ts.map +1 -1
  358. package/out/zql/src/query/expression.js.map +1 -1
  359. package/out/zql/src/query/named.d.ts.map +1 -1
  360. package/out/zql/src/query/named.js +9 -1
  361. package/out/zql/src/query/named.js.map +1 -1
  362. package/out/zql/src/query/query-delegate.d.ts +3 -3
  363. package/out/zql/src/query/query-delegate.d.ts.map +1 -1
  364. package/out/zql/src/query/query-impl.d.ts +8 -8
  365. package/out/zql/src/query/query-impl.d.ts.map +1 -1
  366. package/out/zql/src/query/query-impl.js.map +1 -1
  367. package/out/zql/src/query/query.d.ts +3 -3
  368. package/out/zql/src/query/query.d.ts.map +1 -1
  369. package/out/zql/src/query/static-query.d.ts +1 -1
  370. package/out/zql/src/query/static-query.d.ts.map +1 -1
  371. package/out/zql/src/query/static-query.js.map +1 -1
  372. package/out/zql/src/query/typed-view.d.ts +1 -1
  373. package/out/zql/src/query/typed-view.d.ts.map +1 -1
  374. package/out/zqlite/src/query-delegate.d.ts +1 -1
  375. package/out/zqlite/src/query-delegate.d.ts.map +1 -1
  376. package/out/zqlite/src/query-delegate.js.map +1 -1
  377. package/out/zqlite/src/sqlite-cost-model.d.ts +17 -0
  378. package/out/zqlite/src/sqlite-cost-model.d.ts.map +1 -0
  379. package/out/zqlite/src/sqlite-cost-model.js +134 -0
  380. package/out/zqlite/src/sqlite-cost-model.js.map +1 -0
  381. package/out/zqlite/src/table-source.d.ts +1 -1
  382. package/out/zqlite/src/table-source.d.ts.map +1 -1
  383. package/out/zqlite/src/table-source.js.map +1 -1
  384. package/package.json +6 -4
  385. package/out/chunk-BJ2CGCME.js.map +0 -7
  386. package/out/chunk-MXPHMVU7.js.map +0 -7
  387. package/out/zero-cache/src/types/error-for-client.d.ts +0 -23
  388. package/out/zero-cache/src/types/error-for-client.d.ts.map +0 -1
  389. package/out/zero-cache/src/types/error-for-client.js +0 -28
  390. package/out/zero-cache/src/types/error-for-client.js.map +0 -1
  391. package/out/zero-client/src/client/ping-result-enum.d.ts +0 -5
  392. package/out/zero-client/src/client/ping-result-enum.d.ts.map +0 -1
  393. /package/out/{chunk-4RB4OYLQ.js.map → chunk-TJFNGO7E.js.map} +0 -0
  394. /package/out/{lazy-inspector-2SW772W4.js.map → lazy-inspector-OXIFYSSQ.js.map} +0 -0
@@ -16,6 +16,25 @@ import { Connection, sendError } from "./connection.js";
16
16
  import { createNotifierFrom, subscribeTo } from "./replicator.js";
17
17
  import { SyncerWsMessageHandler } from "./syncer-ws-message-handler.js";
18
18
  import { recordConnectionSuccess, recordConnectionAttempted, setActiveClientGroupsGetter, } from "../server/anonymous-otel-start.js";
19
+ import { ErrorOrigin } from "../../../zero-protocol/src/error-origin.js";
20
+ function getWebSocketServerOptions(config) {
21
+ const options = {
22
+ noServer: true,
23
+ };
24
+ if (config.websocketCompression) {
25
+ options.perMessageDeflate = true;
26
+ if (config.websocketCompressionOptions) {
27
+ try {
28
+ const compressionOptions = JSON.parse(config.websocketCompressionOptions);
29
+ options.perMessageDeflate = compressionOptions;
30
+ }
31
+ catch (e) {
32
+ throw new Error(`Failed to parse ZERO_WEBSOCKET_COMPRESSION_OPTIONS: ${String(e)}. Expected valid JSON.`);
33
+ }
34
+ }
35
+ }
36
+ return options;
37
+ }
19
38
  /**
20
39
  * The Syncer worker receives websocket handoffs for "/sync" connections
21
40
  * from the Dispatcher in the main thread, and creates websocket
@@ -48,7 +67,7 @@ export class Syncer {
48
67
  this.#pushers = new ServiceRunner(lc, pusherFactory, p => p.hasRefs());
49
68
  }
50
69
  this.#parent = parent;
51
- this.#wss = new WebSocketServer({ noServer: true });
70
+ this.#wss = new WebSocketServer(getWebSocketServerOptions(config));
52
71
  installWebSocketReceiver(lc, this.#wss, this.#createConnection, this.#parent);
53
72
  setActiveClientGroupsGetter(() => this.#viewSyncers.size);
54
73
  }
@@ -86,6 +105,7 @@ export class Syncer {
86
105
  sendError(this.#lc, ws, {
87
106
  kind: ErrorKind.AuthInvalidated,
88
107
  message: `Failed to decode auth token: ${String(e)}`,
108
+ origin: ErrorOrigin.ZeroCache,
89
109
  }, e);
90
110
  ws.close(3000, 'Failed to decode JWT');
91
111
  return;
@@ -105,9 +125,7 @@ export class Syncer {
105
125
  pusher?.ref();
106
126
  let connection;
107
127
  try {
108
- connection = new Connection(this.#lc, params, ws, new SyncerWsMessageHandler(this.#lc, params,
109
- // auth is an empty string if the user is not authenticated
110
- auth
128
+ connection = new Connection(this.#lc, params, ws, new SyncerWsMessageHandler(this.#lc, params, auth
111
129
  ? {
112
130
  raw: auth,
113
131
  decoded: decodedToken ?? {},
@@ -1 +1 @@
1
- {"version":3,"file":"syncer.js","sourceRoot":"","sources":["../../../../../zero-cache/src/workers/syncer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAC,QAAQ,EAAC,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAiB,MAAM,MAAM,CAAC;AACrC,OAAO,EAAC,GAAG,EAAC,MAAM,cAAc,CAAC;AACjC,OAAO,EAAC,WAAW,EAAC,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAC,eAAe,EAAiB,MAAM,IAAI,CAAC;AACnD,OAAO,EAAC,WAAW,EAAC,MAAM,0CAA0C,CAAC;AACrE,OAAO,EAAC,SAAS,EAAC,MAAM,0CAA0C,CAAC;AACnE,OAAO,EAAC,kBAAkB,EAAE,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAiB,MAAM,0BAA0B,CAAC;AAIzD,OAAO,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAC;AAMpD,OAAO,EAAC,gBAAgB,EAA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MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACzB,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,YAAY,IAAI,CAAC,YAAY,CAAC,IAAI,eAAe,CAAC,CAAC;QAEnE,IAAI,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;QAEtC,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC;YAC9B,MAAM,IAAI,CAAC,iBAAiB,CAAC,iBAAiB,CAAC;YAE/C,gDAAgD;YAChD,KAAK,MAAM,EAAE,IAAI,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,EAAE,CAAC;gBACjD,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,wBAAwB,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC;gBAC3D,6EAA6E;gBAC7E,yCAAyC;gBACzC,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC;gBACf,MAAM;YACR,CAAC;QACH,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,sBAAsB,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,MAAM,CAAC,CAAC;IAClE,CAAC;IAED,IAAI;QACF,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QAClB,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;QACxB,OAAO,WAAW,CAAC;IACrB,CAAC;CACF"}
@@ -5,8 +5,12 @@ export declare const ConnectTimeout = "ConnectTimeout";
5
5
  export declare const DisconnectTimeout = "DisconnectTimeout";
6
6
  export declare const UnexpectedBaseCookie = "UnexpectedBaseCookie";
7
7
  export declare const PingTimeout = "PingTimeout";
8
+ export declare const PullTimeout = "PullTimeout";
8
9
  export declare const Hidden = "Hidden";
9
10
  export declare const NoSocketOrigin = "NoSocketOrigin";
11
+ export declare const InvalidMessage = "InvalidMessage";
12
+ export declare const UserDisconnect = "UserDisconnect";
13
+ export declare const Internal = "Internal";
10
14
  export type AbruptClose = typeof AbruptClose;
11
15
  export type CleanClose = typeof CleanClose;
12
16
  export type ClientClosed = typeof ClientClosed;
@@ -14,6 +18,10 @@ export type ConnectTimeout = typeof ConnectTimeout;
14
18
  export type DisconnectTimeout = typeof DisconnectTimeout;
15
19
  export type UnexpectedBaseCookie = typeof UnexpectedBaseCookie;
16
20
  export type PingTimeout = typeof PingTimeout;
21
+ export type PullTimeout = typeof PullTimeout;
17
22
  export type Hidden = typeof Hidden;
18
23
  export type NoSocketOrigin = typeof NoSocketOrigin;
24
+ export type InvalidMessage = typeof InvalidMessage;
25
+ export type UserDisconnect = typeof UserDisconnect;
26
+ export type Internal = typeof Internal;
19
27
  //# sourceMappingURL=client-error-kind-enum.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client-error-kind-enum.d.ts","sourceRoot":"","sources":["../../../../../zero-client/src/client/client-error-kind-enum.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,gBAAgB,CAAC;AACzC,eAAO,MAAM,UAAU,eAAe,CAAC;AACvC,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAC3C,eAAO,MAAM,cAAc,mBAAmB,CAAC;AAC/C,eAAO,MAAM,iBAAiB,sBAAsB,CAAC;AACrD,eAAO,MAAM,oBAAoB,yBAAyB,CAAC;AAC3D,eAAO,MAAM,WAAW,gBAAgB,CAAC;AACzC,eAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,eAAO,MAAM,cAAc,mBAAmB,CAAC;AAE/C,MAAM,MAAM,WAAW,GAAG,OAAO,WAAW,CAAC;AAC7C,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC;AAC3C,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC;AAC/C,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC;AACnD,MAAM,MAAM,iBAAiB,GAAG,OAAO,iBAAiB,CAAC;AACzD,MAAM,MAAM,oBAAoB,GAAG,OAAO,oBAAoB,CAAC;AAC/D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AO,cAAc,CAAC;AACnD,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC;AACnD,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC;AACnD,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC"}
@@ -1,9 +1,28 @@
1
1
  import { Subscribable } from '../../../shared/src/subscribable.ts';
2
2
  import { ConnectionStatus } from './connection-status.ts';
3
- import type { ZeroError } from './error.ts';
3
+ import { type AuthError, type ZeroError } from './error.ts';
4
+ /**
5
+ * The current connection state of the Zero instance. It can be one of the following states:
6
+ *
7
+ * - `connecting`: The client is actively trying to connect every 5 seconds.
8
+ * - `attempt` counts the number of retries within the current retry window,
9
+ * - `disconnectAt` is the epoch timestamp when the client will transition to `disconnected` state
10
+ * - `reason` is the optional error associated with the connection attempt.
11
+ * - `disconnected`: The client is now in an "offline" state. It will continue
12
+ * to try to connect every 5 seconds.
13
+ * - `connected`: The client has opened a successful connection to the server.
14
+ * - `needs-auth`: Authentication is invalid or expired. No connection retries will be made
15
+ * until the host application calls `connect({auth: token})`.
16
+ * - `reason` is the `ZeroError` associated with the error state.
17
+ * - `error`: A fatal error occurred. No connection retries will be made until the host
18
+ * application calls `connect()` again.
19
+ * - `reason` is the `ZeroError` associated with the error state.
20
+ * - `closed`: The client was shut down (for example via `zero.close()`). This is
21
+ * a terminal state, and a new Zero instance must be created to reconnect.
22
+ */
4
23
  export type ConnectionState = {
5
24
  name: ConnectionStatus.Disconnected;
6
- reason?: ZeroError | undefined;
25
+ reason: ZeroError;
7
26
  } | {
8
27
  name: ConnectionStatus.Connecting;
9
28
  attempt: number;
@@ -11,8 +30,15 @@ export type ConnectionState = {
11
30
  reason?: ZeroError | undefined;
12
31
  } | {
13
32
  name: ConnectionStatus.Connected;
33
+ } | {
34
+ name: ConnectionStatus.NeedsAuth;
35
+ reason: AuthError;
36
+ } | {
37
+ name: ConnectionStatus.Error;
38
+ reason: ZeroError;
14
39
  } | {
15
40
  name: ConnectionStatus.Closed;
41
+ reason: ZeroError;
16
42
  };
17
43
  export type ConnectionManagerOptions = {
18
44
  /**
@@ -26,6 +52,11 @@ export type ConnectionManagerOptions = {
26
52
  */
27
53
  timeoutCheckIntervalMs?: number | undefined;
28
54
  };
55
+ declare const TERMINAL_STATES: ["needs-auth", "error"];
56
+ type TerminalConnectionStatus = (typeof TERMINAL_STATES)[number];
57
+ type TerminalConnectionState = Extract<ConnectionState, {
58
+ name: TerminalConnectionStatus;
59
+ }>;
29
60
  export declare class ConnectionManager extends Subscribable<ConnectionState> {
30
61
  #private;
31
62
  constructor(options: ConnectionManagerOptions);
@@ -34,13 +65,27 @@ export declare class ConnectionManager extends Subscribable<ConnectionState> {
34
65
  * Returns true if the current state is equal to the given status.
35
66
  */
36
67
  is(status: ConnectionStatus): boolean;
68
+ /**
69
+ * Returns true if the current state is a terminal state
70
+ * that can be recovered from by calling connect().
71
+ */
72
+ isInTerminalState(): boolean;
73
+ /**
74
+ * Returns true if the given status is a terminal state
75
+ * that can be recovered from by calling connect().
76
+ */
77
+ static isTerminalState(state: ConnectionState): state is TerminalConnectionState;
37
78
  /**
38
79
  * Returns true if the run loop should continue.
39
- * The run loop continues in disconnected, connecting, and connected states.
40
- * It stops in closed state.
80
+ * The run loop continues in all states except closed.
81
+ * In needs-auth and error states, the run loop pauses and waits for connect() to be called.
41
82
  */
42
83
  shouldContinueRunLoop(): boolean;
43
- waitForStateChange(): Promise<void>;
84
+ /**
85
+ * Waits for the next state change.
86
+ * @returns A promise that resolves when the next state change occurs.
87
+ */
88
+ waitForStateChange(): Promise<ConnectionState>;
44
89
  /**
45
90
  * Transition to connecting state.
46
91
  *
@@ -49,8 +94,8 @@ export declare class ConnectionManager extends Subscribable<ConnectionState> {
49
94
  *
50
95
  * @returns An object containing a promise that resolves on the next state change.
51
96
  */
52
- connecting(reason?: ZeroError | undefined): {
53
- nextStatePromise: Promise<void>;
97
+ connecting(reason?: ZeroError): {
98
+ nextStatePromise: Promise<ConnectionState>;
54
99
  };
55
100
  /**
56
101
  * Transition to connected state.
@@ -59,7 +104,7 @@ export declare class ConnectionManager extends Subscribable<ConnectionState> {
59
104
  * @returns An object containing a promise that resolves on the next state change.
60
105
  */
61
106
  connected(): {
62
- nextStatePromise: Promise<void>;
107
+ nextStatePromise: Promise<ConnectionState>;
63
108
  };
64
109
  /**
65
110
  * Transition to disconnected state.
@@ -69,18 +114,41 @@ export declare class ConnectionManager extends Subscribable<ConnectionState> {
69
114
  *
70
115
  * @returns An object containing a promise that resolves on the next state change.
71
116
  */
72
- disconnected(reason?: ZeroError | undefined): {
73
- nextStatePromise: Promise<void>;
117
+ disconnected(reason: ZeroError): {
118
+ nextStatePromise: Promise<ConnectionState>;
74
119
  };
75
120
  /**
76
- * Transition to closed state.
77
- * This is terminal - no further transitions are allowed.
121
+ * Transition to needs-auth state.
122
+ * This pauses the run loop until connect() is called with new credentials.
123
+ * Resets the retry window and attempt counter.
124
+ *
125
+ * @returns An object containing a promise that resolves on the next state change.
126
+ */
127
+ needsAuth(reason: AuthError): {
128
+ nextStatePromise: Promise<ConnectionState>;
129
+ };
130
+ /**
131
+ * Transition to error state.
132
+ * This pauses the run loop until connect() is called.
133
+ * Resets the retry window and attempt counter.
78
134
  *
79
135
  * @returns An object containing a promise that resolves on the next state change.
80
136
  */
81
- closed(): {
82
- nextStatePromise: Promise<void>;
137
+ error(reason: ZeroError): {
138
+ nextStatePromise: Promise<ConnectionState>;
83
139
  };
140
+ /**
141
+ * Transition to closed state.
142
+ * This is terminal - no further transitions are allowed.
143
+ */
144
+ closed(): void;
84
145
  cleanup: () => void;
85
146
  }
147
+ /**
148
+ * Used to trigger the catch block when a terminal state is reached.
149
+ *
150
+ * @param state - The current connection state.
151
+ */
152
+ export declare const throwIfConnectionError: (state: ConnectionState) => void;
153
+ export {};
86
154
  //# sourceMappingURL=connection-manager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"connection-manager.d.ts","sourceRoot":"","sources":["../../../../../zero-client/src/client/connection-man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A;KAAC;IAsB9C;;;;;;;OAOG;IACH,YAAY,CAAC,MAAM,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG;QAC5C,gBAAgB,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;KACjC;IA6BD;;;;;OAKG;IACH,MAAM,IAAI;QAAC,gBAAgB,EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;KAAC;IAgBlC,OAAO,QAAO,IAAI,CAGzB;CAuDH"}
1
+ {"version":3,"file":"connection-manager.d.ts","sourceRoot":"","sources":["../../../../../zero-client/src/client/connection-manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAC,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAC,gBAAgB,EAAC,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAGL,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,YAAY,CAAC;AAKpB;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,eAAe,GACvB;IACE,IAAI,EAAE,gBAAgB,CAAC,YAAY,CAAC;IACpC,MAAM,EAAE,SAAS,CAAC;CACnB,GACD;IACE,IAAI,EAAE,gBAAgB,CAAC,UAAU,CAAC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CAChC,GACD;IACE,IAAI,EAAE,gBAAgB,CAAC,SAAS,CAAC;CAClC,GACD;IACE,IAAI,EAAE,gBAAgB,CAAC,SAAS,CAAC;IACjC,MAAM,EAAE,SAAS,CAAC;CACnB,GACD;IACE,IAAI,EAAE,gBAAgB,CAAC,KAAK,CAAC;IAC7B,MAAM,EAAE,SAAS,CAAC;CACnB,GACD;IACE,IAAI,EAAE,gBAAgB,CAAC,MAAM,CAAC;IAC9B,MAAM,EAAE,SAAS,CAAC;CACnB,CAAC;AAEN,MAAM,MAAM,wBAAwB,GAAG;IACrC;;;OAGG;IACH,mBAAmB,EAAE,MAA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G;QAAC,gBAAgB,EAAE,OAAO,CAAC,eAAe,CAAC,CAAA;KAAC;IAuBtE;;;OAGG;IACH,MAAM;IAqBG,OAAO,QAAO,IAAI,CAGzB;CA4DH;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GAAI,OAAO,eAAe,SAkB5D,CAAC"}
@@ -1,9 +1,13 @@
1
1
  export declare const Disconnected = "disconnected";
2
2
  export declare const Connecting = "connecting";
3
3
  export declare const Connected = "connected";
4
+ export declare const NeedsAuth = "needs-auth";
5
+ export declare const Error = "error";
4
6
  export declare const Closed = "closed";
5
7
  export type Disconnected = typeof Disconnected;
6
8
  export type Connecting = typeof Connecting;
7
9
  export type Connected = typeof Connected;
10
+ export type NeedsAuth = typeof NeedsAuth;
11
+ export type Error = typeof Error;
8
12
  export type Closed = typeof Closed;
9
13
  //# sourceMappingURL=connection-status-enum.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"connection-status-enum.d.ts","sourceRoot":"","sources":["../../../../../zero-client/src/client/connection-status-enum.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAC3C,eAAO,MAAM,UAAU,eAAe,CAAC;AACvC,eAAO,MAAM,SAAS,cAAc,CAAC;AACrC,eAAO,MAAM,MAAM,WAAW,CAAC;AAE/B,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC;AAC/C,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC;AAC3C,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC;AACzC,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC"}
1
+ {"version":3,"file":"connection-status-enum.d.ts","sourceRoot":"","sources":["../../../../../zero-client/src/client/connection-status-enum.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAC3C,eAAO,MAAM,UAAU,eAAe,CAAC;AACvC,eAAO,MAAM,SAAS,cAAc,CAAC;AACrC,eAAO,MAAM,SAAS,eAAe,CAAC;AACtC,eAAO,MAAM,KAAK,UAAU,CAAC;AAC7B,eAAO,MAAM,MAAM,WAAW,CAAC;AAE/B,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC;AAC/C,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC;AAC3C,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC;AACzC,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC;AACzC,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC;AACjC,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC"}
@@ -0,0 +1,53 @@
1
+ import type { ConnectionManager, ConnectionState } from './connection-manager.ts';
2
+ import type { ZeroLogContext } from './zero-log-context.ts';
3
+ export interface Source<T> {
4
+ /**
5
+ * The current state value.
6
+ */
7
+ readonly current: T;
8
+ /**
9
+ * Subscribe to state changes.
10
+ *
11
+ * @param listener - Called when the state changes with the new state value.
12
+ * @returns A function to unsubscribe from state changes.
13
+ */
14
+ subscribe(listener: (state: T) => void): () => void;
15
+ }
16
+ /**
17
+ * Connection API for managing Zero's connection lifecycle.
18
+ */
19
+ export interface Connection {
20
+ /**
21
+ * The current connection state as a subscribable value.
22
+ */
23
+ readonly state: Source<ConnectionState>;
24
+ /**
25
+ * Resumes the connection from a terminal state.
26
+ *
27
+ * If called when not in a terminal state, this method does nothing.
28
+ *
29
+ * @param opts - Optional connection options
30
+ * @param opts.auth - Token to use for authentication. If provided, this overrides
31
+ * the stored auth credential for this connection attempt.
32
+ * If `null` or `undefined`, the stored auth credential is cleared.
33
+ * @returns A promise that resolves once the connection state has transitioned to connecting.
34
+ */
35
+ connect(opts?: {
36
+ auth: string | null | undefined;
37
+ }): Promise<void>;
38
+ }
39
+ export declare class ConnectionImpl implements Connection {
40
+ #private;
41
+ constructor(connectionManager: ConnectionManager, lc: ZeroLogContext, setAuth: (auth: string | null | undefined) => void);
42
+ get state(): Source<ConnectionState>;
43
+ connect(opts?: {
44
+ auth: string | null | undefined;
45
+ }): Promise<void>;
46
+ }
47
+ export declare class ConnectionSource implements Source<ConnectionState> {
48
+ #private;
49
+ constructor(connectionManager: ConnectionManager);
50
+ get current(): ConnectionState;
51
+ get subscribe(): (listener: (obj: ConnectionState) => unknown) => (() => void);
52
+ }
53
+ //# sourceMappingURL=connection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../../../../zero-client/src/client/connection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,iBAAiB,EAAE,eAAe,EAAC,MAAM,yBAAyB,CAAC;AAChF,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC;AAE1D,MAAM,WAAW,MAAM,CAAC,CAAC;IACvB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IAEpB;;;;;OAKG;IACH,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CACrD;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,eAAe,CAAC,CAAC;IAExC;;;;;;;;;;OAUG;IACH,OAAO,CAAC,IAAI,CAAC,EAAE;QAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;KAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAClE;AAED,qBAAa,cAAe,YAAW,UAAU;;gBAO7C,iBAAiB,EAAE,iBAAiB,EACpC,EAAE,EAAE,cAAc,EAClB,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,KAAK,IAAI;IAQpD,IAAI,KAAK,IAAI,MAAM,CAAC,eAAe,CAAC,CAEnC;IAEK,OAAO,CAAC,IAAI,CAAC,EAAE;QAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;KAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CA0BvE;AAED,qBAAa,gBAAiB,YAAW,MAAM,CAAC,eAAe,CAAC;;gBAGlD,iBAAiB,EAAE,iBAAiB;IAIhD,IAAI,OAAO,IAAI,eAAe,CAE7B;IAED,IAAI,SAAS,kEAEZ;CACF"}
@@ -1,37 +1,64 @@
1
1
  import type { Expand } from '../../../shared/src/expand.ts';
2
2
  import { ErrorKind } from '../../../zero-protocol/src/error-kind.ts';
3
- import type { BackoffBody, ErrorBody } from '../../../zero-protocol/src/error.ts';
3
+ import { ErrorOrigin } from '../../../zero-protocol/src/error-origin.ts';
4
+ import { ErrorReason } from '../../../zero-protocol/src/error-reason.ts';
5
+ import { type BackoffBody, type ErrorBody, ProtocolError, type PushFailedBody, type TransformFailedBody } from '../../../zero-protocol/src/error.ts';
4
6
  import { ClientErrorKind } from './client-error-kind.ts';
7
+ import { ConnectionStatus } from './connection-status.ts';
8
+ export type ZeroError = ProtocolError<ErrorBody> | ClientError;
9
+ export type ZeroErrorBody = Expand<ErrorBody | ClientErrorBody>;
10
+ export type ZeroErrorKind = Expand<ErrorKind | ClientErrorKind>;
11
+ export type AuthError = ProtocolError<NeedsAuthReason>;
12
+ export type NeedsAuthReason = Expand<(ErrorBody & {
13
+ kind: ErrorKind.AuthInvalidated | ErrorKind.Unauthorized;
14
+ }) | (Extract<PushFailedBody, {
15
+ reason: ErrorReason.HTTP;
16
+ }> & {
17
+ status: 401 | 403;
18
+ }) | (Extract<TransformFailedBody, {
19
+ reason: ErrorReason.HTTP;
20
+ }> & {
21
+ status: 401 | 403;
22
+ })>;
5
23
  export type ClientErrorBody = {
6
24
  kind: ClientErrorKind;
25
+ origin: typeof ErrorOrigin.Client;
7
26
  message: string;
8
27
  };
9
- export type ZeroErrorBody = Expand<ErrorBody | ClientErrorBody>;
10
- export type ZeroErrorKind = Expand<ErrorKind | ClientErrorKind>;
11
- declare abstract class BaseError<T extends ErrorBody | ClientErrorBody, Name extends T extends ErrorBody ? 'ServerError' : 'ClientError'> extends Error {
12
- readonly errorBody: T;
13
- constructor(errorBody: T, options?: ErrorOptions);
14
- get kind(): T['kind'];
15
- abstract get name(): Name;
16
- }
17
- /**
18
- * Represents an error sent by server as part of Zero protocol.
19
- */
20
- export declare class ServerError extends BaseError<ErrorBody, 'ServerError'> {
21
- get name(): "ServerError";
22
- }
23
28
  /**
24
29
  * Represents an error encountered by the client.
25
30
  */
26
- export declare class ClientError extends BaseError<ClientErrorBody, 'ClientError'> {
27
- get name(): "ClientError";
31
+ export declare class ClientError<const T extends Omit<ClientErrorBody, 'origin'> = Omit<ClientErrorBody, 'origin'>> extends Error {
32
+ readonly errorBody: {
33
+ origin: typeof ErrorOrigin.Client;
34
+ } & T;
35
+ constructor(errorBody: T, options?: ErrorOptions);
36
+ get kind(): T['kind'];
28
37
  }
29
- export type ZeroError = ServerError | ClientError;
30
- export declare function isServerError(ex: unknown): ex is ServerError;
31
- export declare function isAuthError(ex: unknown): ex is ServerError & {
32
- kind: ErrorKind.AuthInvalidated | ErrorKind.Unauthorized;
38
+ export declare function isServerError(ex: unknown): ex is ProtocolError<ErrorBody>;
39
+ export declare function isAuthError(ex: unknown): ex is AuthError;
40
+ export declare function getBackoffParams(error: ZeroError): BackoffBody | undefined;
41
+ export declare function isClientError(ex: unknown): ex is ClientError<ClientErrorBody>;
42
+ export declare const NO_STATUS_TRANSITION = "NO_STATUS_TRANSITION";
43
+ export type ErrorConnectionTransition = {
44
+ status: typeof NO_STATUS_TRANSITION;
45
+ reason: ZeroError;
46
+ } | {
47
+ status: ConnectionStatus.NeedsAuth;
48
+ reason: AuthError;
49
+ } | {
50
+ status: ConnectionStatus.Error;
51
+ reason: ZeroError;
52
+ } | {
53
+ status: ConnectionStatus.Disconnected;
54
+ reason: ZeroError;
55
+ } | {
56
+ status: ConnectionStatus.Closed;
57
+ reason: ZeroError;
33
58
  };
34
- export declare function isBackoffError(ex: unknown): BackoffBody | undefined;
35
- export declare function isClientError(ex: unknown): ex is ClientError;
36
- export {};
59
+ /**
60
+ * Returns the status to transition to, or null if the error
61
+ * indicates that the connection should continue in the current state.
62
+ */
63
+ export declare function getErrorConnectionTransition(ex: unknown): ErrorConnectionTransition;
37
64
  //# sourceMappingURL=error.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../../../zero-client/src/client/error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAC,SAAS,EAAC,MAAM,0CAA0C,CAAC;AACnE,OAAO,KAAK,EAAC,WAAW,EAAE,SAAS,EAAC,MAAM,qCAAqC,CAAC;AAChF,OAAO,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAC;AAEvD,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,eAAe,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,SAAS,GAAG,eAAe,CAAC,CAAC;AAChE,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,SAAS,GAAG,eAAe,CAAC,CAAC;AAEhE,uBAAe,SAAS,CACtB,CAAC,SAAS,SAAS,GAAG,eAAe,EACrC,IAAI,SAAS,CAAC,SAAS,SAAS,GAAG,aAAa,GAAG,aAAa,CAChE,SAAQ,KAAK;IACb,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC;gBACV,SAAS,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,YAAY;IAIhD,IAAI,IAAI,IAAI,CAAC,CAAC,MAAM,CAAC,CAEpB;IACD,QAAQ,KAAK,IAAI,IAAI,IAAI,CAAC;CAC3B;AAED;;GAEG;AACH,qBAAa,WAAY,SAAQ,SAAS,CAAC,SAAS,EAAE,aAAa,CAAC;IAClE,IAAI,IAAI,IACC,aAAa,CACrB;CACF;AAED;;GAEG;AACH,qBAAa,WAAY,SAAQ,SAAS,CAAC,eA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AAC,KAAK,EAAE,SAAS,GAAG,WAAW,GAAG,SAAS,CAU1E;AAED,wBAAgB,aAAa,CAAC,EAAE,EAAE,OAAO,GAAG,EAAE,IAAI,WAAW,CAAC,eAAe,CAAC,CAI7E;AAED,eAAO,MAAM,oBAAoB,yBAAyB,CAAC;AAE3D,MAAM,MAAM,yBAAyB,GACjC;IAAC,MAAM,EAAE,OAAO,oBAAoB,CAAC;IAAC,MAAM,EAAE,SAAS,CAAA;CAAC,GACxD;IAAC,MAAM,EAAE,gBAAgB,CAAC,SAAS,CAAC;IAAC,MAAM,EAAE,SAAS,CAAA;CAAC,GACvD;IAAC,MAAM,EAAE,gBAAgB,CAAC,KAAK,CAAC;IAAC,MAAM,EAAE,SAAS,CAAA;CAAC,GACnD;IAAC,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC;IAAC,MAAM,EAAE,SAAS,CAAA;CAAC,GAC1D;IAAC,MAAM,EAAE,gBAAgB,CAAC,MAAM,CAAC;IAAC,MAAM,EAAE,SAAS,CAAA;CAAC,CAAC;AAEzD;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,EAAE,EAAE,OAAO,GACV,yBAAyB,CAmG3B"}
@@ -24,7 +24,7 @@ import type { LazyStore } from '../../../replicache/src/dag/lazy-store.ts';
24
24
  export declare class IVMSourceBranch {
25
25
  #private;
26
26
  hash: Hash | undefined;
27
- constructor(tables: Record<string, TableSchema>, hash?: Hash | undefined, sources?: Map<string, MemorySource | undefined>);
27
+ constructor(tables: Record<string, TableSchema>, hash?: Hash, sources?: Map<string, MemorySource | undefined>);
28
28
  getSource(name: string): MemorySource | undefined;
29
29
  clear(): void;
30
30
  /**
@@ -35,7 +35,7 @@ export declare class IVMSourceBranch {
35
35
  /**
36
36
  * Fork the branch and patch it up to match the desired head.
37
37
  */
38
- forkToHead(store: LazyStore, desiredHead: Hash, readOptions?: ZeroReadOptions | undefined): Promise<IVMSourceBranch>;
38
+ forkToHead(store: LazyStore, desiredHead: Hash, readOptions?: ZeroReadOptions): Promise<IVMSourceBranch>;
39
39
  /**
40
40
  * Creates a new IVMSourceBranch that is a copy of the current one.
41
41
  * This is a cheap operation since the b-trees are shared until a write is performed
@@ -1 +1 @@
1
- {"version":3,"file":"ivm-branch.d.ts","sourceRoot":"","sources":["../../../../../zero-client/src/client/ivm-branch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,uCAAuC,CAAC;AACnE,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,0CAA0C,CAAC;AAE1E,OAAO,EAAY,KAAK,KAAK,EAAC,MAAM,sCAAsC,CAAC;AAE3E,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,iCAAiC,CAAC;AAO1D,OAAO,KAAK,EAGV,WAAW,EACZ,MAAM,uCAAuC,CAAC;AAG/C,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,+CAA+C,CAAC;AACnF,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,2CAA2C,CAAC;AAEzE;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,eAAe;;IAG1B,IAAI,EAAE,IAAI,GAAG,SAAS,CAAC;gBAGrB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EACnC,IAAI,CAAC,EAAE,IAAI,GAAG,SAAS,EACvB,OAAO,GAAE,GAAG,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS,CAAa;IAO5D,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAajD,KAAK;IAIL;;;OAGG;IACH,OAAO,CAAC,YAAY,EAAE,IAAI,GAAG,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW;IAWzE;;OAEG;IACG,UAAU,CACd,KAAK,EAAE,SAAS,EAChB,WAAW,EAAE,IAAI,EACjB,WAAW,CAAC,EAAE,eAAe,GAAG,SAAS,GACxC,OAAO,CAAC,eAAe,CAAC;IAY3B;;;;;;;OAOG;IACH,IAAI;CA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ACvB,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,iBAkBb"}
@@ -4,6 +4,15 @@ import type { ZeroLogContext } from './zero-log-context.ts';
4
4
  export declare const DID_NOT_CONNECT_VALUE: number;
5
5
  export declare const REPORT_INTERVAL_MS = 5000;
6
6
  export declare function getLastConnectErrorValue(reason: ZeroError): `server_${string}` | `client_${string}`;
7
+ /**
8
+ * Returns whether an error should be reported in metrics and
9
+ * increment the connect error count.
10
+ *
11
+ * Returns `true` for all server errors and client errors that represent actual
12
+ * connection problems. Returns `false` for expected client-side disconnections
13
+ * (user disconnect, client closed, hidden tab, clean/abrupt close).
14
+ */
15
+ export declare function shouldReportConnectError(reason: ZeroError): boolean;
7
16
  type MetricsReporter = (metrics: Series[]) => MaybePromise<void>;
8
17
  export type MetricManagerOptions = {
9
18
  reportIntervalMs: number;
@@ -1 +1 @@
1
- {"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../../../../zero-client/src/client/metrics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAgB,KAAK,SAAS,EAAqB,MAAM,YAAY,CAAC;AAE7E,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC;AAM1D,eAAO,MAAM,qBAAqB,QAAa,CAAC;AAEhD,eAAO,MAAM,kBAAkB,OAAQ,CAAC;AASxC,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,SAAS,2CAEzD;AAYD,KAAK,eAAe,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC;AAEjE,MAAM,MAAM,oBAAoB,GAAG;IACjC,gBAAgB,EAAE,MAAM,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,eAAe,CAAC;IAC1B,EAAE,EAAE,cAAc,CAAC;CACpB,CAAC;AAEF;;;GAG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E,CAAC,CAAC;AAMvC,KAAK,SAAS,GAAG;IACf,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE,QAAQ,GAAG,QAAQ,CAAC,GAAG,SAAS,CAAC;CACxD,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,qBAAa,KAAM,YAAW,SAAS;;gBAIzB,IAAI,EAAE,MAAM;IAIxB,GAAG,CAAC,KAAK,EAAE,MAAM;IAIjB,GAAG;IAIH,KAAK;IAIL,KAAK;;;;CASN;AAMD;;;;;;;;;;;;GAYG;AACH,qBAAa,KAAM,YAAW,SAAS;;gBAKzB,MAAM,EAAE,MAAM,EAAE,YAAY,UAAQ;IAKhD,GAAG,CAAC,KAAK,EAAE,MAAM;IAIjB,GAAG;IAIH,KAAK;IAIL,KAAK;;;;CAYN"}
@@ -1,13 +1,14 @@
1
1
  import type { EphemeralID, MutationTrackingData } from '../../../replicache/src/replicache-options.ts';
2
- import { type MutationID, type PushResponse } from '../../../zero-protocol/src/push.ts';
3
- import type { ZeroLogContext } from './zero-log-context.ts';
4
2
  import type { ReplicacheImpl } from '../../../replicache/src/impl.ts';
3
+ import { type MutationID, type PushResponseBody } from '../../../zero-protocol/src/push.ts';
4
+ import { type ZeroError } from './error.ts';
5
+ import type { ZeroLogContext } from './zero-log-context.ts';
5
6
  /**
6
7
  * Tracks what pushes are in-flight and resolves promises when they're acked.
7
8
  */
8
9
  export declare class MutationTracker {
9
10
  #private;
10
- constructor(lc: ZeroLogContext, ackMutations: (upTo: MutationID) => void);
11
+ constructor(lc: ZeroLogContext, ackMutations: (upTo: MutationID) => void, onFatalError: (error: ZeroError) => void);
11
12
  setClientIDAndWatch(clientID: string, experimentalWatch: ReplicacheImpl['experimentalWatch']): void;
12
13
  trackMutation(): MutationTrackingData;
13
14
  mutationIDAssigned(id: EphemeralID, mutationID: number): void;
@@ -16,7 +17,7 @@ export declare class MutationTracker {
16
17
  * The mutation must not have been persisted to the client store.
17
18
  */
18
19
  rejectMutation(id: EphemeralID, e: unknown): void;
19
- processPushResponse(response: PushResponse): void;
20
+ processPushResponse(response: PushResponseBody): void;
20
21
  /**
21
22
  * DEPRECATED: to be removed when we switch to fully driving
22
23
  * mutation resolution via poke.
@@ -1 +1 @@
1
- {"version":3,"file":"mutation-tracker.d.ts","sourceRoot":"","sources":["../../../../../zero-client/src/client/mutation-tracker.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EACX,oBAAoB,EACrB,MAAM,+CAA+C,CAAC;AAGvD,OAAO,EAGL,KAAK,UAAU,EAIf,KAAK,YAAY,EAClB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,iCAAiC,CAAC;AAiBpE;;GAEG;AACH,qBAAa,eAAe;;gBAiBd,EAAE,EAAE,cAAc,EAAE,YAAY,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI;IAUxE,mBAAmB,CACjB,QAAQ,EAAE,MAAM,EAChB,iBAAiB,EAAE,cAAc,CAAC,mBAAmB,CAAC;IAexD,aAAa,IAAI,oBAAoB;IAUrC,kBAAkB,CAAC,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI;IAY7D;;;OAGG;IACH,cAAc,CAAC,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE,OAAO,GAAG,IAAI;IA+CjD,mBAAmB,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI;IAWjD;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,WAAW,CAAC,cAAc,EAAE,MAAM;IAIlC;;;;;;OAMG;IACH,YAAY,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI;IAoB1C,IAAI,IAAI,WAEP;IA4GD;;;;;;;;;OASG;IACH,qBAAqB,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI;CASlD"}
1
+ {"version":3,"file":"mutation-tracker.d.ts","sourceRoot":"","sources":["../../../../../zero-client/src/client/mutation-tracker.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EACX,oBAAoB,EACrB,MAAM,+CAA+C,CAAC;AACvD,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,iCAAiC,CAAC;AAOpE,OAAO,EAGL,KAAK,UAAU,EAIf,KAAK,gBAAgB,EACtB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAC,KAAK,SAAS,EAAC,MAAM,YAAY,CAAC;AAE1C,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC;AAoB1D;;GAEG;AACH,qBAAa,eAAe;;gBAmBxB,EAAE,EAAE,cAAc,EAClB,YAAY,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,EACxC,YAAY,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI;IAY1C,mBAAmB,CACjB,QAAQ,EAAE,MAAM,EAChB,iBAAiB,EAAE,cAAc,CAAC,mBAAmB,CAAC;IAexD,aAAa,IAAI,oBAAoB;IAUrC,kBAAkB,CAAC,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI;IAY7D;;;OAGG;IACH,cAAc,CAAC,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE,OAAO,GAAG,IAAI;IA+CjD,mBAAmB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI;IAuDrD;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,WAAW,CAAC,cAAc,EAAE,MAAM;IAIlC;;;;;;OAMG;IACH,YAAY,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI;IAoB1C,IAAI,IAAI,WAEP;IAuID;;;;;;;;;OASG;IACH,qBAAqB,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI;CASlD"}
@@ -1,6 +1,5 @@
1
1
  import type { LogLevel } from '@rocicorp/logger';
2
2
  import type { StoreProvider } from '../../../replicache/src/kv/store.ts';
3
- import type { MaybePromise } from '../../../shared/src/types.ts';
4
3
  import * as v from '../../../shared/src/valita.ts';
5
4
  import type { Schema } from '../../../zero-schema/src/builder/schema-builder.ts';
6
5
  import type { CustomMutatorDefs } from './custom.ts';
@@ -23,24 +22,18 @@ export interface ZeroOptions<S extends Schema, MD extends CustomMutatorDefs | un
23
22
  */
24
23
  server?: string | null | undefined;
25
24
  /**
26
- * A JWT to identify and authenticate the user. Can be provided as either:
27
- * - A string containing the JWT token
28
- * - A function that returns a JWT token
29
- * - `undefined` if there is no logged in user
25
+ * A token to identify and authenticate the user.
30
26
  *
31
- * Token validation behavior:
32
- * 1. **For function providers:**
33
- * When zero-cache reports that a token is invalid (expired, malformed,
34
- * or has an invalid signature), Zero will call the function again with
35
- * `error='invalid-token'` to obtain a new token.
27
+ * Set `auth` to `null` or `undefined` if there is no logged in user.
36
28
  *
37
- * 2. **For string tokens:**
38
- * Zero will continue to use the provided token even if zero-cache initially
39
- * reports it as invalid. This is because zero-cache may be able to validate
40
- * the token after fetching new public keys from its configured JWKS URL
41
- * (if `ZERO_AUTH_JWKS_URL` is set).
29
+ * When a 401 or 403 HTTP status code is received from your server, Zero will
30
+ * transition to the `needs-auth` connection state. The app should call
31
+ * `zero.connection.connect({auth: newToken})` with a new token to reconnect.
32
+ *
33
+ * The call to `connect` is handled automatically by the ZeroProvider component
34
+ * for React and SolidJS when the `auth` prop changes.
42
35
  */
43
- auth?: string | ((error?: 'invalid-token') => MaybePromise<string | undefined>) | undefined;
36
+ auth?: string | null | undefined;
44
37
  /**
45
38
  * A unique identifier for the user. Must be non-empty.
46
39
  *
@@ -96,11 +89,15 @@ export interface ZeroOptions<S extends Schema, MD extends CustomMutatorDefs | un
96
89
  /**
97
90
  * `onOnlineChange` is called when the Zero instance's online status changes.
98
91
  *
99
- * @deprecated Use `onOnline` on the Zero instance instead. e.g.
92
+ * @deprecated Use {@linkcode Connection.state.subscribe} on the Zero instance instead. e.g.
100
93
  * ```ts
101
94
  * const zero = new Zero({...});
102
- * zero.onOnline((online) => { ... });
95
+ * zero.connection.state.subscribe((state) => {
96
+ * console.log('Connection state:', state.name);
97
+ * });
103
98
  * ```
99
+ *
100
+ * Or use a hook like {@linkcode useZeroConnectionState} to subscribe to state changes.
104
101
  */
105
102
  onOnlineChange?: ((online: boolean) => void) | undefined;
106
103
  /**