@rocicorp/zero 1.12.0-canary.8 → 1.12.0-canary.9

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 (516) hide show
  1. package/out/replicache/src/btree/node.d.ts +0 -2
  2. package/out/replicache/src/btree/node.d.ts.map +1 -1
  3. package/out/replicache/src/btree/node.js.map +1 -1
  4. package/out/replicache/src/connection-loop.d.ts.map +1 -1
  5. package/out/replicache/src/connection-loop.js +1 -1
  6. package/out/replicache/src/connection-loop.js.map +1 -1
  7. package/out/replicache/src/db/commit.d.ts +0 -1
  8. package/out/replicache/src/db/commit.d.ts.map +1 -1
  9. package/out/replicache/src/db/commit.js +1 -1
  10. package/out/replicache/src/db/commit.js.map +1 -1
  11. package/out/replicache/src/db/write.d.ts +0 -2
  12. package/out/replicache/src/db/write.d.ts.map +1 -1
  13. package/out/replicache/src/db/write.js +1 -1
  14. package/out/replicache/src/db/write.js.map +1 -1
  15. package/out/replicache/src/deleted-clients.d.ts +0 -2
  16. package/out/replicache/src/deleted-clients.d.ts.map +1 -1
  17. package/out/replicache/src/deleted-clients.js +1 -1
  18. package/out/replicache/src/deleted-clients.js.map +1 -1
  19. package/out/replicache/src/frozen-json.d.ts +0 -1
  20. package/out/replicache/src/frozen-json.d.ts.map +1 -1
  21. package/out/replicache/src/frozen-json.js.map +1 -1
  22. package/out/replicache/src/index-defs.d.ts +0 -2
  23. package/out/replicache/src/index-defs.d.ts.map +1 -1
  24. package/out/replicache/src/index-defs.js +1 -1
  25. package/out/replicache/src/index-defs.js.map +1 -1
  26. package/out/replicache/src/kv/expo-sqlite/store.d.ts +0 -1
  27. package/out/replicache/src/kv/expo-sqlite/store.d.ts.map +1 -1
  28. package/out/replicache/src/kv/expo-sqlite/store.js +1 -1
  29. package/out/replicache/src/kv/expo-sqlite/store.js.map +1 -1
  30. package/out/replicache/src/kv/idb-store.js +1 -1
  31. package/out/replicache/src/kv/idb-store.js.map +1 -1
  32. package/out/replicache/src/kv/throw-if-closed.d.ts +0 -3
  33. package/out/replicache/src/kv/throw-if-closed.d.ts.map +1 -1
  34. package/out/replicache/src/kv/throw-if-closed.js.map +1 -1
  35. package/out/replicache/src/persist/client-group-gc.d.ts +0 -7
  36. package/out/replicache/src/persist/client-group-gc.d.ts.map +1 -1
  37. package/out/replicache/src/persist/client-group-gc.js +1 -1
  38. package/out/replicache/src/persist/client-group-gc.js.map +1 -1
  39. package/out/replicache/src/process-scheduler.js +1 -1
  40. package/out/replicache/src/process-scheduler.js.map +1 -1
  41. package/out/replicache/src/replicache-impl.d.ts +2 -7
  42. package/out/replicache/src/replicache-impl.d.ts.map +1 -1
  43. package/out/replicache/src/replicache-impl.js +1 -1
  44. package/out/replicache/src/replicache-impl.js.map +1 -1
  45. package/out/replicache/src/sync/patch.d.ts +0 -5
  46. package/out/replicache/src/sync/patch.d.ts.map +1 -1
  47. package/out/replicache/src/sync/patch.js +1 -1
  48. package/out/replicache/src/sync/patch.js.map +1 -1
  49. package/out/replicache/src/sync/pull.d.ts +0 -1
  50. package/out/replicache/src/sync/pull.d.ts.map +1 -1
  51. package/out/replicache/src/sync/pull.js.map +1 -1
  52. package/out/replicache/src/sync/push.d.ts +2 -1
  53. package/out/replicache/src/sync/push.d.ts.map +1 -1
  54. package/out/replicache/src/sync/push.js.map +1 -1
  55. package/out/replicache/src/types.d.ts +2 -1
  56. package/out/replicache/src/types.d.ts.map +1 -1
  57. package/out/shared/src/asserts.d.ts +0 -5
  58. package/out/shared/src/asserts.d.ts.map +1 -1
  59. package/out/shared/src/asserts.js +1 -1
  60. package/out/shared/src/asserts.js.map +1 -1
  61. package/out/shared/src/browser-env.d.ts +0 -17
  62. package/out/shared/src/browser-env.d.ts.map +1 -1
  63. package/out/shared/src/browser-env.js.map +1 -1
  64. package/out/shared/src/deep-clone.d.ts +0 -1
  65. package/out/shared/src/deep-clone.d.ts.map +1 -1
  66. package/out/shared/src/deep-clone.js +1 -1
  67. package/out/shared/src/deep-clone.js.map +1 -1
  68. package/out/shared/src/document-visible.js +1 -1
  69. package/out/shared/src/document-visible.js.map +1 -1
  70. package/out/shared/src/expand.d.ts +0 -3
  71. package/out/shared/src/expand.d.ts.map +1 -1
  72. package/out/shared/src/immutable.d.ts +1 -1
  73. package/out/shared/src/immutable.d.ts.map +1 -1
  74. package/out/shared/src/iterables.d.ts +0 -1
  75. package/out/shared/src/iterables.d.ts.map +1 -1
  76. package/out/shared/src/iterables.js.map +1 -1
  77. package/out/shared/src/logging-test-utils.js +1 -1
  78. package/out/shared/src/logging-test-utils.js.map +1 -1
  79. package/out/shared/src/options-types.d.ts +1 -1
  80. package/out/shared/src/options-types.d.ts.map +1 -1
  81. package/out/shared/src/options.d.ts +2 -3
  82. package/out/shared/src/options.d.ts.map +1 -1
  83. package/out/shared/src/options.js +1 -1
  84. package/out/shared/src/options.js.map +1 -1
  85. package/out/shared/src/promise-race.js +1 -1
  86. package/out/shared/src/promise-race.js.map +1 -1
  87. package/out/shared/src/queue.js +1 -1
  88. package/out/shared/src/queue.js.map +1 -1
  89. package/out/shared/src/resolved-promises.d.ts +0 -4
  90. package/out/shared/src/resolved-promises.d.ts.map +1 -1
  91. package/out/shared/src/resolved-promises.js +0 -1
  92. package/out/shared/src/resolved-promises.js.map +1 -1
  93. package/out/shared/src/resolver.d.ts +9 -0
  94. package/out/shared/src/resolver.d.ts.map +1 -0
  95. package/out/shared/src/resolver.js +6 -0
  96. package/out/shared/src/resolver.js.map +1 -0
  97. package/out/shared/src/sleep.js +1 -1
  98. package/out/shared/src/sleep.js.map +1 -1
  99. package/out/shared/src/tdigest.d.ts +0 -1
  100. package/out/shared/src/tdigest.d.ts.map +1 -1
  101. package/out/shared/src/tdigest.js.map +1 -1
  102. package/out/z2s/src/sql.d.ts +1 -5
  103. package/out/z2s/src/sql.d.ts.map +1 -1
  104. package/out/z2s/src/sql.js.map +1 -1
  105. package/out/zero/package.js +2 -3
  106. package/out/zero/package.js.map +1 -1
  107. package/out/zero/src/zero-cache-dev.js +1 -1
  108. package/out/zero/src/zero-cache-dev.js.map +1 -1
  109. package/out/zero-cache/src/config/zero-config.d.ts +14 -11
  110. package/out/zero-cache/src/config/zero-config.d.ts.map +1 -1
  111. package/out/zero-cache/src/config/zero-config.js +23 -0
  112. package/out/zero-cache/src/config/zero-config.js.map +1 -1
  113. package/out/zero-cache/src/db/migration-lite.js.map +1 -1
  114. package/out/zero-cache/src/db/migration.js +1 -1
  115. package/out/zero-cache/src/db/migration.js.map +1 -1
  116. package/out/zero-cache/src/db/pg-copy-binary.js +1 -1
  117. package/out/zero-cache/src/db/pg-copy-binary.js.map +1 -1
  118. package/out/zero-cache/src/db/pg-type-parser.js.map +1 -1
  119. package/out/zero-cache/src/db/specs.d.ts +3 -4
  120. package/out/zero-cache/src/db/specs.d.ts.map +1 -1
  121. package/out/zero-cache/src/db/specs.js +5 -7
  122. package/out/zero-cache/src/db/specs.js.map +1 -1
  123. package/out/zero-cache/src/db/transaction-pool.js +2 -2
  124. package/out/zero-cache/src/db/transaction-pool.js.map +1 -1
  125. package/out/zero-cache/src/observability/events.js +1 -1
  126. package/out/zero-cache/src/observability/events.js.map +1 -1
  127. package/out/zero-cache/src/server/change-streamer.js +1 -1
  128. package/out/zero-cache/src/server/change-streamer.js.map +1 -1
  129. package/out/zero-cache/src/server/main.js +1 -1
  130. package/out/zero-cache/src/server/main.js.map +1 -1
  131. package/out/zero-cache/src/server/runner/run-worker.js +1 -1
  132. package/out/zero-cache/src/server/runner/run-worker.js.map +1 -1
  133. package/out/zero-cache/src/services/change-source/common/backfill-manager.js +1 -1
  134. package/out/zero-cache/src/services/change-source/common/backfill-manager.js.map +1 -1
  135. package/out/zero-cache/src/services/change-source/common/change-stream-multiplexer.js +1 -1
  136. package/out/zero-cache/src/services/change-source/common/change-stream-multiplexer.js.map +1 -1
  137. package/out/zero-cache/src/services/change-source/common/replica-restore.js.map +1 -1
  138. package/out/zero-cache/src/services/change-source/custom/change-source.js +1 -1
  139. package/out/zero-cache/src/services/change-source/custom/change-source.js.map +1 -1
  140. package/out/zero-cache/src/services/change-source/pg/backfill-stream.js +1 -1
  141. package/out/zero-cache/src/services/change-source/pg/backfill-stream.js.map +1 -1
  142. package/out/zero-cache/src/services/change-source/pg/change-source.js +1 -1
  143. package/out/zero-cache/src/services/change-source/pg/change-source.js.map +1 -1
  144. package/out/zero-cache/src/services/change-source/pg/initial-sync.js +1 -1
  145. package/out/zero-cache/src/services/change-source/pg/initial-sync.js.map +1 -1
  146. package/out/zero-cache/src/services/change-source/pg/lsn.d.ts +0 -2
  147. package/out/zero-cache/src/services/change-source/pg/lsn.d.ts.map +1 -1
  148. package/out/zero-cache/src/services/change-source/pg/lsn.js.map +1 -1
  149. package/out/zero-cache/src/services/change-source/pg/replication-slots.js +1 -1
  150. package/out/zero-cache/src/services/change-source/pg/replication-slots.js.map +1 -1
  151. package/out/zero-cache/src/services/change-source/pg/schema/ddl.d.ts +0 -12
  152. package/out/zero-cache/src/services/change-source/pg/schema/ddl.d.ts.map +1 -1
  153. package/out/zero-cache/src/services/change-source/pg/schema/ddl.js +5 -3
  154. package/out/zero-cache/src/services/change-source/pg/schema/ddl.js.map +1 -1
  155. package/out/zero-cache/src/services/change-source/pg/schema/index-predicate.d.ts +1 -1
  156. package/out/zero-cache/src/services/change-source/pg/schema/index-predicate.d.ts.map +1 -1
  157. package/out/zero-cache/src/services/change-source/pg/schema/index-predicate.js.map +1 -1
  158. package/out/zero-cache/src/services/change-source/pg/schema/validation.d.ts +0 -1
  159. package/out/zero-cache/src/services/change-source/pg/schema/validation.d.ts.map +1 -1
  160. package/out/zero-cache/src/services/change-source/pg/schema/validation.js.map +1 -1
  161. package/out/zero-cache/src/services/change-streamer/backup-monitor.js +1 -1
  162. package/out/zero-cache/src/services/change-streamer/backup-monitor.js.map +1 -1
  163. package/out/zero-cache/src/services/change-streamer/broadcast.js +1 -1
  164. package/out/zero-cache/src/services/change-streamer/broadcast.js.map +1 -1
  165. package/out/zero-cache/src/services/change-streamer/change-streamer-http.js +1 -1
  166. package/out/zero-cache/src/services/change-streamer/change-streamer-http.js.map +1 -1
  167. package/out/zero-cache/src/services/change-streamer/change-streamer-service.js +1 -1
  168. package/out/zero-cache/src/services/change-streamer/change-streamer-service.js.map +1 -1
  169. package/out/zero-cache/src/services/change-streamer/change-streamer.js +1 -1
  170. package/out/zero-cache/src/services/change-streamer/change-streamer.js.map +1 -1
  171. package/out/zero-cache/src/services/change-streamer/drain-tracker.js +1 -1
  172. package/out/zero-cache/src/services/change-streamer/drain-tracker.js.map +1 -1
  173. package/out/zero-cache/src/services/change-streamer/litestream3-prometheus-poller.js +2 -2
  174. package/out/zero-cache/src/services/change-streamer/litestream3-prometheus-poller.js.map +1 -1
  175. package/out/zero-cache/src/services/change-streamer/restore-admission.js +2 -2
  176. package/out/zero-cache/src/services/change-streamer/restore-admission.js.map +1 -1
  177. package/out/zero-cache/src/services/change-streamer/schema/tables.js +1 -1
  178. package/out/zero-cache/src/services/change-streamer/schema/tables.js.map +1 -1
  179. package/out/zero-cache/src/services/change-streamer/snapshot-message.js +2 -3
  180. package/out/zero-cache/src/services/change-streamer/snapshot-message.js.map +1 -1
  181. package/out/zero-cache/src/services/change-streamer/sqlite-change-log-catchup.js +2 -2
  182. package/out/zero-cache/src/services/change-streamer/sqlite-change-log-catchup.js.map +1 -1
  183. package/out/zero-cache/src/services/change-streamer/sqlite-change-log-read-router.js.map +1 -1
  184. package/out/zero-cache/src/services/change-streamer/storer.js +1 -1
  185. package/out/zero-cache/src/services/change-streamer/storer.js.map +1 -1
  186. package/out/zero-cache/src/services/change-streamer/subscribe.js +1 -1
  187. package/out/zero-cache/src/services/change-streamer/subscribe.js.map +1 -1
  188. package/out/zero-cache/src/services/change-streamer/subscriber.js +1 -1
  189. package/out/zero-cache/src/services/change-streamer/subscriber.js.map +1 -1
  190. package/out/zero-cache/src/services/life-cycle.js +1 -1
  191. package/out/zero-cache/src/services/life-cycle.js.map +1 -1
  192. package/out/zero-cache/src/services/litestream/commands.js +1 -1
  193. package/out/zero-cache/src/services/litestream/commands.js.map +1 -1
  194. package/out/zero-cache/src/services/litestream/metrics.js.map +1 -1
  195. package/out/zero-cache/src/services/mutagen/mutagen.js +2 -2
  196. package/out/zero-cache/src/services/mutagen/mutagen.js.map +1 -1
  197. package/out/zero-cache/src/services/plannerz.d.ts +4 -12
  198. package/out/zero-cache/src/services/plannerz.d.ts.map +1 -1
  199. package/out/zero-cache/src/services/plannerz.js +1 -3
  200. package/out/zero-cache/src/services/plannerz.js.map +1 -1
  201. package/out/zero-cache/src/services/replicator/change-log-db.js +1 -1
  202. package/out/zero-cache/src/services/replicator/change-log-db.js.map +1 -1
  203. package/out/zero-cache/src/services/replicator/change-log-stream-writer.js +1 -1
  204. package/out/zero-cache/src/services/replicator/change-log-stream-writer.js.map +1 -1
  205. package/out/zero-cache/src/services/replicator/drain-handler.js +1 -1
  206. package/out/zero-cache/src/services/replicator/drain-handler.js.map +1 -1
  207. package/out/zero-cache/src/services/replicator/reporter/recorder.js +1 -1
  208. package/out/zero-cache/src/services/replicator/reporter/recorder.js.map +1 -1
  209. package/out/zero-cache/src/services/replicator/reporter/report-schema.d.ts +2 -11
  210. package/out/zero-cache/src/services/replicator/reporter/report-schema.d.ts.map +1 -1
  211. package/out/zero-cache/src/services/replicator/reporter/report-schema.js +1 -1
  212. package/out/zero-cache/src/services/replicator/reporter/report-schema.js.map +1 -1
  213. package/out/zero-cache/src/services/replicator/schema/change-log.d.ts +0 -10
  214. package/out/zero-cache/src/services/replicator/schema/change-log.d.ts.map +1 -1
  215. package/out/zero-cache/src/services/replicator/schema/change-log.js.map +1 -1
  216. package/out/zero-cache/src/services/replicator/schema/column-metadata.d.ts +0 -7
  217. package/out/zero-cache/src/services/replicator/schema/column-metadata.d.ts.map +1 -1
  218. package/out/zero-cache/src/services/replicator/schema/column-metadata.js +1 -1
  219. package/out/zero-cache/src/services/replicator/schema/column-metadata.js.map +1 -1
  220. package/out/zero-cache/src/services/replicator/write-worker-client.js +1 -1
  221. package/out/zero-cache/src/services/replicator/write-worker-client.js.map +1 -1
  222. package/out/zero-cache/src/services/running-state.js +1 -1
  223. package/out/zero-cache/src/services/running-state.js.map +1 -1
  224. package/out/zero-cache/src/services/view-syncer/client-handler.js.map +1 -1
  225. package/out/zero-cache/src/services/view-syncer/connection-context-manager.js.map +1 -1
  226. package/out/zero-cache/src/services/view-syncer/cvr-store.js +1 -1
  227. package/out/zero-cache/src/services/view-syncer/cvr-store.js.map +1 -1
  228. package/out/zero-cache/src/services/view-syncer/cvr.js.map +1 -1
  229. package/out/zero-cache/src/services/view-syncer/drain-coordinator.js +1 -1
  230. package/out/zero-cache/src/services/view-syncer/drain-coordinator.js.map +1 -1
  231. package/out/zero-cache/src/services/view-syncer/pipeline-driver.js.map +1 -1
  232. package/out/zero-cache/src/services/view-syncer/query-stats.js.map +1 -1
  233. package/out/zero-cache/src/services/view-syncer/row-record-cache.js +1 -1
  234. package/out/zero-cache/src/services/view-syncer/row-record-cache.js.map +1 -1
  235. package/out/zero-cache/src/services/view-syncer/schema/cvr.js +1 -1
  236. package/out/zero-cache/src/services/view-syncer/schema/cvr.js.map +1 -1
  237. package/out/zero-cache/src/services/view-syncer/schema/types.js +3 -17
  238. package/out/zero-cache/src/services/view-syncer/schema/types.js.map +1 -1
  239. package/out/zero-cache/src/services/view-syncer/snapshotter.js +1 -1
  240. package/out/zero-cache/src/services/view-syncer/snapshotter.js.map +1 -1
  241. package/out/zero-cache/src/services/view-syncer/view-syncer.js +10 -10
  242. package/out/zero-cache/src/services/view-syncer/view-syncer.js.map +1 -1
  243. package/out/zero-cache/src/types/lite.d.ts +0 -1
  244. package/out/zero-cache/src/types/lite.d.ts.map +1 -1
  245. package/out/zero-cache/src/types/lite.js +2 -2
  246. package/out/zero-cache/src/types/lite.js.map +1 -1
  247. package/out/zero-cache/src/types/pg-types.d.ts +0 -40
  248. package/out/zero-cache/src/types/pg-types.d.ts.map +1 -1
  249. package/out/zero-cache/src/types/pg-types.js.map +1 -1
  250. package/out/zero-cache/src/types/poke-chunk.js +1 -1
  251. package/out/zero-cache/src/types/poke-chunk.js.map +1 -1
  252. package/out/zero-cache/src/types/row-key.d.ts +0 -5
  253. package/out/zero-cache/src/types/row-key.d.ts.map +1 -1
  254. package/out/zero-cache/src/types/row-key.js.map +1 -1
  255. package/out/zero-cache/src/types/streams.js +1 -1
  256. package/out/zero-cache/src/types/streams.js.map +1 -1
  257. package/out/zero-cache/src/types/subscription.js +1 -1
  258. package/out/zero-cache/src/types/subscription.js.map +1 -1
  259. package/out/zero-cache/src/types/websocket-handoff.d.ts +0 -6
  260. package/out/zero-cache/src/types/websocket-handoff.d.ts.map +1 -1
  261. package/out/zero-cache/src/types/websocket-handoff.js +8 -2
  262. package/out/zero-cache/src/types/websocket-handoff.js.map +1 -1
  263. package/out/zero-cache/src/types/ws.d.ts +2 -1
  264. package/out/zero-cache/src/types/ws.d.ts.map +1 -1
  265. package/out/zero-cache/src/types/ws.js +1 -1
  266. package/out/zero-cache/src/types/ws.js.map +1 -1
  267. package/out/zero-cache/src/workers/connection.js +4 -1
  268. package/out/zero-cache/src/workers/connection.js.map +1 -1
  269. package/out/zero-cache/src/workers/mutator.js +1 -1
  270. package/out/zero-cache/src/workers/mutator.js.map +1 -1
  271. package/out/zero-cache/src/workers/syncer.js +36 -2
  272. package/out/zero-cache/src/workers/syncer.js.map +1 -1
  273. package/out/zero-client/src/client/active-clients-manager.d.ts.map +1 -1
  274. package/out/zero-client/src/client/active-clients-manager.js +1 -1
  275. package/out/zero-client/src/client/active-clients-manager.js.map +1 -1
  276. package/out/zero-client/src/client/connection-manager.js +1 -1
  277. package/out/zero-client/src/client/connection-manager.js.map +1 -1
  278. package/out/zero-client/src/client/crud.d.ts +2 -8
  279. package/out/zero-client/src/client/crud.d.ts.map +1 -1
  280. package/out/zero-client/src/client/crud.js +1 -1
  281. package/out/zero-client/src/client/crud.js.map +1 -1
  282. package/out/zero-client/src/client/custom.d.ts +0 -2
  283. package/out/zero-client/src/client/custom.d.ts.map +1 -1
  284. package/out/zero-client/src/client/custom.js +1 -1
  285. package/out/zero-client/src/client/custom.js.map +1 -1
  286. package/out/zero-client/src/client/enable-analytics.d.ts +0 -1
  287. package/out/zero-client/src/client/enable-analytics.d.ts.map +1 -1
  288. package/out/zero-client/src/client/enable-analytics.js +2 -1
  289. package/out/zero-client/src/client/enable-analytics.js.map +1 -1
  290. package/out/zero-client/src/client/error.d.ts +4 -5
  291. package/out/zero-client/src/client/error.d.ts.map +1 -1
  292. package/out/zero-client/src/client/error.js.map +1 -1
  293. package/out/zero-client/src/client/keys.d.ts +0 -1
  294. package/out/zero-client/src/client/keys.d.ts.map +1 -1
  295. package/out/zero-client/src/client/keys.js +4 -2
  296. package/out/zero-client/src/client/keys.js.map +1 -1
  297. package/out/zero-client/src/client/mutation-tracker.d.ts.map +1 -1
  298. package/out/zero-client/src/client/mutation-tracker.js +1 -1
  299. package/out/zero-client/src/client/mutation-tracker.js.map +1 -1
  300. package/out/zero-client/src/client/options.d.ts +0 -4
  301. package/out/zero-client/src/client/options.d.ts.map +1 -1
  302. package/out/zero-client/src/client/options.js.map +1 -1
  303. package/out/zero-client/src/client/replicache-types.d.ts +3 -2
  304. package/out/zero-client/src/client/replicache-types.d.ts.map +1 -1
  305. package/out/zero-client/src/client/version.js +1 -1
  306. package/out/zero-client/src/client/zero-poke-handler.d.ts +1 -2
  307. package/out/zero-client/src/client/zero-poke-handler.d.ts.map +1 -1
  308. package/out/zero-client/src/client/zero-poke-handler.js +1 -1
  309. package/out/zero-client/src/client/zero-poke-handler.js.map +1 -1
  310. package/out/zero-client/src/client/zero.d.ts +1 -5
  311. package/out/zero-client/src/client/zero.d.ts.map +1 -1
  312. package/out/zero-client/src/client/zero.js +1 -1
  313. package/out/zero-client/src/client/zero.js.map +1 -1
  314. package/out/zero-client/src/types/client-state.d.ts +0 -6
  315. package/out/zero-client/src/types/client-state.d.ts.map +1 -1
  316. package/out/zero-permissions/src/permissions.d.ts +1 -12
  317. package/out/zero-permissions/src/permissions.d.ts.map +1 -1
  318. package/out/zero-permissions/src/permissions.js +1 -2
  319. package/out/zero-permissions/src/permissions.js.map +1 -1
  320. package/out/zero-protocol/src/ast.d.ts +0 -4
  321. package/out/zero-protocol/src/ast.d.ts.map +1 -1
  322. package/out/zero-protocol/src/ast.js +1 -2
  323. package/out/zero-protocol/src/ast.js.map +1 -1
  324. package/out/zero-protocol/src/change-desired-queries.d.ts +0 -20
  325. package/out/zero-protocol/src/change-desired-queries.d.ts.map +1 -1
  326. package/out/zero-protocol/src/change-desired-queries.js.map +1 -1
  327. package/out/zero-protocol/src/client-schema.d.ts +2 -5
  328. package/out/zero-protocol/src/client-schema.d.ts.map +1 -1
  329. package/out/zero-protocol/src/client-schema.js +1 -1
  330. package/out/zero-protocol/src/client-schema.js.map +1 -1
  331. package/out/zero-protocol/src/close-connection.d.ts +0 -8
  332. package/out/zero-protocol/src/close-connection.d.ts.map +1 -1
  333. package/out/zero-protocol/src/close-connection.js +1 -1
  334. package/out/zero-protocol/src/close-connection.js.map +1 -1
  335. package/out/zero-protocol/src/connect.d.ts +0 -12
  336. package/out/zero-protocol/src/connect.d.ts.map +1 -1
  337. package/out/zero-protocol/src/connect.js +1 -1
  338. package/out/zero-protocol/src/connect.js.map +1 -1
  339. package/out/zero-protocol/src/custom-queries.d.ts +3 -17
  340. package/out/zero-protocol/src/custom-queries.d.ts.map +1 -1
  341. package/out/zero-protocol/src/custom-queries.js +1 -1
  342. package/out/zero-protocol/src/custom-queries.js.map +1 -1
  343. package/out/zero-protocol/src/data.d.ts +0 -1
  344. package/out/zero-protocol/src/data.d.ts.map +1 -1
  345. package/out/zero-protocol/src/data.js +1 -1
  346. package/out/zero-protocol/src/data.js.map +1 -1
  347. package/out/zero-protocol/src/down.d.ts +27 -27
  348. package/out/zero-protocol/src/inspect-down.d.ts +82 -84
  349. package/out/zero-protocol/src/inspect-down.d.ts.map +1 -1
  350. package/out/zero-protocol/src/inspect-down.js +1 -1
  351. package/out/zero-protocol/src/inspect-down.js.map +1 -1
  352. package/out/zero-protocol/src/inspect-up.d.ts +0 -28
  353. package/out/zero-protocol/src/inspect-up.d.ts.map +1 -1
  354. package/out/zero-protocol/src/inspect-up.js +1 -1
  355. package/out/zero-protocol/src/inspect-up.js.map +1 -1
  356. package/out/zero-protocol/src/mutate-server.d.ts +0 -21
  357. package/out/zero-protocol/src/mutate-server.d.ts.map +1 -1
  358. package/out/zero-protocol/src/mutate-server.js +1 -1
  359. package/out/zero-protocol/src/mutate-server.js.map +1 -1
  360. package/out/zero-protocol/src/mutation-type-enum.d.ts +0 -1
  361. package/out/zero-protocol/src/mutation-type-enum.d.ts.map +1 -1
  362. package/out/zero-protocol/src/mutation-type-enum.js.map +1 -1
  363. package/out/zero-protocol/src/mutation.d.ts +2 -4
  364. package/out/zero-protocol/src/mutation.d.ts.map +1 -1
  365. package/out/zero-protocol/src/mutation.js +1 -1
  366. package/out/zero-protocol/src/mutation.js.map +1 -1
  367. package/out/zero-protocol/src/mutations-patch.d.ts +0 -33
  368. package/out/zero-protocol/src/mutations-patch.d.ts.map +1 -1
  369. package/out/zero-protocol/src/mutations-patch.js +1 -1
  370. package/out/zero-protocol/src/mutations-patch.js.map +1 -1
  371. package/out/zero-protocol/src/ping.d.ts +0 -2
  372. package/out/zero-protocol/src/ping.d.ts.map +1 -1
  373. package/out/zero-protocol/src/ping.js +1 -1
  374. package/out/zero-protocol/src/ping.js.map +1 -1
  375. package/out/zero-protocol/src/poke.d.ts +3 -2
  376. package/out/zero-protocol/src/poke.d.ts.map +1 -1
  377. package/out/zero-protocol/src/poke.js +1 -1
  378. package/out/zero-protocol/src/poke.js.map +1 -1
  379. package/out/zero-protocol/src/pong.d.ts +0 -2
  380. package/out/zero-protocol/src/pong.d.ts.map +1 -1
  381. package/out/zero-protocol/src/pong.js +1 -1
  382. package/out/zero-protocol/src/pong.js.map +1 -1
  383. package/out/zero-protocol/src/pull.d.ts +2 -7
  384. package/out/zero-protocol/src/pull.d.ts.map +1 -1
  385. package/out/zero-protocol/src/pull.js +1 -1
  386. package/out/zero-protocol/src/pull.js.map +1 -1
  387. package/out/zero-protocol/src/push.d.ts +1 -3
  388. package/out/zero-protocol/src/push.d.ts.map +1 -1
  389. package/out/zero-protocol/src/push.js +1 -1
  390. package/out/zero-protocol/src/push.js.map +1 -1
  391. package/out/zero-protocol/src/queries-patch.d.ts +0 -16
  392. package/out/zero-protocol/src/queries-patch.d.ts.map +1 -1
  393. package/out/zero-protocol/src/queries-patch.js +1 -1
  394. package/out/zero-protocol/src/queries-patch.js.map +1 -1
  395. package/out/zero-protocol/src/query-server.d.ts +2 -41
  396. package/out/zero-protocol/src/query-server.d.ts.map +1 -1
  397. package/out/zero-protocol/src/query-server.js +1 -1
  398. package/out/zero-protocol/src/query-server.js.map +1 -1
  399. package/out/zero-protocol/src/up.d.ts +42 -42
  400. package/out/zero-protocol/src/version.d.ts +0 -1
  401. package/out/zero-protocol/src/version.d.ts.map +1 -1
  402. package/out/zero-protocol/src/version.js.map +1 -1
  403. package/out/zero-react/src/use-query.js +1 -1
  404. package/out/zero-react/src/use-query.js.map +1 -1
  405. package/out/zero-schema/src/builder/relationship-builder.d.ts +0 -2
  406. package/out/zero-schema/src/builder/relationship-builder.d.ts.map +1 -1
  407. package/out/zero-schema/src/builder/relationship-builder.js.map +1 -1
  408. package/out/zero-schema/src/builder/table-builder.d.ts +1 -1
  409. package/out/zero-schema/src/builder/table-builder.d.ts.map +1 -1
  410. package/out/zero-schema/src/builder/table-builder.js +1 -1
  411. package/out/zero-schema/src/builder/table-builder.js.map +1 -1
  412. package/out/zero-schema/src/schema-config.d.ts +0 -1
  413. package/out/zero-schema/src/schema-config.d.ts.map +1 -1
  414. package/out/zero-schema/src/schema-config.js +1 -1
  415. package/out/zero-schema/src/schema-config.js.map +1 -1
  416. package/out/zero-schema/src/table-schema.d.ts +3 -11
  417. package/out/zero-schema/src/table-schema.d.ts.map +1 -1
  418. package/out/zero-server/src/queries/process-queries.d.ts +2 -4
  419. package/out/zero-server/src/queries/process-queries.d.ts.map +1 -1
  420. package/out/zero-server/src/queries/process-queries.js.map +1 -1
  421. package/out/zero-solid/src/solid-view.d.ts +0 -2
  422. package/out/zero-solid/src/solid-view.d.ts.map +1 -1
  423. package/out/zero-solid/src/solid-view.js +1 -1
  424. package/out/zero-solid/src/solid-view.js.map +1 -1
  425. package/out/zero-types/src/name-mapper.d.ts +2 -1
  426. package/out/zero-types/src/name-mapper.d.ts.map +1 -1
  427. package/out/zero-types/src/name-mapper.js.map +1 -1
  428. package/out/zero-types/src/schema-value.d.ts +3 -2
  429. package/out/zero-types/src/schema-value.d.ts.map +1 -1
  430. package/out/zero-types/src/schema.d.ts +1 -1
  431. package/out/zero-types/src/schema.d.ts.map +1 -1
  432. package/out/zql/src/builder/builder.d.ts +1 -11
  433. package/out/zql/src/builder/builder.d.ts.map +1 -1
  434. package/out/zql/src/builder/builder.js +1 -1
  435. package/out/zql/src/builder/builder.js.map +1 -1
  436. package/out/zql/src/builder/filter.d.ts +0 -1
  437. package/out/zql/src/builder/filter.d.ts.map +1 -1
  438. package/out/zql/src/builder/filter.js.map +1 -1
  439. package/out/zql/src/error.d.ts +0 -5
  440. package/out/zql/src/error.d.ts.map +1 -1
  441. package/out/zql/src/error.js.map +1 -1
  442. package/out/zql/src/ivm/constraint.d.ts +0 -7
  443. package/out/zql/src/ivm/constraint.d.ts.map +1 -1
  444. package/out/zql/src/ivm/constraint.js +1 -1
  445. package/out/zql/src/ivm/constraint.js.map +1 -1
  446. package/out/zql/src/ivm/data.d.ts +0 -1
  447. package/out/zql/src/ivm/data.d.ts.map +1 -1
  448. package/out/zql/src/ivm/data.js.map +1 -1
  449. package/out/zql/src/ivm/memory-source.d.ts +1 -2
  450. package/out/zql/src/ivm/memory-source.d.ts.map +1 -1
  451. package/out/zql/src/ivm/memory-source.js +1 -1
  452. package/out/zql/src/ivm/memory-source.js.map +1 -1
  453. package/out/zql/src/ivm/stream.d.ts +0 -1
  454. package/out/zql/src/ivm/stream.d.ts.map +1 -1
  455. package/out/zql/src/ivm/stream.js.map +1 -1
  456. package/out/zql/src/ivm/union-fan-in.d.ts +0 -1
  457. package/out/zql/src/ivm/union-fan-in.d.ts.map +1 -1
  458. package/out/zql/src/ivm/union-fan-in.js +1 -1
  459. package/out/zql/src/ivm/union-fan-in.js.map +1 -1
  460. package/out/zql/src/ivm/view-apply-change.d.ts +5 -35
  461. package/out/zql/src/ivm/view-apply-change.d.ts.map +1 -1
  462. package/out/zql/src/ivm/view-apply-change.js +1 -1
  463. package/out/zql/src/ivm/view-apply-change.js.map +1 -1
  464. package/out/zql/src/mutate/crud.d.ts +1 -3
  465. package/out/zql/src/mutate/crud.d.ts.map +1 -1
  466. package/out/zql/src/mutate/crud.js +1 -1
  467. package/out/zql/src/mutate/crud.js.map +1 -1
  468. package/out/zql/src/mutate/mutator-registry.d.ts +1 -1
  469. package/out/zql/src/mutate/mutator-registry.d.ts.map +1 -1
  470. package/out/zql/src/mutate/mutator-registry.js.map +1 -1
  471. package/out/zql/src/mutate/mutator.d.ts +1 -1
  472. package/out/zql/src/mutate/mutator.d.ts.map +1 -1
  473. package/out/zql/src/mutate/mutator.js.map +1 -1
  474. package/out/zql/src/planner/planner-debug.d.ts +10 -9
  475. package/out/zql/src/planner/planner-debug.d.ts.map +1 -1
  476. package/out/zql/src/planner/planner-debug.js.map +1 -1
  477. package/out/zql/src/planner/planner-node.d.ts +0 -1
  478. package/out/zql/src/planner/planner-node.d.ts.map +1 -1
  479. package/out/zql/src/planner/planner-node.js.map +1 -1
  480. package/out/zql/src/planner/planner-warnings.d.ts +3 -3
  481. package/out/zql/src/planner/planner-warnings.d.ts.map +1 -1
  482. package/out/zql/src/planner/planner-warnings.js.map +1 -1
  483. package/out/zql/src/query/expression.d.ts +0 -22
  484. package/out/zql/src/query/expression.d.ts.map +1 -1
  485. package/out/zql/src/query/expression.js +1 -1
  486. package/out/zql/src/query/expression.js.map +1 -1
  487. package/out/zql/src/query/query-delegate-base.d.ts +0 -7
  488. package/out/zql/src/query/query-delegate-base.d.ts.map +1 -1
  489. package/out/zql/src/query/query-delegate-base.js +2 -2
  490. package/out/zql/src/query/query-delegate-base.js.map +1 -1
  491. package/out/zql/src/query/query-delegate.d.ts +1 -4
  492. package/out/zql/src/query/query-delegate.d.ts.map +1 -1
  493. package/out/zql/src/query/query-internals.d.ts +0 -3
  494. package/out/zql/src/query/query-internals.d.ts.map +1 -1
  495. package/out/zql/src/query/query-internals.js.map +1 -1
  496. package/out/zql/src/query/query-registry.d.ts +5 -5
  497. package/out/zql/src/query/query-registry.d.ts.map +1 -1
  498. package/out/zql/src/query/query-registry.js.map +1 -1
  499. package/out/zql/src/query/query.d.ts +2 -13
  500. package/out/zql/src/query/query.d.ts.map +1 -1
  501. package/out/zql/src/query/runnable-query-impl.d.ts +1 -19
  502. package/out/zql/src/query/runnable-query-impl.d.ts.map +1 -1
  503. package/out/zql/src/query/runnable-query-impl.js +1 -1
  504. package/out/zql/src/query/runnable-query-impl.js.map +1 -1
  505. package/out/zql/src/query/ttl.d.ts +2 -3
  506. package/out/zql/src/query/ttl.d.ts.map +1 -1
  507. package/out/zql/src/query/ttl.js.map +1 -1
  508. package/out/zqlite/src/query-builder.d.ts +0 -2
  509. package/out/zqlite/src/query-builder.d.ts.map +1 -1
  510. package/out/zqlite/src/query-builder.js +1 -1
  511. package/out/zqlite/src/query-builder.js.map +1 -1
  512. package/out/zqlite/src/table-source.d.ts +0 -1
  513. package/out/zqlite/src/table-source.d.ts.map +1 -1
  514. package/out/zqlite/src/table-source.js +1 -1
  515. package/out/zqlite/src/table-source.js.map +1 -1
  516. package/package.json +2 -3
@@ -1,23 +1,5 @@
1
1
  import * as v from '../../shared/src/valita.ts';
2
- export declare const queryResultSchema: v.UnionType<[v.ObjectType<{
3
- id: v.Type<string>;
4
- name: v.Type<string>;
5
- ast: v.Type<import("./ast.ts").AST>;
6
- }, undefined>, v.UnionType<[v.ObjectType<{
7
- error: v.Type<"app">;
8
- id: v.Type<string>;
9
- name: v.Type<string>;
10
- message: v.Optional<string>;
11
- details: v.Optional<import("../../shared/src/json.ts").ReadonlyJSONValue>;
12
- }, undefined>, v.ObjectType<{
13
- error: v.Type<"parse">;
14
- id: v.Type<string>;
15
- name: v.Type<string>;
16
- message: v.Type<string>;
17
- details: v.Optional<import("../../shared/src/json.ts").ReadonlyJSONValue>;
18
- }, undefined>]>]>;
19
- export type QueryResult = v.Infer<typeof queryResultSchema>;
20
- export declare const queryResponseBodySchema: v.ArrayType<v.UnionType<[v.ObjectType<{
2
+ declare const queryResponseBodySchema: v.ArrayType<v.UnionType<[v.ObjectType<{
21
3
  id: v.Type<string>;
22
4
  name: v.Type<string>;
23
5
  ast: v.Type<import("./ast.ts").AST>;
@@ -35,28 +17,6 @@ export declare const queryResponseBodySchema: v.ArrayType<v.UnionType<[v.ObjectT
35
17
  details: v.Optional<import("../../shared/src/json.ts").ReadonlyJSONValue>;
36
18
  }, undefined>]>]>>;
37
19
  export type QueryResponseBody = v.Infer<typeof queryResponseBodySchema>;
38
- export declare const querySuccessSchema: v.ObjectType<{
39
- kind: v.Type<"QueryResponse">;
40
- userID: v.Optional<string | null>;
41
- queries: v.ArrayType<v.UnionType<[v.ObjectType<{
42
- id: v.Type<string>;
43
- name: v.Type<string>;
44
- ast: v.Type<import("./ast.ts").AST>;
45
- }, undefined>, v.UnionType<[v.ObjectType<{
46
- error: v.Type<"app">;
47
- id: v.Type<string>;
48
- name: v.Type<string>;
49
- message: v.Optional<string>;
50
- details: v.Optional<import("../../shared/src/json.ts").ReadonlyJSONValue>;
51
- }, undefined>, v.ObjectType<{
52
- error: v.Type<"parse">;
53
- id: v.Type<string>;
54
- name: v.Type<string>;
55
- message: v.Type<string>;
56
- details: v.Optional<import("../../shared/src/json.ts").ReadonlyJSONValue>;
57
- }, undefined>]>]>>;
58
- }, undefined>;
59
- export type QuerySuccess = v.Infer<typeof querySuccessSchema>;
60
20
  export declare const queryResponseSchema: v.UnionType<[v.ObjectType<{
61
21
  kind: v.Type<"QueryResponse">;
62
22
  userID: v.Optional<string | null>;
@@ -147,4 +107,5 @@ export declare const queryResponseSchema: v.UnionType<[v.ObjectType<{
147
107
  reason: v.Type<"internal" | "parse" | "timeout">;
148
108
  }, undefined>]>]>]>]>;
149
109
  export type QueryResponse = v.Infer<typeof queryResponseSchema>;
110
+ export {};
150
111
  //# sourceMappingURL=query-server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"query-server.d.ts","sourceRoot":"","sources":["../../../../zero-protocol/src/query-server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,4BAA4B,CAAC;AAQhD,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;iBAG7B,CAAC;AACF,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;kBAA6B,CAAC;AAClE,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;aAI7B,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAK/B,CAAC;AACF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
1
+ {"version":3,"file":"query-server.d.ts","sourceRoot":"","sources":["../../../../zero-protocol/src/query-server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,4BAA4B,CAAC;AAUhD,QAAA,MAAM,uBAAuB;;;;;;;;;;;;;;;;kBAA6B,CAAC;AAC3D,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAQxE,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAK/B,CAAC;AACF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
@@ -11,6 +11,6 @@ var querySuccessSchema = valita_exports.object({
11
11
  });
12
12
  var queryResponseSchema = valita_exports.union(querySuccessSchema, transformFailedBodySchema, transformResponseMessageSchema);
13
13
  //#endregion
14
- export { queryResponseBodySchema, queryResponseSchema, queryResultSchema, querySuccessSchema };
14
+ export { queryResponseSchema };
15
15
 
16
16
  //# sourceMappingURL=query-server.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"query-server.js","names":["v"],"sources":["../../../../zero-protocol/src/query-server.ts"],"sourcesContent":["import * as v from '../../shared/src/valita.ts';\nimport {\n erroredQuerySchema,\n transformedQuerySchema,\n transformResponseMessageSchema,\n} from './custom-queries.ts';\nimport {transformFailedBodySchema} from './error.ts';\n\nexport const queryResultSchema = v.union(\n transformedQuerySchema,\n erroredQuerySchema,\n);\nexport type QueryResult = v.Infer<typeof queryResultSchema>;\n\nexport const queryResponseBodySchema = v.array(queryResultSchema);\nexport type QueryResponseBody = v.Infer<typeof queryResponseBodySchema>;\n\nexport const querySuccessSchema = v.object({\n kind: v.literal('QueryResponse'),\n userID: v.string().nullable().optional(),\n queries: queryResponseBodySchema,\n});\nexport type QuerySuccess = v.Infer<typeof querySuccessSchema>;\n\nexport const queryResponseSchema = v.union(\n querySuccessSchema,\n transformFailedBodySchema,\n // for backwards compatibility\n transformResponseMessageSchema,\n);\nexport type QueryResponse = v.Infer<typeof queryResponseSchema>;\n"],"mappings":";;;;AAQA,IAAa,oBAAoBA,eAAE,MACjC,wBACA,kBACF;AAGA,IAAa,0BAA0BA,eAAE,MAAM,iBAAiB;AAGhE,IAAa,qBAAqBA,eAAE,OAAO;CACzC,MAAMA,eAAE,QAAQ,eAAe;CAC/B,QAAQA,eAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS;CACvC,SAAS;AACX,CAAC;AAGD,IAAa,sBAAsBA,eAAE,MACnC,oBACA,2BAEA,8BACF"}
1
+ {"version":3,"file":"query-server.js","names":["v"],"sources":["../../../../zero-protocol/src/query-server.ts"],"sourcesContent":["import * as v from '../../shared/src/valita.ts';\nimport {\n erroredQuerySchema,\n transformedQuerySchema,\n transformResponseMessageSchema,\n} from './custom-queries.ts';\nimport {transformFailedBodySchema} from './error.ts';\n\nconst queryResultSchema = v.union(transformedQuerySchema, erroredQuerySchema);\n\nconst queryResponseBodySchema = v.array(queryResultSchema);\nexport type QueryResponseBody = v.Infer<typeof queryResponseBodySchema>;\n\nconst querySuccessSchema = v.object({\n kind: v.literal('QueryResponse'),\n userID: v.string().nullable().optional(),\n queries: queryResponseBodySchema,\n});\n\nexport const queryResponseSchema = v.union(\n querySuccessSchema,\n transformFailedBodySchema,\n // for backwards compatibility\n transformResponseMessageSchema,\n);\nexport type QueryResponse = v.Infer<typeof queryResponseSchema>;\n"],"mappings":";;;;AAQA,IAAM,oBAAoBA,eAAE,MAAM,wBAAwB,kBAAkB;AAE5E,IAAM,0BAA0BA,eAAE,MAAM,iBAAiB;AAGzD,IAAM,qBAAqBA,eAAE,OAAO;CAClC,MAAMA,eAAE,QAAQ,eAAe;CAC/B,QAAQA,eAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS;CACvC,SAAS;AACX,CAAC;AAED,IAAa,sBAAsBA,eAAE,MACnC,oBACA,2BAEA,8BACF"}
@@ -85,6 +85,13 @@ export declare const upstreamSchema: v.Type<v.UnrecognizedTuple | ["ackMutationR
85
85
  }] | ["push", {
86
86
  clientGroupID: string;
87
87
  mutations: ({
88
+ type: "custom";
89
+ id: number;
90
+ clientID: string;
91
+ name: string;
92
+ args: import("../../shared/src/json.ts").ReadonlyJSONValue[];
93
+ timestamp: number;
94
+ } | {
88
95
  type: "crud";
89
96
  id: number;
90
97
  clientID: string;
@@ -113,13 +120,6 @@ export declare const upstreamSchema: v.Type<v.UnrecognizedTuple | ["ackMutationR
113
120
  })[];
114
121
  }];
115
122
  timestamp: number;
116
- } | {
117
- type: "custom";
118
- id: number;
119
- clientID: string;
120
- name: string;
121
- args: import("../../shared/src/json.ts").ReadonlyJSONValue[];
122
- timestamp: number;
123
123
  })[];
124
124
  pushVersion: number;
125
125
  schemaVersion?: number | undefined;
@@ -216,6 +216,13 @@ export declare const upstreamSchema: v.Type<v.UnrecognizedTuple | ["ackMutationR
216
216
  }] | ["push", {
217
217
  clientGroupID: string;
218
218
  mutations: ({
219
+ type: "custom";
220
+ id: number;
221
+ clientID: string;
222
+ name: string;
223
+ args: import("../../shared/src/json.ts").ReadonlyJSONValue[];
224
+ timestamp: number;
225
+ } | {
219
226
  type: "crud";
220
227
  id: number;
221
228
  clientID: string;
@@ -244,13 +251,6 @@ export declare const upstreamSchema: v.Type<v.UnrecognizedTuple | ["ackMutationR
244
251
  })[];
245
252
  }];
246
253
  timestamp: number;
247
- } | {
248
- type: "custom";
249
- id: number;
250
- clientID: string;
251
- name: string;
252
- args: import("../../shared/src/json.ts").ReadonlyJSONValue[];
253
- timestamp: number;
254
254
  })[];
255
255
  pushVersion: number;
256
256
  schemaVersion?: number | undefined;
@@ -346,6 +346,13 @@ export declare const upstreamSchema: v.Type<v.UnrecognizedTuple | ["ackMutationR
346
346
  }] | ["push", {
347
347
  clientGroupID: string;
348
348
  mutations: ({
349
+ type: "custom";
350
+ id: number;
351
+ clientID: string;
352
+ name: string;
353
+ args: import("../../shared/src/json.ts").ReadonlyJSONValue[];
354
+ timestamp: number;
355
+ } | {
349
356
  type: "crud";
350
357
  id: number;
351
358
  clientID: string;
@@ -374,13 +381,6 @@ export declare const upstreamSchema: v.Type<v.UnrecognizedTuple | ["ackMutationR
374
381
  })[];
375
382
  }];
376
383
  timestamp: number;
377
- } | {
378
- type: "custom";
379
- id: number;
380
- clientID: string;
381
- name: string;
382
- args: import("../../shared/src/json.ts").ReadonlyJSONValue[];
383
- timestamp: number;
384
384
  })[];
385
385
  pushVersion: number;
386
386
  schemaVersion?: number | undefined;
@@ -478,6 +478,13 @@ export declare const upstreamSchemaWithUnparsedAnalyzeQuery: v.Type<v.Unrecogniz
478
478
  }] | ["push", {
479
479
  clientGroupID: string;
480
480
  mutations: ({
481
+ type: "custom";
482
+ id: number;
483
+ clientID: string;
484
+ name: string;
485
+ args: import("../../shared/src/json.ts").ReadonlyJSONValue[];
486
+ timestamp: number;
487
+ } | {
481
488
  type: "crud";
482
489
  id: number;
483
490
  clientID: string;
@@ -506,13 +513,6 @@ export declare const upstreamSchemaWithUnparsedAnalyzeQuery: v.Type<v.Unrecogniz
506
513
  })[];
507
514
  }];
508
515
  timestamp: number;
509
- } | {
510
- type: "custom";
511
- id: number;
512
- clientID: string;
513
- name: string;
514
- args: import("../../shared/src/json.ts").ReadonlyJSONValue[];
515
- timestamp: number;
516
516
  })[];
517
517
  pushVersion: number;
518
518
  schemaVersion?: number | undefined;
@@ -609,6 +609,13 @@ export declare const upstreamSchemaWithUnparsedAnalyzeQuery: v.Type<v.Unrecogniz
609
609
  }] | ["push", {
610
610
  clientGroupID: string;
611
611
  mutations: ({
612
+ type: "custom";
613
+ id: number;
614
+ clientID: string;
615
+ name: string;
616
+ args: import("../../shared/src/json.ts").ReadonlyJSONValue[];
617
+ timestamp: number;
618
+ } | {
612
619
  type: "crud";
613
620
  id: number;
614
621
  clientID: string;
@@ -637,13 +644,6 @@ export declare const upstreamSchemaWithUnparsedAnalyzeQuery: v.Type<v.Unrecogniz
637
644
  })[];
638
645
  }];
639
646
  timestamp: number;
640
- } | {
641
- type: "custom";
642
- id: number;
643
- clientID: string;
644
- name: string;
645
- args: import("../../shared/src/json.ts").ReadonlyJSONValue[];
646
- timestamp: number;
647
647
  })[];
648
648
  pushVersion: number;
649
649
  schemaVersion?: number | undefined;
@@ -739,6 +739,13 @@ export declare const upstreamSchemaWithUnparsedAnalyzeQuery: v.Type<v.Unrecogniz
739
739
  }] | ["push", {
740
740
  clientGroupID: string;
741
741
  mutations: ({
742
+ type: "custom";
743
+ id: number;
744
+ clientID: string;
745
+ name: string;
746
+ args: import("../../shared/src/json.ts").ReadonlyJSONValue[];
747
+ timestamp: number;
748
+ } | {
742
749
  type: "crud";
743
750
  id: number;
744
751
  clientID: string;
@@ -767,13 +774,6 @@ export declare const upstreamSchemaWithUnparsedAnalyzeQuery: v.Type<v.Unrecogniz
767
774
  })[];
768
775
  }];
769
776
  timestamp: number;
770
- } | {
771
- type: "custom";
772
- id: number;
773
- clientID: string;
774
- name: string;
775
- args: import("../../shared/src/json.ts").ReadonlyJSONValue[];
776
- timestamp: number;
777
777
  })[];
778
778
  pushVersion: number;
779
779
  schemaVersion?: number | undefined;
@@ -1,6 +1,5 @@
1
1
  import * as v from '../../shared/src/valita.ts';
2
2
  export declare const versionSchema: v.Type<string>;
3
3
  export declare const nullableVersionSchema: v.UnionType<[v.Type<string>, v.Type<null>]>;
4
- export type Version = v.Infer<typeof versionSchema>;
5
4
  export type NullableVersion = v.Infer<typeof nullableVersionSchema>;
6
5
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../../zero-protocol/src/version.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,4BAA4B,CAAC;AAEhD,eAAO,MAAM,aAAa,gBAAa,CAAC;AACxC,eAAO,MAAM,qBAAqB,6CAAmC,CAAC;AAEtE,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AACpD,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../../zero-protocol/src/version.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,4BAA4B,CAAC;AAEhD,eAAO,MAAM,aAAa,gBAAa,CAAC;AACxC,eAAO,MAAM,qBAAqB,6CAAmC,CAAC;AAEtE,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","names":["v"],"sources":["../../../../zero-protocol/src/version.ts"],"sourcesContent":["import * as v from '../../shared/src/valita.ts';\n\nexport const versionSchema = v.string();\nexport const nullableVersionSchema = v.union(versionSchema, v.null());\n\nexport type Version = v.Infer<typeof versionSchema>;\nexport type NullableVersion = v.Infer<typeof nullableVersionSchema>;\n"],"mappings":";;AAEA,IAAa,gBAAgBA,eAAE,OAAO;AACtC,IAAa,wBAAwBA,eAAE,MAAM,eAAeA,eAAE,KAAK,CAAC"}
1
+ {"version":3,"file":"version.js","names":["v"],"sources":["../../../../zero-protocol/src/version.ts"],"sourcesContent":["import * as v from '../../shared/src/valita.ts';\n\nexport const versionSchema = v.string();\nexport const nullableVersionSchema = v.union(versionSchema, v.null());\n\nexport type NullableVersion = v.Infer<typeof nullableVersionSchema>;\n"],"mappings":";;AAEA,IAAa,gBAAgBA,eAAE,OAAO;AACtC,IAAa,wBAAwBA,eAAE,MAAM,eAAeA,eAAE,KAAK,CAAC"}
@@ -1,10 +1,10 @@
1
1
  import { deepEqual } from "../../shared/src/json.js";
2
+ import { resolver } from "../../shared/src/resolver.js";
2
3
  import { asQueryInternals } from "../../zql/src/query/query-internals.js";
3
4
  import { addContextToQuery } from "../../zql/src/query/query-registry.js";
4
5
  import { DEFAULT_TTL_MS } from "../../zql/src/query/ttl.js";
5
6
  import { useZero } from "./zero-provider.js";
6
7
  import "./bindings.js";
7
- import { resolver } from "@rocicorp/resolver";
8
8
  import React, { useRef, useSyncExternalStore } from "react";
9
9
  //#region ../zero-react/src/use-query.tsx
10
10
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"use-query.js","names":[],"sources":["../../../../zero-react/src/use-query.tsx"],"sourcesContent":["import {resolver} from '@rocicorp/resolver';\nimport React, {useRef, useSyncExternalStore} from 'react';\nimport {deepEqual} from '../../shared/src/json.ts';\nimport {TESTING} from '../../shared/src/testing.ts';\nimport {\n type Immutable,\n addContextToQuery,\n asQueryInternals,\n DEFAULT_TTL_MS,\n} from './bindings.ts';\nimport {useZero} from './zero-provider.tsx';\nimport type {\n AnyMutatorRegistry,\n BaseDefaultContext,\n BaseDefaultSchema,\n CustomMutatorDefs,\n DefaultContext,\n DefaultSchema,\n ErroredQuery,\n Falsy,\n HumanReadable,\n PullRow,\n Query,\n QueryErrorDetails,\n QueryOrQueryRequest,\n QueryResultDetails,\n ReadonlyJSONValue,\n ResultType,\n TTL,\n TypedView,\n Zero,\n} from './zero.ts';\n\ntype StableQueryCache = {\n zero: unknown;\n context: unknown;\n /** The last input, so an unchanged one is an identity compare and nothing else. */\n rawQuery: object;\n /** The `CustomQuery` a query request names; undefined for a plain query. */\n customQuery: unknown;\n args: ReadonlyJSONValue | undefined;\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n q: Query<any, any, any>;\n};\n\n/**\n * Resolves a query request against the Zero context, reusing the previous\n * result while the request means the same thing.\n *\n * Interning already makes an unchanged *plain* query come back as the same\n * object, so this is aimed at the query-request form -- `queries.issue({id})`\n * -- where every render allocates a fresh request and `addContextToQuery`\n * re-runs the definition. That costs argument validation (a zod parse of\n * byte-identical args) plus a walk of the builder chain, neither of which\n * interning removes: it makes rebuilding the chain cheap and gives the same\n * object back, but only after the work has been done again.\n *\n * A request resolves to the previous query when it names the same\n * `CustomQuery`, the same context, and deep-equal args. Those are exactly the\n * inputs the definition is allowed to depend on: a named query is re-derived\n * on the server from its name and args, so it has to be a pure function of\n * them, or client and server would build different queries.\n *\n * The ref is written during render. That is safe here because it is a pure\n * cache: an entry is derived only from the inputs, so a StrictMode double\n * render or a discarded concurrent render leaves it valid either way.\n */\nfunction useStableQuery<\n TTable extends keyof TSchema['tables'] & string,\n TInput extends ReadonlyJSONValue | undefined,\n TOutput extends ReadonlyJSONValue | undefined,\n TSchema extends BaseDefaultSchema,\n TReturn,\n TContext extends BaseDefaultContext,\n>(\n query:\n | QueryOrQueryRequest<TTable, TInput, TOutput, TSchema, TReturn, TContext>\n | Falsy,\n zero: Zero<TSchema, undefined, TContext>,\n): Query<TTable, TSchema, TReturn> | undefined {\n const cacheRef = useRef<StableQueryCache | undefined>(undefined);\n\n // Deliberately kept rather than cleared: a query toggled off and back on\n // reuses what it had.\n if (!query) {\n return undefined;\n }\n\n const cache = cacheRef.current;\n if (cache && cache.zero === zero) {\n if (cache.rawQuery === query) {\n return cache.q as Query<TTable, TSchema, TReturn>;\n }\n if (\n 'query' in query &&\n cache.customQuery === query.query &&\n cache.context === zero.context &&\n deepEqual(cache.args, query.args)\n ) {\n // Same meaning, new wrapper object: remember it so the next render is\n // the identity compare above.\n cache.rawQuery = query;\n return cache.q as Query<TTable, TSchema, TReturn>;\n }\n }\n\n const q = addContextToQuery(query, zero.context);\n const isRequest = 'query' in query;\n cacheRef.current = {\n zero: zero,\n context: zero.context,\n rawQuery: query,\n customQuery: isRequest ? query.query : undefined,\n args: isRequest ? query.args : undefined,\n q,\n };\n return q;\n}\n\nexport type QueryResult<TReturn> = readonly [\n HumanReadable<TReturn>,\n QueryResultDetails & {},\n];\n\n/**\n * Result type for \"maybe queries\" - queries that may be falsy.\n * The data value can be undefined when the query is falsy/disabled.\n */\nexport type MaybeQueryResult<TReturn> = readonly [\n HumanReadable<TReturn> | undefined,\n QueryResultDetails & {},\n];\n\nexport type UseQueryOptions = {\n enabled?: boolean | undefined;\n /**\n * Time to live (TTL) in seconds. Controls how long query results are cached\n * after the query is removed. During this time, Zero continues to sync the query.\n * Default is 'never'.\n */\n ttl?: TTL | undefined;\n};\n\nexport type UseSuspenseQueryOptions = UseQueryOptions & {\n /**\n * Whether to suspend until:\n * - 'partial': the query has partial results (partial array or defined\n * value for singular results) which may be of result type 'unknown',\n * or the query result type is 'complete' or 'cached' (in which case\n * results may be empty: a server-confirmed empty answer, from this\n * connection or a previous one, is something to render). This is useful\n * for suspending until there are partial optimistic local results, or\n * the query has completed loading from the server.\n * - 'complete': the query result type is 'complete'.\n *\n * Default is 'partial'.\n */\n suspendUntil?: 'complete' | 'partial';\n};\n\nconst reactUse = (React as {use?: (p: Promise<unknown>) => void}).use;\nconst suspend: (p: Promise<unknown>) => void = reactUse\n ? reactUse\n : p => {\n throw p;\n };\n\n// Overload 1: Query\nexport function useQuery<\n TTable extends keyof TSchema['tables'] & string,\n TInput extends ReadonlyJSONValue | undefined,\n TOutput extends ReadonlyJSONValue | undefined,\n TSchema extends BaseDefaultSchema = DefaultSchema,\n TReturn = PullRow<TTable, TSchema>,\n TContext extends BaseDefaultContext = DefaultContext,\n>(\n query: QueryOrQueryRequest<\n TTable,\n TInput,\n TOutput,\n TSchema,\n TReturn,\n TContext\n >,\n options?: UseQueryOptions | boolean,\n): QueryResult<TReturn>;\n\n// Overload 2: Maybe query\nexport function useQuery<\n TTable extends keyof TSchema['tables'] & string,\n TInput extends ReadonlyJSONValue | undefined,\n TOutput extends ReadonlyJSONValue | undefined,\n TSchema extends BaseDefaultSchema = DefaultSchema,\n TReturn = PullRow<TTable, TSchema>,\n TContext extends BaseDefaultContext = DefaultContext,\n>(\n query:\n | QueryOrQueryRequest<TTable, TInput, TOutput, TSchema, TReturn, TContext>\n | Falsy,\n options?: UseQueryOptions | boolean,\n): MaybeQueryResult<TReturn>;\n\n// Implementation\nexport function useQuery<\n TTable extends keyof TSchema['tables'] & string,\n TInput extends ReadonlyJSONValue | undefined,\n TOutput extends ReadonlyJSONValue | undefined,\n TSchema extends BaseDefaultSchema = DefaultSchema,\n TReturn = PullRow<TTable, TSchema>,\n TContext extends BaseDefaultContext = DefaultContext,\n>(\n query:\n | QueryOrQueryRequest<TTable, TInput, TOutput, TSchema, TReturn, TContext>\n | Falsy,\n options?: UseQueryOptions | boolean,\n): QueryResult<TReturn> | MaybeQueryResult<TReturn> {\n let enabled = true;\n let ttl: TTL = DEFAULT_TTL_MS;\n if (typeof options === 'boolean') {\n enabled = options;\n } else if (options) {\n ({enabled = true, ttl = DEFAULT_TTL_MS} = options);\n }\n\n const zero = useZero<TSchema, undefined, TContext>();\n\n // When query is falsy, use disabled subscriber/snapshot to maintain hook order\n const q = useStableQuery(query, zero);\n const view = q ? viewStore.getView(zero, q, enabled, ttl) : undefined;\n\n // https://react.dev/reference/react/useSyncExternalStore\n // Always call useSyncExternalStore to maintain consistent hook order\n return useSyncExternalStore(\n view?.subscribeReactInternals ?? disabledSubscriber,\n view?.getSnapshot ??\n (getDisabledSnapshot as () => MaybeQueryResult<TReturn>),\n view?.getSnapshot ??\n (getDisabledSnapshot as () => MaybeQueryResult<TReturn>),\n );\n}\n\n// Overload 1: Query\nexport function useSuspenseQuery<\n TTable extends keyof TSchema['tables'] & string,\n TInput extends ReadonlyJSONValue | undefined,\n TOutput extends ReadonlyJSONValue | undefined,\n TSchema extends BaseDefaultSchema = DefaultSchema,\n TReturn = PullRow<TTable, TSchema>,\n TContext extends BaseDefaultContext = DefaultContext,\n>(\n query: QueryOrQueryRequest<\n TTable,\n TInput,\n TOutput,\n TSchema,\n TReturn,\n TContext\n >,\n options?: UseSuspenseQueryOptions | boolean,\n): QueryResult<TReturn>;\n\n// Overload 2: Maybe query\nexport function useSuspenseQuery<\n TTable extends keyof TSchema['tables'] & string,\n TInput extends ReadonlyJSONValue | undefined,\n TOutput extends ReadonlyJSONValue | undefined,\n TSchema extends BaseDefaultSchema = DefaultSchema,\n TReturn = PullRow<TTable, TSchema>,\n TContext extends BaseDefaultContext = DefaultContext,\n>(\n query:\n | QueryOrQueryRequest<TTable, TInput, TOutput, TSchema, TReturn, TContext>\n | Falsy,\n options?: UseSuspenseQueryOptions | boolean,\n): MaybeQueryResult<TReturn>;\n\n// Implementation\nexport function useSuspenseQuery<\n TTable extends keyof TSchema['tables'] & string,\n TInput extends ReadonlyJSONValue | undefined,\n TOutput extends ReadonlyJSONValue | undefined,\n TSchema extends BaseDefaultSchema = DefaultSchema,\n TReturn = PullRow<TTable, TSchema>,\n TContext extends BaseDefaultContext = DefaultContext,\n>(\n query:\n | QueryOrQueryRequest<TTable, TInput, TOutput, TSchema, TReturn, TContext>\n | Falsy,\n options?: UseSuspenseQueryOptions | boolean,\n): QueryResult<TReturn> | MaybeQueryResult<TReturn> {\n let enabled = true;\n let ttl: TTL = DEFAULT_TTL_MS;\n let suspendUntil: 'complete' | 'partial' = 'partial';\n if (typeof options === 'boolean') {\n enabled = options;\n } else if (options) {\n ({\n enabled = true,\n ttl = DEFAULT_TTL_MS,\n suspendUntil = 'partial',\n } = options);\n }\n\n const zero = useZero<TSchema, undefined, TContext>();\n\n // When query is falsy, use disabled subscriber/snapshot to maintain hook order\n const q = useStableQuery(query, zero);\n const view = q ? viewStore.getView(zero, q, enabled, ttl) : undefined;\n\n // https://react.dev/reference/react/useSyncExternalStore\n // Always call useSyncExternalStore to maintain consistent hook order\n const snapshot = useSyncExternalStore(\n view?.subscribeReactInternals ?? disabledSubscriber,\n view?.getSnapshot ??\n (getDisabledSnapshot as () => MaybeQueryResult<TReturn>),\n view?.getSnapshot ??\n (getDisabledSnapshot as () => MaybeQueryResult<TReturn>),\n );\n\n if (view && enabled) {\n if (suspendUntil === 'complete' && !view.complete) {\n suspend(view.waitForComplete());\n }\n\n if (suspendUntil === 'partial' && !view.nonEmpty) {\n suspend(view.waitForNonEmpty());\n }\n }\n\n return snapshot;\n}\n\nconst emptyArray: unknown[] = [];\nconst disabledSubscriber = () => () => {};\n\nconst resultTypeUnknown = {type: 'unknown'} as const;\nconst resultTypeCached = {type: 'cached'} as const;\nconst resultTypeComplete = {type: 'complete'} as const;\nconst resultTypeError = {type: 'error'} as const;\n\nconst disabledQuerySnapshot = [undefined, resultTypeUnknown] as const;\nconst getDisabledSnapshot = () => disabledQuerySnapshot;\n\nconst emptySnapshotSingularUnknown = [undefined, resultTypeUnknown] as const;\nconst emptySnapshotSingularCached = [undefined, resultTypeCached] as const;\nconst emptySnapshotSingularComplete = [undefined, resultTypeComplete] as const;\nconst emptySnapshotSingularErrorUnknown = [undefined, resultTypeError] as const;\nconst emptySnapshotPluralUnknown = [emptyArray, resultTypeUnknown] as const;\nconst emptySnapshotPluralCached = [emptyArray, resultTypeCached] as const;\nconst emptySnapshotPluralComplete = [emptyArray, resultTypeComplete] as const;\nconst emptySnapshotErrorUnknown = [emptyArray, resultTypeError] as const;\n\nfunction getDefaultSnapshot<TReturn>(singular: boolean): QueryResult<TReturn> {\n return (\n singular ? emptySnapshotSingularUnknown : emptySnapshotPluralUnknown\n ) as QueryResult<TReturn>;\n}\n\n/**\n * Returns a new snapshot or one of the empty predefined ones. Returning the\n * predefined ones is important to prevent unnecessary re-renders in React.\n */\nfunction getSnapshot<TReturn>(\n singular: boolean,\n data: HumanReadable<TReturn>,\n resultType: ResultType,\n retryFn: () => void,\n error?: ErroredQuery,\n): QueryResult<TReturn> {\n if (singular && data === undefined) {\n switch (resultType) {\n case 'error':\n if (error) {\n return [\n undefined,\n makeError(retryFn, error),\n ] as unknown as QueryResult<TReturn>;\n }\n return emptySnapshotSingularErrorUnknown as unknown as QueryResult<TReturn>;\n case 'complete':\n return emptySnapshotSingularComplete as unknown as QueryResult<TReturn>;\n case 'unknown':\n return emptySnapshotSingularUnknown as unknown as QueryResult<TReturn>;\n case 'cached':\n return emptySnapshotSingularCached as unknown as QueryResult<TReturn>;\n }\n }\n\n if (!singular && (data as unknown[]).length === 0) {\n switch (resultType) {\n case 'error':\n if (error) {\n return [\n emptyArray,\n makeError(retryFn, error),\n ] as unknown as QueryResult<TReturn>;\n }\n return emptySnapshotErrorUnknown as unknown as QueryResult<TReturn>;\n case 'complete':\n return emptySnapshotPluralComplete as unknown as QueryResult<TReturn>;\n case 'unknown':\n return emptySnapshotPluralUnknown as unknown as QueryResult<TReturn>;\n case 'cached':\n return emptySnapshotPluralCached as unknown as QueryResult<TReturn>;\n }\n }\n\n switch (resultType) {\n case 'error':\n if (error) {\n return [data, makeError(retryFn, error)];\n }\n return [\n data,\n makeError(retryFn, {\n error: 'app',\n id: 'unknown',\n name: 'unknown',\n message: 'An unknown error occurred',\n }),\n ];\n case 'complete':\n return [data, resultTypeComplete];\n case 'unknown':\n return [data, resultTypeUnknown];\n case 'cached':\n return [data, resultTypeCached];\n }\n}\n\nfunction makeError(retry: () => void, error: ErroredQuery): QueryErrorDetails {\n const message = error.message ?? 'An unknown error occurred';\n return {\n type: 'error',\n retry,\n refetch: retry,\n error: {\n type: error.error,\n message,\n ...(error.details ? {details: error.details} : {}),\n },\n };\n}\n\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyViewWrapper = ViewWrapper<any, any, any, any, any>;\n\nconst allViews = new WeakMap<\n ViewStore,\n Map<string, Map<string, AnyViewWrapper>>\n>();\n\nexport function getAllViewsSizeForTesting(store: ViewStore): number {\n if (TESTING) {\n let size = 0;\n for (const byHash of allViews.get(store)?.values() ?? []) {\n size += byHash.size;\n }\n return size;\n }\n return 0;\n}\n\n/**\n * A global store of all active views.\n *\n * React subscribes and unsubscribes to these views\n * via `useSyncExternalStore`.\n *\n * Managing views through `useEffect` or `useLayoutEffect` causes\n * inconsistencies because effects run after render.\n *\n * For example, if useQuery used use*Effect in the component below:\n * ```ts\n * function Foo({issueID}) {\n * const issue = useQuery(z.query.issue.where('id', issueID).one());\n * if (issue?.id !== undefined && issue.id !== issueID) {\n * console.log('MISMATCH!', issue.id, issueID);\n * }\n * }\n * ```\n *\n * `MISMATCH` will be printed whenever the `issueID` prop changes.\n *\n * This is because the component will render once with\n * the old state returned from `useQuery`. Then the effect inside\n * `useQuery` will run. The component will render again with the new\n * state. This inconsistent transition can cause unexpected results.\n *\n * Emulating `useEffect` via `useState` and `if` causes resource leaks.\n * That is:\n *\n * ```ts\n * function useQuery(q) {\n * const [oldHash, setOldHash] = useState();\n * if (hash(q) !== oldHash) {\n * // make new view\n * }\n *\n * useEffect(() => {\n * return () => view.destroy();\n * }, []);\n * }\n * ```\n *\n * I'm not sure why but in strict mode the cleanup function\n * fails to be called for the first instance of the view and only\n * cleans up later instances.\n *\n * Swapping `useState` to `useRef` has similar problems.\n */\nexport class ViewStore {\n /**\n * Client id, then query hash.\n *\n * Nested rather than keyed by the two joined together, because this is\n * looked up on every render of every `useQuery`. Joining them builds a\n * string that V8 has to hash from scratch, where both halves on their own\n * are strings it has already hashed and cached -- `hash()` is memoized on an\n * interned query, so the same string comes back each render. Measured over a\n * rebuild-and-look-up of one chain, that is the difference between 202ns and\n * 123ns; the join cost more than rebuilding and hashing the whole query.\n */\n #views = new Map<string, Map<string, AnyViewWrapper>>();\n\n constructor() {\n if (TESTING) {\n allViews.set(this, this.#views);\n }\n }\n\n getView<\n TTable extends keyof TSchema['tables'] & string,\n TSchema extends BaseDefaultSchema,\n TReturn,\n MD extends CustomMutatorDefs | undefined,\n TContext extends BaseDefaultContext,\n >(\n zero: Zero<TSchema, MD, TContext>,\n q: Query<TTable, TSchema, TReturn>,\n enabled: boolean,\n ttl: TTL,\n ): {\n getSnapshot: () => QueryResult<TReturn>;\n subscribeReactInternals: (internals: () => void) => () => void;\n updateTTL: (ttl: TTL) => void;\n waitForComplete: () => Promise<void>;\n waitForNonEmpty: () => Promise<void>;\n complete: boolean;\n nonEmpty: boolean;\n } {\n const qi = asQueryInternals(q);\n\n if (!enabled) {\n return {\n getSnapshot: () => getDefaultSnapshot(qi.format.singular),\n subscribeReactInternals: disabledSubscriber,\n updateTTL: () => {},\n waitForComplete: () => Promise.resolve(),\n waitForNonEmpty: () => Promise.resolve(),\n complete: false,\n nonEmpty: false,\n };\n }\n\n const {clientID} = zero;\n const hash = qi.hash();\n let byHash = this.#views.get(clientID);\n let existing = byHash?.get(hash);\n if (!existing) {\n existing = new ViewWrapper(q, zero, ttl, view => {\n const views = this.#views.get(clientID);\n const currentView = views?.get(hash);\n if (currentView && currentView !== view) {\n // we replaced the view with a new one already.\n return;\n }\n views?.delete(hash);\n if (views?.size === 0) {\n // Nothing is left for this client, so drop its map rather than\n // keeping one per client id the page has ever seen.\n this.#views.delete(clientID);\n }\n });\n if (!byHash) {\n byHash = new Map();\n this.#views.set(clientID, byHash);\n }\n byHash.set(hash, existing);\n } else {\n existing.updateTTL(ttl);\n }\n return existing as ViewWrapper<TTable, TSchema, TReturn, MD, TContext>;\n }\n}\n\nconst viewStore = new ViewStore();\n\n/**\n * This wraps and ref counts a view.\n *\n * The only signal we have from React as to whether or not it is\n * done with a view is when it calls `unsubscribe`.\n *\n * In non-strict-mode we can clean up the view as soon\n * as the listener count goes to 0.\n *\n * In strict-mode, the listener count will go to 0 then a\n * new listener for the same view is immediately added back.\n *\n * This is why the `onMaterialized` and `onDematerialized` callbacks exist --\n * they allow a view which React is still referencing to be added\n * back into the store when React re-subscribes to it.\n *\n * This wrapper also exists to deal with the various\n * `useSyncExternalStore` caveats that cause excessive\n * re-renders and materializations.\n *\n * See: https://react.dev/reference/react/useSyncExternalStore#caveats\n * Especially:\n * 1. The store snapshot returned by getSnapshot must be immutable. If the underlying store has mutable data, return a new immutable snapshot if the data has changed. Otherwise, return a cached last snapshot.\n * 2. If a different subscribe function is passed during a re-render, React will re-subscribe to the store using the newly passed subscribe function. You can prevent this by declaring subscribe outside the component.\n */\nclass ViewWrapper<\n TTable extends keyof TSchema['tables'] & string,\n TSchema extends BaseDefaultSchema,\n TReturn,\n MD extends AnyMutatorRegistry | CustomMutatorDefs | undefined,\n TContext extends BaseDefaultContext,\n> {\n #view: TypedView<HumanReadable<TReturn>> | undefined;\n readonly #onDematerialized;\n readonly #query: Query<TTable, TSchema, TReturn>;\n #snapshot: QueryResult<TReturn>;\n readonly #reactInternals: Set<() => void> = new Set();\n #ttl: TTL;\n #complete = false;\n #completeResolver = resolver<void>();\n #nonEmpty = false;\n #nonEmptyResolver = resolver<void>();\n readonly #zero: Pick<Zero<TSchema, undefined, TContext>, 'materialize'>;\n readonly #singular: boolean;\n #destroyTimer: ReturnType<typeof setTimeout> | undefined;\n\n // Inputs of the previous #onData call. When a view flush delivers\n // reference-identical data with the same resultType and error, the previous\n // snapshot tuple is kept and React is not notified — building a fresh tuple\n // would defeat useSyncExternalStore's Object.is bailout and re-render every\n // subscriber with identical data. #lastResultType doubles as the \"has fired\n // before\" sentinel (data and error may both legitimately be undefined).\n #lastData: Immutable<HumanReadable<TReturn>> | undefined;\n #lastResultType: ResultType | undefined;\n #lastError: ErroredQuery | undefined;\n\n constructor(\n query: Query<TTable, TSchema, TReturn>,\n zero: Pick<Zero<TSchema, undefined, TContext>, 'materialize'>,\n ttl: TTL,\n onDematerialized: (\n view: ViewWrapper<TTable, TSchema, TReturn, MD, TContext>,\n ) => void,\n ) {\n this.#query = query;\n this.#zero = zero;\n this.#ttl = ttl;\n this.#onDematerialized = onDematerialized;\n const {singular} = asQueryInternals(query).format;\n this.#singular = singular;\n this.#snapshot = getDefaultSnapshot(singular);\n this.#materializeIfNeeded();\n }\n\n #onData = (\n snap: Immutable<HumanReadable<TReturn>>,\n resultType: ResultType,\n error?: ErroredQuery,\n ) => {\n const wasCached = this.#snapshot[1].type === 'cached';\n const changed =\n this.#lastResultType === undefined ||\n this.#lastData !== snap ||\n this.#lastResultType !== resultType ||\n this.#lastError !== error;\n this.#lastData = snap;\n this.#lastResultType = resultType;\n this.#lastError = error;\n\n if (changed) {\n // applyChange now returns immutable data structures, so no deep clone needed.\n // Unchanged rows preserve their object identity for React.memo optimization.\n const data = snap as HumanReadable<TReturn>;\n this.#snapshot = getSnapshot(\n this.#singular,\n data,\n resultType,\n this.#retry,\n error,\n );\n }\n\n // The resolver bookkeeping runs even when unchanged: after a\n // destroy/re-materialize cycle the resolvers are fresh but the new view\n // may deliver the same data/resultType as before the destroy.\n if (resultType === 'complete' || resultType === 'error') {\n this.#complete = true;\n this.#completeResolver.resolve();\n this.#nonEmpty = true;\n this.#nonEmptyResolver.resolve();\n }\n\n const hasData = this.#singular\n ? this.#snapshot[0] !== undefined\n : (this.#snapshot[0] as unknown[]).length !== 0;\n // A 'cached' result is the server-confirmed answer from a previous\n // session, so even an empty one is something to render. It never\n // satisfies `complete`; only a confirmation on this connection does.\n if (resultType === 'cached' || hasData) {\n this.#nonEmpty = true;\n this.#nonEmptyResolver.resolve();\n } else if (wasCached && resultType === 'unknown') {\n // The cached claim was revoked (the got key was evicted before this\n // connection confirmed the query) and the view is empty: there is\n // nothing to render again until rows or a confirmation arrive.\n this.#nonEmpty = false;\n this.#nonEmptyResolver = resolver();\n }\n\n if (changed) {\n for (const internals of this.#reactInternals) {\n internals();\n }\n }\n };\n\n /**\n * Called by the user to force a retry of the query\n * in the case the query errored.\n */\n #retry = () => {\n this.#view?.destroy();\n this.#view = undefined;\n this.#materializeIfNeeded();\n };\n\n #materializeIfNeeded = () => {\n if (this.#view) {\n return;\n }\n this.#view = this.#zero.materialize(this.#query, {\n ttl: this.#ttl,\n });\n this.#view.addListener(this.#onData);\n };\n\n getSnapshot = () => this.#snapshot;\n\n subscribeReactInternals = (internals: () => void): (() => void) => {\n this.#reactInternals.add(internals);\n // Cancel any pending destroy timer from a previous unsubscribe.\n // Without this, rapid unsub/resub cycles accumulate stale timers\n // that can fire during a gap between unsubscribe and resubscribe,\n // destroying the view even though it was actively used.\n if (this.#destroyTimer !== undefined) {\n clearTimeout(this.#destroyTimer);\n this.#destroyTimer = undefined;\n }\n this.#materializeIfNeeded();\n return () => {\n this.#reactInternals.delete(internals);\n\n // only schedule a cleanup task if we have no listeners left\n if (this.#reactInternals.size === 0) {\n this.#destroyTimer = setTimeout(() => {\n this.#destroyTimer = undefined;\n\n // We already destroyed the view\n if (this.#view === undefined) {\n return;\n }\n\n // Someone re-registered a listener on this view before the timeout elapsed.\n // This happens often in strict-mode which forces a component\n // to mount, unmount, remount.\n if (this.#reactInternals.size > 0) {\n return;\n }\n\n this.#view.destroy();\n this.#view = undefined;\n this.#complete = false;\n this.#completeResolver = resolver();\n this.#nonEmpty = false;\n this.#nonEmptyResolver = resolver();\n this.#onDematerialized(this);\n }, 10);\n }\n };\n };\n\n updateTTL(ttl: TTL): void {\n // `getView` calls this on every render, and forwarding an unchanged TTL\n // reaches the query manager, which re-derives the query's id from its AST\n // to find the entry. Nothing downstream distinguishes a repeat, so skip\n // it. A change in how the same duration is spelled ('60s' vs 60000) is\n // still a change here and still propagates, as it did before.\n if (this.#ttl === ttl) {\n return;\n }\n this.#ttl = ttl;\n this.#view?.updateTTL(ttl);\n }\n\n get complete() {\n return this.#complete;\n }\n\n waitForComplete(): Promise<void> {\n return this.#completeResolver.promise;\n }\n\n get nonEmpty() {\n return this.#nonEmpty;\n }\n\n waitForNonEmpty(): Promise<void> {\n return this.#nonEmptyResolver.promise;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmEA,SAAS,eAQP,OAGA,MAC6C;CAC7C,MAAM,WAAW,OAAqC,KAAA,CAAS;CAI/D,IAAI,CAAC,OACH;CAGF,MAAM,QAAQ,SAAS;CACvB,IAAI,SAAS,MAAM,SAAS,MAAM;EAChC,IAAI,MAAM,aAAa,OACrB,OAAO,MAAM;EAEf,IACE,WAAW,SACX,MAAM,gBAAgB,MAAM,SAC5B,MAAM,YAAY,KAAK,WACvB,UAAU,MAAM,MAAM,MAAM,IAAI,GAChC;GAGA,MAAM,WAAW;GACjB,OAAO,MAAM;EACf;CACF;CAEA,MAAM,IAAI,kBAAkB,OAAO,KAAK,OAAO;CAC/C,MAAM,YAAY,WAAW;CAC7B,SAAS,UAAU;EACX;EACN,SAAS,KAAK;EACd,UAAU;EACV,aAAa,YAAY,MAAM,QAAQ,KAAA;EACvC,MAAM,YAAY,MAAM,OAAO,KAAA;EAC/B;CACF;CACA,OAAO;AACT;AA2CA,IAAM,WAAY,MAAgD;AAClE,IAAM,UAAyC,WAC3C,YACA,MAAK;CACH,MAAM;AACR;AAsCJ,SA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AQ,KAAA;EACb,KAAK,qBAAqB;CAC5B;CAEA,6BAA6B;EAC3B,IAAI,KAAK,OACP;EAEF,KAAK,QAAQ,KAAK,MAAM,YAAY,KAAK,QAAQ,EAC/C,KAAK,KAAK,KACZ,CAAC;EACD,KAAK,MAAM,YAAY,KAAK,OAAO;CACrC;CAEA,oBAAoB,KAAK;CAEzB,2BAA2B,cAAwC;EACjE,KAAK,gBAAgB,IAAI,SAAS;EAKlC,IAAI,KAAK,kBAAkB,KAAA,GAAW;GACpC,aAAa,KAAK,aAAa;GAC/B,KAAK,gBAAgB,KAAA;EACvB;EACA,KAAK,qBAAqB;EAC1B,aAAa;GACX,KAAK,gBAAgB,OAAO,SAAS;GAGrC,IAAI,KAAK,gBAAgB,SAAS,GAChC,KAAK,gBAAgB,iBAAiB;IACpC,KAAK,gBAAgB,KAAA;IAGrB,IAAI,KAAK,UAAU,KAAA,GACjB;IAMF,IAAI,KAAK,gBAAgB,OAAO,GAC9B;IAGF,KAAK,MAAM,QAAQ;IACnB,KAAK,QAAQ,KAAA;IACb,KAAK,YAAY;IACjB,KAAK,oBAAoB,SAAS;IAClC,KAAK,YAAY;IACjB,KAAK,oBAAoB,SAAS;IAClC,KAAK,kBAAkB,IAAI;GAC7B,GAAG,EAAE;EAET;CACF;CAEA,UAAU,KAAgB;EAMxB,IAAI,KAAK,SAAS,KAChB;EAEF,KAAK,OAAO;EACZ,KAAK,OAAO,UAAU,GAAG;CAC3B;CAEA,IAAI,WAAW;EACb,OAAO,KAAK;CACd;CAEA,kBAAiC;EAC/B,OAAO,KAAK,kBAAkB;CAChC;CAEA,IAAI,WAAW;EACb,OAAO,KAAK;CACd;CAEA,kBAAiC;EAC/B,OAAO,KAAK,kBAAkB;CAChC;AACF"}
1
+ {"version":3,"file":"use-query.js","names":[],"sources":["../../../../zero-react/src/use-query.tsx"],"sourcesContent":["import React, {useRef, useSyncExternalStore} from 'react';\nimport {deepEqual} from '../../shared/src/json.ts';\nimport {resolver} from '../../shared/src/resolver.ts';\nimport {TESTING} from '../../shared/src/testing.ts';\nimport {\n type Immutable,\n addContextToQuery,\n asQueryInternals,\n DEFAULT_TTL_MS,\n} from './bindings.ts';\nimport {useZero} from './zero-provider.tsx';\nimport type {\n AnyMutatorRegistry,\n BaseDefaultContext,\n BaseDefaultSchema,\n CustomMutatorDefs,\n DefaultContext,\n DefaultSchema,\n ErroredQuery,\n Falsy,\n HumanReadable,\n PullRow,\n Query,\n QueryErrorDetails,\n QueryOrQueryRequest,\n QueryResultDetails,\n ReadonlyJSONValue,\n ResultType,\n TTL,\n TypedView,\n Zero,\n} from './zero.ts';\n\ntype StableQueryCache = {\n zero: unknown;\n context: unknown;\n /** The last input, so an unchanged one is an identity compare and nothing else. */\n rawQuery: object;\n /** The `CustomQuery` a query request names; undefined for a plain query. */\n customQuery: unknown;\n args: ReadonlyJSONValue | undefined;\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n q: Query<any, any, any>;\n};\n\n/**\n * Resolves a query request against the Zero context, reusing the previous\n * result while the request means the same thing.\n *\n * Interning already makes an unchanged *plain* query come back as the same\n * object, so this is aimed at the query-request form -- `queries.issue({id})`\n * -- where every render allocates a fresh request and `addContextToQuery`\n * re-runs the definition. That costs argument validation (a zod parse of\n * byte-identical args) plus a walk of the builder chain, neither of which\n * interning removes: it makes rebuilding the chain cheap and gives the same\n * object back, but only after the work has been done again.\n *\n * A request resolves to the previous query when it names the same\n * `CustomQuery`, the same context, and deep-equal args. Those are exactly the\n * inputs the definition is allowed to depend on: a named query is re-derived\n * on the server from its name and args, so it has to be a pure function of\n * them, or client and server would build different queries.\n *\n * The ref is written during render. That is safe here because it is a pure\n * cache: an entry is derived only from the inputs, so a StrictMode double\n * render or a discarded concurrent render leaves it valid either way.\n */\nfunction useStableQuery<\n TTable extends keyof TSchema['tables'] & string,\n TInput extends ReadonlyJSONValue | undefined,\n TOutput extends ReadonlyJSONValue | undefined,\n TSchema extends BaseDefaultSchema,\n TReturn,\n TContext extends BaseDefaultContext,\n>(\n query:\n | QueryOrQueryRequest<TTable, TInput, TOutput, TSchema, TReturn, TContext>\n | Falsy,\n zero: Zero<TSchema, undefined, TContext>,\n): Query<TTable, TSchema, TReturn> | undefined {\n const cacheRef = useRef<StableQueryCache | undefined>(undefined);\n\n // Deliberately kept rather than cleared: a query toggled off and back on\n // reuses what it had.\n if (!query) {\n return undefined;\n }\n\n const cache = cacheRef.current;\n if (cache && cache.zero === zero) {\n if (cache.rawQuery === query) {\n return cache.q as Query<TTable, TSchema, TReturn>;\n }\n if (\n 'query' in query &&\n cache.customQuery === query.query &&\n cache.context === zero.context &&\n deepEqual(cache.args, query.args)\n ) {\n // Same meaning, new wrapper object: remember it so the next render is\n // the identity compare above.\n cache.rawQuery = query;\n return cache.q as Query<TTable, TSchema, TReturn>;\n }\n }\n\n const q = addContextToQuery(query, zero.context);\n const isRequest = 'query' in query;\n cacheRef.current = {\n zero: zero,\n context: zero.context,\n rawQuery: query,\n customQuery: isRequest ? query.query : undefined,\n args: isRequest ? query.args : undefined,\n q,\n };\n return q;\n}\n\nexport type QueryResult<TReturn> = readonly [\n HumanReadable<TReturn>,\n QueryResultDetails & {},\n];\n\n/**\n * Result type for \"maybe queries\" - queries that may be falsy.\n * The data value can be undefined when the query is falsy/disabled.\n */\nexport type MaybeQueryResult<TReturn> = readonly [\n HumanReadable<TReturn> | undefined,\n QueryResultDetails & {},\n];\n\nexport type UseQueryOptions = {\n enabled?: boolean | undefined;\n /**\n * Time to live (TTL) in seconds. Controls how long query results are cached\n * after the query is removed. During this time, Zero continues to sync the query.\n * Default is 'never'.\n */\n ttl?: TTL | undefined;\n};\n\nexport type UseSuspenseQueryOptions = UseQueryOptions & {\n /**\n * Whether to suspend until:\n * - 'partial': the query has partial results (partial array or defined\n * value for singular results) which may be of result type 'unknown',\n * or the query result type is 'complete' or 'cached' (in which case\n * results may be empty: a server-confirmed empty answer, from this\n * connection or a previous one, is something to render). This is useful\n * for suspending until there are partial optimistic local results, or\n * the query has completed loading from the server.\n * - 'complete': the query result type is 'complete'.\n *\n * Default is 'partial'.\n */\n suspendUntil?: 'complete' | 'partial';\n};\n\nconst reactUse = (React as {use?: (p: Promise<unknown>) => void}).use;\nconst suspend: (p: Promise<unknown>) => void = reactUse\n ? reactUse\n : p => {\n throw p;\n };\n\n// Overload 1: Query\nexport function useQuery<\n TTable extends keyof TSchema['tables'] & string,\n TInput extends ReadonlyJSONValue | undefined,\n TOutput extends ReadonlyJSONValue | undefined,\n TSchema extends BaseDefaultSchema = DefaultSchema,\n TReturn = PullRow<TTable, TSchema>,\n TContext extends BaseDefaultContext = DefaultContext,\n>(\n query: QueryOrQueryRequest<\n TTable,\n TInput,\n TOutput,\n TSchema,\n TReturn,\n TContext\n >,\n options?: UseQueryOptions | boolean,\n): QueryResult<TReturn>;\n\n// Overload 2: Maybe query\nexport function useQuery<\n TTable extends keyof TSchema['tables'] & string,\n TInput extends ReadonlyJSONValue | undefined,\n TOutput extends ReadonlyJSONValue | undefined,\n TSchema extends BaseDefaultSchema = DefaultSchema,\n TReturn = PullRow<TTable, TSchema>,\n TContext extends BaseDefaultContext = DefaultContext,\n>(\n query:\n | QueryOrQueryRequest<TTable, TInput, TOutput, TSchema, TReturn, TContext>\n | Falsy,\n options?: UseQueryOptions | boolean,\n): MaybeQueryResult<TReturn>;\n\n// Implementation\nexport function useQuery<\n TTable extends keyof TSchema['tables'] & string,\n TInput extends ReadonlyJSONValue | undefined,\n TOutput extends ReadonlyJSONValue | undefined,\n TSchema extends BaseDefaultSchema = DefaultSchema,\n TReturn = PullRow<TTable, TSchema>,\n TContext extends BaseDefaultContext = DefaultContext,\n>(\n query:\n | QueryOrQueryRequest<TTable, TInput, TOutput, TSchema, TReturn, TContext>\n | Falsy,\n options?: UseQueryOptions | boolean,\n): QueryResult<TReturn> | MaybeQueryResult<TReturn> {\n let enabled = true;\n let ttl: TTL = DEFAULT_TTL_MS;\n if (typeof options === 'boolean') {\n enabled = options;\n } else if (options) {\n ({enabled = true, ttl = DEFAULT_TTL_MS} = options);\n }\n\n const zero = useZero<TSchema, undefined, TContext>();\n\n // When query is falsy, use disabled subscriber/snapshot to maintain hook order\n const q = useStableQuery(query, zero);\n const view = q ? viewStore.getView(zero, q, enabled, ttl) : undefined;\n\n // https://react.dev/reference/react/useSyncExternalStore\n // Always call useSyncExternalStore to maintain consistent hook order\n return useSyncExternalStore(\n view?.subscribeReactInternals ?? disabledSubscriber,\n view?.getSnapshot ??\n (getDisabledSnapshot as () => MaybeQueryResult<TReturn>),\n view?.getSnapshot ??\n (getDisabledSnapshot as () => MaybeQueryResult<TReturn>),\n );\n}\n\n// Overload 1: Query\nexport function useSuspenseQuery<\n TTable extends keyof TSchema['tables'] & string,\n TInput extends ReadonlyJSONValue | undefined,\n TOutput extends ReadonlyJSONValue | undefined,\n TSchema extends BaseDefaultSchema = DefaultSchema,\n TReturn = PullRow<TTable, TSchema>,\n TContext extends BaseDefaultContext = DefaultContext,\n>(\n query: QueryOrQueryRequest<\n TTable,\n TInput,\n TOutput,\n TSchema,\n TReturn,\n TContext\n >,\n options?: UseSuspenseQueryOptions | boolean,\n): QueryResult<TReturn>;\n\n// Overload 2: Maybe query\nexport function useSuspenseQuery<\n TTable extends keyof TSchema['tables'] & string,\n TInput extends ReadonlyJSONValue | undefined,\n TOutput extends ReadonlyJSONValue | undefined,\n TSchema extends BaseDefaultSchema = DefaultSchema,\n TReturn = PullRow<TTable, TSchema>,\n TContext extends BaseDefaultContext = DefaultContext,\n>(\n query:\n | QueryOrQueryRequest<TTable, TInput, TOutput, TSchema, TReturn, TContext>\n | Falsy,\n options?: UseSuspenseQueryOptions | boolean,\n): MaybeQueryResult<TReturn>;\n\n// Implementation\nexport function useSuspenseQuery<\n TTable extends keyof TSchema['tables'] & string,\n TInput extends ReadonlyJSONValue | undefined,\n TOutput extends ReadonlyJSONValue | undefined,\n TSchema extends BaseDefaultSchema = DefaultSchema,\n TReturn = PullRow<TTable, TSchema>,\n TContext extends BaseDefaultContext = DefaultContext,\n>(\n query:\n | QueryOrQueryRequest<TTable, TInput, TOutput, TSchema, TReturn, TContext>\n | Falsy,\n options?: UseSuspenseQueryOptions | boolean,\n): QueryResult<TReturn> | MaybeQueryResult<TReturn> {\n let enabled = true;\n let ttl: TTL = DEFAULT_TTL_MS;\n let suspendUntil: 'complete' | 'partial' = 'partial';\n if (typeof options === 'boolean') {\n enabled = options;\n } else if (options) {\n ({\n enabled = true,\n ttl = DEFAULT_TTL_MS,\n suspendUntil = 'partial',\n } = options);\n }\n\n const zero = useZero<TSchema, undefined, TContext>();\n\n // When query is falsy, use disabled subscriber/snapshot to maintain hook order\n const q = useStableQuery(query, zero);\n const view = q ? viewStore.getView(zero, q, enabled, ttl) : undefined;\n\n // https://react.dev/reference/react/useSyncExternalStore\n // Always call useSyncExternalStore to maintain consistent hook order\n const snapshot = useSyncExternalStore(\n view?.subscribeReactInternals ?? disabledSubscriber,\n view?.getSnapshot ??\n (getDisabledSnapshot as () => MaybeQueryResult<TReturn>),\n view?.getSnapshot ??\n (getDisabledSnapshot as () => MaybeQueryResult<TReturn>),\n );\n\n if (view && enabled) {\n if (suspendUntil === 'complete' && !view.complete) {\n suspend(view.waitForComplete());\n }\n\n if (suspendUntil === 'partial' && !view.nonEmpty) {\n suspend(view.waitForNonEmpty());\n }\n }\n\n return snapshot;\n}\n\nconst emptyArray: unknown[] = [];\nconst disabledSubscriber = () => () => {};\n\nconst resultTypeUnknown = {type: 'unknown'} as const;\nconst resultTypeCached = {type: 'cached'} as const;\nconst resultTypeComplete = {type: 'complete'} as const;\nconst resultTypeError = {type: 'error'} as const;\n\nconst disabledQuerySnapshot = [undefined, resultTypeUnknown] as const;\nconst getDisabledSnapshot = () => disabledQuerySnapshot;\n\nconst emptySnapshotSingularUnknown = [undefined, resultTypeUnknown] as const;\nconst emptySnapshotSingularCached = [undefined, resultTypeCached] as const;\nconst emptySnapshotSingularComplete = [undefined, resultTypeComplete] as const;\nconst emptySnapshotSingularErrorUnknown = [undefined, resultTypeError] as const;\nconst emptySnapshotPluralUnknown = [emptyArray, resultTypeUnknown] as const;\nconst emptySnapshotPluralCached = [emptyArray, resultTypeCached] as const;\nconst emptySnapshotPluralComplete = [emptyArray, resultTypeComplete] as const;\nconst emptySnapshotErrorUnknown = [emptyArray, resultTypeError] as const;\n\nfunction getDefaultSnapshot<TReturn>(singular: boolean): QueryResult<TReturn> {\n return (\n singular ? emptySnapshotSingularUnknown : emptySnapshotPluralUnknown\n ) as QueryResult<TReturn>;\n}\n\n/**\n * Returns a new snapshot or one of the empty predefined ones. Returning the\n * predefined ones is important to prevent unnecessary re-renders in React.\n */\nfunction getSnapshot<TReturn>(\n singular: boolean,\n data: HumanReadable<TReturn>,\n resultType: ResultType,\n retryFn: () => void,\n error?: ErroredQuery,\n): QueryResult<TReturn> {\n if (singular && data === undefined) {\n switch (resultType) {\n case 'error':\n if (error) {\n return [\n undefined,\n makeError(retryFn, error),\n ] as unknown as QueryResult<TReturn>;\n }\n return emptySnapshotSingularErrorUnknown as unknown as QueryResult<TReturn>;\n case 'complete':\n return emptySnapshotSingularComplete as unknown as QueryResult<TReturn>;\n case 'unknown':\n return emptySnapshotSingularUnknown as unknown as QueryResult<TReturn>;\n case 'cached':\n return emptySnapshotSingularCached as unknown as QueryResult<TReturn>;\n }\n }\n\n if (!singular && (data as unknown[]).length === 0) {\n switch (resultType) {\n case 'error':\n if (error) {\n return [\n emptyArray,\n makeError(retryFn, error),\n ] as unknown as QueryResult<TReturn>;\n }\n return emptySnapshotErrorUnknown as unknown as QueryResult<TReturn>;\n case 'complete':\n return emptySnapshotPluralComplete as unknown as QueryResult<TReturn>;\n case 'unknown':\n return emptySnapshotPluralUnknown as unknown as QueryResult<TReturn>;\n case 'cached':\n return emptySnapshotPluralCached as unknown as QueryResult<TReturn>;\n }\n }\n\n switch (resultType) {\n case 'error':\n if (error) {\n return [data, makeError(retryFn, error)];\n }\n return [\n data,\n makeError(retryFn, {\n error: 'app',\n id: 'unknown',\n name: 'unknown',\n message: 'An unknown error occurred',\n }),\n ];\n case 'complete':\n return [data, resultTypeComplete];\n case 'unknown':\n return [data, resultTypeUnknown];\n case 'cached':\n return [data, resultTypeCached];\n }\n}\n\nfunction makeError(retry: () => void, error: ErroredQuery): QueryErrorDetails {\n const message = error.message ?? 'An unknown error occurred';\n return {\n type: 'error',\n retry,\n refetch: retry,\n error: {\n type: error.error,\n message,\n ...(error.details ? {details: error.details} : {}),\n },\n };\n}\n\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyViewWrapper = ViewWrapper<any, any, any, any, any>;\n\nconst allViews = new WeakMap<\n ViewStore,\n Map<string, Map<string, AnyViewWrapper>>\n>();\n\nexport function getAllViewsSizeForTesting(store: ViewStore): number {\n if (TESTING) {\n let size = 0;\n for (const byHash of allViews.get(store)?.values() ?? []) {\n size += byHash.size;\n }\n return size;\n }\n return 0;\n}\n\n/**\n * A global store of all active views.\n *\n * React subscribes and unsubscribes to these views\n * via `useSyncExternalStore`.\n *\n * Managing views through `useEffect` or `useLayoutEffect` causes\n * inconsistencies because effects run after render.\n *\n * For example, if useQuery used use*Effect in the component below:\n * ```ts\n * function Foo({issueID}) {\n * const issue = useQuery(z.query.issue.where('id', issueID).one());\n * if (issue?.id !== undefined && issue.id !== issueID) {\n * console.log('MISMATCH!', issue.id, issueID);\n * }\n * }\n * ```\n *\n * `MISMATCH` will be printed whenever the `issueID` prop changes.\n *\n * This is because the component will render once with\n * the old state returned from `useQuery`. Then the effect inside\n * `useQuery` will run. The component will render again with the new\n * state. This inconsistent transition can cause unexpected results.\n *\n * Emulating `useEffect` via `useState` and `if` causes resource leaks.\n * That is:\n *\n * ```ts\n * function useQuery(q) {\n * const [oldHash, setOldHash] = useState();\n * if (hash(q) !== oldHash) {\n * // make new view\n * }\n *\n * useEffect(() => {\n * return () => view.destroy();\n * }, []);\n * }\n * ```\n *\n * I'm not sure why but in strict mode the cleanup function\n * fails to be called for the first instance of the view and only\n * cleans up later instances.\n *\n * Swapping `useState` to `useRef` has similar problems.\n */\nexport class ViewStore {\n /**\n * Client id, then query hash.\n *\n * Nested rather than keyed by the two joined together, because this is\n * looked up on every render of every `useQuery`. Joining them builds a\n * string that V8 has to hash from scratch, where both halves on their own\n * are strings it has already hashed and cached -- `hash()` is memoized on an\n * interned query, so the same string comes back each render. Measured over a\n * rebuild-and-look-up of one chain, that is the difference between 202ns and\n * 123ns; the join cost more than rebuilding and hashing the whole query.\n */\n #views = new Map<string, Map<string, AnyViewWrapper>>();\n\n constructor() {\n if (TESTING) {\n allViews.set(this, this.#views);\n }\n }\n\n getView<\n TTable extends keyof TSchema['tables'] & string,\n TSchema extends BaseDefaultSchema,\n TReturn,\n MD extends CustomMutatorDefs | undefined,\n TContext extends BaseDefaultContext,\n >(\n zero: Zero<TSchema, MD, TContext>,\n q: Query<TTable, TSchema, TReturn>,\n enabled: boolean,\n ttl: TTL,\n ): {\n getSnapshot: () => QueryResult<TReturn>;\n subscribeReactInternals: (internals: () => void) => () => void;\n updateTTL: (ttl: TTL) => void;\n waitForComplete: () => Promise<void>;\n waitForNonEmpty: () => Promise<void>;\n complete: boolean;\n nonEmpty: boolean;\n } {\n const qi = asQueryInternals(q);\n\n if (!enabled) {\n return {\n getSnapshot: () => getDefaultSnapshot(qi.format.singular),\n subscribeReactInternals: disabledSubscriber,\n updateTTL: () => {},\n waitForComplete: () => Promise.resolve(),\n waitForNonEmpty: () => Promise.resolve(),\n complete: false,\n nonEmpty: false,\n };\n }\n\n const {clientID} = zero;\n const hash = qi.hash();\n let byHash = this.#views.get(clientID);\n let existing = byHash?.get(hash);\n if (!existing) {\n existing = new ViewWrapper(q, zero, ttl, view => {\n const views = this.#views.get(clientID);\n const currentView = views?.get(hash);\n if (currentView && currentView !== view) {\n // we replaced the view with a new one already.\n return;\n }\n views?.delete(hash);\n if (views?.size === 0) {\n // Nothing is left for this client, so drop its map rather than\n // keeping one per client id the page has ever seen.\n this.#views.delete(clientID);\n }\n });\n if (!byHash) {\n byHash = new Map();\n this.#views.set(clientID, byHash);\n }\n byHash.set(hash, existing);\n } else {\n existing.updateTTL(ttl);\n }\n return existing as ViewWrapper<TTable, TSchema, TReturn, MD, TContext>;\n }\n}\n\nconst viewStore = new ViewStore();\n\n/**\n * This wraps and ref counts a view.\n *\n * The only signal we have from React as to whether or not it is\n * done with a view is when it calls `unsubscribe`.\n *\n * In non-strict-mode we can clean up the view as soon\n * as the listener count goes to 0.\n *\n * In strict-mode, the listener count will go to 0 then a\n * new listener for the same view is immediately added back.\n *\n * This is why the `onMaterialized` and `onDematerialized` callbacks exist --\n * they allow a view which React is still referencing to be added\n * back into the store when React re-subscribes to it.\n *\n * This wrapper also exists to deal with the various\n * `useSyncExternalStore` caveats that cause excessive\n * re-renders and materializations.\n *\n * See: https://react.dev/reference/react/useSyncExternalStore#caveats\n * Especially:\n * 1. The store snapshot returned by getSnapshot must be immutable. If the underlying store has mutable data, return a new immutable snapshot if the data has changed. Otherwise, return a cached last snapshot.\n * 2. If a different subscribe function is passed during a re-render, React will re-subscribe to the store using the newly passed subscribe function. You can prevent this by declaring subscribe outside the component.\n */\nclass ViewWrapper<\n TTable extends keyof TSchema['tables'] & string,\n TSchema extends BaseDefaultSchema,\n TReturn,\n MD extends AnyMutatorRegistry | CustomMutatorDefs | undefined,\n TContext extends BaseDefaultContext,\n> {\n #view: TypedView<HumanReadable<TReturn>> | undefined;\n readonly #onDematerialized;\n readonly #query: Query<TTable, TSchema, TReturn>;\n #snapshot: QueryResult<TReturn>;\n readonly #reactInternals: Set<() => void> = new Set();\n #ttl: TTL;\n #complete = false;\n #completeResolver = resolver<void>();\n #nonEmpty = false;\n #nonEmptyResolver = resolver<void>();\n readonly #zero: Pick<Zero<TSchema, undefined, TContext>, 'materialize'>;\n readonly #singular: boolean;\n #destroyTimer: ReturnType<typeof setTimeout> | undefined;\n\n // Inputs of the previous #onData call. When a view flush delivers\n // reference-identical data with the same resultType and error, the previous\n // snapshot tuple is kept and React is not notified — building a fresh tuple\n // would defeat useSyncExternalStore's Object.is bailout and re-render every\n // subscriber with identical data. #lastResultType doubles as the \"has fired\n // before\" sentinel (data and error may both legitimately be undefined).\n #lastData: Immutable<HumanReadable<TReturn>> | undefined;\n #lastResultType: ResultType | undefined;\n #lastError: ErroredQuery | undefined;\n\n constructor(\n query: Query<TTable, TSchema, TReturn>,\n zero: Pick<Zero<TSchema, undefined, TContext>, 'materialize'>,\n ttl: TTL,\n onDematerialized: (\n view: ViewWrapper<TTable, TSchema, TReturn, MD, TContext>,\n ) => void,\n ) {\n this.#query = query;\n this.#zero = zero;\n this.#ttl = ttl;\n this.#onDematerialized = onDematerialized;\n const {singular} = asQueryInternals(query).format;\n this.#singular = singular;\n this.#snapshot = getDefaultSnapshot(singular);\n this.#materializeIfNeeded();\n }\n\n #onData = (\n snap: Immutable<HumanReadable<TReturn>>,\n resultType: ResultType,\n error?: ErroredQuery,\n ) => {\n const wasCached = this.#snapshot[1].type === 'cached';\n const changed =\n this.#lastResultType === undefined ||\n this.#lastData !== snap ||\n this.#lastResultType !== resultType ||\n this.#lastError !== error;\n this.#lastData = snap;\n this.#lastResultType = resultType;\n this.#lastError = error;\n\n if (changed) {\n // applyChange now returns immutable data structures, so no deep clone needed.\n // Unchanged rows preserve their object identity for React.memo optimization.\n const data = snap as HumanReadable<TReturn>;\n this.#snapshot = getSnapshot(\n this.#singular,\n data,\n resultType,\n this.#retry,\n error,\n );\n }\n\n // The resolver bookkeeping runs even when unchanged: after a\n // destroy/re-materialize cycle the resolvers are fresh but the new view\n // may deliver the same data/resultType as before the destroy.\n if (resultType === 'complete' || resultType === 'error') {\n this.#complete = true;\n this.#completeResolver.resolve();\n this.#nonEmpty = true;\n this.#nonEmptyResolver.resolve();\n }\n\n const hasData = this.#singular\n ? this.#snapshot[0] !== undefined\n : (this.#snapshot[0] as unknown[]).length !== 0;\n // A 'cached' result is the server-confirmed answer from a previous\n // session, so even an empty one is something to render. It never\n // satisfies `complete`; only a confirmation on this connection does.\n if (resultType === 'cached' || hasData) {\n this.#nonEmpty = true;\n this.#nonEmptyResolver.resolve();\n } else if (wasCached && resultType === 'unknown') {\n // The cached claim was revoked (the got key was evicted before this\n // connection confirmed the query) and the view is empty: there is\n // nothing to render again until rows or a confirmation arrive.\n this.#nonEmpty = false;\n this.#nonEmptyResolver = resolver();\n }\n\n if (changed) {\n for (const internals of this.#reactInternals) {\n internals();\n }\n }\n };\n\n /**\n * Called by the user to force a retry of the query\n * in the case the query errored.\n */\n #retry = () => {\n this.#view?.destroy();\n this.#view = undefined;\n this.#materializeIfNeeded();\n };\n\n #materializeIfNeeded = () => {\n if (this.#view) {\n return;\n }\n this.#view = this.#zero.materialize(this.#query, {\n ttl: this.#ttl,\n });\n this.#view.addListener(this.#onData);\n };\n\n getSnapshot = () => this.#snapshot;\n\n subscribeReactInternals = (internals: () => void): (() => void) => {\n this.#reactInternals.add(internals);\n // Cancel any pending destroy timer from a previous unsubscribe.\n // Without this, rapid unsub/resub cycles accumulate stale timers\n // that can fire during a gap between unsubscribe and resubscribe,\n // destroying the view even though it was actively used.\n if (this.#destroyTimer !== undefined) {\n clearTimeout(this.#destroyTimer);\n this.#destroyTimer = undefined;\n }\n this.#materializeIfNeeded();\n return () => {\n this.#reactInternals.delete(internals);\n\n // only schedule a cleanup task if we have no listeners left\n if (this.#reactInternals.size === 0) {\n this.#destroyTimer = setTimeout(() => {\n this.#destroyTimer = undefined;\n\n // We already destroyed the view\n if (this.#view === undefined) {\n return;\n }\n\n // Someone re-registered a listener on this view before the timeout elapsed.\n // This happens often in strict-mode which forces a component\n // to mount, unmount, remount.\n if (this.#reactInternals.size > 0) {\n return;\n }\n\n this.#view.destroy();\n this.#view = undefined;\n this.#complete = false;\n this.#completeResolver = resolver();\n this.#nonEmpty = false;\n this.#nonEmptyResolver = resolver();\n this.#onDematerialized(this);\n }, 10);\n }\n };\n };\n\n updateTTL(ttl: TTL): void {\n // `getView` calls this on every render, and forwarding an unchanged TTL\n // reaches the query manager, which re-derives the query's id from its AST\n // to find the entry. Nothing downstream distinguishes a repeat, so skip\n // it. A change in how the same duration is spelled ('60s' vs 60000) is\n // still a change here and still propagates, as it did before.\n if (this.#ttl === ttl) {\n return;\n }\n this.#ttl = ttl;\n this.#view?.updateTTL(ttl);\n }\n\n get complete() {\n return this.#complete;\n }\n\n waitForComplete(): Promise<void> {\n return this.#completeResolver.promise;\n }\n\n get nonEmpty() {\n return this.#nonEmpty;\n }\n\n waitForNonEmpty(): Promise<void> {\n return this.#nonEmptyResolver.promise;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmEA,SAAS,eAQP,OAGA,MAC6C;CAC7C,MAAM,WAAW,OAAqC,KAAA,CAAS;CAI/D,IAAI,CAAC,OACH;CAGF,MAAM,QAAQ,SAAS;CACvB,IAAI,SAAS,MAAM,SAAS,MAAM;EAChC,IAAI,MAAM,aAAa,OACrB,OAAO,MAAM;EAEf,IACE,WAAW,SACX,MAAM,gBAAgB,MAAM,SAC5B,MAAM,YAAY,KAAK,WACvB,UAAU,MAAM,MAAM,MAAM,IAAI,GAChC;GAGA,MAAM,WAAW;GACjB,OAAO,MAAM;EACf;CACF;CAEA,MAAM,IAAI,kBAAkB,OAAO,KAAK,OAAO;CAC/C,MAAM,YAAY,WAAW;CAC7B,SAAS,UAAU;EACX;EACN,SAAS,KAAK;EACd,UAAU;EACV,aAAa,YAAY,MAAM,QAAQ,KAAA;EACvC,MAAM,YAAY,MAAM,OAAO,KAAA;EAC/B;CACF;CACA,OAAO;AACT;AA2CA,IAAM,WAAY,MAAgD;AAClE,IAAM,UAAyC,WAC3C,YACA,MAAK;CACH,MAAM;AACR;AAsCJ,SAAgB,SAQd,OAGA,SACkD;CAClD,IAAI,UAAU;CACd,IAAI,MAAW;CACf,IAAI,OAAO,YAAY,WACrB,UAAU;MACL,IAAI,SACT,CAAC,CAAC,UAAU,MAAM,MAAM,kBAAkB;CAG5C,MAAM,OAAO,QAAsC;CAGnD,MAAM,IAAI,eAAe,OAAO,IA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AAoB,KAAK;CAEzB,2BAA2B,cAAwC;EACjE,KAAK,gBAAgB,IAAI,SAAS;EAKlC,IAAI,KAAK,kBAAkB,KAAA,GAAW;GACpC,aAAa,KAAK,aAAa;GAC/B,KAAK,gBAAgB,KAAA;EACvB;EACA,KAAK,qBAAqB;EAC1B,aAAa;GACX,KAAK,gBAAgB,OAAO,SAAS;GAGrC,IAAI,KAAK,gBAAgB,SAAS,GAChC,KAAK,gBAAgB,iBAAiB;IACpC,KAAK,gBAAgB,KAAA;IAGrB,IAAI,KAAK,UAAU,KAAA,GACjB;IAMF,IAAI,KAAK,gBAAgB,OAAO,GAC9B;IAGF,KAAK,MAAM,QAAQ;IACnB,KAAK,QAAQ,KAAA;IACb,KAAK,YAAY;IACjB,KAAK,oBAAoB,SAAS;IAClC,KAAK,YAAY;IACjB,KAAK,oBAAoB,SAAS;IAClC,KAAK,kBAAkB,IAAI;GAC7B,GAAG,EAAE;EAET;CACF;CAEA,UAAU,KAAgB;EAMxB,IAAI,KAAK,SAAS,KAChB;EAEF,KAAK,OAAO;EACZ,KAAK,OAAO,UAAU,GAAG;CAC3B;CAEA,IAAI,WAAW;EACb,OAAO,KAAK;CACd;CAEA,kBAAiC;EAC/B,OAAO,KAAK,kBAAkB;CAChC;CAEA,IAAI,WAAW;EACb,OAAO,KAAK;CACd;CAEA,kBAAiC;EAC/B,OAAO,KAAK,kBAAkB;CAChC;AACF"}
@@ -17,8 +17,6 @@ type OneConnection<TSourceField, TDestField, TDest extends TableSchema> = {
17
17
  readonly destSchema: TDest['name'];
18
18
  readonly cardinality: 'one';
19
19
  };
20
- type Prev = [-1, 0, 1, 2, 3, 4, 5, 6];
21
- export type PreviousSchema<TSource extends TableSchema, K extends number, TDests extends TableSchema[]> = K extends 0 ? TSource : TDests[Prev[K]];
22
20
  export type Relationships = {
23
21
  name: string;
24
22
  relationships: Record<string, Relationship>;
@@ -1 +1 @@
1
- {"version":3,"file":"relationship-builder.d.ts","sourceRoot":"","sources":["../../../../../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CAAC,GAAG,MAAM,CAAC,EAAE,EACpD,aAAa,CACd,EACD,SAAS,EAAE,UAAU,CACnB,SAAS,CAAC,MAAM,aAAa,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,EAAE,EACpD,SAAS,CAAC,MAAM,KAAK,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,EAAE,EAC5C,KAAK,CACN,GACA;QACD,aAAa,CACX,SAAS,CAAC,MAAM,OAAO,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,EAAE,EAC9C,SAAS,CAAC,MAAM,aAAa,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,EAAE,EACpD,aAAa,CACd;QACD,aAAa,CACX,SAAS,CAAC,MAAM,aAAa,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,EAAE,EACpD,SAAS,CAAC,MAAM,KAAK,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,EAAE,EAC5C,KAAK,CACN;KACF,CAAC;CACH,CAAC;AAEF,wBAAgB,aAAa,CAC3B,OAAO,SAAS,WAAW,EAC3B,cAAc,SAAS,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,EAEnD,KAAK,EAAE,uBAAuB,CAAC,OAAO,CAAC,EACvC,EAAE,EAAE,CAAC,QAAQ,EAAE;IACb,IAAI,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IAC7B,GAAG,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;CAC5B,KAAK,cAAc,GACnB;IAAC,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAAC,aAAa,EAAE,cAAc,CAAA;CAAC,CAUxD"}
@@ -1 +1 @@
1
- {"version":3,"file":"relationship-builder.js","names":[],"sources":["../../../../../zero-schema/src/builder/relationship-builder.ts"],"sourcesContent":["/* oxlint-disable @typescript-eslint/no-explicit-any */\nimport {mapValues} from '../../../shared/src/objects.ts';\nimport type {Relationship, TableSchema} from '../table-schema.ts';\nimport type {TableBuilderWithColumns} from './table-builder.ts';\n\ntype ConnectArg<TSourceField, TDestField, TDest extends TableSchema> = {\n readonly sourceField: TSourceField;\n readonly destField: TDestField;\n readonly destSchema: TableBuilderWithColumns<TDest>;\n};\n\ntype ManyConnection<TSourceField, TDestField, TDest extends TableSchema> = {\n readonly sourceField: TSourceField;\n readonly destField: TDestField;\n readonly destSchema: TDest['name'];\n readonly cardinality: 'many';\n};\n\ntype OneConnection<TSourceField, TDestField, TDest extends TableSchema> = {\n readonly sourceField: TSourceField;\n readonly destField: TDestField;\n readonly destSchema: TDest['name'];\n readonly cardinality: 'one';\n};\n\ntype Prev = [-1, 0, 1, 2, 3, 4, 5, 6];\n\nexport type PreviousSchema<\n TSource extends TableSchema,\n K extends number,\n TDests extends TableSchema[],\n> = K extends 0 ? TSource : TDests[Prev[K]];\n\nexport type Relationships = {\n name: string; // table name\n relationships: Record<string, Relationship>; // relationships for that table\n};\n\n// Overloaded types for better inference\ntype ManyConnector<TSource extends TableSchema> = {\n // Single direct relationship\n <TDest extends TableSchema>(\n arg: ConnectArg<\n readonly (keyof TSource['columns'] & string)[],\n readonly (keyof TDest['columns'] & string)[],\n TDest\n >,\n ): [\n ManyConnection<\n readonly (keyof TSource['columns'] & string)[],\n readonly (keyof TDest['columns'] & string)[],\n TDest\n >,\n ];\n\n // Junction relationship (two hops)\n <TJunction extends TableSchema, TDest extends TableSchema>(\n firstHop: ConnectArg<\n readonly (keyof TSource['columns'] & string)[],\n readonly (keyof TJunction['columns'] & string)[],\n TJunction\n >,\n secondHop: ConnectArg<\n readonly (keyof TJunction['columns'] & string)[],\n readonly (keyof TDest['columns'] & string)[],\n TDest\n >,\n ): [\n ManyConnection<\n readonly (keyof TSource['columns'] & string)[],\n readonly (keyof TJunction['columns'] & string)[],\n TJunction\n >,\n ManyConnection<\n readonly (keyof TJunction['columns'] & string)[],\n readonly (keyof TDest['columns'] & string)[],\n TDest\n >,\n ];\n};\n\ntype OneConnector<TSource extends TableSchema> = {\n // Single direct relationship\n <TDest extends TableSchema>(\n arg: ConnectArg<\n readonly (keyof TSource['columns'] & string)[],\n readonly (keyof TDest['columns'] & string)[],\n TDest\n >,\n ): [\n OneConnection<\n readonly (keyof TSource['columns'] & string)[],\n readonly (keyof TDest['columns'] & string)[],\n TDest\n >,\n ];\n\n // Two-hop relationship (e.g., invoice_line -> invoice -> customer)\n <TIntermediate extends TableSchema, TDest extends TableSchema>(\n firstHop: ConnectArg<\n readonly (keyof TSource['columns'] & string)[],\n readonly (keyof TIntermediate['columns'] & string)[],\n TIntermediate\n >,\n secondHop: ConnectArg<\n readonly (keyof TIntermediate['columns'] & string)[],\n readonly (keyof TDest['columns'] & string)[],\n TDest\n >,\n ): [\n OneConnection<\n readonly (keyof TSource['columns'] & string)[],\n readonly (keyof TIntermediate['columns'] & string)[],\n TIntermediate\n >,\n OneConnection<\n readonly (keyof TIntermediate['columns'] & string)[],\n readonly (keyof TDest['columns'] & string)[],\n TDest\n >,\n ];\n};\n\nexport function relationships<\n TSource extends TableSchema,\n TRelationships extends Record<string, Relationship>,\n>(\n table: TableBuilderWithColumns<TSource>,\n cb: (connects: {\n many: ManyConnector<TSource>;\n one: OneConnector<TSource>;\n }) => TRelationships,\n): {name: TSource['name']; relationships: TRelationships} {\n const relationships = mapValues(\n cb({many, one} as any),\n relationship => relationship,\n );\n\n return {\n name: table.schema.name,\n relationships: relationships as TRelationships,\n };\n}\n\nfunction many(\n ...args: readonly ConnectArg<any, any, TableSchema>[]\n): ManyConnection<any, any, any>[] {\n return args.map(arg => ({\n sourceField: arg.sourceField,\n destField: arg.destField,\n destSchema: arg.destSchema.schema.name,\n cardinality: 'many',\n }));\n}\n\nfunction one(\n ...args: readonly ConnectArg<any, any, TableSchema>[]\n): OneConnection<any, any, any>[] {\n return args.map(arg => ({\n sourceField: arg.sourceField,\n destField: arg.destField,\n destSchema: arg.destSchema.schema.name,\n cardinality: 'one',\n }));\n}\n"],"mappings":";;AA2HA,SAAgB,cAId,OACA,IAIwD;CACxD,MAAM,gBAAgB,UACpB,GAAG;EAAC;EAAM;CAAG,CAAQ,IACrB,iBAAgB,YAClB;CAEA,OAAO;EACL,MAAM,MAAM,OAAO;EACJ;CACjB;AACF;AAEA,SAAS,KACP,GAAG,MAC8B;CACjC,OAAO,KAAK,KAAI,SAAQ;EACtB,aAAa,IAAI;EACjB,WAAW,IAAI;EACf,YAAY,IAAI,WAAW,OAAO;EAClC,aAAa;CACf,EAAE;AACJ;AAEA,SAAS,IACP,GAAG,MAC6B;CAChC,OAAO,KAAK,KAAI,SAAQ;EACtB,aAAa,IAAI;EACjB,WAAW,IAAI;EACf,YAAY,IAAI,WAAW,OAAO;EAClC,aAAa;CACf,EAAE;AACJ"}
1
+ {"version":3,"file":"relationship-builder.js","names":[],"sources":["../../../../../zero-schema/src/builder/relationship-builder.ts"],"sourcesContent":["/* oxlint-disable @typescript-eslint/no-explicit-any */\nimport {mapValues} from '../../../shared/src/objects.ts';\nimport type {Relationship, TableSchema} from '../table-schema.ts';\nimport type {TableBuilderWithColumns} from './table-builder.ts';\n\ntype ConnectArg<TSourceField, TDestField, TDest extends TableSchema> = {\n readonly sourceField: TSourceField;\n readonly destField: TDestField;\n readonly destSchema: TableBuilderWithColumns<TDest>;\n};\n\ntype ManyConnection<TSourceField, TDestField, TDest extends TableSchema> = {\n readonly sourceField: TSourceField;\n readonly destField: TDestField;\n readonly destSchema: TDest['name'];\n readonly cardinality: 'many';\n};\n\ntype OneConnection<TSourceField, TDestField, TDest extends TableSchema> = {\n readonly sourceField: TSourceField;\n readonly destField: TDestField;\n readonly destSchema: TDest['name'];\n readonly cardinality: 'one';\n};\n\nexport type Relationships = {\n name: string; // table name\n relationships: Record<string, Relationship>; // relationships for that table\n};\n\n// Overloaded types for better inference\ntype ManyConnector<TSource extends TableSchema> = {\n // Single direct relationship\n <TDest extends TableSchema>(\n arg: ConnectArg<\n readonly (keyof TSource['columns'] & string)[],\n readonly (keyof TDest['columns'] & string)[],\n TDest\n >,\n ): [\n ManyConnection<\n readonly (keyof TSource['columns'] & string)[],\n readonly (keyof TDest['columns'] & string)[],\n TDest\n >,\n ];\n\n // Junction relationship (two hops)\n <TJunction extends TableSchema, TDest extends TableSchema>(\n firstHop: ConnectArg<\n readonly (keyof TSource['columns'] & string)[],\n readonly (keyof TJunction['columns'] & string)[],\n TJunction\n >,\n secondHop: ConnectArg<\n readonly (keyof TJunction['columns'] & string)[],\n readonly (keyof TDest['columns'] & string)[],\n TDest\n >,\n ): [\n ManyConnection<\n readonly (keyof TSource['columns'] & string)[],\n readonly (keyof TJunction['columns'] & string)[],\n TJunction\n >,\n ManyConnection<\n readonly (keyof TJunction['columns'] & string)[],\n readonly (keyof TDest['columns'] & string)[],\n TDest\n >,\n ];\n};\n\ntype OneConnector<TSource extends TableSchema> = {\n // Single direct relationship\n <TDest extends TableSchema>(\n arg: ConnectArg<\n readonly (keyof TSource['columns'] & string)[],\n readonly (keyof TDest['columns'] & string)[],\n TDest\n >,\n ): [\n OneConnection<\n readonly (keyof TSource['columns'] & string)[],\n readonly (keyof TDest['columns'] & string)[],\n TDest\n >,\n ];\n\n // Two-hop relationship (e.g., invoice_line -> invoice -> customer)\n <TIntermediate extends TableSchema, TDest extends TableSchema>(\n firstHop: ConnectArg<\n readonly (keyof TSource['columns'] & string)[],\n readonly (keyof TIntermediate['columns'] & string)[],\n TIntermediate\n >,\n secondHop: ConnectArg<\n readonly (keyof TIntermediate['columns'] & string)[],\n readonly (keyof TDest['columns'] & string)[],\n TDest\n >,\n ): [\n OneConnection<\n readonly (keyof TSource['columns'] & string)[],\n readonly (keyof TIntermediate['columns'] & string)[],\n TIntermediate\n >,\n OneConnection<\n readonly (keyof TIntermediate['columns'] & string)[],\n readonly (keyof TDest['columns'] & string)[],\n TDest\n >,\n ];\n};\n\nexport function relationships<\n TSource extends TableSchema,\n TRelationships extends Record<string, Relationship>,\n>(\n table: TableBuilderWithColumns<TSource>,\n cb: (connects: {\n many: ManyConnector<TSource>;\n one: OneConnector<TSource>;\n }) => TRelationships,\n): {name: TSource['name']; relationships: TRelationships} {\n const relationships = mapValues(\n cb({many, one} as any),\n relationship => relationship,\n );\n\n return {\n name: table.schema.name,\n relationships: relationships as TRelationships,\n };\n}\n\nfunction many(\n ...args: readonly ConnectArg<any, any, TableSchema>[]\n): ManyConnection<any, any, any>[] {\n return args.map(arg => ({\n sourceField: arg.sourceField,\n destField: arg.destField,\n destSchema: arg.destSchema.schema.name,\n cardinality: 'many',\n }));\n}\n\nfunction one(\n ...args: readonly ConnectArg<any, any, TableSchema>[]\n): OneConnection<any, any, any>[] {\n return args.map(arg => ({\n sourceField: arg.sourceField,\n destField: arg.destField,\n destSchema: arg.destSchema.schema.name,\n cardinality: 'one',\n }));\n}\n"],"mappings":";;AAmHA,SAAgB,cAId,OACA,IAIwD;CACxD,MAAM,gBAAgB,UACpB,GAAG;EAAC;EAAM;CAAG,CAAQ,IACrB,iBAAgB,YAClB;CAEA,OAAO;EACL,MAAM,MAAM,OAAO;EACJ;CACjB;AACF;AAEA,SAAS,KACP,GAAG,MAC8B;CACjC,OAAO,KAAK,KAAI,SAAQ;EACtB,aAAa,IAAI;EACjB,WAAW,IAAI;EACf,YAAY,IAAI,WAAW,OAAO;EAClC,aAAa;CACf,EAAE;AACJ;AAEA,SAAS,IACP,GAAG,MAC6B;CAChC,OAAO,KAAK,KAAI,SAAQ;EACtB,aAAa,IAAI;EACjB,WAAW,IAAI;EACf,YAAY,IAAI,WAAW,OAAO;EAClC,aAAa;CACf,EAAE;AACJ"}
@@ -38,7 +38,7 @@ export declare const column: {
38
38
  json: typeof json;
39
39
  enumeration: typeof enumeration;
40
40
  };
41
- export declare class TableBuilder<TShape extends TableSchema> {
41
+ declare class TableBuilder<TShape extends TableSchema> {
42
42
  #private;
43
43
  constructor(schema: TShape);
44
44
  from<ServerName extends string>(serverName: ServerName): TableBuilder<TShape>;
@@ -1 +1 @@
1
- {"version":3,"file":"table-builder.d.ts","sourceRoot":"","sources":["../../../../../zero-schema/src/builder/table-builder.ts"],"names":[],"mappings":"AA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,qBAAa,uBAAuB,CAAC,MAAM,SAAS,WAAW;;IAG7D,YAAY,MAAM,EAAE,MAAM,EAEzB;IAED,UAAU,CAAC,WAAW,SAAS,CAAC,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,EACxD,GAAG,aAAa,EAAE,WAAW;;OAM9B;IAED;;;;;;;;;;;OAWG;IACH,MAAM,CACJ,KAAK,CAAC,eAAe,SAAS;QAC5B,MAAM,MAAM,CAAC,SAAS,CAAC,GAAG,MAAM;QAChC,GAAG,CAAC,MAAM,MAAM,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,EAAE;KACxC,EAED,GAAG,WAAW,EAAE,eAAe,GAC9B,uBAAuB,CACxB,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG;QAC3B,UAAU,EAAE;YACV,GAAG,CAAC,MAAM,SAAS;gBACjB,UAAU,EAAE,MAAM,SAAS,SAAS,SAAS,UAAU,EAAE,CAAC;aAC3D,GACG,SAAS,GACT,EAAE,CAAC;YACP,eAAe;SAChB,CAAC;KACH,CACF,CAKA;IAED,IAAI,MAAM,WAET;IAED,KAAK,WAoBJ;CACF;AAED,cAAM,aAAa,CAAC,MAAM,SAAS,WAAW,CAAC,GAAG,CAAC;;IAEjD,YAAY,MAAM,EAAE,MAAM,EAEzB;IAED,IAAI,CAAC,UAAU,SAAS,MAAM,EAAE,UAAU,EAAE,UAAU;oBACL,MAAM;OAItD;IAED,QAAQ,IAAI,aAAa,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG;QAAC,QAAQ,EAAE,IAAI,CAAA;KAAC,CAAC,CAKrE;IAED,IAAI,MAAM,WAET;CACF;AAED,YAAY,EAAC,aAAa,EAAC,CAAC"}
1
+ {"version":3,"file":"table-builder.d.ts","sourceRoot":"","sources":["../../../../../zero-schema/src/builder/table-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,6BAA6B,CAAC;AAEnE,OAAO,K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M,EAEzB;IAED,UAAU,CAAC,WAAW,SAAS,CAAC,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,EACxD,GAAG,aAAa,EAAE,WAAW;;OAM9B;IAED;;;;;;;;;;;OAWG;IACH,MAAM,CACJ,KAAK,CAAC,eAAe,SAAS;QAC5B,MAAM,MAAM,CAAC,SAAS,CAAC,GAAG,MAAM;QAChC,GAAG,CAAC,MAAM,MAAM,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,EAAE;KACxC,EAED,GAAG,WAAW,EAAE,eAAe,GAC9B,uBAAuB,CACxB,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG;QAC3B,UAAU,EAAE;YACV,GAAG,CAAC,MAAM,SAAS;gBACjB,UAAU,EAAE,MAAM,SAAS,SAAS,SAAS,UAAU,EAAE,CAAC;aAC3D,GACG,SAAS,GACT,EAAE,CAAC;YACP,eAAe;SAChB,CAAC;KACH,CACF,CAKA;IAED,IAAI,MAAM,WAET;IAED,KAAK,WAoBJ;CACF;AAED,cAAM,aAAa,CAAC,MAAM,SAAS,WAAW,CAAC,GAAG,CAAC;;IAEjD,YAAY,MAAM,EAAE,MAAM,EAEzB;IAED,IAAI,CAAC,UAAU,SAAS,MAAM,EAAE,UAAU,EAAE,UAAU;oBACL,MAAM;OAItD;IAED,QAAQ,IAAI,aAAa,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG;QAAC,QAAQ,EAAE,IAAI,CAAA;KAAC,CAAC,CAKrE;IAED,IAAI,MAAM,WAET;CACF;AAED,YAAY,EAAC,aAAa,EAAC,CAAC"}
@@ -126,6 +126,6 @@ var ColumnBuilder = class ColumnBuilder {
126
126
  }
127
127
  };
128
128
  //#endregion
129
- export { TableBuilder, TableBuilderWithColumns, boolean, enumeration, json, number, string, table };
129
+ export { TableBuilderWithColumns, boolean, enumeration, json, number, string, table };
130
130
 
131
131
  //# sourceMappingURL=table-builder.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"table-builder.js","names":[],"sources":["../../../../../zero-schema/src/builder/table-builder.ts"],"sourcesContent":["import type {ReadonlyJSONValue} from '../../../shared/src/json.ts';\nimport {mapValues} from '../../../shared/src/objects.ts';\nimport type {PrimaryKey} from '../../../zero-protocol/src/primary-key.ts';\nimport type {SchemaValue, TableSchema} from '../table-schema.ts';\n\n/* oxlint-disable @typescript-eslint/no-explicit-any */\nexport function table<TName extends string>(name: TName) {\n return new TableBuilder({\n name,\n columns: {},\n primaryKey: [] as any as PrimaryKey,\n });\n}\n\nexport function string<T extends string = string>() {\n return new ColumnBuilder({\n type: 'string',\n optional: false,\n customType: null as unknown as T,\n });\n}\n\nexport function number<T extends number = number>() {\n return new ColumnBuilder({\n type: 'number',\n optional: false,\n customType: null as unknown as T,\n });\n}\n\nexport function boolean<T extends boolean = boolean>() {\n return new ColumnBuilder({\n type: 'boolean',\n optional: false,\n customType: null as unknown as T,\n });\n}\n\nexport function json<T extends ReadonlyJSONValue = ReadonlyJSONValue>() {\n return new ColumnBuilder({\n type: 'json',\n optional: false,\n customType: null as unknown as T,\n });\n}\n\nexport function enumeration<T extends string>() {\n return new ColumnBuilder({\n type: 'string',\n optional: false,\n customType: null as unknown as T,\n });\n}\n\nexport const column = {\n string,\n number,\n boolean,\n json,\n enumeration,\n};\n\nexport class TableBuilder<TShape extends TableSchema> {\n readonly #schema: TShape;\n constructor(schema: TShape) {\n this.#schema = schema;\n }\n\n from<ServerName extends string>(serverName: ServerName) {\n return new TableBuilder<TShape>({\n ...this.#schema,\n // Strip the \"public.\" schema if specified, as tables in the upstream\n // \"public\" schema are created without the schema prefix on the replica.\n // See liteTableName() in zero-cache/src/types/names.ts\n serverName: serverName.startsWith('public.')\n ? serverName.substring('public.'.length)\n : serverName,\n });\n }\n\n columns<const TColumns extends Record<string, ColumnBuilder<SchemaValue>>>(\n columns: TColumns,\n ): TableBuilderWithColumns<{\n name: TShape['name'];\n columns: {[K in keyof TColumns]: TColumns[K]['schema']};\n primaryKey: TShape['primaryKey'];\n }> {\n const columnSchemas = mapValues(columns, column => column.schema);\n return new TableBuilderWithColumns({\n ...this.#schema,\n columns: columnSchemas,\n }) as any;\n }\n}\n\nexport class TableBuilderWithColumns<TShape extends TableSchema> {\n readonly #schema: TShape;\n\n constructor(schema: TShape) {\n this.#schema = schema;\n }\n\n primaryKey<TPKColNames extends (keyof TShape['columns'])[]>(\n ...pkColumnNames: TPKColNames\n ) {\n return new TableBuilderWithColumns({\n ...this.#schema,\n primaryKey: pkColumnNames,\n });\n }\n\n /**\n * Declares that `columnNames` together are unique — mirroring a unique index\n * that already exists upstream. Call once per index.\n *\n * Zero neither creates nor enforces the constraint; declaring it tells the\n * type checker what the server already knows from the replica, which is what\n * lets a `{scalar: true}` subquery pinned on these columns typecheck.\n *\n * The return type is spelled out so the column names stay literal — spreading\n * the accumulated keys widens them to `PrimaryKey`, which loses exactly the\n * information the check needs.\n */\n unique<\n const TUniqueColNames extends [\n keyof TShape['columns'] & string,\n ...(keyof TShape['columns'] & string)[],\n ],\n >(\n ...columnNames: TUniqueColNames\n ): TableBuilderWithColumns<\n Omit<TShape, 'uniqueKeys'> & {\n uniqueKeys: [\n ...(TShape extends {\n uniqueKeys: infer TExisting extends readonly PrimaryKey[];\n }\n ? TExisting\n : []),\n TUniqueColNames,\n ];\n }\n > {\n return new TableBuilderWithColumns({\n ...this.#schema,\n uniqueKeys: [...(this.#schema.uniqueKeys ?? []), columnNames],\n }) as any;\n }\n\n get schema() {\n return this.#schema;\n }\n\n build() {\n // We can probably get the type system to throw an error if primaryKey is not called\n // before passing the schema to createSchema\n // Till then --\n if (this.#schema.primaryKey.length === 0) {\n throw new Error(`Table \"${this.#schema.name}\" is missing a primary key`);\n }\n const names = new Set<string>();\n for (const [col, {serverName}] of Object.entries(this.#schema.columns)) {\n const name = serverName ?? col;\n if (names.has(name)) {\n throw new Error(\n `Table \"${\n this.#schema.name\n }\" has multiple columns referencing \"${name}\"`,\n );\n }\n names.add(name);\n }\n return this.#schema;\n }\n}\n\nclass ColumnBuilder<TShape extends SchemaValue<any>> {\n readonly #schema: TShape;\n constructor(schema: TShape) {\n this.#schema = schema;\n }\n\n from<ServerName extends string>(serverName: ServerName) {\n return new ColumnBuilder<TShape & {serverName: string}>({\n ...this.#schema,\n serverName,\n });\n }\n\n optional(): ColumnBuilder<Omit<TShape, 'optional'> & {optional: true}> {\n return new ColumnBuilder({\n ...this.#schema,\n optional: true,\n });\n }\n\n get schema() {\n return this.#schema;\n }\n}\n\nexport type {ColumnBuilder};\n"],"mappings":";;AAMA,SAAgB,MAA4B,MAAa;CACvD,OAAO,IAAI,aAAa;EACtB;EACA,SAAS,CAAC;EACV,YAAY,CAAC;CACf,CAAC;AACH;AAEA,SAAgB,SAAoC;CAClD,OAAO,IAAI,cAAc;EACvB,MAAM;EACN,UAAU;EACV,YAAY;CACd,CAAC;AACH;AAEA,SAAgB,SAAoC;CAClD,OAAO,IAAI,cAAc;EACvB,MAAM;EACN,UAAU;EACV,YAAY;CACd,CAAC;AACH;AAEA,SAAgB,UAAuC;CACrD,OAAO,IAAI,cAAc;EACvB,MAAM;EACN,UAAU;EACV,YAAY;CACd,CAAC;AACH;AAEA,SAAgB,OAAwD;CACtE,OAAO,IAAI,cAAc;EACvB,MAAM;EACN,UAAU;EACV,YAAY;CACd,CAAC;AACH;AAEA,SAAgB,cAAgC;CAC9C,OAAO,IAAI,cAAc;EACvB,MAAM;EACN,UAAU;EACV,YAAY;CACd,CAAC;AACH;AAUA,IAAa,eAAb,MAAa,aAAyC;CACpD;CACA,YAAY,QAAgB;EAC1B,KAAK,UAAU;CACjB;CAEA,KAAgC,YAAwB;EACtD,OAAO,IAAI,aAAqB;GAC9B,GAAG,KAAK;GAIR,YAAY,WAAW,WAAW,SAAS,IACvC,WAAW,UAAU,CAAgB,IACrC;EACN,CAAC;CACH;CAEA,QACE,SAKC;EACD,MAAM,gBAAgB,UAAU,UAAS,WAAU,OAAO,MAAM;EAChE,OAAO,IAAI,wBAAwB;GACjC,GAAG,KAAK;GACR,SAAS;EACX,CAAC;CACH;AACF;AAEA,IAAa,0BAAb,MAAa,wBAAoD;CAC/D;CAEA,YAAY,QAAgB;EAC1B,KAAK,UAAU;CACjB;CAEA,WACE,GAAG,eACH;EACA,OAAO,IAAI,wBAAwB;GACjC,GAAG,KAAK;GACR,YAAY;EACd,CAAC;CACH;;;;;;;;;;;;;CAcA,OAME,GAAG,aAYH;EACA,OAAO,IAAI,wBAAwB;GACjC,GAAG,KAAK;GACR,YAAY,CAAC,GAAI,KAAK,QAAQ,cAAc,CAAC,GAAI,WAAW;EAC9D,CAAC;CACH;CAEA,IAAI,SAAS;EACX,OAAO,KAAK;CACd;CAEA,QAAQ;EAIN,IAAI,KAAK,QAAQ,WAAW,WAAW,GACrC,MAAM,IAAI,MAAM,UAAU,KAAK,QAAQ,KAAK,2BAA2B;EAEzE,MAAM,wBAAQ,IAAI,IAAY;EAC9B,KAAK,MAAM,CAAC,KAAK,EAAC,iBAAgB,OAAO,QAAQ,KAAK,QAAQ,OAAO,GAAG;GACtE,MAAM,OAAO,cAAc;GAC3B,IAAI,MAAM,IAAI,IAAI,GAChB,MAAM,IAAI,MACR,UACE,KAAK,QAAQ,KACd,sCAAsC,KAAK,EAC9C;GAEF,MAAM,IAAI,IAAI;EAChB;EACA,OAAO,KAAK;CACd;AACF;AAEA,IAAM,gBAAN,MAAM,cAA+C;CACnD;CACA,YAAY,QAAgB;EAC1B,KAAK,UAAU;CACjB;CAEA,KAAgC,YAAwB;EACtD,OAAO,IAAI,cAA6C;GACtD,GAAG,KAAK;GACR;EACF,CAAC;CACH;CAEA,WAAuE;EACrE,OAAO,IAAI,cAAc;GACvB,GAAG,KAAK;GACR,UAAU;EACZ,CAAC;CACH;CAEA,IAAI,SAAS;EACX,OAAO,KAAK;CACd;AACF"}
1
+ {"version":3,"file":"table-builder.js","names":[],"sources":["../../../../../zero-schema/src/builder/table-builder.ts"],"sourcesContent":["import type {ReadonlyJSONValue} from '../../../shared/src/json.ts';\nimport {mapValues} from '../../../shared/src/objects.ts';\nimport type {PrimaryKey} from '../../../zero-protocol/src/primary-key.ts';\nimport type {SchemaValue, TableSchema} from '../table-schema.ts';\n\n/* oxlint-disable @typescript-eslint/no-explicit-any */\nexport function table<TName extends string>(name: TName) {\n return new TableBuilder({\n name,\n columns: {},\n primaryKey: [] as any as PrimaryKey,\n });\n}\n\nexport function string<T extends string = string>() {\n return new ColumnBuilder({\n type: 'string',\n optional: false,\n customType: null as unknown as T,\n });\n}\n\nexport function number<T extends number = number>() {\n return new ColumnBuilder({\n type: 'number',\n optional: false,\n customType: null as unknown as T,\n });\n}\n\nexport function boolean<T extends boolean = boolean>() {\n return new ColumnBuilder({\n type: 'boolean',\n optional: false,\n customType: null as unknown as T,\n });\n}\n\nexport function json<T extends ReadonlyJSONValue = ReadonlyJSONValue>() {\n return new ColumnBuilder({\n type: 'json',\n optional: false,\n customType: null as unknown as T,\n });\n}\n\nexport function enumeration<T extends string>() {\n return new ColumnBuilder({\n type: 'string',\n optional: false,\n customType: null as unknown as T,\n });\n}\n\nexport const column = {\n string,\n number,\n boolean,\n json,\n enumeration,\n};\n\nclass TableBuilder<TShape extends TableSchema> {\n readonly #schema: TShape;\n constructor(schema: TShape) {\n this.#schema = schema;\n }\n\n from<ServerName extends string>(serverName: ServerName) {\n return new TableBuilder<TShape>({\n ...this.#schema,\n // Strip the \"public.\" schema if specified, as tables in the upstream\n // \"public\" schema are created without the schema prefix on the replica.\n // See liteTableName() in zero-cache/src/types/names.ts\n serverName: serverName.startsWith('public.')\n ? serverName.substring('public.'.length)\n : serverName,\n });\n }\n\n columns<const TColumns extends Record<string, ColumnBuilder<SchemaValue>>>(\n columns: TColumns,\n ): TableBuilderWithColumns<{\n name: TShape['name'];\n columns: {[K in keyof TColumns]: TColumns[K]['schema']};\n primaryKey: TShape['primaryKey'];\n }> {\n const columnSchemas = mapValues(columns, column => column.schema);\n return new TableBuilderWithColumns({\n ...this.#schema,\n columns: columnSchemas,\n }) as any;\n }\n}\n\nexport class TableBuilderWithColumns<TShape extends TableSchema> {\n readonly #schema: TShape;\n\n constructor(schema: TShape) {\n this.#schema = schema;\n }\n\n primaryKey<TPKColNames extends (keyof TShape['columns'])[]>(\n ...pkColumnNames: TPKColNames\n ) {\n return new TableBuilderWithColumns({\n ...this.#schema,\n primaryKey: pkColumnNames,\n });\n }\n\n /**\n * Declares that `columnNames` together are unique — mirroring a unique index\n * that already exists upstream. Call once per index.\n *\n * Zero neither creates nor enforces the constraint; declaring it tells the\n * type checker what the server already knows from the replica, which is what\n * lets a `{scalar: true}` subquery pinned on these columns typecheck.\n *\n * The return type is spelled out so the column names stay literal — spreading\n * the accumulated keys widens them to `PrimaryKey`, which loses exactly the\n * information the check needs.\n */\n unique<\n const TUniqueColNames extends [\n keyof TShape['columns'] & string,\n ...(keyof TShape['columns'] & string)[],\n ],\n >(\n ...columnNames: TUniqueColNames\n ): TableBuilderWithColumns<\n Omit<TShape, 'uniqueKeys'> & {\n uniqueKeys: [\n ...(TShape extends {\n uniqueKeys: infer TExisting extends readonly PrimaryKey[];\n }\n ? TExisting\n : []),\n TUniqueColNames,\n ];\n }\n > {\n return new TableBuilderWithColumns({\n ...this.#schema,\n uniqueKeys: [...(this.#schema.uniqueKeys ?? []), columnNames],\n }) as any;\n }\n\n get schema() {\n return this.#schema;\n }\n\n build() {\n // We can probably get the type system to throw an error if primaryKey is not called\n // before passing the schema to createSchema\n // Till then --\n if (this.#schema.primaryKey.length === 0) {\n throw new Error(`Table \"${this.#schema.name}\" is missing a primary key`);\n }\n const names = new Set<string>();\n for (const [col, {serverName}] of Object.entries(this.#schema.columns)) {\n const name = serverName ?? col;\n if (names.has(name)) {\n throw new Error(\n `Table \"${\n this.#schema.name\n }\" has multiple columns referencing \"${name}\"`,\n );\n }\n names.add(name);\n }\n return this.#schema;\n }\n}\n\nclass ColumnBuilder<TShape extends SchemaValue<any>> {\n readonly #schema: TShape;\n constructor(schema: TShape) {\n this.#schema = schema;\n }\n\n from<ServerName extends string>(serverName: ServerName) {\n return new ColumnBuilder<TShape & {serverName: string}>({\n ...this.#schema,\n serverName,\n });\n }\n\n optional(): ColumnBuilder<Omit<TShape, 'optional'> & {optional: true}> {\n return new ColumnBuilder({\n ...this.#schema,\n optional: true,\n });\n }\n\n get schema() {\n return this.#schema;\n }\n}\n\nexport type {ColumnBuilder};\n"],"mappings":";;AAMA,SAAgB,MAA4B,MAAa;CACvD,OAAO,IAAI,aAAa;EACtB;EACA,SAAS,CAAC;EACV,YAAY,CAAC;CACf,CAAC;AACH;AAEA,SAAgB,SAAoC;CAClD,OAAO,IAAI,cAAc;EACvB,MAAM;EACN,UAAU;EACV,YAAY;CACd,CAAC;AACH;AAEA,SAAgB,SAAoC;CAClD,OAAO,IAAI,cAAc;EACvB,MAAM;EACN,UAAU;EACV,YAAY;CACd,CAAC;AACH;AAEA,SAAgB,UAAuC;CACrD,OAAO,IAAI,cAAc;EACvB,MAAM;EACN,UAAU;EACV,YAAY;CACd,CAAC;AACH;AAEA,SAAgB,OAAwD;CACtE,OAAO,IAAI,cAAc;EACvB,MAAM;EACN,UAAU;EACV,YAAY;CACd,CAAC;AACH;AAEA,SAAgB,cAAgC;CAC9C,OAAO,IAAI,cAAc;EACvB,MAAM;EACN,UAAU;EACV,YAAY;CACd,CAAC;AACH;AAUA,IAAM,eAAN,MAAM,aAAyC;CAC7C;CACA,YAAY,QAAgB;EAC1B,KAAK,UAAU;CACjB;CAEA,KAAgC,YAAwB;EACtD,OAAO,IAAI,aAAqB;GAC9B,GAAG,KAAK;GAIR,YAAY,WAAW,WAAW,SAAS,IACvC,WAAW,UAAU,CAAgB,IACrC;EACN,CAAC;CACH;CAEA,QACE,SAKC;EACD,MAAM,gBAAgB,UAAU,UAAS,WAAU,OAAO,MAAM;EAChE,OAAO,IAAI,wBAAwB;GACjC,GAAG,KAAK;GACR,SAAS;EACX,CAAC;CACH;AACF;AAEA,IAAa,0BAAb,MAAa,wBAAoD;CAC/D;CAEA,YAAY,QAAgB;EAC1B,KAAK,UAAU;CACjB;CAEA,WACE,GAAG,eACH;EACA,OAAO,IAAI,wBAAwB;GACjC,GAAG,KAAK;GACR,YAAY;EACd,CAAC;CACH;;;;;;;;;;;;;CAcA,OAME,GAAG,aAYH;EACA,OAAO,IAAI,wBAAwB;GACjC,GAAG,KAAK;GACR,YAAY,CAAC,GAAI,KAAK,QAAQ,cAAc,CAAC,GAAI,WAAW;EAC9D,CAAC;CACH;CAEA,IAAI,SAAS;EACX,OAAO,KAAK;CACd;CAEA,QAAQ;EAIN,IAAI,KAAK,QAAQ,WAAW,WAAW,GACrC,MAAM,IAAI,MAAM,UAAU,KAAK,QAAQ,KAAK,2BAA2B;EAEzE,MAAM,wBAAQ,IAAI,IAAY;EAC9B,KAAK,MAAM,CAAC,KAAK,EAAC,iBAAgB,OAAO,QAAQ,KAAK,QAAQ,OAAO,GAAG;GACtE,MAAM,OAAO,cAAc;GAC3B,IAAI,MAAM,IAAI,IAAI,GAChB,MAAM,IAAI,MACR,UACE,KAAK,QAAQ,KACd,sCAAsC,KAAK,EAC9C;GAEF,MAAM,IAAI,IAAI;EAChB;EACA,OAAO,KAAK;CACd;AACF;AAEA,IAAM,gBAAN,MAAM,cAA+C;CACnD;CACA,YAAY,QAAgB;EAC1B,KAAK,UAAU;CACjB;CAEA,KAAgC,YAAwB;EACtD,OAAO,IAAI,cAA6C;GACtD,GAAG,KAAK;GACR;EACF,CAAC;CACH;CAEA,WAAuE;EACrE,OAAO,IAAI,cAAc;GACvB,GAAG,KAAK;GACR,UAAU;EACZ,CAAC;CACH;CAEA,IAAI,SAAS;EACX,OAAO,KAAK;CACd;AACF"}
@@ -12,7 +12,6 @@ export declare const schemaValueSchema: v.ObjectType<Readonly<{
12
12
  serverName: v.Optional<string>;
13
13
  optional: v.Optional<boolean>;
14
14
  }>, undefined>;
15
- export declare const tableSchemaSchema: v.Type<TableSchema>;
16
15
  export declare const schemaSchema: v.ObjectType<Readonly<{
17
16
  tables: v.Type<Record<string, TableSchema>>;
18
17
  relationships: v.Type<Record<string, Record<string, Relationship>>>;
@@ -1 +1 @@
1
- {"version":3,"file":"schema-config.d.ts","sourceRoot":"","sources":["../../../../zero-schema/src/schema-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,4BAA4B,CAAC;AAIhD,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAC,KAAK,iBAAiB,EAAC,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EAAC,YAAY,EAAE,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAEjE,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,iBAAiB,CAAC;CAChC,CAAC;AASF,eAAO,MAAM,kBAAkB,EAAE,CAAC,CAAC,IAAI,CAAC,YAAY,CAGnD,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;cAI5B,CAAC;AAEH,eAAO,MAAM,iBAAiB,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW,CAKhD,CAAC;AAEH,eAAO,MAAM,YAAY;;;;;cAKvB,CAAC;AAGH,wBAAgB,cAAc,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,YAAY,CAGhE"}
1
+ {"version":3,"file":"schema-config.d.ts","sourceRoot":"","sources":["../../../../zero-schema/src/schema-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,4BAA4B,CAAC;AAIhD,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAC,KAAK,iBAAiB,EAAC,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EAAC,YAAY,EAAE,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAEjE,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,iBAAiB,CAAC;CAChC,CAAC;AASF,eAAO,MAAM,kBAAkB,EAAE,CAAC,CAAC,IAAI,CAAC,YAAY,CAGnD,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;cAI5B,CAAC;AASH,eAAO,MAAM,YAAY;;;;;cAKvB,CAAC;AAGH,wBAAgB,cAAc,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,YAAY,CAGhE"}
@@ -32,6 +32,6 @@ function isSchemaConfig(value) {
32
32
  return value != null && "schema" in value;
33
33
  }
34
34
  //#endregion
35
- export { isSchemaConfig, relationshipSchema, schemaValueSchema, tableSchemaSchema };
35
+ export { isSchemaConfig, relationshipSchema, schemaValueSchema };
36
36
 
37
37
  //# sourceMappingURL=schema-config.js.map