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

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 (337) hide show
  1. package/out/{chunk-BJ2CGCME.js → chunk-55BOUNXO.js} +3 -3
  2. package/out/chunk-55BOUNXO.js.map +7 -0
  3. package/out/{chunk-MXPHMVU7.js → chunk-AIPM77UE.js} +2337 -548
  4. package/out/chunk-AIPM77UE.js.map +7 -0
  5. package/out/{chunk-4RB4OYLQ.js → chunk-TJFNGO7E.js} +3 -2
  6. package/out/{lazy-inspector-2SW772W4.js → lazy-inspector-OXIFYSSQ.js} +2 -2
  7. package/out/react.js +16 -4
  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/options.d.ts +1 -1
  18. package/out/shared/src/options.d.ts.map +1 -1
  19. package/out/shared/src/promise-race.d.ts +17 -0
  20. package/out/shared/src/promise-race.d.ts.map +1 -0
  21. package/out/solid.js +19 -6
  22. package/out/solid.js.map +4 -4
  23. package/out/z2s/src/compiler.d.ts +1 -1
  24. package/out/z2s/src/compiler.d.ts.map +1 -1
  25. package/out/z2s/src/compiler.js +1 -1
  26. package/out/z2s/src/compiler.js.map +1 -1
  27. package/out/z2s/src/sql.d.ts.map +1 -1
  28. package/out/z2s/src/sql.js +1 -1
  29. package/out/z2s/src/sql.js.map +1 -1
  30. package/out/zero/package.json +4 -3
  31. package/out/zero-cache/src/config/zero-config.d.ts +12 -0
  32. package/out/zero-cache/src/config/zero-config.d.ts.map +1 -1
  33. package/out/zero-cache/src/config/zero-config.js +36 -0
  34. package/out/zero-cache/src/config/zero-config.js.map +1 -1
  35. package/out/zero-cache/src/custom/fetch.d.ts +3 -1
  36. package/out/zero-cache/src/custom/fetch.d.ts.map +1 -1
  37. package/out/zero-cache/src/custom/fetch.js +101 -24
  38. package/out/zero-cache/src/custom/fetch.js.map +1 -1
  39. package/out/zero-cache/src/custom-queries/transform-query.d.ts +2 -6
  40. package/out/zero-cache/src/custom-queries/transform-query.d.ts.map +1 -1
  41. package/out/zero-cache/src/custom-queries/transform-query.js +42 -41
  42. package/out/zero-cache/src/custom-queries/transform-query.js.map +1 -1
  43. package/out/zero-cache/src/db/create.d.ts +4 -0
  44. package/out/zero-cache/src/db/create.d.ts.map +1 -1
  45. package/out/zero-cache/src/db/create.js +7 -9
  46. package/out/zero-cache/src/db/create.js.map +1 -1
  47. package/out/zero-cache/src/db/lite-tables.js +2 -2
  48. package/out/zero-cache/src/db/lite-tables.js.map +1 -1
  49. package/out/zero-cache/src/db/pg-to-lite.d.ts.map +1 -1
  50. package/out/zero-cache/src/db/pg-to-lite.js +7 -6
  51. package/out/zero-cache/src/db/pg-to-lite.js.map +1 -1
  52. package/out/zero-cache/src/db/specs.d.ts +12 -12
  53. package/out/zero-cache/src/server/change-streamer.d.ts.map +1 -1
  54. package/out/zero-cache/src/server/change-streamer.js +1 -1
  55. package/out/zero-cache/src/server/change-streamer.js.map +1 -1
  56. package/out/zero-cache/src/server/inspector-delegate.d.ts.map +1 -1
  57. package/out/zero-cache/src/server/inspector-delegate.js +5 -1
  58. package/out/zero-cache/src/server/inspector-delegate.js.map +1 -1
  59. package/out/zero-cache/src/server/syncer.d.ts.map +1 -1
  60. package/out/zero-cache/src/server/syncer.js +1 -1
  61. package/out/zero-cache/src/server/syncer.js.map +1 -1
  62. package/out/zero-cache/src/services/change-source/pg/change-source.js +1 -0
  63. package/out/zero-cache/src/services/change-source/pg/change-source.js.map +1 -1
  64. package/out/zero-cache/src/services/change-source/pg/logical-replication/binary-reader.d.ts +1 -1
  65. package/out/zero-cache/src/services/change-source/pg/logical-replication/binary-reader.d.ts.map +1 -1
  66. package/out/zero-cache/src/services/change-source/pg/logical-replication/binary-reader.js +1 -1
  67. package/out/zero-cache/src/services/change-source/pg/logical-replication/binary-reader.js.map +1 -1
  68. package/out/zero-cache/src/services/change-source/pg/schema/ddl.d.ts +25 -25
  69. package/out/zero-cache/src/services/change-source/pg/schema/published.d.ts +10 -10
  70. package/out/zero-cache/src/services/change-source/pg/schema/shard.d.ts +5 -5
  71. package/out/zero-cache/src/services/change-source/protocol/current/data.d.ts +16 -16
  72. package/out/zero-cache/src/services/change-source/protocol/current/downstream.d.ts +24 -24
  73. package/out/zero-cache/src/services/change-streamer/change-streamer-http.d.ts +2 -1
  74. package/out/zero-cache/src/services/change-streamer/change-streamer-http.d.ts.map +1 -1
  75. package/out/zero-cache/src/services/change-streamer/change-streamer-http.js +18 -2
  76. package/out/zero-cache/src/services/change-streamer/change-streamer-http.js.map +1 -1
  77. package/out/zero-cache/src/services/change-streamer/change-streamer.d.ts +8 -8
  78. package/out/zero-cache/src/services/mutagen/mutagen.d.ts.map +1 -1
  79. package/out/zero-cache/src/services/mutagen/mutagen.js +9 -7
  80. package/out/zero-cache/src/services/mutagen/mutagen.js.map +1 -1
  81. package/out/zero-cache/src/services/mutagen/pusher.d.ts +4 -4
  82. package/out/zero-cache/src/services/mutagen/pusher.d.ts.map +1 -1
  83. package/out/zero-cache/src/services/mutagen/pusher.js +74 -56
  84. package/out/zero-cache/src/services/mutagen/pusher.js.map +1 -1
  85. package/out/zero-cache/src/services/view-syncer/client-handler.d.ts +3 -1
  86. package/out/zero-cache/src/services/view-syncer/client-handler.d.ts.map +1 -1
  87. package/out/zero-cache/src/services/view-syncer/client-handler.js +10 -6
  88. package/out/zero-cache/src/services/view-syncer/client-handler.js.map +1 -1
  89. package/out/zero-cache/src/services/view-syncer/client-schema.d.ts.map +1 -1
  90. package/out/zero-cache/src/services/view-syncer/client-schema.js +6 -3
  91. package/out/zero-cache/src/services/view-syncer/client-schema.js.map +1 -1
  92. package/out/zero-cache/src/services/view-syncer/cvr-store.d.ts +4 -4
  93. package/out/zero-cache/src/services/view-syncer/cvr-store.d.ts.map +1 -1
  94. package/out/zero-cache/src/services/view-syncer/cvr-store.js +15 -6
  95. package/out/zero-cache/src/services/view-syncer/cvr-store.js.map +1 -1
  96. package/out/zero-cache/src/services/view-syncer/cvr.d.ts.map +1 -1
  97. package/out/zero-cache/src/services/view-syncer/cvr.js +4 -2
  98. package/out/zero-cache/src/services/view-syncer/cvr.js.map +1 -1
  99. package/out/zero-cache/src/services/view-syncer/key-columns.d.ts.map +1 -1
  100. package/out/zero-cache/src/services/view-syncer/key-columns.js +4 -2
  101. package/out/zero-cache/src/services/view-syncer/key-columns.js.map +1 -1
  102. package/out/zero-cache/src/services/view-syncer/pipeline-driver.d.ts +1 -1
  103. package/out/zero-cache/src/services/view-syncer/pipeline-driver.d.ts.map +1 -1
  104. package/out/zero-cache/src/services/view-syncer/pipeline-driver.js +19 -2
  105. package/out/zero-cache/src/services/view-syncer/pipeline-driver.js.map +1 -1
  106. package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts.map +1 -1
  107. package/out/zero-cache/src/services/view-syncer/view-syncer.js +67 -31
  108. package/out/zero-cache/src/services/view-syncer/view-syncer.js.map +1 -1
  109. package/out/zero-cache/src/types/error-with-level.d.ts +9 -0
  110. package/out/zero-cache/src/types/error-with-level.d.ts.map +1 -0
  111. package/out/zero-cache/src/types/error-with-level.js +24 -0
  112. package/out/zero-cache/src/types/error-with-level.js.map +1 -0
  113. package/out/zero-cache/src/types/lite.d.ts +15 -13
  114. package/out/zero-cache/src/types/lite.d.ts.map +1 -1
  115. package/out/zero-cache/src/types/lite.js +17 -5
  116. package/out/zero-cache/src/types/lite.js.map +1 -1
  117. package/out/zero-cache/src/types/pg-data-type.d.ts +73 -0
  118. package/out/zero-cache/src/types/pg-data-type.d.ts.map +1 -0
  119. package/out/zero-cache/src/types/pg-data-type.js +76 -0
  120. package/out/zero-cache/src/types/pg-data-type.js.map +1 -0
  121. package/out/zero-cache/src/types/pg.d.ts +1 -73
  122. package/out/zero-cache/src/types/pg.d.ts.map +1 -1
  123. package/out/zero-cache/src/types/pg.js +0 -77
  124. package/out/zero-cache/src/types/pg.js.map +1 -1
  125. package/out/zero-cache/src/types/processes.d.ts +1 -1
  126. package/out/zero-cache/src/types/processes.d.ts.map +1 -1
  127. package/out/zero-cache/src/types/processes.js.map +1 -1
  128. package/out/zero-cache/src/types/schema-versions.d.ts +7 -3
  129. package/out/zero-cache/src/types/schema-versions.d.ts.map +1 -1
  130. package/out/zero-cache/src/types/schema-versions.js +7 -5
  131. package/out/zero-cache/src/types/schema-versions.js.map +1 -1
  132. package/out/zero-cache/src/types/subscription.d.ts +1 -1
  133. package/out/zero-cache/src/types/subscription.js +1 -1
  134. package/out/zero-cache/src/types/websocket-handoff.d.ts +3 -3
  135. package/out/zero-cache/src/types/websocket-handoff.d.ts.map +1 -1
  136. package/out/zero-cache/src/types/websocket-handoff.js +6 -4
  137. package/out/zero-cache/src/types/websocket-handoff.js.map +1 -1
  138. package/out/zero-cache/src/workers/connection.d.ts +6 -1
  139. package/out/zero-cache/src/workers/connection.d.ts.map +1 -1
  140. package/out/zero-cache/src/workers/connection.js +26 -9
  141. package/out/zero-cache/src/workers/connection.js.map +1 -1
  142. package/out/zero-cache/src/workers/syncer-ws-message-handler.d.ts.map +1 -1
  143. package/out/zero-cache/src/workers/syncer-ws-message-handler.js +7 -1
  144. package/out/zero-cache/src/workers/syncer-ws-message-handler.js.map +1 -1
  145. package/out/zero-cache/src/workers/syncer.d.ts.map +1 -1
  146. package/out/zero-cache/src/workers/syncer.js +21 -1
  147. package/out/zero-cache/src/workers/syncer.js.map +1 -1
  148. package/out/zero-client/src/client/client-error-kind-enum.d.ts +8 -0
  149. package/out/zero-client/src/client/client-error-kind-enum.d.ts.map +1 -1
  150. package/out/zero-client/src/client/connection-manager.d.ts +65 -13
  151. package/out/zero-client/src/client/connection-manager.d.ts.map +1 -1
  152. package/out/zero-client/src/client/connection-status-enum.d.ts +2 -0
  153. package/out/zero-client/src/client/connection-status-enum.d.ts.map +1 -1
  154. package/out/zero-client/src/client/connection.d.ts +45 -0
  155. package/out/zero-client/src/client/connection.d.ts.map +1 -0
  156. package/out/zero-client/src/client/error.d.ts +178 -23
  157. package/out/zero-client/src/client/error.d.ts.map +1 -1
  158. package/out/zero-client/src/client/ivm-branch.d.ts +2 -2
  159. package/out/zero-client/src/client/ivm-branch.d.ts.map +1 -1
  160. package/out/zero-client/src/client/metrics.d.ts +9 -0
  161. package/out/zero-client/src/client/metrics.d.ts.map +1 -1
  162. package/out/zero-client/src/client/mutation-tracker.d.ts +5 -4
  163. package/out/zero-client/src/client/mutation-tracker.d.ts.map +1 -1
  164. package/out/zero-client/src/client/options.d.ts +6 -2
  165. package/out/zero-client/src/client/options.d.ts.map +1 -1
  166. package/out/zero-client/src/client/query-manager.d.ts +5 -4
  167. package/out/zero-client/src/client/query-manager.d.ts.map +1 -1
  168. package/out/zero-client/src/client/zero-rep.d.ts +1 -1
  169. package/out/zero-client/src/client/zero-rep.d.ts.map +1 -1
  170. package/out/zero-client/src/client/zero.d.ts +27 -5
  171. package/out/zero-client/src/client/zero.d.ts.map +1 -1
  172. package/out/zero-client/src/mod.d.ts +9 -1
  173. package/out/zero-client/src/mod.d.ts.map +1 -1
  174. package/out/zero-protocol/src/custom-queries.d.ts +75 -4
  175. package/out/zero-protocol/src/custom-queries.d.ts.map +1 -1
  176. package/out/zero-protocol/src/custom-queries.js +18 -1
  177. package/out/zero-protocol/src/custom-queries.js.map +1 -1
  178. package/out/zero-protocol/src/down.d.ts +1 -1
  179. package/out/zero-protocol/src/error-kind-enum.d.ts +65 -0
  180. package/out/zero-protocol/src/error-kind-enum.d.ts.map +1 -1
  181. package/out/zero-protocol/src/error-kind-enum.js +2 -0
  182. package/out/zero-protocol/src/error-kind-enum.js.map +1 -1
  183. package/out/zero-protocol/src/error-origin-enum.d.ts +7 -0
  184. package/out/zero-protocol/src/error-origin-enum.d.ts.map +1 -0
  185. package/out/zero-protocol/src/error-origin-enum.js +4 -0
  186. package/out/zero-protocol/src/error-origin-enum.js.map +1 -0
  187. package/out/zero-protocol/src/error-origin.d.ts +5 -0
  188. package/out/zero-protocol/src/error-origin.d.ts.map +1 -0
  189. package/out/zero-protocol/src/error-origin.js +3 -0
  190. package/out/zero-protocol/src/error-origin.js.map +1 -0
  191. package/out/zero-protocol/src/error-reason-enum.d.ts +15 -0
  192. package/out/zero-protocol/src/error-reason-enum.d.ts.map +1 -0
  193. package/out/zero-protocol/src/error-reason-enum.js +8 -0
  194. package/out/zero-protocol/src/error-reason-enum.js.map +1 -0
  195. package/out/zero-protocol/src/error-reason.d.ts +5 -0
  196. package/out/zero-protocol/src/error-reason.d.ts.map +1 -0
  197. package/out/zero-protocol/src/error-reason.js +3 -0
  198. package/out/zero-protocol/src/error-reason.js.map +1 -0
  199. package/out/zero-protocol/src/error.d.ts +139 -1
  200. package/out/zero-protocol/src/error.d.ts.map +1 -1
  201. package/out/zero-protocol/src/error.js +64 -2
  202. package/out/zero-protocol/src/error.js.map +1 -1
  203. package/out/zero-protocol/src/mutation-id.d.ts +7 -0
  204. package/out/zero-protocol/src/mutation-id.d.ts.map +1 -0
  205. package/out/zero-protocol/src/mutation-id.js +6 -0
  206. package/out/zero-protocol/src/mutation-id.js.map +1 -0
  207. package/out/zero-protocol/src/mutations-patch.d.ts +3 -3
  208. package/out/zero-protocol/src/mutations-patch.d.ts.map +1 -1
  209. package/out/zero-protocol/src/mutations-patch.js +2 -1
  210. package/out/zero-protocol/src/mutations-patch.js.map +1 -1
  211. package/out/zero-protocol/src/protocol-version.d.ts +1 -1
  212. package/out/zero-protocol/src/protocol-version.d.ts.map +1 -1
  213. package/out/zero-protocol/src/protocol-version.js +2 -1
  214. package/out/zero-protocol/src/protocol-version.js.map +1 -1
  215. package/out/zero-protocol/src/push.d.ts +138 -13
  216. package/out/zero-protocol/src/push.d.ts.map +1 -1
  217. package/out/zero-protocol/src/push.js +34 -13
  218. package/out/zero-protocol/src/push.js.map +1 -1
  219. package/out/zero-react/src/mod.d.ts +2 -1
  220. package/out/zero-react/src/mod.d.ts.map +1 -1
  221. package/out/zero-react/src/use-zero-connection-state.d.ts +9 -0
  222. package/out/zero-react/src/use-zero-connection-state.d.ts.map +1 -0
  223. package/out/zero-react/src/use-zero-online.d.ts +2 -0
  224. package/out/zero-react/src/use-zero-online.d.ts.map +1 -1
  225. package/out/zero-server/src/process-mutations.d.ts +3 -3
  226. package/out/zero-server/src/process-mutations.d.ts.map +1 -1
  227. package/out/zero-server/src/process-mutations.js.map +1 -1
  228. package/out/zero-server/src/schema.js +1 -1
  229. package/out/zero-server/src/schema.js.map +1 -1
  230. package/out/zero-server/src/zql-database.d.ts +1 -1
  231. package/out/zero-server/src/zql-database.d.ts.map +1 -1
  232. package/out/zero-server/src/zql-database.js.map +1 -1
  233. package/out/zero-solid/src/mod.d.ts +3 -2
  234. package/out/zero-solid/src/mod.d.ts.map +1 -1
  235. package/out/zero-solid/src/use-zero-connection-state.d.ts +10 -0
  236. package/out/zero-solid/src/use-zero-connection-state.d.ts.map +1 -0
  237. package/out/zero-solid/src/use-zero-online.d.ts +1 -7
  238. package/out/zero-solid/src/use-zero-online.d.ts.map +1 -1
  239. package/out/zero.js +13 -3
  240. package/out/zql/src/builder/builder.d.ts +2 -1
  241. package/out/zql/src/builder/builder.d.ts.map +1 -1
  242. package/out/zql/src/builder/builder.js +5 -1
  243. package/out/zql/src/builder/builder.js.map +1 -1
  244. package/out/zql/src/ivm/data.d.ts +1 -1
  245. package/out/zql/src/ivm/data.d.ts.map +1 -1
  246. package/out/zql/src/ivm/data.js.map +1 -1
  247. package/out/zql/src/ivm/filter-push.d.ts +1 -1
  248. package/out/zql/src/ivm/filter-push.d.ts.map +1 -1
  249. package/out/zql/src/ivm/filter-push.js.map +1 -1
  250. package/out/zql/src/ivm/memory-source.d.ts +2 -2
  251. package/out/zql/src/ivm/memory-source.d.ts.map +1 -1
  252. package/out/zql/src/ivm/memory-source.js.map +1 -1
  253. package/out/zql/src/ivm/source.d.ts +1 -1
  254. package/out/zql/src/ivm/source.d.ts.map +1 -1
  255. package/out/zql/src/ivm/take.d.ts +1 -1
  256. package/out/zql/src/ivm/take.d.ts.map +1 -1
  257. package/out/zql/src/ivm/take.js.map +1 -1
  258. package/out/zql/src/planner/planner-builder.d.ts +14 -0
  259. package/out/zql/src/planner/planner-builder.d.ts.map +1 -0
  260. package/out/zql/src/planner/planner-builder.js +180 -0
  261. package/out/zql/src/planner/planner-builder.js.map +1 -0
  262. package/out/zql/src/planner/planner-connection.d.ts +119 -0
  263. package/out/zql/src/planner/planner-connection.d.ts.map +1 -0
  264. package/out/zql/src/planner/planner-connection.js +301 -0
  265. package/out/zql/src/planner/planner-connection.js.map +1 -0
  266. package/out/zql/src/planner/planner-constraint.d.ts +14 -0
  267. package/out/zql/src/planner/planner-constraint.d.ts.map +1 -0
  268. package/out/zql/src/planner/planner-constraint.js +12 -0
  269. package/out/zql/src/planner/planner-constraint.js.map +1 -0
  270. package/out/zql/src/planner/planner-debug.d.ts +118 -0
  271. package/out/zql/src/planner/planner-debug.d.ts.map +1 -0
  272. package/out/zql/src/planner/planner-debug.js +125 -0
  273. package/out/zql/src/planner/planner-debug.js.map +1 -0
  274. package/out/zql/src/planner/planner-fan-in.d.ts +37 -0
  275. package/out/zql/src/planner/planner-fan-in.d.ts.map +1 -0
  276. package/out/zql/src/planner/planner-fan-in.js +149 -0
  277. package/out/zql/src/planner/planner-fan-in.js.map +1 -0
  278. package/out/zql/src/planner/planner-fan-out.d.ts +21 -0
  279. package/out/zql/src/planner/planner-fan-out.d.ts.map +1 -0
  280. package/out/zql/src/planner/planner-fan-out.js +45 -0
  281. package/out/zql/src/planner/planner-fan-out.js.map +1 -0
  282. package/out/zql/src/planner/planner-graph.d.ts +103 -0
  283. package/out/zql/src/planner/planner-graph.d.ts.map +1 -0
  284. package/out/zql/src/planner/planner-graph.js +411 -0
  285. package/out/zql/src/planner/planner-graph.js.map +1 -0
  286. package/out/zql/src/planner/planner-join.d.ts +81 -0
  287. package/out/zql/src/planner/planner-join.d.ts.map +1 -0
  288. package/out/zql/src/planner/planner-join.js +246 -0
  289. package/out/zql/src/planner/planner-join.js.map +1 -0
  290. package/out/zql/src/planner/planner-node.d.ts +21 -0
  291. package/out/zql/src/planner/planner-node.d.ts.map +1 -0
  292. package/out/zql/src/planner/planner-node.js +2 -0
  293. package/out/zql/src/planner/planner-node.js.map +1 -0
  294. package/out/zql/src/planner/planner-source.d.ts +11 -0
  295. package/out/zql/src/planner/planner-source.d.ts.map +1 -0
  296. package/out/zql/src/planner/planner-source.js +13 -0
  297. package/out/zql/src/planner/planner-source.js.map +1 -0
  298. package/out/zql/src/planner/planner-terminus.d.ts +16 -0
  299. package/out/zql/src/planner/planner-terminus.d.ts.map +1 -0
  300. package/out/zql/src/planner/planner-terminus.js +28 -0
  301. package/out/zql/src/planner/planner-terminus.js.map +1 -0
  302. package/out/zql/src/query/expression.d.ts +2 -2
  303. package/out/zql/src/query/expression.d.ts.map +1 -1
  304. package/out/zql/src/query/expression.js.map +1 -1
  305. package/out/zql/src/query/query-delegate.d.ts +3 -3
  306. package/out/zql/src/query/query-delegate.d.ts.map +1 -1
  307. package/out/zql/src/query/query-impl.d.ts +8 -8
  308. package/out/zql/src/query/query-impl.d.ts.map +1 -1
  309. package/out/zql/src/query/query-impl.js.map +1 -1
  310. package/out/zql/src/query/query.d.ts +3 -3
  311. package/out/zql/src/query/query.d.ts.map +1 -1
  312. package/out/zql/src/query/static-query.d.ts +1 -1
  313. package/out/zql/src/query/static-query.d.ts.map +1 -1
  314. package/out/zql/src/query/static-query.js.map +1 -1
  315. package/out/zql/src/query/typed-view.d.ts +1 -1
  316. package/out/zql/src/query/typed-view.d.ts.map +1 -1
  317. package/out/zqlite/src/query-delegate.d.ts +1 -1
  318. package/out/zqlite/src/query-delegate.d.ts.map +1 -1
  319. package/out/zqlite/src/query-delegate.js.map +1 -1
  320. package/out/zqlite/src/sqlite-cost-model.d.ts +17 -0
  321. package/out/zqlite/src/sqlite-cost-model.d.ts.map +1 -0
  322. package/out/zqlite/src/sqlite-cost-model.js +134 -0
  323. package/out/zqlite/src/sqlite-cost-model.js.map +1 -0
  324. package/out/zqlite/src/table-source.d.ts +1 -1
  325. package/out/zqlite/src/table-source.d.ts.map +1 -1
  326. package/out/zqlite/src/table-source.js.map +1 -1
  327. package/package.json +4 -3
  328. package/out/chunk-BJ2CGCME.js.map +0 -7
  329. package/out/chunk-MXPHMVU7.js.map +0 -7
  330. package/out/zero-cache/src/types/error-for-client.d.ts +0 -23
  331. package/out/zero-cache/src/types/error-for-client.d.ts.map +0 -1
  332. package/out/zero-cache/src/types/error-for-client.js +0 -28
  333. package/out/zero-cache/src/types/error-for-client.js.map +0 -1
  334. package/out/zero-client/src/client/ping-result-enum.d.ts +0 -5
  335. package/out/zero-client/src/client/ping-result-enum.d.ts.map +0 -1
  336. /package/out/{chunk-4RB4OYLQ.js.map → chunk-TJFNGO7E.js.map} +0 -0
  337. /package/out/{lazy-inspector-2SW772W4.js.map → lazy-inspector-OXIFYSSQ.js.map} +0 -0
@@ -0,0 +1,180 @@
1
+ import { assert } from "../../../shared/src/asserts.js";
2
+ import { must } from "../../../shared/src/must.js";
3
+ import { planIdSymbol } from "../../../zero-protocol/src/ast.js";
4
+ import { PlannerFanIn } from "./planner-fan-in.js";
5
+ import { PlannerFanOut } from "./planner-fan-out.js";
6
+ import { PlannerGraph } from "./planner-graph.js";
7
+ import { PlannerJoin } from "./planner-join.js";
8
+ import { PlannerTerminus } from "./planner-terminus.js";
9
+ function wireOutput(from, to) {
10
+ switch (from.kind) {
11
+ case 'connection':
12
+ case 'join':
13
+ case 'fan-in':
14
+ from.setOutput(to);
15
+ break;
16
+ case 'fan-out':
17
+ from.addOutput(to);
18
+ break;
19
+ case 'terminus':
20
+ assert(false, 'Terminus nodes cannot have outputs');
21
+ }
22
+ }
23
+ export function buildPlanGraph(ast, model, baseConstraints) {
24
+ const graph = new PlannerGraph();
25
+ let nextPlanId = 0;
26
+ const source = graph.addSource(ast.table, model);
27
+ const connection = source.connect(ast.orderBy ?? [], ast.where, baseConstraints, ast.limit);
28
+ graph.connections.push(connection);
29
+ let end = connection;
30
+ if (ast.where) {
31
+ end = processCondition(ast.where, end, graph, model, ast.table, () => nextPlanId++);
32
+ }
33
+ const terminus = new PlannerTerminus(end);
34
+ wireOutput(end, terminus);
35
+ graph.setTerminus(terminus);
36
+ const subPlans = {};
37
+ if (ast.related) {
38
+ for (const csq of ast.related) {
39
+ const alias = must(csq.subquery.alias, 'Related subquery must have alias');
40
+ const childConstraints = extractConstraint(csq.correlation.childField, csq.subquery.table);
41
+ subPlans[alias] = buildPlanGraph(csq.subquery, model, childConstraints);
42
+ }
43
+ }
44
+ return { plan: graph, subPlans };
45
+ }
46
+ function processCondition(condition, input, graph, model, parentTable, getPlanId) {
47
+ switch (condition.type) {
48
+ case 'simple':
49
+ return input;
50
+ case 'and':
51
+ return processAnd(condition, input, graph, model, parentTable, getPlanId);
52
+ case 'or':
53
+ return processOr(condition, input, graph, model, parentTable, getPlanId);
54
+ case 'correlatedSubquery':
55
+ return processCorrelatedSubquery(condition, input, graph, model, parentTable, getPlanId);
56
+ }
57
+ }
58
+ function processAnd(condition, input, graph, model, parentTable, getPlanId) {
59
+ let end = input;
60
+ for (const subCondition of condition.conditions) {
61
+ end = processCondition(subCondition, end, graph, model, parentTable, getPlanId);
62
+ }
63
+ return end;
64
+ }
65
+ function processOr(condition, input, graph, model, parentTable, getPlanId) {
66
+ const subqueryConditions = condition.conditions.filter(c => c.type === 'correlatedSubquery' || hasCorrelatedSubquery(c));
67
+ if (subqueryConditions.length === 0) {
68
+ return input;
69
+ }
70
+ const fanOut = new PlannerFanOut(input);
71
+ graph.fanOuts.push(fanOut);
72
+ wireOutput(input, fanOut);
73
+ const branches = [];
74
+ for (const subCondition of subqueryConditions) {
75
+ const branch = processCondition(subCondition, fanOut, graph, model, parentTable, getPlanId);
76
+ branches.push(branch);
77
+ fanOut.addOutput(branch);
78
+ }
79
+ const fanIn = new PlannerFanIn(branches);
80
+ graph.fanIns.push(fanIn);
81
+ for (const branch of branches) {
82
+ wireOutput(branch, fanIn);
83
+ }
84
+ return fanIn;
85
+ }
86
+ function processCorrelatedSubquery(condition, input, graph, model, parentTable, getPlanId) {
87
+ const { related } = condition;
88
+ const childTable = related.subquery.table;
89
+ const childSource = graph.hasSource(childTable)
90
+ ? graph.getSource(childTable)
91
+ : graph.addSource(childTable, model);
92
+ const childConnection = childSource.connect(related.subquery.orderBy ?? [], related.subquery.where, undefined, // no base constraints for EXISTS/NOT EXISTS
93
+ condition.op === 'EXISTS' ? 1 : undefined);
94
+ graph.connections.push(childConnection);
95
+ let childEnd = childConnection;
96
+ if (related.subquery.where) {
97
+ childEnd = processCondition(related.subquery.where, childEnd, graph, model, childTable, getPlanId);
98
+ }
99
+ const parentConstraint = extractConstraint(related.correlation.parentField, parentTable);
100
+ const childConstraint = extractConstraint(related.correlation.childField, childTable);
101
+ const planId = getPlanId();
102
+ condition[planIdSymbol] = planId;
103
+ const join = new PlannerJoin(input, childEnd, parentConstraint, childConstraint, condition.op !== 'NOT EXISTS', planId);
104
+ graph.joins.push(join);
105
+ wireOutput(input, join);
106
+ wireOutput(childEnd, join);
107
+ return join;
108
+ }
109
+ function hasCorrelatedSubquery(condition) {
110
+ if (condition.type === 'correlatedSubquery') {
111
+ return true;
112
+ }
113
+ if (condition.type === 'and' || condition.type === 'or') {
114
+ return condition.conditions.some(hasCorrelatedSubquery);
115
+ }
116
+ return false;
117
+ }
118
+ function extractConstraint(fields, _tableName) {
119
+ return Object.fromEntries(fields.map(field => [field, undefined]));
120
+ }
121
+ function planRecursively(plans, planDebugger) {
122
+ for (const subPlan of Object.values(plans.subPlans)) {
123
+ planRecursively(subPlan, planDebugger);
124
+ }
125
+ plans.plan.plan(planDebugger);
126
+ }
127
+ export function planQuery(ast, model, planDebugger) {
128
+ const plans = buildPlanGraph(ast, model);
129
+ planRecursively(plans, planDebugger);
130
+ return applyPlansToAST(ast, plans);
131
+ }
132
+ function applyToCondition(condition, flippedIds) {
133
+ if (condition.type === 'simple') {
134
+ return condition;
135
+ }
136
+ if (condition.type === 'correlatedSubquery') {
137
+ const planId = condition[planIdSymbol];
138
+ const shouldFlip = planId !== undefined && flippedIds.has(planId);
139
+ return {
140
+ ...condition,
141
+ flip: shouldFlip ? true : condition.flip,
142
+ related: {
143
+ ...condition.related,
144
+ subquery: {
145
+ ...condition.related.subquery,
146
+ where: condition.related.subquery.where
147
+ ? applyToCondition(condition.related.subquery.where, flippedIds)
148
+ : undefined,
149
+ },
150
+ },
151
+ };
152
+ }
153
+ return {
154
+ ...condition,
155
+ conditions: condition.conditions.map(c => applyToCondition(c, flippedIds)),
156
+ };
157
+ }
158
+ function applyPlansToAST(ast, plans) {
159
+ const flippedIds = new Set();
160
+ for (const join of plans.plan.joins) {
161
+ if (join.type === 'flipped' && join.planId !== undefined) {
162
+ flippedIds.add(join.planId);
163
+ }
164
+ }
165
+ return {
166
+ ...ast,
167
+ where: ast.where ? applyToCondition(ast.where, flippedIds) : undefined,
168
+ related: ast.related?.map(csq => {
169
+ const alias = must(csq.subquery.alias, 'Related subquery must have alias');
170
+ const subPlan = plans.subPlans[alias];
171
+ return {
172
+ ...csq,
173
+ subquery: subPlan
174
+ ? applyPlansToAST(csq.subquery, subPlan)
175
+ : csq.subquery,
176
+ };
177
+ }),
178
+ };
179
+ }
180
+ //# sourceMappingURL=planner-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planner-builder.js","sourceRoot":"","sources":["../../../../../zql/src/planner/planner-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,gCAAgC,CAAC;AACtD,OAAO,EAAC,IAAI,EAAC,MAAM,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,CAAC"}
@@ -0,0 +1,119 @@
1
+ import type { Condition, Ordering } from '../../../zero-protocol/src/ast.ts';
2
+ import { type PlannerConstraint } from './planner-constraint.ts';
3
+ import type { CostEstimate, JoinOrConnection, PlannerNode } from './planner-node.ts';
4
+ /**
5
+ * Represents a connection to a source (table scan).
6
+ *
7
+ * # Dual State Pattern
8
+ * Like all planner nodes, PlannerConnection separates:
9
+ * 1. immutable structure: Ordering, filters, cost model (set at construction)
10
+ * 2. mutable state: Pinned status, constraints (mutated during planning)
11
+ *
12
+ * # Cost Estimation
13
+ * The ordering and filters determine the initial cost. As planning progresses,
14
+ * constraints from parent joins refine the cost estimate.
15
+ *
16
+ * # Constraint Flow
17
+ * When a connection is pinned as the outer loop, it reveals constraints for
18
+ * connected joins. These constraints propagate through the graph, allowing
19
+ * other connections to update their cost estimates.
20
+ *
21
+ * Example:
22
+ *
23
+ * ```ts
24
+ * builder.issue.whereExists('assignee', a => a.where('name', 'Alice'))
25
+ * ```
26
+ *
27
+ * ```
28
+ * [issue] [assignee]
29
+ * | |
30
+ * | +-- where name = 'Alice'
31
+ * \ /
32
+ * \ /
33
+ * [join]
34
+ * |
35
+ * ```
36
+ *
37
+ * - Initial state: Both connections have no constraints, costs are unconstrained
38
+ * - If `issue` chosen first: Reveals constraint `assignee_id` for assignee connection
39
+ * - If `assignee` chosen first: Reveals constraint `assignee_id` for issue connection
40
+ * - Updated costs guide the next selection
41
+ *
42
+ * # Lifecycle
43
+ * 1. Construct with immutable structure (ordering, filters, cost model)
44
+ * 2. Wire to output node during graph construction
45
+ * 3. Planning mutates pinned status and accumulates constraints
46
+ * 4. reset() clears mutable state for replanning
47
+ */
48
+ export declare class PlannerConnection {
49
+ #private;
50
+ readonly kind: "connection";
51
+ readonly table: string;
52
+ readonly name: string;
53
+ readonly selectivity: number;
54
+ /**
55
+ * Current limit during planning. Can be cleared (set to undefined) when a
56
+ * parent join is flipped, indicating this connection is now in an outer loop
57
+ * and should not be limited by EXISTS semantics.
58
+ */
59
+ limit: number | undefined;
60
+ constructor(table: string, model: ConnectionCostModel, sort: Ordering, filters: Condition | undefined, baseConstraints?: PlannerConstraint, limit?: number, name?: string);
61
+ setOutput(node: PlannerNode): void;
62
+ get output(): PlannerNode;
63
+ closestJoinOrSource(): JoinOrConnection;
64
+ /**
65
+ * Constraints are uniquely identified by their path through the
66
+ * graph.
67
+ *
68
+ * FO represents all sub-joins as a single path.
69
+ * UFO represents each sub-join as a separate path.
70
+ * The first branch in a UFO will match the path of FO so no re-set needs to happen
71
+ * when swapping from FO to UFO.
72
+ *
73
+ * FO swaps to UFO when a join inside FO-FI gets flipped.
74
+ *
75
+ * The max of the last element of the paths is the number of
76
+ * root branches.
77
+ */
78
+ propagateConstraints(path: number[], c: PlannerConstraint | undefined): void;
79
+ estimateCost(branchPattern?: number[]): CostEstimate;
80
+ /**
81
+ * Remove the limit from this connection.
82
+ * Called when a parent join is flipped, making this connection part of an
83
+ * outer loop that should produce all rows rather than stopping at the limit.
84
+ */
85
+ unlimit(): void;
86
+ /**
87
+ * Propagate unlimiting when a parent join is flipped.
88
+ * For connections, we simply remove the limit.
89
+ */
90
+ propagateUnlimitFromFlippedJoin(): void;
91
+ reset(): void;
92
+ /**
93
+ * Capture constraint state for snapshotting.
94
+ * Used by PlannerGraph to save/restore planning state.
95
+ */
96
+ captureConstraints(): Map<string, PlannerConstraint | undefined>;
97
+ /**
98
+ * Restore constraint state from a snapshot.
99
+ * Used by PlannerGraph to restore planning state.
100
+ */
101
+ restoreConstraints(constraints: Map<string, PlannerConstraint | undefined>): void;
102
+ /**
103
+ * Get current constraints for debugging.
104
+ * Returns a copy of the constraints map.
105
+ */
106
+ getConstraintsForDebug(): Map<string, PlannerConstraint | undefined>;
107
+ /**
108
+ * Get estimated cost for each constraint branch.
109
+ * Returns a map of constraint key to cost estimate.
110
+ * Forces cost calculation if not already cached.
111
+ */
112
+ getConstraintCostsForDebug(): Map<string, CostEstimate>;
113
+ }
114
+ export type CostModelCost = {
115
+ startupCost: number;
116
+ rows: number;
117
+ };
118
+ export type ConnectionCostModel = (table: string, sort: Ordering, filters: Condition | undefined, constraint: PlannerConstraint | undefined) => CostModelCost;
119
+ //# sourceMappingURL=planner-connection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planner-connection.d.ts","sourceRoot":"","sources":["../../../../../zql/src/planner/planner-connection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,SAAS,EAAE,QAAQ,EAAC,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,qBAAa,iBAAiB;;IAC5B,QAAQ,CAAC,IAAI,EAAG,YAAY,CAAU;IAQtC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAGtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAM7B;;;;OAIG;IACH,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;gBA2BxB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,mBAAmB,EAC1B,IAAI,EAAE,QAAQ,EACd,OAAO,EAAE,SAAS,GAAG,SAAS,EAC9B,eAAe,CAAC,EAAE,iBAAiB,EACnC,KAAK,CAAC,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,MAAM;IA2Bf,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI;IAIlC,IAAI,MAAM,IAAI,WAAW,CAGxB;IAED,mBAAmB,IAAI,gBAAgB;IAIvC;;;;;;;;;;;;;OAaG;IACH,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,iBAAiB,GAAG,SAAS,GAAG,IAAI;IAS5E,YAAY,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,GAAG,YAAY;IAmHpD;;;;OAIG;IACH,OAAO,IAAI,IAAI;IASf;;;OAGG;IACH,+BAA+B,IAAI,IAAI;IAIvC,KAAK;IASL;;;OAGG;IACH,kBAAkB,IAAI,GAAG,CAAC,MAAM,EAAE,iBAAiB,GAAG,SAAS,CAAC;IAIhE;;;OAGG;IACH,kBAAkB,CAChB,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,iBAAiB,GAAG,SAAS,CAAC,GACtD,IAAI;IAWP;;;OAGG;IACH,sBAAsB,IAAI,GAAG,CAAC,MAAM,EAAE,iBAAiB,GAAG,SAAS,CAAC;IAIpE;;;;OAIG;IACH,0BAA0B,IAAI,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC;CAMxD;AAED,MAAM,MAAM,aAAa,GAAG;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,CAAC;AAChE,MAAM,MAAM,mBAAmB,GAAG,CAChC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,QAAQ,EACd,OAAO,EAAE,SAAS,GAAG,SAAS,EAC9B,UAAU,EAAE,iBAAiB,GAAG,SAAS,KACtC,aAAa,CAAC"}
@@ -0,0 +1,301 @@
1
+ import { assert } from "../../../shared/src/asserts.js";
2
+ import { mergeConstraints, } from "./planner-constraint.js";
3
+ /**
4
+ * Represents a connection to a source (table scan).
5
+ *
6
+ * # Dual State Pattern
7
+ * Like all planner nodes, PlannerConnection separates:
8
+ * 1. immutable structure: Ordering, filters, cost model (set at construction)
9
+ * 2. mutable state: Pinned status, constraints (mutated during planning)
10
+ *
11
+ * # Cost Estimation
12
+ * The ordering and filters determine the initial cost. As planning progresses,
13
+ * constraints from parent joins refine the cost estimate.
14
+ *
15
+ * # Constraint Flow
16
+ * When a connection is pinned as the outer loop, it reveals constraints for
17
+ * connected joins. These constraints propagate through the graph, allowing
18
+ * other connections to update their cost estimates.
19
+ *
20
+ * Example:
21
+ *
22
+ * ```ts
23
+ * builder.issue.whereExists('assignee', a => a.where('name', 'Alice'))
24
+ * ```
25
+ *
26
+ * ```
27
+ * [issue] [assignee]
28
+ * | |
29
+ * | +-- where name = 'Alice'
30
+ * \ /
31
+ * \ /
32
+ * [join]
33
+ * |
34
+ * ```
35
+ *
36
+ * - Initial state: Both connections have no constraints, costs are unconstrained
37
+ * - If `issue` chosen first: Reveals constraint `assignee_id` for assignee connection
38
+ * - If `assignee` chosen first: Reveals constraint `assignee_id` for issue connection
39
+ * - Updated costs guide the next selection
40
+ *
41
+ * # Lifecycle
42
+ * 1. Construct with immutable structure (ordering, filters, cost model)
43
+ * 2. Wire to output node during graph construction
44
+ * 3. Planning mutates pinned status and accumulates constraints
45
+ * 4. reset() clears mutable state for replanning
46
+ */
47
+ export class PlannerConnection {
48
+ kind = 'connection';
49
+ // ========================================================================
50
+ // IMMUTABLE STRUCTURE (set during construction, never changes)
51
+ // ========================================================================
52
+ #sort;
53
+ #filters;
54
+ #model;
55
+ table;
56
+ name; // Human-readable name for debugging (defaults to table name)
57
+ #baseConstraints; // Constraints from parent correlation
58
+ #baseLimit; // Original limit from query structure (never modified)
59
+ selectivity; // Fraction of rows passing filters (1.0 = no filtering)
60
+ #output; // Set once during graph construction
61
+ // ========================================================================
62
+ // MUTABLE PLANNING STATE (changes during plan search)
63
+ // ========================================================================
64
+ /**
65
+ * Current limit during planning. Can be cleared (set to undefined) when a
66
+ * parent join is flipped, indicating this connection is now in an outer loop
67
+ * and should not be limited by EXISTS semantics.
68
+ */
69
+ limit;
70
+ /**
71
+ * Constraints accumulated from parent joins during planning.
72
+ * Key is a path through the graph (e.g., "0,1" for branch pattern [0,1]).
73
+ *
74
+ * Undefined constraints are possible when a FO converts to UFO and only
75
+ * a single join in the UFO is flipped - other branches report undefined.
76
+ */
77
+ #constraints;
78
+ /**
79
+ * Cached total cost (sum of all branches) to avoid redundant calculations.
80
+ * Invalidated when constraints change.
81
+ */
82
+ #cachedTotalCost = undefined;
83
+ /**
84
+ * Cached per-constraint costs to avoid redundant cost model calls.
85
+ * Maps constraint key (branch pattern string) to computed cost.
86
+ * Invalidated when constraints change.
87
+ */
88
+ #cachedConstraintCosts = new Map();
89
+ #costDirty = true;
90
+ constructor(table, model, sort, filters, baseConstraints, limit, name) {
91
+ this.table = table;
92
+ this.name = name ?? table;
93
+ this.#sort = sort;
94
+ this.#filters = filters;
95
+ this.#model = model;
96
+ this.#baseConstraints = baseConstraints;
97
+ this.#baseLimit = limit;
98
+ this.limit = limit;
99
+ this.#constraints = new Map();
100
+ // Compute selectivity for EXISTS child connections (baseLimit === 1)
101
+ // Selectivity = fraction of rows that pass filters
102
+ if (limit !== undefined && filters) {
103
+ const costWithFilters = model(table, sort, filters, undefined);
104
+ const costWithoutFilters = model(table, sort, undefined, undefined);
105
+ this.selectivity =
106
+ costWithoutFilters.rows > 0
107
+ ? costWithFilters.rows / costWithoutFilters.rows
108
+ : 1.0;
109
+ }
110
+ else {
111
+ // Root connections or connections without filters
112
+ this.selectivity = 1.0;
113
+ }
114
+ }
115
+ setOutput(node) {
116
+ this.#output = node;
117
+ }
118
+ get output() {
119
+ assert(this.#output !== undefined, 'Output not set');
120
+ return this.#output;
121
+ }
122
+ closestJoinOrSource() {
123
+ return 'connection';
124
+ }
125
+ /**
126
+ * Constraints are uniquely identified by their path through the
127
+ * graph.
128
+ *
129
+ * FO represents all sub-joins as a single path.
130
+ * UFO represents each sub-join as a separate path.
131
+ * The first branch in a UFO will match the path of FO so no re-set needs to happen
132
+ * when swapping from FO to UFO.
133
+ *
134
+ * FO swaps to UFO when a join inside FO-FI gets flipped.
135
+ *
136
+ * The max of the last element of the paths is the number of
137
+ * root branches.
138
+ */
139
+ propagateConstraints(path, c) {
140
+ const key = path.join(',');
141
+ this.#constraints.set(key, c);
142
+ // Constraints changed, invalidate cost caches
143
+ this.#cachedTotalCost = undefined;
144
+ this.#cachedConstraintCosts.clear();
145
+ this.#costDirty = true;
146
+ }
147
+ estimateCost(branchPattern) {
148
+ // If no branch pattern specified, return sum of all branches
149
+ // This is used by getUnpinnedConnectionCosts to get total cost
150
+ if (branchPattern === undefined) {
151
+ // Return cached total cost if still valid
152
+ if (!this.#costDirty && this.#cachedTotalCost !== undefined) {
153
+ return this.#cachedTotalCost;
154
+ }
155
+ // Calculate fresh cost - sum of all branch costs
156
+ let totalRows = 0;
157
+ let maxStartupCost = 0;
158
+ if (this.#constraints.size === 0) {
159
+ // No constraints - compute unconstrained cost (but still merge base constraints)
160
+ const key = '';
161
+ let cost = this.#cachedConstraintCosts.get(key);
162
+ if (cost === undefined) {
163
+ // Merge base constraints even when no propagated constraints
164
+ const { startupCost, rows } = this.#model(this.table, this.#sort, this.#filters, this.#baseConstraints);
165
+ cost = {
166
+ rows,
167
+ runningCost: rows,
168
+ startupCost,
169
+ selectivity: this.selectivity,
170
+ limit: this.limit,
171
+ };
172
+ this.#cachedConstraintCosts.set(key, cost);
173
+ }
174
+ totalRows = cost.rows;
175
+ maxStartupCost = cost.startupCost;
176
+ }
177
+ else {
178
+ // Sum costs for all constraint branches
179
+ for (const [key, constraint] of this.#constraints.entries()) {
180
+ let cost = this.#cachedConstraintCosts.get(key);
181
+ if (cost === undefined) {
182
+ // Merge base constraints with propagated constraints
183
+ const mergedConstraint = mergeConstraints(this.#baseConstraints, constraint);
184
+ const { startupCost, rows } = this.#model(this.table, this.#sort, this.#filters, mergedConstraint);
185
+ cost = {
186
+ rows,
187
+ runningCost: rows,
188
+ startupCost,
189
+ selectivity: this.selectivity,
190
+ limit: this.limit,
191
+ };
192
+ this.#cachedConstraintCosts.set(key, cost);
193
+ }
194
+ totalRows += cost.rows;
195
+ // TODO: if no branch pattern is specified, should we sum startup costs?
196
+ maxStartupCost = Math.max(maxStartupCost, cost.startupCost);
197
+ }
198
+ }
199
+ const ret = {
200
+ rows: totalRows,
201
+ runningCost: totalRows,
202
+ startupCost: maxStartupCost,
203
+ selectivity: this.selectivity,
204
+ limit: this.limit,
205
+ };
206
+ // Cache total and mark as clean
207
+ this.#cachedTotalCost = ret;
208
+ this.#costDirty = false;
209
+ return ret;
210
+ }
211
+ // Branch pattern specified - return cost for this specific branch
212
+ const key = branchPattern.join(',');
213
+ // Check per-constraint cache first
214
+ let cost = this.#cachedConstraintCosts.get(key);
215
+ if (cost !== undefined) {
216
+ return cost;
217
+ }
218
+ // Cache miss - compute and cache
219
+ const constraint = this.#constraints.get(key);
220
+ // Merge base constraints with propagated constraints
221
+ const mergedConstraint = mergeConstraints(this.#baseConstraints, constraint);
222
+ const { startupCost, rows } = this.#model(this.table, this.#sort, this.#filters, mergedConstraint);
223
+ cost = {
224
+ rows,
225
+ runningCost: rows,
226
+ startupCost,
227
+ selectivity: this.selectivity,
228
+ limit: this.limit,
229
+ };
230
+ this.#cachedConstraintCosts.set(key, cost);
231
+ return cost;
232
+ }
233
+ /**
234
+ * Remove the limit from this connection.
235
+ * Called when a parent join is flipped, making this connection part of an
236
+ * outer loop that should produce all rows rather than stopping at the limit.
237
+ */
238
+ unlimit() {
239
+ if (this.limit !== undefined) {
240
+ this.limit = undefined;
241
+ // Limit changes do not impact connection costs.
242
+ // Limit is taken into account at the join level.
243
+ // Given that, we do not need to invalidate cost caches here.
244
+ }
245
+ }
246
+ /**
247
+ * Propagate unlimiting when a parent join is flipped.
248
+ * For connections, we simply remove the limit.
249
+ */
250
+ propagateUnlimitFromFlippedJoin() {
251
+ this.unlimit();
252
+ }
253
+ reset() {
254
+ this.#constraints.clear();
255
+ this.limit = this.#baseLimit;
256
+ // Clear all cost caches
257
+ this.#cachedTotalCost = undefined;
258
+ this.#cachedConstraintCosts.clear();
259
+ this.#costDirty = true;
260
+ }
261
+ /**
262
+ * Capture constraint state for snapshotting.
263
+ * Used by PlannerGraph to save/restore planning state.
264
+ */
265
+ captureConstraints() {
266
+ return new Map(this.#constraints);
267
+ }
268
+ /**
269
+ * Restore constraint state from a snapshot.
270
+ * Used by PlannerGraph to restore planning state.
271
+ */
272
+ restoreConstraints(constraints) {
273
+ this.#constraints.clear();
274
+ for (const [key, value] of constraints) {
275
+ this.#constraints.set(key, value);
276
+ }
277
+ // Constraints changed, invalidate cost caches
278
+ this.#cachedTotalCost = undefined;
279
+ this.#cachedConstraintCosts.clear();
280
+ this.#costDirty = true;
281
+ }
282
+ /**
283
+ * Get current constraints for debugging.
284
+ * Returns a copy of the constraints map.
285
+ */
286
+ getConstraintsForDebug() {
287
+ return new Map(this.#constraints);
288
+ }
289
+ /**
290
+ * Get estimated cost for each constraint branch.
291
+ * Returns a map of constraint key to cost estimate.
292
+ * Forces cost calculation if not already cached.
293
+ */
294
+ getConstraintCostsForDebug() {
295
+ // Trigger cost calculation to populate cache
296
+ this.estimateCost(undefined);
297
+ // Return copy of cached costs
298
+ return new Map(this.#cachedConstraintCosts);
299
+ }
300
+ }
301
+ //# sourceMappingURL=planner-connection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planner-connection.js","sourceRoot":"","sources":["../../../../../zql/src/planner/planner-connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,gCAAgC,CAAC;AAEtD,OAAO,EACL,gBAAgB,GAEjB,MAAM,yBAAyB,CAAC;AAOjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,MAAM,OAAO,iBAAiB;IACnB,IAAI,GAAG,YAAqB,CAAC;IAEtC,2EAA2E;IAC3E,+DAA+D;IAC/D,2EAA2E;IAClE,KAAK,CAAW;IAChB,QAAQ,CAAwB;IAChC,MAAM,CAAsB;IAC5B,KAAK,CAAS;IACd,IAAI,CAAS,CAAC,6DAA6D;IAC3E,gBAAgB,CAAgC,CAAC,sCAAsC;IACvF,UAAU,CAAqB,CAAC,uDAAuD;IACvF,WAAW,CAAS,CAAC,wDAAwD;IACtF,OAAO,CAA2B,CAAC,qCAAqC;IAExE,2EAA2E;IAC3E,sDAAsD;IACtD,2EAA2E;IAC3E;;;;OAIG;IACH,KAAK,CA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QACpB,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACpC,CAAC;IAED;;;;OAIG;IACH,0BAA0B;QACxB,6CAA6C;QAC7C,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QAC7B,8BAA8B;QAC9B,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;IAC9C,CAAC;CACF"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * We do not know the value a constraint will take until runtime.
3
+ *
4
+ * However, we do know the column.
5
+ *
6
+ * E.g., we know that `issue.assignee_id` will be constrained to typeof issue.assignee_id.
7
+ */
8
+ export type PlannerConstraint = Record<string, undefined>;
9
+ /**
10
+ * Multiple flipped joins will contribute extra constraints to a parent join.
11
+ * These need to be merged.
12
+ */
13
+ export declare function mergeConstraints(a: PlannerConstraint | undefined, b: PlannerConstraint | undefined): PlannerConstraint | undefined;
14
+ //# sourceMappingURL=planner-constraint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planner-constraint.d.ts","sourceRoot":"","sources":["../../../../../zql/src/planner/planner-constraint.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAE1D;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,CAAC,EAAE,iBAAiB,GAAG,SAAS,EAChC,CAAC,EAAE,iBAAiB,GAAG,SAAS,GAC/B,iBAAiB,GAAG,SAAS,CAI/B"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Multiple flipped joins will contribute extra constraints to a parent join.
3
+ * These need to be merged.
4
+ */
5
+ export function mergeConstraints(a, b) {
6
+ if (!a)
7
+ return b;
8
+ if (!b)
9
+ return a;
10
+ return { ...a, ...b };
11
+ }
12
+ //# sourceMappingURL=planner-constraint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planner-constraint.js","sourceRoot":"","sources":["../../../../../zql/src/planner/planner-constraint.ts"],"names":[],"mappings":"AASA;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAC9B,CAAgC,EAChC,CAAgC;IAEhC,IAAI,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC;IACjB,IAAI,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC;IACjB,OAAO,EAAC,GAAG,CAAC,EAAE,GAAG,CAAC,EAAC,CAAC;AACtB,CAAC"}