@rocicorp/zero 1.10.0-canary.24 → 1.10.0-canary.26

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 (568) hide show
  1. package/out/analyze-query/src/bin-analyze.js +8 -9
  2. package/out/analyze-query/src/bin-analyze.js.map +1 -1
  3. package/out/replicache/src/btree/node.d.ts.map +1 -1
  4. package/out/replicache/src/btree/node.js +6 -3
  5. package/out/replicache/src/btree/node.js.map +1 -1
  6. package/out/replicache/src/btree/read.d.ts +1 -12
  7. package/out/replicache/src/btree/read.d.ts.map +1 -1
  8. package/out/replicache/src/btree/read.js +12 -24
  9. package/out/replicache/src/btree/read.js.map +1 -1
  10. package/out/replicache/src/dag/gc.d.ts.map +1 -1
  11. package/out/replicache/src/dag/gc.js +11 -8
  12. package/out/replicache/src/dag/gc.js.map +1 -1
  13. package/out/replicache/src/dag/store-impl.d.ts +2 -12
  14. package/out/replicache/src/dag/store-impl.d.ts.map +1 -1
  15. package/out/replicache/src/dag/store-impl.js +8 -22
  16. package/out/replicache/src/dag/store-impl.js.map +1 -1
  17. package/out/replicache/src/db/rebase.d.ts +2 -14
  18. package/out/replicache/src/db/rebase.d.ts.map +1 -1
  19. package/out/replicache/src/db/rebase.js +5 -27
  20. package/out/replicache/src/db/rebase.js.map +1 -1
  21. package/out/replicache/src/db/write.js.map +1 -1
  22. package/out/replicache/src/kv/expo-sqlite/store.d.ts.map +1 -1
  23. package/out/replicache/src/kv/expo-sqlite/store.js +5 -28
  24. package/out/replicache/src/kv/expo-sqlite/store.js.map +1 -1
  25. package/out/replicache/src/kv/idb-store-with-mem-fallback.d.ts +5 -15
  26. package/out/replicache/src/kv/idb-store-with-mem-fallback.d.ts.map +1 -1
  27. package/out/replicache/src/kv/idb-store-with-mem-fallback.js +25 -25
  28. package/out/replicache/src/kv/idb-store-with-mem-fallback.js.map +1 -1
  29. package/out/replicache/src/kv/idb-store.d.ts +0 -9
  30. package/out/replicache/src/kv/idb-store.d.ts.map +1 -1
  31. package/out/replicache/src/kv/idb-store.js +2 -14
  32. package/out/replicache/src/kv/idb-store.js.map +1 -1
  33. package/out/replicache/src/kv/mem-store.d.ts +0 -1
  34. package/out/replicache/src/kv/mem-store.d.ts.map +1 -1
  35. package/out/replicache/src/kv/mem-store.js +0 -3
  36. package/out/replicache/src/kv/mem-store.js.map +1 -1
  37. package/out/replicache/src/kv/op-sqlite/store.d.ts.map +1 -1
  38. package/out/replicache/src/kv/op-sqlite/store.js +1 -1
  39. package/out/replicache/src/kv/op-sqlite/store.js.map +1 -1
  40. package/out/replicache/src/kv/sqlite-store.d.ts +1 -13
  41. package/out/replicache/src/kv/sqlite-store.d.ts.map +1 -1
  42. package/out/replicache/src/kv/sqlite-store.js +6 -73
  43. package/out/replicache/src/kv/sqlite-store.js.map +1 -1
  44. package/out/replicache/src/kv/store.d.ts +0 -6
  45. package/out/replicache/src/kv/store.d.ts.map +1 -1
  46. package/out/replicache/src/persist/collect-idb-databases.d.ts +5 -10
  47. package/out/replicache/src/persist/collect-idb-databases.d.ts.map +1 -1
  48. package/out/replicache/src/persist/collect-idb-databases.js +9 -16
  49. package/out/replicache/src/persist/collect-idb-databases.js.map +1 -1
  50. package/out/replicache/src/persist/persist.d.ts.map +1 -1
  51. package/out/replicache/src/persist/persist.js +6 -13
  52. package/out/replicache/src/persist/persist.js.map +1 -1
  53. package/out/replicache/src/persist/refresh.js +2 -6
  54. package/out/replicache/src/persist/refresh.js.map +1 -1
  55. package/out/replicache/src/replicache-impl.d.ts +3 -14
  56. package/out/replicache/src/replicache-impl.d.ts.map +1 -1
  57. package/out/replicache/src/replicache-impl.js +11 -118
  58. package/out/replicache/src/replicache-impl.js.map +1 -1
  59. package/out/replicache/src/replicache-options.d.ts +0 -9
  60. package/out/replicache/src/replicache-options.d.ts.map +1 -1
  61. package/out/replicache/src/transactions.d.ts.map +1 -1
  62. package/out/replicache/src/transactions.js +1 -1
  63. package/out/replicache/src/transactions.js.map +1 -1
  64. package/out/shared/src/arrays.d.ts +0 -5
  65. package/out/shared/src/arrays.d.ts.map +1 -1
  66. package/out/shared/src/arrays.js +24 -8
  67. package/out/shared/src/arrays.js.map +1 -1
  68. package/out/shared/src/base64.d.ts +19 -0
  69. package/out/shared/src/base64.d.ts.map +1 -0
  70. package/out/shared/src/base64.js +40 -0
  71. package/out/shared/src/base64.js.map +1 -0
  72. package/out/shared/src/error.d.ts +0 -11
  73. package/out/shared/src/error.d.ts.map +1 -1
  74. package/out/shared/src/error.js +1 -35
  75. package/out/shared/src/error.js.map +1 -1
  76. package/out/shared/src/hash.d.ts +0 -1
  77. package/out/shared/src/hash.d.ts.map +1 -1
  78. package/out/shared/src/hash.js +10 -87
  79. package/out/shared/src/hash.js.map +1 -1
  80. package/out/shared/src/iterables.d.ts +0 -2
  81. package/out/shared/src/iterables.d.ts.map +1 -1
  82. package/out/shared/src/iterables.js +1 -18
  83. package/out/shared/src/iterables.js.map +1 -1
  84. package/out/shared/src/json.d.ts.map +1 -1
  85. package/out/shared/src/json.js +2 -2
  86. package/out/shared/src/json.js.map +1 -1
  87. package/out/shared/src/map.d.ts +2 -24
  88. package/out/shared/src/map.d.ts.map +1 -1
  89. package/out/shared/src/map.js +4 -18
  90. package/out/shared/src/map.js.map +1 -1
  91. package/out/shared/src/ring-buffer.d.ts +0 -8
  92. package/out/shared/src/ring-buffer.d.ts.map +1 -1
  93. package/out/shared/src/ring-buffer.js +1 -22
  94. package/out/shared/src/ring-buffer.js.map +1 -1
  95. package/out/z2s/src/sql.d.ts.map +1 -1
  96. package/out/z2s/src/sql.js +2 -2
  97. package/out/z2s/src/sql.js.map +1 -1
  98. package/out/zero/package.js +3 -2
  99. package/out/zero/package.js.map +1 -1
  100. package/out/zero-cache/src/auth/read-authorizer.js +1 -1
  101. package/out/zero-cache/src/auth/write-authorizer.d.ts.map +1 -1
  102. package/out/zero-cache/src/auth/write-authorizer.js +0 -1
  103. package/out/zero-cache/src/auth/write-authorizer.js.map +1 -1
  104. package/out/zero-cache/src/config/zero-config.d.ts +2 -42
  105. package/out/zero-cache/src/config/zero-config.d.ts.map +1 -1
  106. package/out/zero-cache/src/config/zero-config.js +28 -149
  107. package/out/zero-cache/src/config/zero-config.js.map +1 -1
  108. package/out/zero-cache/src/custom-queries/transform-query.js +1 -1
  109. package/out/zero-cache/src/db/create.d.ts.map +1 -1
  110. package/out/zero-cache/src/db/create.js +1 -4
  111. package/out/zero-cache/src/db/create.js.map +1 -1
  112. package/out/zero-cache/src/db/lite-tables.d.ts +2 -10
  113. package/out/zero-cache/src/db/lite-tables.d.ts.map +1 -1
  114. package/out/zero-cache/src/db/lite-tables.js +6 -10
  115. package/out/zero-cache/src/db/lite-tables.js.map +1 -1
  116. package/out/zero-cache/src/db/specs.d.ts +0 -41
  117. package/out/zero-cache/src/db/specs.d.ts.map +1 -1
  118. package/out/zero-cache/src/db/specs.js +3 -30
  119. package/out/zero-cache/src/db/specs.js.map +1 -1
  120. package/out/zero-cache/src/observability/metrics.d.ts.map +1 -1
  121. package/out/zero-cache/src/observability/metrics.js +7 -2
  122. package/out/zero-cache/src/observability/metrics.js.map +1 -1
  123. package/out/zero-cache/src/server/change-streamer.d.ts.map +1 -1
  124. package/out/zero-cache/src/server/change-streamer.js +4 -13
  125. package/out/zero-cache/src/server/change-streamer.js.map +1 -1
  126. package/out/zero-cache/src/server/inspector-delegate.d.ts +2 -18
  127. package/out/zero-cache/src/server/inspector-delegate.d.ts.map +1 -1
  128. package/out/zero-cache/src/server/inspector-delegate.js +17 -25
  129. package/out/zero-cache/src/server/inspector-delegate.js.map +1 -1
  130. package/out/zero-cache/src/server/main.d.ts.map +1 -1
  131. package/out/zero-cache/src/server/main.js +1 -8
  132. package/out/zero-cache/src/server/main.js.map +1 -1
  133. package/out/zero-cache/src/server/mutator.js +0 -2
  134. package/out/zero-cache/src/server/mutator.js.map +1 -1
  135. package/out/zero-cache/src/server/reaper.d.ts.map +1 -1
  136. package/out/zero-cache/src/server/reaper.js +0 -2
  137. package/out/zero-cache/src/server/reaper.js.map +1 -1
  138. package/out/zero-cache/src/server/replicator.d.ts.map +1 -1
  139. package/out/zero-cache/src/server/replicator.js +2 -8
  140. package/out/zero-cache/src/server/replicator.js.map +1 -1
  141. package/out/zero-cache/src/server/runner/zero-dispatcher.d.ts.map +1 -1
  142. package/out/zero-cache/src/server/runner/zero-dispatcher.js +0 -3
  143. package/out/zero-cache/src/server/runner/zero-dispatcher.js.map +1 -1
  144. package/out/zero-cache/src/server/syncer.d.ts.map +1 -1
  145. package/out/zero-cache/src/server/syncer.js +1 -5
  146. package/out/zero-cache/src/server/syncer.js.map +1 -1
  147. package/out/zero-cache/src/services/analyze.d.ts.map +1 -1
  148. package/out/zero-cache/src/services/analyze.js +9 -11
  149. package/out/zero-cache/src/services/analyze.js.map +1 -1
  150. package/out/zero-cache/src/services/change-source/common/backfill-manager.d.ts.map +1 -1
  151. package/out/zero-cache/src/services/change-source/common/backfill-manager.js +1 -14
  152. package/out/zero-cache/src/services/change-source/common/backfill-manager.js.map +1 -1
  153. package/out/zero-cache/src/services/change-source/common/change-stream-multiplexer.d.ts.map +1 -1
  154. package/out/zero-cache/src/services/change-source/common/change-stream-multiplexer.js +3 -15
  155. package/out/zero-cache/src/services/change-source/common/change-stream-multiplexer.js.map +1 -1
  156. package/out/zero-cache/src/services/change-source/pg/change-source.d.ts +1 -11
  157. package/out/zero-cache/src/services/change-source/pg/change-source.d.ts.map +1 -1
  158. package/out/zero-cache/src/services/change-source/pg/change-source.js +2 -21
  159. package/out/zero-cache/src/services/change-source/pg/change-source.js.map +1 -1
  160. package/out/zero-cache/src/services/change-source/pg/initial-sync.d.ts +0 -1
  161. package/out/zero-cache/src/services/change-source/pg/initial-sync.d.ts.map +1 -1
  162. package/out/zero-cache/src/services/change-source/pg/initial-sync.js +7 -8
  163. package/out/zero-cache/src/services/change-source/pg/initial-sync.js.map +1 -1
  164. package/out/zero-cache/src/services/change-source/pg/schema/ddl.d.ts +229 -1513
  165. package/out/zero-cache/src/services/change-source/pg/schema/ddl.d.ts.map +1 -1
  166. package/out/zero-cache/src/services/change-source/pg/schema/ddl.js +2 -2
  167. package/out/zero-cache/src/services/change-source/pg/schema/ddl.js.map +1 -1
  168. package/out/zero-cache/src/services/change-source/pg/schema/init.d.ts +1 -1
  169. package/out/zero-cache/src/services/change-source/pg/schema/init.d.ts.map +1 -1
  170. package/out/zero-cache/src/services/change-source/pg/schema/init.js +6 -15
  171. package/out/zero-cache/src/services/change-source/pg/schema/init.js.map +1 -1
  172. package/out/zero-cache/src/services/change-source/pg/schema/published.d.ts +20 -137
  173. package/out/zero-cache/src/services/change-source/pg/schema/published.d.ts.map +1 -1
  174. package/out/zero-cache/src/services/change-source/pg/schema/published.js +13 -82
  175. package/out/zero-cache/src/services/change-source/pg/schema/published.js.map +1 -1
  176. package/out/zero-cache/src/services/change-source/pg/schema/shard.d.ts +21 -128
  177. package/out/zero-cache/src/services/change-source/pg/schema/shard.d.ts.map +1 -1
  178. package/out/zero-cache/src/services/change-source/pg/schema/shard.js +5 -5
  179. package/out/zero-cache/src/services/change-source/pg/schema/shard.js.map +1 -1
  180. package/out/zero-cache/src/services/change-source/protocol/current/data.d.ts +0 -2
  181. package/out/zero-cache/src/services/change-source/protocol/current/data.d.ts.map +1 -1
  182. package/out/zero-cache/src/services/change-source/protocol/current/downstream.d.ts +0 -3
  183. package/out/zero-cache/src/services/change-source/protocol/current/downstream.d.ts.map +1 -1
  184. package/out/zero-cache/src/services/change-streamer/change-streamer-http.d.ts +0 -3
  185. package/out/zero-cache/src/services/change-streamer/change-streamer-http.d.ts.map +1 -1
  186. package/out/zero-cache/src/services/change-streamer/change-streamer-http.js +1 -3
  187. package/out/zero-cache/src/services/change-streamer/change-streamer-http.js.map +1 -1
  188. package/out/zero-cache/src/services/change-streamer/change-streamer.d.ts +0 -1
  189. package/out/zero-cache/src/services/change-streamer/change-streamer.d.ts.map +1 -1
  190. package/out/zero-cache/src/services/litestream/commands.d.ts.map +1 -1
  191. package/out/zero-cache/src/services/litestream/commands.js +3 -8
  192. package/out/zero-cache/src/services/litestream/commands.js.map +1 -1
  193. package/out/zero-cache/src/services/litestream/config-v5.yml +1 -15
  194. package/out/zero-cache/src/services/mutagen/mutagen.d.ts +0 -5
  195. package/out/zero-cache/src/services/mutagen/mutagen.d.ts.map +1 -1
  196. package/out/zero-cache/src/services/mutagen/mutagen.js +1 -7
  197. package/out/zero-cache/src/services/mutagen/mutagen.js.map +1 -1
  198. package/out/zero-cache/src/services/mutagen/pusher.d.ts +119 -119
  199. package/out/zero-cache/src/services/mutagen/pusher.d.ts.map +1 -1
  200. package/out/zero-cache/src/services/mutagen/pusher.js +6 -5
  201. package/out/zero-cache/src/services/mutagen/pusher.js.map +1 -1
  202. package/out/zero-cache/src/services/replicator/change-processor.d.ts.map +1 -1
  203. package/out/zero-cache/src/services/replicator/change-processor.js +16 -16
  204. package/out/zero-cache/src/services/replicator/change-processor.js.map +1 -1
  205. package/out/zero-cache/src/services/replicator/incremental-sync.d.ts.map +1 -1
  206. package/out/zero-cache/src/services/replicator/incremental-sync.js +0 -1
  207. package/out/zero-cache/src/services/replicator/incremental-sync.js.map +1 -1
  208. package/out/zero-cache/src/services/replicator/write-worker-client.d.ts +2 -27
  209. package/out/zero-cache/src/services/replicator/write-worker-client.d.ts.map +1 -1
  210. package/out/zero-cache/src/services/replicator/write-worker-client.js +2 -3
  211. package/out/zero-cache/src/services/replicator/write-worker-client.js.map +1 -1
  212. package/out/zero-cache/src/services/replicator/write-worker.js +5 -24
  213. package/out/zero-cache/src/services/replicator/write-worker.js.map +1 -1
  214. package/out/zero-cache/src/services/run-ast.d.ts +0 -12
  215. package/out/zero-cache/src/services/run-ast.d.ts.map +1 -1
  216. package/out/zero-cache/src/services/run-ast.js +15 -27
  217. package/out/zero-cache/src/services/run-ast.js.map +1 -1
  218. package/out/zero-cache/src/services/runner.d.ts.map +1 -1
  219. package/out/zero-cache/src/services/runner.js +1 -1
  220. package/out/zero-cache/src/services/runner.js.map +1 -1
  221. package/out/zero-cache/src/services/view-syncer/cvr.d.ts +0 -45
  222. package/out/zero-cache/src/services/view-syncer/cvr.d.ts.map +1 -1
  223. package/out/zero-cache/src/services/view-syncer/cvr.js +1 -133
  224. package/out/zero-cache/src/services/view-syncer/cvr.js.map +1 -1
  225. package/out/zero-cache/src/services/view-syncer/drain-coordinator.d.ts +1 -14
  226. package/out/zero-cache/src/services/view-syncer/drain-coordinator.d.ts.map +1 -1
  227. package/out/zero-cache/src/services/view-syncer/drain-coordinator.js +4 -30
  228. package/out/zero-cache/src/services/view-syncer/drain-coordinator.js.map +1 -1
  229. package/out/zero-cache/src/services/view-syncer/inspect-handler.d.ts +1 -1
  230. package/out/zero-cache/src/services/view-syncer/inspect-handler.d.ts.map +1 -1
  231. package/out/zero-cache/src/services/view-syncer/inspect-handler.js +2 -2
  232. package/out/zero-cache/src/services/view-syncer/inspect-handler.js.map +1 -1
  233. package/out/zero-cache/src/services/view-syncer/pipeline-driver.d.ts +1 -2
  234. package/out/zero-cache/src/services/view-syncer/pipeline-driver.d.ts.map +1 -1
  235. package/out/zero-cache/src/services/view-syncer/pipeline-driver.js +27 -48
  236. package/out/zero-cache/src/services/view-syncer/pipeline-driver.js.map +1 -1
  237. package/out/zero-cache/src/services/view-syncer/query-covering.d.ts.map +1 -1
  238. package/out/zero-cache/src/services/view-syncer/query-covering.js +6 -2
  239. package/out/zero-cache/src/services/view-syncer/query-covering.js.map +1 -1
  240. package/out/zero-cache/src/services/view-syncer/snapshotter.d.ts +4 -42
  241. package/out/zero-cache/src/services/view-syncer/snapshotter.d.ts.map +1 -1
  242. package/out/zero-cache/src/services/view-syncer/snapshotter.js +28 -117
  243. package/out/zero-cache/src/services/view-syncer/snapshotter.js.map +1 -1
  244. package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts +1 -11
  245. package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts.map +1 -1
  246. package/out/zero-cache/src/services/view-syncer/view-syncer.js +95 -466
  247. package/out/zero-cache/src/services/view-syncer/view-syncer.js.map +1 -1
  248. package/out/zero-cache/src/types/processes.d.ts +0 -32
  249. package/out/zero-cache/src/types/processes.d.ts.map +1 -1
  250. package/out/zero-cache/src/types/processes.js +4 -43
  251. package/out/zero-cache/src/types/processes.js.map +1 -1
  252. package/out/zero-cache/src/types/profiler.d.ts +0 -12
  253. package/out/zero-cache/src/types/profiler.d.ts.map +1 -1
  254. package/out/zero-cache/src/types/profiler.js +1 -46
  255. package/out/zero-cache/src/types/profiler.js.map +1 -1
  256. package/out/zero-cache/src/types/row-key.d.ts.map +1 -1
  257. package/out/zero-cache/src/types/row-key.js +5 -5
  258. package/out/zero-cache/src/types/row-key.js.map +1 -1
  259. package/out/zero-cache/src/workers/connect-params.d.ts +7 -0
  260. package/out/zero-cache/src/workers/connect-params.d.ts.map +1 -1
  261. package/out/zero-cache/src/workers/connect-params.js +20 -1
  262. package/out/zero-cache/src/workers/connect-params.js.map +1 -1
  263. package/out/zero-cache/src/workers/connection.d.ts +4 -4
  264. package/out/zero-cache/src/workers/connection.d.ts.map +1 -1
  265. package/out/zero-cache/src/workers/connection.js +8 -8
  266. package/out/zero-cache/src/workers/connection.js.map +1 -1
  267. package/out/zero-cache/src/workers/replicator.d.ts +0 -1
  268. package/out/zero-cache/src/workers/replicator.d.ts.map +1 -1
  269. package/out/zero-cache/src/workers/replicator.js +2 -4
  270. package/out/zero-cache/src/workers/replicator.js.map +1 -1
  271. package/out/zero-cache/src/workers/syncer-ws-message-handler.d.ts.map +1 -1
  272. package/out/zero-cache/src/workers/syncer-ws-message-handler.js +16 -21
  273. package/out/zero-cache/src/workers/syncer-ws-message-handler.js.map +1 -1
  274. package/out/zero-cache/src/workers/syncer.d.ts.map +1 -1
  275. package/out/zero-cache/src/workers/syncer.js +1 -10
  276. package/out/zero-cache/src/workers/syncer.js.map +1 -1
  277. package/out/zero-client/src/client/connection-manager.d.ts +0 -20
  278. package/out/zero-client/src/client/connection-manager.d.ts.map +1 -1
  279. package/out/zero-client/src/client/connection-manager.js +13 -77
  280. package/out/zero-client/src/client/connection-manager.js.map +1 -1
  281. package/out/zero-client/src/client/connection-status-enum.d.ts +0 -2
  282. package/out/zero-client/src/client/connection-status-enum.d.ts.map +1 -1
  283. package/out/zero-client/src/client/connection-status-enum.js +1 -3
  284. package/out/zero-client/src/client/connection-status-enum.js.map +1 -1
  285. package/out/zero-client/src/client/connection.d.ts +0 -6
  286. package/out/zero-client/src/client/connection.d.ts.map +1 -1
  287. package/out/zero-client/src/client/connection.js +1 -2
  288. package/out/zero-client/src/client/connection.js.map +1 -1
  289. package/out/zero-client/src/client/context.d.ts +2 -27
  290. package/out/zero-client/src/client/context.d.ts.map +1 -1
  291. package/out/zero-client/src/client/context.js +1 -112
  292. package/out/zero-client/src/client/context.js.map +1 -1
  293. package/out/zero-client/src/client/custom.js +2 -2
  294. package/out/zero-client/src/client/custom.js.map +1 -1
  295. package/out/zero-client/src/client/error.js +1 -1
  296. package/out/zero-client/src/client/inspector/lazy-inspector.js +2 -2
  297. package/out/zero-client/src/client/inspector/lazy-inspector.js.map +1 -1
  298. package/out/zero-client/src/client/ivm-branch.d.ts.map +1 -1
  299. package/out/zero-client/src/client/ivm-branch.js +3 -20
  300. package/out/zero-client/src/client/ivm-branch.js.map +1 -1
  301. package/out/zero-client/src/client/mutation-tracker.d.ts.map +1 -1
  302. package/out/zero-client/src/client/mutation-tracker.js +1 -1
  303. package/out/zero-client/src/client/mutation-tracker.js.map +1 -1
  304. package/out/zero-client/src/client/mutator-proxy.d.ts.map +1 -1
  305. package/out/zero-client/src/client/mutator-proxy.js +1 -2
  306. package/out/zero-client/src/client/mutator-proxy.js.map +1 -1
  307. package/out/zero-client/src/client/options.d.ts +0 -3
  308. package/out/zero-client/src/client/options.d.ts.map +1 -1
  309. package/out/zero-client/src/client/options.js.map +1 -1
  310. package/out/zero-client/src/client/query-manager.d.ts +0 -2
  311. package/out/zero-client/src/client/query-manager.d.ts.map +1 -1
  312. package/out/zero-client/src/client/query-manager.js +14 -50
  313. package/out/zero-client/src/client/query-manager.js.map +1 -1
  314. package/out/zero-client/src/client/version.js +1 -1
  315. package/out/zero-client/src/client/zero-rep.d.ts +0 -1
  316. package/out/zero-client/src/client/zero-rep.d.ts.map +1 -1
  317. package/out/zero-client/src/client/zero-rep.js +6 -9
  318. package/out/zero-client/src/client/zero-rep.js.map +1 -1
  319. package/out/zero-client/src/client/zero.d.ts +3 -18
  320. package/out/zero-client/src/client/zero.d.ts.map +1 -1
  321. package/out/zero-client/src/client/zero.js +36 -123
  322. package/out/zero-client/src/client/zero.js.map +1 -1
  323. package/out/zero-client/src/types/query-result.d.ts +0 -2
  324. package/out/zero-client/src/types/query-result.d.ts.map +1 -1
  325. package/out/zero-protocol/src/analyze-query-result.d.ts +5 -5
  326. package/out/zero-protocol/src/analyze-query-result.d.ts.map +1 -1
  327. package/out/zero-protocol/src/analyze-query-result.js +1 -1
  328. package/out/zero-protocol/src/analyze-query-result.js.map +1 -1
  329. package/out/zero-protocol/src/ast.d.ts +1 -64
  330. package/out/zero-protocol/src/ast.d.ts.map +1 -1
  331. package/out/zero-protocol/src/ast.js +54 -225
  332. package/out/zero-protocol/src/ast.js.map +1 -1
  333. package/out/zero-protocol/src/connect.d.ts +13 -0
  334. package/out/zero-protocol/src/connect.d.ts.map +1 -1
  335. package/out/zero-protocol/src/connect.js +30 -1
  336. package/out/zero-protocol/src/connect.js.map +1 -1
  337. package/out/zero-protocol/src/down.d.ts +2 -2
  338. package/out/zero-protocol/src/error.d.ts +1 -1
  339. package/out/zero-protocol/src/inspect-down.d.ts +6 -6
  340. package/out/zero-protocol/src/poke.d.ts +11 -4
  341. package/out/zero-protocol/src/poke.d.ts.map +1 -1
  342. package/out/zero-protocol/src/poke.js +3 -2
  343. package/out/zero-protocol/src/poke.js.map +1 -1
  344. package/out/zero-protocol/src/protocol-flag-enum.d.ts +7 -0
  345. package/out/zero-protocol/src/protocol-flag-enum.d.ts.map +1 -0
  346. package/out/zero-protocol/src/protocol-flag-enum.js +7 -0
  347. package/out/zero-protocol/src/protocol-flag-enum.js.map +1 -0
  348. package/out/zero-protocol/src/protocol-flag.d.ts +14 -0
  349. package/out/zero-protocol/src/protocol-flag.d.ts.map +1 -0
  350. package/out/zero-protocol/src/protocol-flag.js +8 -0
  351. package/out/zero-protocol/src/protocol-flag.js.map +1 -0
  352. package/out/zero-protocol/src/protocol-version.d.ts +30 -6
  353. package/out/zero-protocol/src/protocol-version.d.ts.map +1 -1
  354. package/out/zero-protocol/src/protocol-version.js +1 -1
  355. package/out/zero-protocol/src/protocol-version.js.map +1 -1
  356. package/out/zero-protocol/src/query-hash.d.ts +2 -7
  357. package/out/zero-protocol/src/query-hash.d.ts.map +1 -1
  358. package/out/zero-protocol/src/query-hash.js +10 -10
  359. package/out/zero-protocol/src/query-hash.js.map +1 -1
  360. package/out/zero-react/src/use-query.d.ts +4 -5
  361. package/out/zero-react/src/use-query.d.ts.map +1 -1
  362. package/out/zero-react/src/use-query.js +9 -86
  363. package/out/zero-react/src/use-query.js.map +1 -1
  364. package/out/zero-solid/src/solid-view.d.ts +0 -17
  365. package/out/zero-solid/src/solid-view.d.ts.map +1 -1
  366. package/out/zero-solid/src/solid-view.js +1 -39
  367. package/out/zero-solid/src/solid-view.js.map +1 -1
  368. package/out/zero-solid/src/use-query.js +3 -5
  369. package/out/zero-solid/src/use-query.js.map +1 -1
  370. package/out/zql/src/builder/builder.d.ts +0 -19
  371. package/out/zql/src/builder/builder.d.ts.map +1 -1
  372. package/out/zql/src/builder/builder.js +11 -28
  373. package/out/zql/src/builder/builder.js.map +1 -1
  374. package/out/zql/src/builder/debug-delegate.d.ts +1 -6
  375. package/out/zql/src/builder/debug-delegate.d.ts.map +1 -1
  376. package/out/zql/src/builder/debug-delegate.js +2 -14
  377. package/out/zql/src/builder/debug-delegate.js.map +1 -1
  378. package/out/zql/src/ivm/array-view.d.ts +0 -29
  379. package/out/zql/src/ivm/array-view.d.ts.map +1 -1
  380. package/out/zql/src/ivm/array-view.js +12 -63
  381. package/out/zql/src/ivm/array-view.js.map +1 -1
  382. package/out/zql/src/ivm/cap.d.ts.map +1 -1
  383. package/out/zql/src/ivm/cap.js +3 -5
  384. package/out/zql/src/ivm/cap.js.map +1 -1
  385. package/out/zql/src/ivm/data.d.ts.map +1 -1
  386. package/out/zql/src/ivm/data.js +3 -8
  387. package/out/zql/src/ivm/data.js.map +1 -1
  388. package/out/zql/src/ivm/exists.d.ts +1 -1
  389. package/out/zql/src/ivm/exists.d.ts.map +1 -1
  390. package/out/zql/src/ivm/exists.js.map +1 -1
  391. package/out/zql/src/ivm/fan-in.d.ts +2 -2
  392. package/out/zql/src/ivm/fan-in.d.ts.map +1 -1
  393. package/out/zql/src/ivm/fan-in.js +5 -6
  394. package/out/zql/src/ivm/fan-in.js.map +1 -1
  395. package/out/zql/src/ivm/fan-out.d.ts +2 -2
  396. package/out/zql/src/ivm/fan-out.d.ts.map +1 -1
  397. package/out/zql/src/ivm/fan-out.js.map +1 -1
  398. package/out/zql/src/ivm/filter-operators.d.ts +6 -7
  399. package/out/zql/src/ivm/filter-operators.d.ts.map +1 -1
  400. package/out/zql/src/ivm/filter-operators.js +12 -29
  401. package/out/zql/src/ivm/filter-operators.js.map +1 -1
  402. package/out/zql/src/ivm/filter.d.ts +2 -2
  403. package/out/zql/src/ivm/filter.d.ts.map +1 -1
  404. package/out/zql/src/ivm/filter.js +4 -7
  405. package/out/zql/src/ivm/filter.js.map +1 -1
  406. package/out/zql/src/ivm/flipped-join.js +2 -2
  407. package/out/zql/src/ivm/flipped-join.js.map +1 -1
  408. package/out/zql/src/ivm/maybe-split-and-push-edit-change.d.ts +1 -1
  409. package/out/zql/src/ivm/maybe-split-and-push-edit-change.d.ts.map +1 -1
  410. package/out/zql/src/ivm/maybe-split-and-push-edit-change.js +4 -6
  411. package/out/zql/src/ivm/maybe-split-and-push-edit-change.js.map +1 -1
  412. package/out/zql/src/ivm/memory-source.d.ts +3 -15
  413. package/out/zql/src/ivm/memory-source.d.ts.map +1 -1
  414. package/out/zql/src/ivm/memory-source.js +23 -57
  415. package/out/zql/src/ivm/memory-source.js.map +1 -1
  416. package/out/zql/src/ivm/operator.d.ts +0 -40
  417. package/out/zql/src/ivm/operator.d.ts.map +1 -1
  418. package/out/zql/src/ivm/operator.js.map +1 -1
  419. package/out/zql/src/ivm/take.d.ts.map +1 -1
  420. package/out/zql/src/ivm/take.js +4 -3
  421. package/out/zql/src/ivm/take.js.map +1 -1
  422. package/out/zql/src/ivm/union-fan-in.d.ts.map +1 -1
  423. package/out/zql/src/ivm/union-fan-in.js +7 -9
  424. package/out/zql/src/ivm/union-fan-in.js.map +1 -1
  425. package/out/zql/src/ivm/view-apply-change.d.ts.map +1 -1
  426. package/out/zql/src/ivm/view-apply-change.js +4 -9
  427. package/out/zql/src/ivm/view-apply-change.js.map +1 -1
  428. package/out/zql/src/ivm/view.d.ts +0 -15
  429. package/out/zql/src/ivm/view.d.ts.map +1 -1
  430. package/out/zql/src/mutate/mutator-registry.d.ts.map +1 -1
  431. package/out/zql/src/mutate/mutator-registry.js +2 -2
  432. package/out/zql/src/mutate/mutator-registry.js.map +1 -1
  433. package/out/zql/src/planner/planner-builder.d.ts +3 -12
  434. package/out/zql/src/planner/planner-builder.d.ts.map +1 -1
  435. package/out/zql/src/planner/planner-builder.js +20 -40
  436. package/out/zql/src/planner/planner-builder.js.map +1 -1
  437. package/out/zql/src/planner/planner-connection.d.ts +2 -28
  438. package/out/zql/src/planner/planner-connection.d.ts.map +1 -1
  439. package/out/zql/src/planner/planner-connection.js +8 -108
  440. package/out/zql/src/planner/planner-connection.js.map +1 -1
  441. package/out/zql/src/planner/planner-debug.d.ts +1 -1
  442. package/out/zql/src/planner/planner-debug.d.ts.map +1 -1
  443. package/out/zql/src/planner/planner-debug.js +8 -3
  444. package/out/zql/src/planner/planner-debug.js.map +1 -1
  445. package/out/zql/src/planner/planner-fan-out.d.ts +0 -1
  446. package/out/zql/src/planner/planner-fan-out.d.ts.map +1 -1
  447. package/out/zql/src/planner/planner-fan-out.js +0 -3
  448. package/out/zql/src/planner/planner-fan-out.js.map +1 -1
  449. package/out/zql/src/planner/planner-graph.d.ts +0 -2
  450. package/out/zql/src/planner/planner-graph.d.ts.map +1 -1
  451. package/out/zql/src/planner/planner-graph.js +0 -2
  452. package/out/zql/src/planner/planner-graph.js.map +1 -1
  453. package/out/zql/src/planner/planner-join.d.ts +0 -2
  454. package/out/zql/src/planner/planner-join.d.ts.map +1 -1
  455. package/out/zql/src/planner/planner-join.js +0 -7
  456. package/out/zql/src/planner/planner-join.js.map +1 -1
  457. package/out/zql/src/planner/planner-node.d.ts +1 -2
  458. package/out/zql/src/planner/planner-node.d.ts.map +1 -1
  459. package/out/zql/src/planner/planner-node.js.map +1 -1
  460. package/out/zql/src/planner/planner-source.d.ts +2 -2
  461. package/out/zql/src/planner/planner-source.d.ts.map +1 -1
  462. package/out/zql/src/planner/planner-source.js +2 -2
  463. package/out/zql/src/planner/planner-source.js.map +1 -1
  464. package/out/zql/src/query/query-delegate-base.d.ts +1 -9
  465. package/out/zql/src/query/query-delegate-base.d.ts.map +1 -1
  466. package/out/zql/src/query/query-delegate-base.js +36 -132
  467. package/out/zql/src/query/query-delegate-base.js.map +1 -1
  468. package/out/zql/src/query/query-delegate.d.ts +1 -50
  469. package/out/zql/src/query/query-delegate.d.ts.map +1 -1
  470. package/out/zql/src/query/query-impl.d.ts +14 -25
  471. package/out/zql/src/query/query-impl.d.ts.map +1 -1
  472. package/out/zql/src/query/query-impl.js +94 -397
  473. package/out/zql/src/query/query-impl.js.map +1 -1
  474. package/out/zql/src/query/query-internals.d.ts +11 -21
  475. package/out/zql/src/query/query-internals.d.ts.map +1 -1
  476. package/out/zql/src/query/query-internals.js.map +1 -1
  477. package/out/zql/src/query/query.d.ts +2 -11
  478. package/out/zql/src/query/query.d.ts.map +1 -1
  479. package/out/zql/src/query/runnable-query-impl.d.ts +2 -3
  480. package/out/zql/src/query/runnable-query-impl.d.ts.map +1 -1
  481. package/out/zql/src/query/runnable-query-impl.js +2 -15
  482. package/out/zql/src/query/runnable-query-impl.js.map +1 -1
  483. package/out/zql/src/query/typed-view.d.ts +1 -1
  484. package/out/zql/src/query/typed-view.d.ts.map +1 -1
  485. package/out/zqlite/src/db.d.ts +1 -9
  486. package/out/zqlite/src/db.d.ts.map +1 -1
  487. package/out/zqlite/src/db.js +2 -8
  488. package/out/zqlite/src/db.js.map +1 -1
  489. package/out/zqlite/src/query-builder.d.ts +1 -1
  490. package/out/zqlite/src/query-builder.d.ts.map +1 -1
  491. package/out/zqlite/src/query-builder.js +2 -4
  492. package/out/zqlite/src/query-builder.js.map +1 -1
  493. package/out/zqlite/src/query-delegate.d.ts.map +1 -1
  494. package/out/zqlite/src/query-delegate.js +6 -5
  495. package/out/zqlite/src/query-delegate.js.map +1 -1
  496. package/out/zqlite/src/sqlite-cost-model.d.ts.map +1 -1
  497. package/out/zqlite/src/sqlite-cost-model.js +30 -2
  498. package/out/zqlite/src/sqlite-cost-model.js.map +1 -1
  499. package/out/zqlite/src/sqlite-stat-fanout.d.ts.map +1 -1
  500. package/out/zqlite/src/sqlite-stat-fanout.js +5 -4
  501. package/out/zqlite/src/sqlite-stat-fanout.js.map +1 -1
  502. package/out/zqlite/src/table-source.d.ts +3 -16
  503. package/out/zqlite/src/table-source.d.ts.map +1 -1
  504. package/out/zqlite/src/table-source.js +14 -33
  505. package/out/zqlite/src/table-source.js.map +1 -1
  506. package/package.json +3 -2
  507. package/out/replicache/src/dag/invalid-ref-count-error.d.ts +0 -12
  508. package/out/replicache/src/dag/invalid-ref-count-error.d.ts.map +0 -1
  509. package/out/replicache/src/dag/invalid-ref-count-error.js +0 -19
  510. package/out/replicache/src/dag/invalid-ref-count-error.js.map +0 -1
  511. package/out/shared/src/xxhash32.d.ts +0 -36
  512. package/out/shared/src/xxhash32.d.ts.map +0 -1
  513. package/out/shared/src/xxhash32.js +0 -51
  514. package/out/shared/src/xxhash32.js.map +0 -1
  515. package/out/zero-cache/src/db/index-predicate.d.ts +0 -4
  516. package/out/zero-cache/src/db/index-predicate.d.ts.map +0 -1
  517. package/out/zero-cache/src/db/index-predicate.js +0 -46
  518. package/out/zero-cache/src/db/index-predicate.js.map +0 -1
  519. package/out/zero-cache/src/services/change-source/pg/schema/index-predicate.d.ts +0 -19
  520. package/out/zero-cache/src/services/change-source/pg/schema/index-predicate.d.ts.map +0 -1
  521. package/out/zero-cache/src/services/change-source/pg/schema/index-predicate.js +0 -581
  522. package/out/zero-cache/src/services/change-source/pg/schema/index-predicate.js.map +0 -1
  523. package/out/zero-cache/src/services/litestream/litestream-checkpointer.js +0 -131
  524. package/out/zero-cache/src/services/litestream/litestream-checkpointer.js.map +0 -1
  525. package/out/zero-cache/src/services/litestream/litestream-controller.d.ts +0 -70
  526. package/out/zero-cache/src/services/litestream/litestream-controller.d.ts.map +0 -1
  527. package/out/zero-cache/src/services/litestream/litestream-controller.js +0 -101
  528. package/out/zero-cache/src/services/litestream/litestream-controller.js.map +0 -1
  529. package/out/zero-cache/src/services/profz.d.ts +0 -7
  530. package/out/zero-cache/src/services/profz.d.ts.map +0 -1
  531. package/out/zero-cache/src/services/profz.js +0 -103
  532. package/out/zero-cache/src/services/profz.js.map +0 -1
  533. package/out/zero-cache/src/services/view-syncer/hydration-budget.d.ts +0 -33
  534. package/out/zero-cache/src/services/view-syncer/hydration-budget.d.ts.map +0 -1
  535. package/out/zero-cache/src/services/view-syncer/hydration-budget.js +0 -62
  536. package/out/zero-cache/src/services/view-syncer/hydration-budget.js.map +0 -1
  537. package/out/zero-cache/src/services/view-syncer/hydration-circuit-breaker.d.ts +0 -51
  538. package/out/zero-cache/src/services/view-syncer/hydration-circuit-breaker.d.ts.map +0 -1
  539. package/out/zero-cache/src/services/view-syncer/hydration-circuit-breaker.js +0 -78
  540. package/out/zero-cache/src/services/view-syncer/hydration-circuit-breaker.js.map +0 -1
  541. package/out/zero-cache/src/services/view-syncer/snapshot-row-cache.d.ts +0 -95
  542. package/out/zero-cache/src/services/view-syncer/snapshot-row-cache.d.ts.map +0 -1
  543. package/out/zero-cache/src/services/view-syncer/snapshot-row-cache.js +0 -155
  544. package/out/zero-cache/src/services/view-syncer/snapshot-row-cache.js.map +0 -1
  545. package/out/zero-protocol/src/query-hash-visitor.d.ts +0 -81
  546. package/out/zero-protocol/src/query-hash-visitor.d.ts.map +0 -1
  547. package/out/zero-protocol/src/query-hash-visitor.js +0 -324
  548. package/out/zero-protocol/src/query-hash-visitor.js.map +0 -1
  549. package/out/zql/src/builder/correlated-predicate-pushdown.d.ts +0 -43
  550. package/out/zql/src/builder/correlated-predicate-pushdown.d.ts.map +0 -1
  551. package/out/zql/src/builder/correlated-predicate-pushdown.js +0 -161
  552. package/out/zql/src/builder/correlated-predicate-pushdown.js.map +0 -1
  553. package/out/zql/src/ivm/connection-index.d.ts +0 -68
  554. package/out/zql/src/ivm/connection-index.d.ts.map +0 -1
  555. package/out/zql/src/ivm/connection-index.js +0 -149
  556. package/out/zql/src/ivm/connection-index.js.map +0 -1
  557. package/out/zql/src/ivm/deferred-input.d.ts +0 -44
  558. package/out/zql/src/ivm/deferred-input.d.ts.map +0 -1
  559. package/out/zql/src/ivm/deferred-input.js +0 -89
  560. package/out/zql/src/ivm/deferred-input.js.map +0 -1
  561. package/out/zql/src/planner/planner-filter.d.ts +0 -59
  562. package/out/zql/src/planner/planner-filter.d.ts.map +0 -1
  563. package/out/zql/src/planner/planner-filter.js +0 -116
  564. package/out/zql/src/planner/planner-filter.js.map +0 -1
  565. package/out/zql/src/query/query-transitions.d.ts +0 -171
  566. package/out/zql/src/query/query-transitions.d.ts.map +0 -1
  567. package/out/zql/src/query/query-transitions.js +0 -204
  568. package/out/zql/src/query/query-transitions.js.map +0 -1
@@ -1,64 +1,18 @@
1
1
  import { assert } from "../../../shared/src/asserts.js";
2
- import { deepEqual } from "../../../shared/src/json.js";
3
- import { getOrInsertComputed, newMap } from "../../../shared/src/map.js";
4
- import { SUBQ_PREFIX, insertRelated, normalizeAST, normalizeCondition, normalizedRelated, tableAST } from "../../../zero-protocol/src/ast.js";
2
+ import { SUBQ_PREFIX } from "../../../zero-protocol/src/ast.js";
5
3
  import { defaultFormat } from "../../../zero-types/src/format.js";
6
- import { hashOfQueryInternals } from "../../../zero-protocol/src/query-hash-visitor.js";
4
+ import { hashOfAST } from "../../../zero-protocol/src/query-hash.js";
7
5
  import { NotImplementedError } from "../error.js";
8
6
  import { ExpressionBuilder, and, cmp, simplifyCondition } from "./expression.js";
9
7
  import { queryInternalsTag } from "./query-internals.js";
10
- import { HashIndex, Transitions } from "./query-transitions.js";
11
8
  //#region ../zql/src/query/query-impl.ts
12
9
  function newQuery(schema, table) {
13
- return newQueryInternal(schema, table, tableAST(table), defaultFormat, "client");
10
+ return newQueryImpl(schema, table, { table }, defaultFormat, "client");
14
11
  }
15
12
  function newQueryImpl(schema, tableName, ast, format, system) {
16
- return newQueryInternal(schema, tableName, normalizeAST(ast), format, system);
17
- }
18
- /**
19
- * Root queries are interned per schema so that two `createBuilder(schema)` calls
20
- * hand out the same starting point, and therefore share the whole transition
21
- * tree below it. Only cleared entries accumulate here, at most one per
22
- * system/table pair, so no sweeping is needed.
23
- */
24
- var rootsBySchema = /* @__PURE__ */ new WeakMap();
25
- /**
26
- * Whether this is the AST `tableAST(tableName)` produces -- the whole table,
27
- * nothing else. A normalized AST carries every field, so this cannot be a key
28
- * count; each one has to be checked.
29
- */
30
- function isRootAST(ast, tableName) {
31
- return ast.table === tableName && ast.schema === void 0 && ast.alias === void 0 && ast.where === void 0 && ast.related === void 0 && ast.start === void 0 && ast.limit === void 0 && ast.orderBy === void 0;
32
- }
33
- function newQueryInternal(schema, tableName, ast, format, system) {
34
- const interned = format === defaultFormat && isRootAST(ast, tableName);
35
- const key = `${system}:${tableName}`;
36
- let roots;
37
- if (interned) {
38
- roots = rootsBySchema.get(schema);
39
- const existing = roots?.get(key)?.deref();
40
- if (existing) return existing;
41
- }
42
13
  const inner = (tableName, ast, format, customQueryID, currentJunction) => new QueryImpl(schema, tableName, ast, format, system, customQueryID, currentJunction, inner);
43
- const created = inner(tableName, ast, format, void 0, void 0);
44
- if (interned) {
45
- if (!roots) {
46
- roots = /* @__PURE__ */ new Map();
47
- rootsBySchema.set(schema, roots);
48
- }
49
- roots.set(key, new WeakRef(created));
50
- }
51
- return created;
14
+ return inner(tableName, ast, format, void 0, void 0);
52
15
  }
53
- /**
54
- * The AST of a QueryImpl is always normalized. Each step builds its AST in
55
- * normalized form rather than normalizing afterwards: a normalized AST has
56
- * every field, so spreading one and replacing a field keeps the field order
57
- * intact, and only the field a step actually changes needs normalizing (the
58
- * conditions of a `where`, the position of a new `related`). The ASTs that
59
- * come in from the outside are normalized by {@link newQueryImpl}, which is
60
- * what the `NormalizedAST` of the AST it holds stands for.
61
- */
62
16
  var QueryImpl = class {
63
17
  [queryInternalsTag] = true;
64
18
  #schema;
@@ -70,26 +24,6 @@ var QueryImpl = class {
70
24
  #currentJunction;
71
25
  customQueryID;
72
26
  #newQuery;
73
- /**
74
- * The query this one was derived from, held *strongly*, and the queries
75
- * derived from this one, held *weakly*. This is the arrangement V8 uses for
76
- * hidden-class transitions, and it is what makes interning stable: as long as
77
- * a query is reachable its whole ancestor spine is too, so re-deriving it from
78
- * the root yields the same instance. See `query-transitions.ts`.
79
- */
80
- #parent;
81
- #transitions;
82
- /**
83
- * The second level of interning, keyed by hash; see `HashIndex`. Set on the
84
- * root only, which is what scopes it to one schema and one delegate.
85
- */
86
- #byHash;
87
- /**
88
- * Memoized because a query is interned: the same node serves every rebuild of
89
- * a chain, so building this once rather than per `where(fn)` call takes the
90
- * whole thing -- the builder and the bound `#exists` -- off the repeat path.
91
- */
92
- #expressionBuilder;
93
27
  constructor(schema, tableName, ast, format, system, customQueryID, currentJunction, newQuery) {
94
28
  this.#schema = schema;
95
29
  this.#tableName = tableName;
@@ -100,44 +34,6 @@ var QueryImpl = class {
100
34
  this.customQueryID = customQueryID;
101
35
  this.#newQuery = newQuery;
102
36
  }
103
- /**
104
- * Interns a transition whose key space is finite and schema-derived; see
105
- * {@linkcode Transitions.storeBounded}. Used for the base sub-query handed to
106
- * a `related`/`exists` callback, which is determined entirely by the
107
- * relationship name.
108
- */
109
- #deriveBounded(key, build) {
110
- const existing = this.#transitions?.lookupBounded(key);
111
- if (existing !== void 0) return existing;
112
- return this.#record(key, void 0, void 0, build(), true);
113
- }
114
- /**
115
- * Interns the result of applying a builder operation to this query.
116
- *
117
- * `key` names the operation and `value` carries its varying argument, kept
118
- * apart so the key stays a string V8 has already hashed. When the two do not
119
- * settle it, `delta` carries the rest and is compared with `deepEqual`. Only
120
- * the delta is compared, never the whole AST: this query is already canonical,
121
- * so two of its children are equal exactly when the operations that produced
122
- * them are.
123
- *
124
- * `T` is deliberately unconstrained so that the contextual return type at each
125
- * call site still drives `#newQuery`'s inference, exactly as it did when the
126
- * call sites returned `this.#newQuery(...)` directly.
127
- */
128
- #derive(key, value, delta, build) {
129
- const existing = this.#transitions?.lookup(key, value, delta);
130
- if (existing !== void 0) return existing;
131
- return this.#record(key, value, delta, build(), false);
132
- }
133
- #record(key, value, delta, created, bounded) {
134
- const q = created;
135
- q.#parent = this;
136
- const transitions = this.#transitions ??= new Transitions();
137
- if (bounded) transitions.storeBounded(key, q);
138
- else transitions.store(key, value, delta, q);
139
- return created;
140
- }
141
37
  run(_options) {
142
38
  throwQueryNotRunnable();
143
39
  }
@@ -148,204 +44,150 @@ var QueryImpl = class {
148
44
  throwQueryNotRunnable();
149
45
  }
150
46
  nameAndArgs(name, args) {
151
- return this.#derive("nameAndArgs", name, args, () => this.#newQuery(this.#tableName, this.#ast, this.format, {
47
+ return this.#newQuery(this.#tableName, this.#ast, this.format, {
152
48
  name,
153
49
  args
154
- }, this.#currentJunction));
50
+ }, this.#currentJunction);
155
51
  }
156
52
  hash() {
157
- if (!this.#hash) {
158
- this.#hash = hashOfQueryInternals(this.#ast, this.format, this.#system, this.#currentJunction, this.customQueryID?.name, this.customQueryID?.args);
159
- this.#canonicalize();
160
- }
53
+ if (!this.#hash) this.#hash = hashOfAST(this.#ast);
161
54
  return this.#hash;
162
55
  }
163
- /**
164
- * Folds this query into its root's hash index, now that its hash is known.
165
- *
166
- * If an equal query is already indexed, the transition that produced this
167
- * one is re-pointed at it, so the next rebuild along this path yields that
168
- * instance rather than a second copy. This query itself is left alone: its
169
- * identity has already been handed out. Content is verified with `#sameAs`
170
- * before anything is redirected, so a hash collision costs nothing worse
171
- * than a missed unification.
172
- */
173
- #canonicalize() {
174
- const parent = this.#parent;
175
- if (parent === void 0) return;
176
- let root = parent;
177
- while (root.#parent !== void 0) root = root.#parent;
178
- const index = root.#byHash ??= new HashIndex();
179
- const existing = index.get(this.#hash);
180
- if (existing === void 0) index.set(this.#hash, this);
181
- else if (existing !== this && this.#sameAs(existing)) parent.#transitions?.replace(this, existing);
182
- }
183
- /**
184
- * Whether `other` is interchangeable with this query: everything `hash()`
185
- * covers, compared structurally. Schema and delegate are not compared. Both
186
- * are fixed by the root, and this only ever compares queries under one root.
187
- */
188
- #sameAs(other) {
189
- return this.#system === other.#system && this.#currentJunction === other.#currentJunction && this.customQueryID?.name === other.customQueryID?.name && deepEqual(this.customQueryID?.args, other.customQueryID?.args) && deepEqual(this.format, other.format) && deepEqual(this.#ast, other.#ast);
190
- }
191
- one() {
192
- return this.#derive("one", void 0, void 0, () => this.#newQuery(this.#tableName, {
193
- ...this.#ast,
194
- limit: 1
195
- }, {
196
- ...this.format,
197
- singular: true
198
- }, this.customQueryID, this.#currentJunction));
199
- }
200
- whereExists(relationship, cbOrOptions, options) {
56
+ one = () => this.#newQuery(this.#tableName, {
57
+ ...this.#ast,
58
+ limit: 1
59
+ }, {
60
+ ...this.format,
61
+ singular: true
62
+ }, this.customQueryID, this.#currentJunction);
63
+ whereExists = (relationship, cbOrOptions, options) => {
201
64
  const cb = typeof cbOrOptions === "function" ? cbOrOptions : void 0;
202
65
  const opts = typeof cbOrOptions === "function" ? options : cbOrOptions;
203
66
  return this.where(({ exists }) => exists(relationship, cb, opts));
204
- }
205
- related(relationship, cb) {
67
+ };
68
+ related = (relationship, cb) => {
206
69
  if (relationship.startsWith("zsubq_")) throw new Error(`Relationship names may not start with "${SUBQ_PREFIX}". That is a reserved prefix.`);
207
70
  cb = cb ?? ((q) => q);
208
71
  const related = this.#schema.relationships[this.#tableName][relationship];
209
72
  assert(related, "Invalid relationship");
210
73
  if (isOneHop(related)) {
211
74
  const { destSchema, destField, sourceField, cardinality } = related[0];
212
- const q = this.#deriveBounded(`relatedBase:${relationship}`, () => this.#newQuery(destSchema, tableAST(destSchema, relationship), {
75
+ const q = this.#newQuery(destSchema, {
76
+ table: destSchema,
77
+ alias: relationship
78
+ }, {
213
79
  relationships: {},
214
80
  singular: cardinality === "one"
215
- }, this.customQueryID, void 0));
81
+ }, this.customQueryID, void 0);
216
82
  const subQuery = asQueryImpl(cb(q));
217
83
  assert(isCompoundKey(sourceField), "The source of a relationship must specify at last 1 field");
218
84
  assert(isCompoundKey(destField), "The destination of a relationship must specify at last 1 field");
219
85
  assert(sourceField.length === destField.length, "The source and destination of a relationship must have the same number of fields");
220
- return this.#derive(relatedKey(relationship), astID(subQuery.#ast), void 0, () => this.#newQuery(this.#tableName, {
86
+ return this.#newQuery(this.#tableName, {
221
87
  ...this.#ast,
222
- related: insertRelated(this.#ast.related, {
88
+ related: [...this.#ast.related ?? [], {
89
+ system: this.#system,
223
90
  correlation: {
224
91
  parentField: sourceField,
225
92
  childField: destField
226
93
  },
227
- subquery: subQuery.#ast,
228
- system: this.#system
229
- })
94
+ subquery: subQuery.#ast
95
+ }]
230
96
  }, {
231
97
  ...this.format,
232
98
  relationships: {
233
99
  ...this.format.relationships,
234
100
  [relationship]: subQuery.format
235
101
  }
236
- }, this.customQueryID, this.#currentJunction));
102
+ }, this.customQueryID, this.#currentJunction);
237
103
  }
238
104
  if (isTwoHop(related)) {
239
105
  const [firstRelation, secondRelation] = related;
240
106
  const { destSchema } = secondRelation;
241
107
  const junctionSchema = firstRelation.destSchema;
242
- const sq = asQueryImpl(cb(this.#deriveBounded(`relatedBase:${relationship}`, () => this.#newQuery(destSchema, tableAST(destSchema, relationship), {
108
+ const sq = asQueryImpl(cb(this.#newQuery(destSchema, {
109
+ table: destSchema,
110
+ alias: relationship
111
+ }, {
243
112
  relationships: {},
244
113
  singular: secondRelation.cardinality === "one"
245
- }, this.customQueryID, relationship))));
246
- const { sourceField: firstSource, destField: firstDest } = firstRelation;
247
- const { sourceField: secondSource, destField: secondDest } = secondRelation;
248
- assert(isCompoundKey(firstSource), "Invalid relationship");
249
- assert(isCompoundKey(firstDest), "Invalid relationship");
250
- assert(isCompoundKey(secondSource), "Invalid relationship");
251
- assert(isCompoundKey(secondDest), "Invalid relationship");
252
- return this.#derive(relatedKey(relationship), astID(sq.#ast), void 0, () => this.#newQuery(this.#tableName, {
114
+ }, this.customQueryID, relationship)));
115
+ assert(isCompoundKey(firstRelation.sourceField), "Invalid relationship");
116
+ assert(isCompoundKey(firstRelation.destField), "Invalid relationship");
117
+ assert(isCompoundKey(secondRelation.sourceField), "Invalid relationship");
118
+ assert(isCompoundKey(secondRelation.destField), "Invalid relationship");
119
+ return this.#newQuery(this.#tableName, {
253
120
  ...this.#ast,
254
- related: insertRelated(this.#ast.related, {
121
+ related: [...this.#ast.related ?? [], {
122
+ system: this.#system,
255
123
  correlation: {
256
- parentField: firstSource,
257
- childField: firstDest
124
+ parentField: firstRelation.sourceField,
125
+ childField: firstRelation.destField
258
126
  },
259
127
  hidden: true,
260
128
  subquery: {
261
- ...tableAST(junctionSchema, relationship),
262
- related: [normalizedRelated({
129
+ table: junctionSchema,
130
+ alias: relationship,
131
+ related: [{
132
+ system: this.#system,
263
133
  correlation: {
264
- parentField: secondSource,
265
- childField: secondDest
134
+ parentField: secondRelation.sourceField,
135
+ childField: secondRelation.destField
266
136
  },
267
- subquery: sq.#ast,
268
- system: this.#system
269
- })]
270
- },
271
- system: this.#system
272
- })
137
+ subquery: sq.#ast
138
+ }]
139
+ }
140
+ }]
273
141
  }, {
274
142
  ...this.format,
275
143
  relationships: {
276
144
  ...this.format.relationships,
277
145
  [relationship]: sq.format
278
146
  }
279
- }, this.customQueryID, this.#currentJunction));
147
+ }, this.customQueryID, this.#currentJunction);
280
148
  }
281
149
  throw new Error(`Invalid relationship ${relationship}`);
282
- }
283
- where(fieldOrExpressionFactory, opOrValue, value) {
150
+ };
151
+ where = function(fieldOrExpressionFactory, opOrValue, value) {
284
152
  let cond;
285
153
  if (typeof fieldOrExpressionFactory === "function") cond = fieldOrExpressionFactory(this.expressionBuilder());
286
154
  else {
287
155
  assert(arguments.length >= 2, "Invalid condition. Too few arguments.");
288
- const twoArg = arguments.length === 2;
289
- const op = twoArg ? "=" : opOrValue;
290
- const raw = twoArg ? opOrValue : value;
291
- if (raw === null || typeof raw !== "object") {
292
- const hit = this.#transitions?.lookup(whereKey(fieldOrExpressionFactory, op), raw ?? null, void 0);
293
- if (hit !== void 0) return hit;
294
- }
295
- cond = twoArg ? cmp(fieldOrExpressionFactory, opOrValue) : cmp(fieldOrExpressionFactory, opOrValue, value);
156
+ if (arguments.length === 2) cond = cmp(fieldOrExpressionFactory, opOrValue);
157
+ else cond = cmp(fieldOrExpressionFactory, opOrValue, value);
296
158
  }
297
- let key;
298
- let tValue;
299
- let delta = cond;
300
- if (cond.type === "simple" && cond.left.type === "column") {
301
- key = whereKey(cond.left.name, cond.op);
302
- const right = cond.right;
303
- tValue = right.type === "literal" && isPrimitive(right.value) ? right.value : rightTag(right);
304
- delta = void 0;
305
- } else {
306
- const exact = condKey(cond);
307
- if (exact === void 0) key = treeKey(cond);
308
- else {
309
- key = "where:tree";
310
- tValue = exact;
311
- delta = void 0;
312
- }
313
- }
314
- return this.#derive(key, tValue, delta, () => {
315
- const existingWhere = this.#ast.where;
316
- const merged = existingWhere ? and(existingWhere, cond) : cond;
317
- return this.#newQuery(this.#tableName, {
318
- ...this.#ast,
319
- where: normalizeCondition(simplifyCondition(merged))
320
- }, this.format, this.customQueryID, this.#currentJunction);
321
- });
322
- }
323
- start(row, opts) {
324
- return this.#derive(opts?.inclusive ? "start:inclusive" : "start:exclusive", valueTag(row), void 0, () => this.#newQuery(this.#tableName, {
159
+ const existingWhere = this.#ast.where;
160
+ if (existingWhere) cond = and(existingWhere, cond);
161
+ const where = simplifyCondition(cond);
162
+ return this.#newQuery(this.#tableName, {
325
163
  ...this.#ast,
326
- start: {
327
- row,
328
- exclusive: !opts?.inclusive
329
- }
330
- }, this.format, this.customQueryID, this.#currentJunction));
331
- }
332
- limit(limit) {
164
+ where
165
+ }, this.format, this.customQueryID, this.#currentJunction);
166
+ }.bind(this);
167
+ start = (row, opts) => this.#newQuery(this.#tableName, {
168
+ ...this.#ast,
169
+ start: {
170
+ row,
171
+ exclusive: !opts?.inclusive
172
+ }
173
+ }, this.format, this.customQueryID, this.#currentJunction);
174
+ limit = (limit) => {
333
175
  if (limit < 0) throw new Error("Limit must be non-negative");
334
176
  if ((limit | 0) !== limit) throw new Error("Limit must be an integer");
335
177
  if (this.#currentJunction) throw new NotImplementedError("Limit is not supported in junction relationships yet. Junction relationship being limited: " + this.#currentJunction);
336
- return this.#derive("limit", limit, void 0, () => this.#newQuery(this.#tableName, {
178
+ return this.#newQuery(this.#tableName, {
337
179
  ...this.#ast,
338
180
  limit
339
- }, this.format, this.customQueryID, this.#currentJunction));
340
- }
341
- orderBy(field, direction) {
181
+ }, this.format, this.customQueryID, this.#currentJunction);
182
+ };
183
+ orderBy = (field, direction) => {
342
184
  if (this.#currentJunction) throw new NotImplementedError("Order by is not supported in junction relationships yet. Junction relationship being ordered: " + this.#currentJunction);
343
- return this.#derive(direction === "asc" ? "orderBy:asc" : "orderBy:desc", field, void 0, () => this.#newQuery(this.#tableName, {
185
+ return this.#newQuery(this.#tableName, {
344
186
  ...this.#ast,
345
187
  orderBy: [...this.#ast.orderBy ?? [], [field, direction]]
346
- }, this.format, this.customQueryID, this.#currentJunction));
347
- }
348
- #exists(relationship, cb, options) {
188
+ }, this.format, this.customQueryID, this.#currentJunction);
189
+ };
190
+ #exists = (relationship, cb, options) => {
349
191
  cb = cb ?? ((q) => q);
350
192
  const flip = options?.flip;
351
193
  const scalar = options?.scalar;
@@ -355,8 +197,10 @@ var QueryImpl = class {
355
197
  const { destSchema: destTableName, sourceField, destField } = related[0];
356
198
  assert(isCompoundKey(sourceField), "Invalid relationship");
357
199
  assert(isCompoundKey(destField), "Invalid relationship");
358
- const subQuery = asQueryImpl(cb(this.#deriveBounded(`existsBase:${relationship}`, () => this.#newQuery(destTableName, tableAST(destTableName, `${SUBQ_PREFIX}${relationship}`), defaultFormat, this.customQueryID, void 0))));
359
- astID(subQuery.#ast);
200
+ const subQuery = asQueryImpl(cb(this.#newQuery(destTableName, {
201
+ table: destTableName,
202
+ alias: `${SUBQ_PREFIX}${relationship}`
203
+ }, defaultFormat, this.customQueryID, void 0)));
360
204
  return {
361
205
  type: "correlatedSubquery",
362
206
  related: {
@@ -380,7 +224,10 @@ var QueryImpl = class {
380
224
  assert(isCompoundKey(secondRelation.destField), "Invalid relationship");
381
225
  const { destSchema } = secondRelation;
382
226
  const junctionSchema = firstRelation.destSchema;
383
- const queryToDest = cb(this.#deriveBounded(`existsJunctionBase:${relationship}`, () => this.#newQuery(destSchema, tableAST(destSchema, `${SUBQ_PREFIX}zhidden_${relationship}`), defaultFormat, this.customQueryID, relationship)));
227
+ const queryToDest = cb(this.#newQuery(destSchema, {
228
+ table: destSchema,
229
+ alias: `${SUBQ_PREFIX}zhidden_${relationship}`
230
+ }, defaultFormat, this.customQueryID, relationship));
384
231
  return {
385
232
  type: "correlatedSubquery",
386
233
  related: {
@@ -390,8 +237,9 @@ var QueryImpl = class {
390
237
  childField: firstRelation.destField
391
238
  },
392
239
  subquery: {
393
- ...tableAST(junctionSchema, `${SUBQ_PREFIX}${relationship}`),
394
- where: normalizeCondition({
240
+ table: junctionSchema,
241
+ alias: `${SUBQ_PREFIX}${relationship}`,
242
+ where: {
395
243
  type: "correlatedSubquery",
396
244
  related: {
397
245
  system: this.#system,
@@ -404,7 +252,7 @@ var QueryImpl = class {
404
252
  op: "EXISTS",
405
253
  ...flip !== void 0 ? { flip } : {},
406
254
  ...scalar !== void 0 ? { scalar } : {}
407
- })
255
+ }
408
256
  }
409
257
  },
410
258
  op: "EXISTS",
@@ -412,169 +260,18 @@ var QueryImpl = class {
412
260
  };
413
261
  }
414
262
  throw new Error(`Invalid relationship ${relationship}`);
415
- }
263
+ };
416
264
  get ast() {
417
265
  return this.#ast;
418
266
  }
419
267
  expressionBuilder() {
420
- return this.#expressionBuilder ??= new ExpressionBuilder(this.#exists.bind(this));
268
+ return new ExpressionBuilder(this.#exists);
421
269
  }
422
270
  };
423
271
  function asQueryImpl(q) {
424
272
  assert(q instanceof QueryImpl, "Expected QueryImpl instance");
425
273
  return q;
426
274
  }
427
- /**
428
- * A stable id per query AST.
429
- *
430
- * Every `QueryImpl` allocates its own AST object, so these are one-to-one with
431
- * queries, and interning makes the object identity stable across rebuilds. That
432
- * lets a `related` or `exists` transition key on *which* sub-query it points at
433
- * rather than comparing the sub-tree.
434
- *
435
- * Assigned only where it is needed. A `WeakMap.set` costs on the order of a
436
- * hundred nanoseconds, so doing this for every query rather than for the few
437
- * that are sub-queries was one of the largest single costs of building a query
438
- * from cold. ASTs that never pass through here -- including the junction AST a
439
- * two-hop `exists` builds inline -- are absent, and fall back to a delta.
440
- */
441
- var astIDs = /* @__PURE__ */ new WeakMap();
442
- var nextASTID = 0;
443
- var newASTID = () => ++nextASTID;
444
- function astID(ast) {
445
- return getOrInsertComputed(astIDs, ast, newASTID);
446
- }
447
- /**
448
- * Memoized transition keys.
449
- *
450
- * A transition key must be a string V8 has already hashed, or the `Map` lookup
451
- * has to hash it from scratch -- measured at ~148ns against ~10ns, which dwarfs
452
- * everything else a lookup does. Both tables are keyed by schema-derived names,
453
- * so they are bounded by the schema.
454
- */
455
- var whereKeys = /* @__PURE__ */ new Map();
456
- function whereKey(column, op) {
457
- return getOrInsertComputed(getOrInsertComputed(whereKeys, column, newMap), op, (op) => `where:${column}:${op}`);
458
- }
459
- var relatedKeys = /* @__PURE__ */ new Map();
460
- var newRelatedKey = (relationship) => `related:${relationship}`;
461
- function relatedKey(relationship) {
462
- return getOrInsertComputed(relatedKeys, relationship, newRelatedKey);
463
- }
464
- function isPrimitive(v) {
465
- return v === null || typeof v !== "object";
466
- }
467
- /**
468
- * Folds a JSON value into a self-delimiting token: a string is
469
- * length-prefixed, a number is terminated, an array or object is
470
- * count-prefixed and encodes its members recursively, and the rest are fixed
471
- * width. Tokens can therefore be concatenated into a key with no way for one
472
- * to run into the next, and the leading tag keeps `'1'` and `1` apart.
473
- *
474
- * Not `JSON.stringify`: it writes `Infinity`, `NaN` and `null` all as `null`,
475
- * and this token is trusted as exact, so a nested value that serialized like
476
- * another's would hand back a query with the wrong value in its AST. Numbers
477
- * are written the way `String` writes them, which keeps those apart. An
478
- * `undefined` property is skipped, as `deepEqual` would skip it; property
479
- * order is part of the encoding, so an object spelled in another order
480
- * interns separately.
481
- */
482
- function valueTag(v) {
483
- switch (typeof v) {
484
- case "string": return `:s${enc(v)}`;
485
- case "number": return `:n${v};`;
486
- case "boolean": return v ? ":t" : ":f";
487
- default: {
488
- if (v === null) return ":z";
489
- if (Array.isArray(v)) {
490
- let out = `:a${v.length}:`;
491
- for (const e of v) out += valueTag(e);
492
- return out;
493
- }
494
- const o = v;
495
- let body = "";
496
- let n = 0;
497
- for (const key in o) {
498
- const e = o[key];
499
- if (e !== void 0 && Object.hasOwn(o, key)) {
500
- body += enc(key) + valueTag(e);
501
- n++;
502
- }
503
- }
504
- return `:o${n}:${body}`;
505
- }
506
- }
507
- }
508
- /**
509
- * Folds the right-hand side of a simple condition into a transition value, so
510
- * that the transition is exact and the lookup needs no comparison at all.
511
- *
512
- * Arrays (`IN`) and parameter references are encoded in full: that is one
513
- * pass over a small value, where leaving them in the delta would instead cost
514
- * a `deepEqual` over the whole condition for every sibling a lookup walks
515
- * past.
516
- */
517
- function rightTag(right) {
518
- if (right.type !== "literal") return `:p${valueTag(right)}`;
519
- return valueTag(right.value);
520
- }
521
- /**
522
- * Length-prefixes a free-form string so it can be concatenated into a key
523
- * without a separator being ambiguous with the content.
524
- */
525
- function enc(s) {
526
- return `${s.length}:${s}`;
527
- }
528
- /** Encodes an optional boolean without collapsing `undefined` into `false`. */
529
- function tri(b) {
530
- return b === void 0 ? "-" : b ? "t" : "f";
531
- }
532
- /**
533
- * An exact key for a whole condition tree, or `undefined` for a shape we cannot
534
- * encode (which falls back to {@linkcode treeKey} plus a delta).
535
- *
536
- * Everything variable-length is length-prefixed, so distinct trees cannot
537
- * produce the same string and the key needs no `deepEqual` to back it up. That
538
- * matters because the alternative -- one coarse bucket per shape -- turns N
539
- * sibling conditions off the same parent into an N-deep scan of tree
540
- * comparisons, which measured far slower than not interning at all.
541
- */
542
- function condKey(cond) {
543
- switch (cond.type) {
544
- case "simple":
545
- if (cond.left.type !== "column") return;
546
- return `S${enc(cond.left.name)}${enc(cond.op)}${rightTag(cond.right)}`;
547
- case "correlatedSubquery": {
548
- const id = astIDs.get(cond.related.subquery);
549
- return id === void 0 ? void 0 : `E${id}:${enc(cond.op)}${tri(cond.flip)}${tri(cond.scalar)}`;
550
- }
551
- case "and":
552
- case "or": {
553
- let out = `${cond.type === "and" ? "A" : "O"}${cond.conditions.length}:`;
554
- for (const c of cond.conditions) {
555
- const k = condKey(c);
556
- if (k === void 0) return;
557
- out += k;
558
- }
559
- return out;
560
- }
561
- default: return;
562
- }
563
- }
564
- /**
565
- * A coarse bucket key for the conditions {@linkcode condKey} cannot encode --
566
- * a two-hop `exists`, whose junction AST is built inline and so has no identity
567
- * of its own. Reads only the top of the tree, so it is cheap; the delta tells
568
- * apart what shares it.
569
- */
570
- function treeKey(cond) {
571
- switch (cond.type) {
572
- case "correlatedSubquery": return `where:e:${cond.related.subquery.alias}:${cond.op}`;
573
- case "and":
574
- case "or": return `where:${cond.type}:${cond.conditions.length}`;
575
- default: return "where:*";
576
- }
577
- }
578
275
  function throwQueryNotRunnable() {
579
276
  throw new Error("Query is not runnable");
580
277
  }