@rocicorp/zero 0.26.1-canary.9 → 0.26.2-canary.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1113) hide show
  1. package/out/_virtual/_@oxc-project_runtime@0.115.0/helpers/usingCtx.js +57 -0
  2. package/out/_virtual/_rolldown/runtime.js +27 -0
  3. package/out/analyze-query/src/bin-analyze.js +195 -280
  4. package/out/analyze-query/src/bin-analyze.js.map +1 -1
  5. package/out/analyze-query/src/bin-transform.js +35 -40
  6. package/out/analyze-query/src/bin-transform.js.map +1 -1
  7. package/out/analyze-query/src/explain-queries.js +11 -13
  8. package/out/analyze-query/src/explain-queries.js.map +1 -1
  9. package/out/analyze-query/src/run-ast.d.ts.map +1 -1
  10. package/out/analyze-query/src/run-ast.js +68 -94
  11. package/out/analyze-query/src/run-ast.js.map +1 -1
  12. package/out/ast-to-zql/src/ast-to-zql.js +105 -153
  13. package/out/ast-to-zql/src/ast-to-zql.js.map +1 -1
  14. package/out/ast-to-zql/src/bin.js +57 -62
  15. package/out/ast-to-zql/src/bin.js.map +1 -1
  16. package/out/ast-to-zql/src/format.js +14 -13
  17. package/out/ast-to-zql/src/format.js.map +1 -1
  18. package/out/datadog/src/datadog-log-sink.js +148 -213
  19. package/out/datadog/src/datadog-log-sink.js.map +1 -1
  20. package/out/otel/src/enabled.js +9 -11
  21. package/out/otel/src/enabled.js.map +1 -1
  22. package/out/otel/src/log-options.js +25 -35
  23. package/out/otel/src/log-options.js.map +1 -1
  24. package/out/otel/src/maybe-time.js +13 -14
  25. package/out/otel/src/maybe-time.js.map +1 -1
  26. package/out/otel/src/span.js +23 -26
  27. package/out/otel/src/span.js.map +1 -1
  28. package/out/otel/src/test-log-config.js +11 -10
  29. package/out/otel/src/test-log-config.js.map +1 -1
  30. package/out/otel/src/version.js +6 -5
  31. package/out/otel/src/version.js.map +1 -1
  32. package/out/replicache/src/async-iterable-to-array.js +8 -9
  33. package/out/replicache/src/async-iterable-to-array.js.map +1 -1
  34. package/out/replicache/src/bg-interval.js +28 -35
  35. package/out/replicache/src/bg-interval.js.map +1 -1
  36. package/out/replicache/src/btree/diff.js +6 -5
  37. package/out/replicache/src/btree/diff.js.map +1 -1
  38. package/out/replicache/src/btree/node.js +281 -372
  39. package/out/replicache/src/btree/node.js.map +1 -1
  40. package/out/replicache/src/btree/read.js +155 -256
  41. package/out/replicache/src/btree/read.js.map +1 -1
  42. package/out/replicache/src/btree/splice.js +60 -80
  43. package/out/replicache/src/btree/splice.js.map +1 -1
  44. package/out/replicache/src/btree/write.js +134 -158
  45. package/out/replicache/src/btree/write.js.map +1 -1
  46. package/out/replicache/src/call-default-fetch.js +28 -32
  47. package/out/replicache/src/call-default-fetch.js.map +1 -1
  48. package/out/replicache/src/config.js +2 -0
  49. package/out/replicache/src/connection-loop-delegates.js +31 -33
  50. package/out/replicache/src/connection-loop-delegates.js.map +1 -1
  51. package/out/replicache/src/connection-loop.js +174 -240
  52. package/out/replicache/src/connection-loop.js.map +1 -1
  53. package/out/replicache/src/cookies.js +22 -32
  54. package/out/replicache/src/cookies.js.map +1 -1
  55. package/out/replicache/src/dag/chunk.js +44 -50
  56. package/out/replicache/src/dag/chunk.js.map +1 -1
  57. package/out/replicache/src/dag/gc.js +94 -114
  58. package/out/replicache/src/dag/gc.js.map +1 -1
  59. package/out/replicache/src/dag/key.js +9 -11
  60. package/out/replicache/src/dag/key.js.map +1 -1
  61. package/out/replicache/src/dag/lazy-store.js +458 -510
  62. package/out/replicache/src/dag/lazy-store.js.map +1 -1
  63. package/out/replicache/src/dag/store-impl.js +147 -178
  64. package/out/replicache/src/dag/store-impl.js.map +1 -1
  65. package/out/replicache/src/dag/store.js +19 -22
  66. package/out/replicache/src/dag/store.js.map +1 -1
  67. package/out/replicache/src/dag/visitor.js +23 -21
  68. package/out/replicache/src/dag/visitor.js.map +1 -1
  69. package/out/replicache/src/db/commit.js +209 -283
  70. package/out/replicache/src/db/commit.js.map +1 -1
  71. package/out/replicache/src/db/index.js +79 -122
  72. package/out/replicache/src/db/index.js.map +1 -1
  73. package/out/replicache/src/db/read.js +44 -60
  74. package/out/replicache/src/db/read.js.map +1 -1
  75. package/out/replicache/src/db/rebase.js +22 -77
  76. package/out/replicache/src/db/rebase.js.map +1 -1
  77. package/out/replicache/src/db/write.js +162 -296
  78. package/out/replicache/src/db/write.js.map +1 -1
  79. package/out/replicache/src/deleted-clients.js +59 -87
  80. package/out/replicache/src/deleted-clients.js.map +1 -1
  81. package/out/replicache/src/error-responses.js +18 -26
  82. package/out/replicache/src/error-responses.js.map +1 -1
  83. package/out/replicache/src/expo-sqlite.js +2 -0
  84. package/out/replicache/src/frozen-json.js +74 -108
  85. package/out/replicache/src/frozen-json.js.map +1 -1
  86. package/out/replicache/src/get-default-puller.js +34 -46
  87. package/out/replicache/src/get-default-puller.js.map +1 -1
  88. package/out/replicache/src/get-default-pusher.js +25 -33
  89. package/out/replicache/src/get-default-pusher.js.map +1 -1
  90. package/out/replicache/src/get-kv-store-provider.js +18 -20
  91. package/out/replicache/src/get-kv-store-provider.js.map +1 -1
  92. package/out/replicache/src/hash.js +29 -29
  93. package/out/replicache/src/hash.js.map +1 -1
  94. package/out/replicache/src/http-request-info.js +9 -8
  95. package/out/replicache/src/http-request-info.js.map +1 -1
  96. package/out/replicache/src/impl.js +2 -0
  97. package/out/replicache/src/index-defs.js +17 -28
  98. package/out/replicache/src/index-defs.js.map +1 -1
  99. package/out/replicache/src/kv/expo-sqlite/store.js +52 -50
  100. package/out/replicache/src/kv/expo-sqlite/store.js.map +1 -1
  101. package/out/replicache/src/kv/idb-store-with-mem-fallback.js +71 -68
  102. package/out/replicache/src/kv/idb-store-with-mem-fallback.js.map +1 -1
  103. package/out/replicache/src/kv/idb-store.js +144 -168
  104. package/out/replicache/src/kv/idb-store.js.map +1 -1
  105. package/out/replicache/src/kv/mem-store.js +57 -45
  106. package/out/replicache/src/kv/mem-store.js.map +1 -1
  107. package/out/replicache/src/kv/op-sqlite/store.js +56 -62
  108. package/out/replicache/src/kv/op-sqlite/store.js.map +1 -1
  109. package/out/replicache/src/kv/op-sqlite/types.d.ts.map +1 -1
  110. package/out/replicache/src/kv/op-sqlite/types.js +7 -6
  111. package/out/replicache/src/kv/op-sqlite/types.js.map +1 -1
  112. package/out/replicache/src/kv/read-impl.js +26 -25
  113. package/out/replicache/src/kv/read-impl.js.map +1 -1
  114. package/out/replicache/src/kv/sqlite-store.js +194 -207
  115. package/out/replicache/src/kv/sqlite-store.js.map +1 -1
  116. package/out/replicache/src/kv/throw-if-closed.js +12 -19
  117. package/out/replicache/src/kv/throw-if-closed.js.map +1 -1
  118. package/out/replicache/src/kv/write-impl-base.js +44 -56
  119. package/out/replicache/src/kv/write-impl-base.js.map +1 -1
  120. package/out/replicache/src/kv/write-impl.js +22 -26
  121. package/out/replicache/src/kv/write-impl.js.map +1 -1
  122. package/out/replicache/src/lazy.js +10 -11
  123. package/out/replicache/src/lazy.js.map +1 -1
  124. package/out/replicache/src/log-options.js +14 -7
  125. package/out/replicache/src/log-options.js.map +1 -1
  126. package/out/replicache/src/make-idb-name.js +14 -9
  127. package/out/replicache/src/make-idb-name.js.map +1 -1
  128. package/out/replicache/src/mutation-recovery.js +12 -0
  129. package/out/replicache/src/mutation-recovery.js.map +1 -0
  130. package/out/replicache/src/new-client-channel.js +34 -42
  131. package/out/replicache/src/new-client-channel.js.map +1 -1
  132. package/out/replicache/src/on-persist-channel.js +26 -29
  133. package/out/replicache/src/on-persist-channel.js.map +1 -1
  134. package/out/replicache/src/op-sqlite.js +2 -0
  135. package/out/replicache/src/patch-operation.js +27 -36
  136. package/out/replicache/src/patch-operation.js.map +1 -1
  137. package/out/replicache/src/pending-mutations.js +14 -12
  138. package/out/replicache/src/pending-mutations.js.map +1 -1
  139. package/out/replicache/src/persist/client-gc.js +36 -51
  140. package/out/replicache/src/persist/client-gc.js.map +1 -1
  141. package/out/replicache/src/persist/client-group-gc.js +29 -36
  142. package/out/replicache/src/persist/client-group-gc.js.map +1 -1
  143. package/out/replicache/src/persist/client-groups.js +80 -154
  144. package/out/replicache/src/persist/client-groups.js.map +1 -1
  145. package/out/replicache/src/persist/clients.js +212 -307
  146. package/out/replicache/src/persist/clients.js.map +1 -1
  147. package/out/replicache/src/persist/collect-idb-databases.js +109 -171
  148. package/out/replicache/src/persist/collect-idb-databases.js.map +1 -1
  149. package/out/replicache/src/persist/gather-mem-only-visitor.js +23 -24
  150. package/out/replicache/src/persist/gather-mem-only-visitor.js.map +1 -1
  151. package/out/replicache/src/persist/gather-not-cached-visitor.js +35 -33
  152. package/out/replicache/src/persist/gather-not-cached-visitor.js.map +1 -1
  153. package/out/replicache/src/persist/heartbeat.js +31 -41
  154. package/out/replicache/src/persist/heartbeat.js.map +1 -1
  155. package/out/replicache/src/persist/idb-databases-store-db-name.js +9 -12
  156. package/out/replicache/src/persist/idb-databases-store-db-name.js.map +1 -1
  157. package/out/replicache/src/persist/idb-databases-store.js +78 -97
  158. package/out/replicache/src/persist/idb-databases-store.js.map +1 -1
  159. package/out/replicache/src/persist/make-client-id.js +13 -9
  160. package/out/replicache/src/persist/make-client-id.js.map +1 -1
  161. package/out/replicache/src/persist/persist.js +113 -174
  162. package/out/replicache/src/persist/persist.js.map +1 -1
  163. package/out/replicache/src/persist/refresh.js +94 -183
  164. package/out/replicache/src/persist/refresh.js.map +1 -1
  165. package/out/replicache/src/process-scheduler.js +122 -143
  166. package/out/replicache/src/process-scheduler.js.map +1 -1
  167. package/out/replicache/src/pusher.js +21 -26
  168. package/out/replicache/src/pusher.js.map +1 -1
  169. package/out/replicache/src/replicache-impl.js +844 -1184
  170. package/out/replicache/src/replicache-impl.js.map +1 -1
  171. package/out/replicache/src/report-error.js +9 -6
  172. package/out/replicache/src/report-error.js.map +1 -1
  173. package/out/replicache/src/request-idle.js +13 -11
  174. package/out/replicache/src/request-idle.js.map +1 -1
  175. package/out/replicache/src/scan-iterator.d.ts.map +1 -1
  176. package/out/replicache/src/scan-iterator.js +108 -135
  177. package/out/replicache/src/scan-iterator.js.map +1 -1
  178. package/out/replicache/src/scan-options.js +33 -39
  179. package/out/replicache/src/scan-options.js.map +1 -1
  180. package/out/replicache/src/set-interval-with-signal.js +11 -10
  181. package/out/replicache/src/set-interval-with-signal.js.map +1 -1
  182. package/out/replicache/src/sqlite.js +2 -0
  183. package/out/replicache/src/subscriptions.js +222 -338
  184. package/out/replicache/src/subscriptions.js.map +1 -1
  185. package/out/replicache/src/sync/diff.js +52 -65
  186. package/out/replicache/src/sync/diff.js.map +1 -1
  187. package/out/replicache/src/sync/ids.js +8 -9
  188. package/out/replicache/src/sync/ids.js.map +1 -1
  189. package/out/replicache/src/sync/patch.js +34 -45
  190. package/out/replicache/src/sync/patch.js.map +1 -1
  191. package/out/replicache/src/sync/pull-error.js +15 -15
  192. package/out/replicache/src/sync/pull-error.js.map +1 -1
  193. package/out/replicache/src/sync/pull.js +145 -283
  194. package/out/replicache/src/sync/pull.js.map +1 -1
  195. package/out/replicache/src/sync/push.js +64 -79
  196. package/out/replicache/src/sync/push.js.map +1 -1
  197. package/out/replicache/src/sync/request-id.js +23 -15
  198. package/out/replicache/src/sync/request-id.js.map +1 -1
  199. package/out/replicache/src/sync/sync-head-name.js +6 -5
  200. package/out/replicache/src/sync/sync-head-name.js.map +1 -1
  201. package/out/replicache/src/to-error.js +7 -8
  202. package/out/replicache/src/to-error.js.map +1 -1
  203. package/out/replicache/src/transaction-closed-error.js +15 -15
  204. package/out/replicache/src/transaction-closed-error.js.map +1 -1
  205. package/out/replicache/src/transactions.js +120 -140
  206. package/out/replicache/src/transactions.js.map +1 -1
  207. package/out/replicache/src/version.js +9 -5
  208. package/out/replicache/src/version.js.map +1 -1
  209. package/out/replicache/src/with-transactions.js +23 -20
  210. package/out/replicache/src/with-transactions.js.map +1 -1
  211. package/out/shared/src/abort-error.js +7 -6
  212. package/out/shared/src/abort-error.js.map +1 -1
  213. package/out/shared/src/arrays.js +35 -42
  214. package/out/shared/src/arrays.js.map +1 -1
  215. package/out/shared/src/asserts.js +21 -45
  216. package/out/shared/src/asserts.js.map +1 -1
  217. package/out/shared/src/bigint-json.js +42 -38
  218. package/out/shared/src/bigint-json.js.map +1 -1
  219. package/out/shared/src/binary-search.js +27 -18
  220. package/out/shared/src/binary-search.js.map +1 -1
  221. package/out/shared/src/broadcast-channel.js +20 -23
  222. package/out/shared/src/broadcast-channel.js.map +1 -1
  223. package/out/shared/src/browser-env.js +11 -17
  224. package/out/shared/src/browser-env.js.map +1 -1
  225. package/out/shared/src/btree-set.js +419 -481
  226. package/out/shared/src/btree-set.js.map +1 -1
  227. package/out/shared/src/cache.js +43 -36
  228. package/out/shared/src/cache.js.map +1 -1
  229. package/out/shared/src/centroid.js +24 -26
  230. package/out/shared/src/centroid.js.map +1 -1
  231. package/out/shared/src/config.js +6 -6
  232. package/out/shared/src/config.js.map +1 -1
  233. package/out/shared/src/custom-key-map.js +54 -58
  234. package/out/shared/src/custom-key-map.js.map +1 -1
  235. package/out/shared/src/custom-key-set.js +53 -51
  236. package/out/shared/src/custom-key-set.js.map +1 -1
  237. package/out/shared/src/deep-clone.js +30 -41
  238. package/out/shared/src/deep-clone.js.map +1 -1
  239. package/out/shared/src/deep-merge.js +25 -24
  240. package/out/shared/src/deep-merge.js.map +1 -1
  241. package/out/shared/src/document-visible.js +63 -70
  242. package/out/shared/src/document-visible.js.map +1 -1
  243. package/out/shared/src/dotenv.js +7 -3
  244. package/out/shared/src/dotenv.js.map +1 -1
  245. package/out/shared/src/error.js +43 -64
  246. package/out/shared/src/error.js.map +1 -1
  247. package/out/shared/src/has-own.js +6 -5
  248. package/out/shared/src/has-own.js.map +1 -1
  249. package/out/shared/src/hash.js +15 -14
  250. package/out/shared/src/hash.js.map +1 -1
  251. package/out/shared/src/iterables.js +34 -47
  252. package/out/shared/src/iterables.js.map +1 -1
  253. package/out/shared/src/json-schema.js +25 -30
  254. package/out/shared/src/json-schema.js.map +1 -1
  255. package/out/shared/src/json.js +90 -129
  256. package/out/shared/src/json.js.map +1 -1
  257. package/out/shared/src/logging-test-utils.js +9 -11
  258. package/out/shared/src/logging-test-utils.js.map +1 -1
  259. package/out/shared/src/logging.js +75 -95
  260. package/out/shared/src/logging.js.map +1 -1
  261. package/out/shared/src/must.js +7 -8
  262. package/out/shared/src/must.js.map +1 -1
  263. package/out/shared/src/navigator.js +6 -5
  264. package/out/shared/src/navigator.js.map +1 -1
  265. package/out/shared/src/object-traversal.js +23 -23
  266. package/out/shared/src/object-traversal.js.map +1 -1
  267. package/out/shared/src/objects.js +15 -18
  268. package/out/shared/src/objects.js.map +1 -1
  269. package/out/shared/src/options.js +225 -302
  270. package/out/shared/src/options.js.map +1 -1
  271. package/out/shared/src/parse-big-int.js +12 -11
  272. package/out/shared/src/parse-big-int.js.map +1 -1
  273. package/out/shared/src/promise-race.js +21 -17
  274. package/out/shared/src/promise-race.js.map +1 -1
  275. package/out/shared/src/queue.js +124 -124
  276. package/out/shared/src/queue.js.map +1 -1
  277. package/out/shared/src/rand.js +13 -7
  278. package/out/shared/src/rand.js.map +1 -1
  279. package/out/shared/src/random-uint64.js +8 -7
  280. package/out/shared/src/random-uint64.js.map +1 -1
  281. package/out/shared/src/random-values.js +8 -11
  282. package/out/shared/src/random-values.js.map +1 -1
  283. package/out/shared/src/record-proxy.js +68 -57
  284. package/out/shared/src/record-proxy.js.map +1 -1
  285. package/out/shared/src/resolved-promises.js +9 -11
  286. package/out/shared/src/resolved-promises.js.map +1 -1
  287. package/out/shared/src/sentinels.js +9 -12
  288. package/out/shared/src/sentinels.js.map +1 -1
  289. package/out/shared/src/set-utils.js +41 -63
  290. package/out/shared/src/set-utils.js.map +1 -1
  291. package/out/shared/src/size-of-value.js +55 -51
  292. package/out/shared/src/size-of-value.js.map +1 -1
  293. package/out/shared/src/sleep.js +50 -45
  294. package/out/shared/src/sleep.js.map +1 -1
  295. package/out/shared/src/string-compare.js +8 -11
  296. package/out/shared/src/string-compare.js.map +1 -1
  297. package/out/shared/src/subscribable.js +34 -33
  298. package/out/shared/src/subscribable.js.map +1 -1
  299. package/out/shared/src/tdigest-schema.js +11 -7
  300. package/out/shared/src/tdigest-schema.js.map +1 -1
  301. package/out/shared/src/tdigest.js +197 -270
  302. package/out/shared/src/tdigest.js.map +1 -1
  303. package/out/shared/src/valita.js +145 -174
  304. package/out/shared/src/valita.js.map +1 -1
  305. package/out/z2s/src/compiler.d.ts.map +1 -1
  306. package/out/z2s/src/compiler.js +238 -468
  307. package/out/z2s/src/compiler.js.map +1 -1
  308. package/out/z2s/src/sql.d.ts +0 -1
  309. package/out/z2s/src/sql.d.ts.map +1 -1
  310. package/out/z2s/src/sql.js +149 -194
  311. package/out/z2s/src/sql.js.map +1 -1
  312. package/out/zero/package.js +193 -0
  313. package/out/zero/package.js.map +1 -0
  314. package/out/zero/src/adapters/drizzle.js +1 -6
  315. package/out/zero/src/adapters/pg.js +1 -6
  316. package/out/zero/src/adapters/postgresjs.js +1 -6
  317. package/out/zero/src/adapters/prisma.js +1 -5
  318. package/out/zero/src/analyze-query.js +1 -1
  319. package/out/zero/src/ast-to-zql.js +1 -1
  320. package/out/zero/src/bindings.js +6 -21
  321. package/out/zero/src/build-schema.js +5 -1
  322. package/out/zero/src/build-schema.js.map +1 -1
  323. package/out/zero/src/change-protocol/v0.js +3 -5
  324. package/out/zero/src/cli.js +2 -2
  325. package/out/zero/src/deploy-permissions.js +1 -1
  326. package/out/zero/src/expo-sqlite.js +2 -4
  327. package/out/zero/src/op-sqlite.js +2 -4
  328. package/out/zero/src/pg.js +2 -20
  329. package/out/zero/src/react-native.js +16 -12
  330. package/out/zero/src/react-native.js.map +1 -1
  331. package/out/zero/src/react.js +3 -12
  332. package/out/zero/src/server/runner/main.js +2 -0
  333. package/out/zero/src/server.js +2 -17
  334. package/out/zero/src/solid.js +3 -12
  335. package/out/zero/src/sqlite.js +2 -6
  336. package/out/zero/src/transform-query.js +1 -1
  337. package/out/zero/src/zero-cache-dev.js +124 -151
  338. package/out/zero/src/zero-cache-dev.js.map +1 -1
  339. package/out/zero/src/zero-out.js +9 -6
  340. package/out/zero/src/zero-out.js.map +1 -1
  341. package/out/zero/src/zero.js +6 -55
  342. package/out/zero/src/zqlite.js +2 -7
  343. package/out/zero-cache/src/auth/auth.js +138 -172
  344. package/out/zero-cache/src/auth/auth.js.map +1 -1
  345. package/out/zero-cache/src/auth/jwt.js +25 -33
  346. package/out/zero-cache/src/auth/jwt.js.map +1 -1
  347. package/out/zero-cache/src/auth/load-permissions.js +54 -62
  348. package/out/zero-cache/src/auth/load-permissions.js.map +1 -1
  349. package/out/zero-cache/src/auth/read-authorizer.js +70 -80
  350. package/out/zero-cache/src/auth/read-authorizer.js.map +1 -1
  351. package/out/zero-cache/src/auth/write-authorizer.js +284 -432
  352. package/out/zero-cache/src/auth/write-authorizer.js.map +1 -1
  353. package/out/zero-cache/src/config/network.js +31 -45
  354. package/out/zero-cache/src/config/network.js.map +1 -1
  355. package/out/zero-cache/src/config/normalize.js +81 -83
  356. package/out/zero-cache/src/config/normalize.js.map +1 -1
  357. package/out/zero-cache/src/config/server-context.js +32 -29
  358. package/out/zero-cache/src/config/server-context.js.map +1 -1
  359. package/out/zero-cache/src/config/zero-config.d.ts +4 -0
  360. package/out/zero-cache/src/config/zero-config.d.ts.map +1 -1
  361. package/out/zero-cache/src/config/zero-config.js +753 -816
  362. package/out/zero-cache/src/config/zero-config.js.map +1 -1
  363. package/out/zero-cache/src/custom/fetch.js +183 -230
  364. package/out/zero-cache/src/custom/fetch.js.map +1 -1
  365. package/out/zero-cache/src/custom-queries/transform-query.js +93 -99
  366. package/out/zero-cache/src/custom-queries/transform-query.js.map +1 -1
  367. package/out/zero-cache/src/db/create.js +27 -29
  368. package/out/zero-cache/src/db/create.js.map +1 -1
  369. package/out/zero-cache/src/db/delete-lite-db.js +11 -7
  370. package/out/zero-cache/src/db/delete-lite-db.js.map +1 -1
  371. package/out/zero-cache/src/db/lite-tables.d.ts +2 -1
  372. package/out/zero-cache/src/db/lite-tables.d.ts.map +1 -1
  373. package/out/zero-cache/src/db/lite-tables.js +120 -156
  374. package/out/zero-cache/src/db/lite-tables.js.map +1 -1
  375. package/out/zero-cache/src/db/migration-lite.js +110 -178
  376. package/out/zero-cache/src/db/migration-lite.js.map +1 -1
  377. package/out/zero-cache/src/db/migration.js +82 -151
  378. package/out/zero-cache/src/db/migration.js.map +1 -1
  379. package/out/zero-cache/src/db/mode-enum.js +8 -9
  380. package/out/zero-cache/src/db/mode-enum.js.map +1 -1
  381. package/out/zero-cache/src/db/pg-copy.js +56 -54
  382. package/out/zero-cache/src/db/pg-copy.js.map +1 -1
  383. package/out/zero-cache/src/db/pg-to-lite.js +74 -110
  384. package/out/zero-cache/src/db/pg-to-lite.js.map +1 -1
  385. package/out/zero-cache/src/db/pg-type-parser.js +19 -36
  386. package/out/zero-cache/src/db/pg-type-parser.js.map +1 -1
  387. package/out/zero-cache/src/db/run-transaction.js +19 -20
  388. package/out/zero-cache/src/db/run-transaction.js.map +1 -1
  389. package/out/zero-cache/src/db/specs.d.ts +8 -2
  390. package/out/zero-cache/src/db/specs.d.ts.map +1 -1
  391. package/out/zero-cache/src/db/specs.js +42 -78
  392. package/out/zero-cache/src/db/specs.js.map +1 -1
  393. package/out/zero-cache/src/db/statements.js +52 -59
  394. package/out/zero-cache/src/db/statements.js.map +1 -1
  395. package/out/zero-cache/src/db/transaction-pool.js +376 -400
  396. package/out/zero-cache/src/db/transaction-pool.js.map +1 -1
  397. package/out/zero-cache/src/db/warmup.js +13 -24
  398. package/out/zero-cache/src/db/warmup.js.map +1 -1
  399. package/out/zero-cache/src/observability/events.js +89 -99
  400. package/out/zero-cache/src/observability/events.js.map +1 -1
  401. package/out/zero-cache/src/observability/metrics.js +30 -54
  402. package/out/zero-cache/src/observability/metrics.js.map +1 -1
  403. package/out/zero-cache/src/scripts/decommission.js +42 -47
  404. package/out/zero-cache/src/scripts/decommission.js.map +1 -1
  405. package/out/zero-cache/src/scripts/deploy-permissions.js +106 -144
  406. package/out/zero-cache/src/scripts/deploy-permissions.js.map +1 -1
  407. package/out/zero-cache/src/scripts/permissions.js +86 -107
  408. package/out/zero-cache/src/scripts/permissions.js.map +1 -1
  409. package/out/zero-cache/src/server/anonymous-otel-start.js +306 -440
  410. package/out/zero-cache/src/server/anonymous-otel-start.js.map +1 -1
  411. package/out/zero-cache/src/server/change-streamer.d.ts.map +1 -1
  412. package/out/zero-cache/src/server/change-streamer.js +57 -128
  413. package/out/zero-cache/src/server/change-streamer.js.map +1 -1
  414. package/out/zero-cache/src/server/inspector-delegate.js +89 -100
  415. package/out/zero-cache/src/server/inspector-delegate.js.map +1 -1
  416. package/out/zero-cache/src/server/logging.js +18 -26
  417. package/out/zero-cache/src/server/logging.js.map +1 -1
  418. package/out/zero-cache/src/server/main.js +85 -142
  419. package/out/zero-cache/src/server/main.js.map +1 -1
  420. package/out/zero-cache/src/server/mutator.js +16 -13
  421. package/out/zero-cache/src/server/mutator.js.map +1 -1
  422. package/out/zero-cache/src/server/otel-diag-logger.js +42 -49
  423. package/out/zero-cache/src/server/otel-diag-logger.js.map +1 -1
  424. package/out/zero-cache/src/server/otel-log-sink.js +34 -44
  425. package/out/zero-cache/src/server/otel-log-sink.js.map +1 -1
  426. package/out/zero-cache/src/server/otel-start.js +43 -51
  427. package/out/zero-cache/src/server/otel-start.js.map +1 -1
  428. package/out/zero-cache/src/server/priority-op.js +27 -25
  429. package/out/zero-cache/src/server/priority-op.js.map +1 -1
  430. package/out/zero-cache/src/server/reaper.js +32 -43
  431. package/out/zero-cache/src/server/reaper.js.map +1 -1
  432. package/out/zero-cache/src/server/replicator.d.ts.map +1 -1
  433. package/out/zero-cache/src/server/replicator.js +41 -57
  434. package/out/zero-cache/src/server/replicator.js.map +1 -1
  435. package/out/zero-cache/src/server/runner/main.js +7 -8
  436. package/out/zero-cache/src/server/runner/main.js.map +1 -1
  437. package/out/zero-cache/src/server/runner/run-worker.js +56 -52
  438. package/out/zero-cache/src/server/runner/run-worker.js.map +1 -1
  439. package/out/zero-cache/src/server/runner/runtime.js +26 -32
  440. package/out/zero-cache/src/server/runner/runtime.js.map +1 -1
  441. package/out/zero-cache/src/server/runner/zero-dispatcher.js +22 -27
  442. package/out/zero-cache/src/server/runner/zero-dispatcher.js.map +1 -1
  443. package/out/zero-cache/src/server/syncer.js +79 -148
  444. package/out/zero-cache/src/server/syncer.js.map +1 -1
  445. package/out/zero-cache/src/server/worker-dispatcher.js +84 -113
  446. package/out/zero-cache/src/server/worker-dispatcher.js.map +1 -1
  447. package/out/zero-cache/src/server/worker-urls.d.ts +2 -1
  448. package/out/zero-cache/src/server/worker-urls.d.ts.map +1 -1
  449. package/out/zero-cache/src/server/worker-urls.js +14 -18
  450. package/out/zero-cache/src/server/worker-urls.js.map +1 -1
  451. package/out/zero-cache/src/server/write-worker.js +2 -0
  452. package/out/zero-cache/src/services/analyze.js +61 -129
  453. package/out/zero-cache/src/services/analyze.js.map +1 -1
  454. package/out/zero-cache/src/services/change-source/common/backfill-manager.js +420 -419
  455. package/out/zero-cache/src/services/change-source/common/backfill-manager.js.map +1 -1
  456. package/out/zero-cache/src/services/change-source/common/change-stream-multiplexer.js +111 -114
  457. package/out/zero-cache/src/services/change-source/common/change-stream-multiplexer.js.map +1 -1
  458. package/out/zero-cache/src/services/change-source/common/replica-schema.d.ts +2 -0
  459. package/out/zero-cache/src/services/change-source/common/replica-schema.d.ts.map +1 -1
  460. package/out/zero-cache/src/services/change-source/common/replica-schema.js +100 -115
  461. package/out/zero-cache/src/services/change-source/common/replica-schema.js.map +1 -1
  462. package/out/zero-cache/src/services/change-source/custom/change-source.js +154 -216
  463. package/out/zero-cache/src/services/change-source/custom/change-source.js.map +1 -1
  464. package/out/zero-cache/src/services/change-source/pg/backfill-metadata.js +11 -14
  465. package/out/zero-cache/src/services/change-source/pg/backfill-metadata.js.map +1 -1
  466. package/out/zero-cache/src/services/change-source/pg/backfill-stream.d.ts.map +1 -1
  467. package/out/zero-cache/src/services/change-source/pg/backfill-stream.js +169 -209
  468. package/out/zero-cache/src/services/change-source/pg/backfill-stream.js.map +1 -1
  469. package/out/zero-cache/src/services/change-source/pg/change-source.d.ts.map +1 -1
  470. package/out/zero-cache/src/services/change-source/pg/change-source.js +676 -835
  471. package/out/zero-cache/src/services/change-source/pg/change-source.js.map +1 -1
  472. package/out/zero-cache/src/services/change-source/pg/decommission.js +19 -23
  473. package/out/zero-cache/src/services/change-source/pg/decommission.js.map +1 -1
  474. package/out/zero-cache/src/services/change-source/pg/initial-sync.js +258 -411
  475. package/out/zero-cache/src/services/change-source/pg/initial-sync.js.map +1 -1
  476. package/out/zero-cache/src/services/change-source/pg/logical-replication/binary-reader.js +59 -65
  477. package/out/zero-cache/src/services/change-source/pg/logical-replication/binary-reader.js.map +1 -1
  478. package/out/zero-cache/src/services/change-source/pg/logical-replication/pgoutput-parser.js +218 -247
  479. package/out/zero-cache/src/services/change-source/pg/logical-replication/pgoutput-parser.js.map +1 -1
  480. package/out/zero-cache/src/services/change-source/pg/logical-replication/stream.js +100 -142
  481. package/out/zero-cache/src/services/change-source/pg/logical-replication/stream.js.map +1 -1
  482. package/out/zero-cache/src/services/change-source/pg/lsn.js +17 -19
  483. package/out/zero-cache/src/services/change-source/pg/lsn.js.map +1 -1
  484. package/out/zero-cache/src/services/change-source/pg/schema/ddl.js +88 -98
  485. package/out/zero-cache/src/services/change-source/pg/schema/ddl.js.map +1 -1
  486. package/out/zero-cache/src/services/change-source/pg/schema/init.js +96 -177
  487. package/out/zero-cache/src/services/change-source/pg/schema/init.js.map +1 -1
  488. package/out/zero-cache/src/services/change-source/pg/schema/published.js +69 -107
  489. package/out/zero-cache/src/services/change-source/pg/schema/published.js.map +1 -1
  490. package/out/zero-cache/src/services/change-source/pg/schema/shard.js +151 -212
  491. package/out/zero-cache/src/services/change-source/pg/schema/shard.js.map +1 -1
  492. package/out/zero-cache/src/services/change-source/pg/schema/validation.js +22 -53
  493. package/out/zero-cache/src/services/change-source/pg/schema/validation.js.map +1 -1
  494. package/out/zero-cache/src/services/change-source/protocol/current/control.js +24 -12
  495. package/out/zero-cache/src/services/change-source/protocol/current/control.js.map +1 -1
  496. package/out/zero-cache/src/services/change-source/protocol/current/data.js +180 -290
  497. package/out/zero-cache/src/services/change-source/protocol/current/data.js.map +1 -1
  498. package/out/zero-cache/src/services/change-source/protocol/current/downstream.js +21 -33
  499. package/out/zero-cache/src/services/change-source/protocol/current/downstream.js.map +1 -1
  500. package/out/zero-cache/src/services/change-source/protocol/current/json.js +7 -18
  501. package/out/zero-cache/src/services/change-source/protocol/current/json.js.map +1 -1
  502. package/out/zero-cache/src/services/change-source/protocol/current/path.js +24 -5
  503. package/out/zero-cache/src/services/change-source/protocol/current/path.js.map +1 -1
  504. package/out/zero-cache/src/services/change-source/protocol/current/status.js +25 -19
  505. package/out/zero-cache/src/services/change-source/protocol/current/status.js.map +1 -1
  506. package/out/zero-cache/src/services/change-source/protocol/current/upstream.js +24 -16
  507. package/out/zero-cache/src/services/change-source/protocol/current/upstream.js.map +1 -1
  508. package/out/zero-cache/src/services/change-source/protocol/current.js +51 -46
  509. package/out/zero-cache/src/services/change-source/protocol/current.js.map +1 -1
  510. package/out/zero-cache/src/services/change-source/protocol/mod.js +2 -0
  511. package/out/zero-cache/src/services/change-streamer/backup-monitor.js +165 -171
  512. package/out/zero-cache/src/services/change-streamer/backup-monitor.js.map +1 -1
  513. package/out/zero-cache/src/services/change-streamer/broadcast.d.ts +100 -0
  514. package/out/zero-cache/src/services/change-streamer/broadcast.d.ts.map +1 -0
  515. package/out/zero-cache/src/services/change-streamer/broadcast.js +165 -0
  516. package/out/zero-cache/src/services/change-streamer/broadcast.js.map +1 -0
  517. package/out/zero-cache/src/services/change-streamer/change-streamer-http.js +154 -221
  518. package/out/zero-cache/src/services/change-streamer/change-streamer-http.js.map +1 -1
  519. package/out/zero-cache/src/services/change-streamer/change-streamer-service.d.ts +1 -1
  520. package/out/zero-cache/src/services/change-streamer/change-streamer-service.d.ts.map +1 -1
  521. package/out/zero-cache/src/services/change-streamer/change-streamer-service.js +341 -293
  522. package/out/zero-cache/src/services/change-streamer/change-streamer-service.js.map +1 -1
  523. package/out/zero-cache/src/services/change-streamer/change-streamer.js +17 -24
  524. package/out/zero-cache/src/services/change-streamer/change-streamer.js.map +1 -1
  525. package/out/zero-cache/src/services/change-streamer/forwarder.d.ts +17 -1
  526. package/out/zero-cache/src/services/change-streamer/forwarder.d.ts.map +1 -1
  527. package/out/zero-cache/src/services/change-streamer/forwarder.js +85 -56
  528. package/out/zero-cache/src/services/change-streamer/forwarder.js.map +1 -1
  529. package/out/zero-cache/src/services/change-streamer/replica-monitor.js +49 -43
  530. package/out/zero-cache/src/services/change-streamer/replica-monitor.js.map +1 -1
  531. package/out/zero-cache/src/services/change-streamer/schema/init.js +61 -89
  532. package/out/zero-cache/src/services/change-streamer/schema/init.js.map +1 -1
  533. package/out/zero-cache/src/services/change-streamer/schema/tables.d.ts +20 -1
  534. package/out/zero-cache/src/services/change-streamer/schema/tables.d.ts.map +1 -1
  535. package/out/zero-cache/src/services/change-streamer/schema/tables.js +131 -109
  536. package/out/zero-cache/src/services/change-streamer/schema/tables.js.map +1 -1
  537. package/out/zero-cache/src/services/change-streamer/snapshot.js +26 -28
  538. package/out/zero-cache/src/services/change-streamer/snapshot.js.map +1 -1
  539. package/out/zero-cache/src/services/change-streamer/storer.js +434 -513
  540. package/out/zero-cache/src/services/change-streamer/storer.js.map +1 -1
  541. package/out/zero-cache/src/services/change-streamer/subscriber.d.ts +18 -0
  542. package/out/zero-cache/src/services/change-streamer/subscriber.d.ts.map +1 -1
  543. package/out/zero-cache/src/services/change-streamer/subscriber.js +143 -100
  544. package/out/zero-cache/src/services/change-streamer/subscriber.js.map +1 -1
  545. package/out/zero-cache/src/services/heapz.js +18 -20
  546. package/out/zero-cache/src/services/heapz.js.map +1 -1
  547. package/out/zero-cache/src/services/http-service.js +59 -57
  548. package/out/zero-cache/src/services/http-service.js.map +1 -1
  549. package/out/zero-cache/src/services/life-cycle.js +182 -214
  550. package/out/zero-cache/src/services/life-cycle.js.map +1 -1
  551. package/out/zero-cache/src/services/limiter/sliding-window-limiter.js +102 -81
  552. package/out/zero-cache/src/services/limiter/sliding-window-limiter.js.map +1 -1
  553. package/out/zero-cache/src/services/litestream/commands.js +144 -205
  554. package/out/zero-cache/src/services/litestream/commands.js.map +1 -1
  555. package/out/zero-cache/src/services/mutagen/error.js +10 -14
  556. package/out/zero-cache/src/services/mutagen/error.js.map +1 -1
  557. package/out/zero-cache/src/services/mutagen/mutagen.js +166 -264
  558. package/out/zero-cache/src/services/mutagen/mutagen.js.map +1 -1
  559. package/out/zero-cache/src/services/mutagen/pusher.js +372 -487
  560. package/out/zero-cache/src/services/mutagen/pusher.js.map +1 -1
  561. package/out/zero-cache/src/services/replicator/change-processor.d.ts.map +1 -1
  562. package/out/zero-cache/src/services/replicator/change-processor.js +483 -595
  563. package/out/zero-cache/src/services/replicator/change-processor.js.map +1 -1
  564. package/out/zero-cache/src/services/replicator/incremental-sync.d.ts +4 -2
  565. package/out/zero-cache/src/services/replicator/incremental-sync.d.ts.map +1 -1
  566. package/out/zero-cache/src/services/replicator/incremental-sync.js +118 -143
  567. package/out/zero-cache/src/services/replicator/incremental-sync.js.map +1 -1
  568. package/out/zero-cache/src/services/replicator/notifier.js +52 -28
  569. package/out/zero-cache/src/services/replicator/notifier.js.map +1 -1
  570. package/out/zero-cache/src/services/replicator/replication-status.js +105 -128
  571. package/out/zero-cache/src/services/replicator/replication-status.js.map +1 -1
  572. package/out/zero-cache/src/services/replicator/replicator.d.ts +2 -1
  573. package/out/zero-cache/src/services/replicator/replicator.d.ts.map +1 -1
  574. package/out/zero-cache/src/services/replicator/replicator.js +32 -34
  575. package/out/zero-cache/src/services/replicator/replicator.js.map +1 -1
  576. package/out/zero-cache/src/services/replicator/schema/change-log.js +101 -133
  577. package/out/zero-cache/src/services/replicator/schema/change-log.js.map +1 -1
  578. package/out/zero-cache/src/services/replicator/schema/column-metadata.js +145 -174
  579. package/out/zero-cache/src/services/replicator/schema/column-metadata.js.map +1 -1
  580. package/out/zero-cache/src/services/replicator/schema/constants.js +11 -5
  581. package/out/zero-cache/src/services/replicator/schema/constants.js.map +1 -1
  582. package/out/zero-cache/src/services/replicator/schema/replication-state.js +56 -107
  583. package/out/zero-cache/src/services/replicator/schema/replication-state.js.map +1 -1
  584. package/out/zero-cache/src/services/replicator/schema/table-metadata.d.ts +28 -7
  585. package/out/zero-cache/src/services/replicator/schema/table-metadata.d.ts.map +1 -1
  586. package/out/zero-cache/src/services/replicator/schema/table-metadata.js +96 -50
  587. package/out/zero-cache/src/services/replicator/schema/table-metadata.js.map +1 -1
  588. package/out/zero-cache/src/services/replicator/write-worker-client.d.ts +69 -0
  589. package/out/zero-cache/src/services/replicator/write-worker-client.d.ts.map +1 -0
  590. package/out/zero-cache/src/services/replicator/write-worker-client.js +96 -0
  591. package/out/zero-cache/src/services/replicator/write-worker-client.js.map +1 -0
  592. package/out/zero-cache/src/services/replicator/write-worker.js +68 -0
  593. package/out/zero-cache/src/services/replicator/write-worker.js.map +1 -0
  594. package/out/zero-cache/src/services/run-ast.d.ts.map +1 -1
  595. package/out/zero-cache/src/services/run-ast.js +79 -118
  596. package/out/zero-cache/src/services/run-ast.js.map +1 -1
  597. package/out/zero-cache/src/services/runner.js +39 -41
  598. package/out/zero-cache/src/services/runner.js.map +1 -1
  599. package/out/zero-cache/src/services/running-state.js +129 -134
  600. package/out/zero-cache/src/services/running-state.js.map +1 -1
  601. package/out/zero-cache/src/services/statz.js +139 -200
  602. package/out/zero-cache/src/services/statz.js.map +1 -1
  603. package/out/zero-cache/src/services/view-syncer/active-users-gauge.js +46 -49
  604. package/out/zero-cache/src/services/view-syncer/active-users-gauge.js.map +1 -1
  605. package/out/zero-cache/src/services/view-syncer/client-handler.js +257 -299
  606. package/out/zero-cache/src/services/view-syncer/client-handler.js.map +1 -1
  607. package/out/zero-cache/src/services/view-syncer/client-schema.js +52 -82
  608. package/out/zero-cache/src/services/view-syncer/client-schema.js.map +1 -1
  609. package/out/zero-cache/src/services/view-syncer/cvr-purger.js +85 -107
  610. package/out/zero-cache/src/services/view-syncer/cvr-purger.js.map +1 -1
  611. package/out/zero-cache/src/services/view-syncer/cvr-store.js +604 -757
  612. package/out/zero-cache/src/services/view-syncer/cvr-store.js.map +1 -1
  613. package/out/zero-cache/src/services/view-syncer/cvr.js +631 -739
  614. package/out/zero-cache/src/services/view-syncer/cvr.js.map +1 -1
  615. package/out/zero-cache/src/services/view-syncer/drain-coordinator.js +60 -40
  616. package/out/zero-cache/src/services/view-syncer/drain-coordinator.js.map +1 -1
  617. package/out/zero-cache/src/services/view-syncer/inspect-handler.js +95 -178
  618. package/out/zero-cache/src/services/view-syncer/inspect-handler.js.map +1 -1
  619. package/out/zero-cache/src/services/view-syncer/pipeline-driver.d.ts +3 -2
  620. package/out/zero-cache/src/services/view-syncer/pipeline-driver.d.ts.map +1 -1
  621. package/out/zero-cache/src/services/view-syncer/pipeline-driver.js +574 -709
  622. package/out/zero-cache/src/services/view-syncer/pipeline-driver.js.map +1 -1
  623. package/out/zero-cache/src/services/view-syncer/row-record-cache.d.ts.map +1 -1
  624. package/out/zero-cache/src/services/view-syncer/row-record-cache.js +246 -257
  625. package/out/zero-cache/src/services/view-syncer/row-record-cache.js.map +1 -1
  626. package/out/zero-cache/src/services/view-syncer/schema/cvr.js +59 -45
  627. package/out/zero-cache/src/services/view-syncer/schema/cvr.js.map +1 -1
  628. package/out/zero-cache/src/services/view-syncer/schema/init.js +121 -189
  629. package/out/zero-cache/src/services/view-syncer/schema/init.js.map +1 -1
  630. package/out/zero-cache/src/services/view-syncer/schema/types.js +138 -263
  631. package/out/zero-cache/src/services/view-syncer/schema/types.js.map +1 -1
  632. package/out/zero-cache/src/services/view-syncer/snapshotter.d.ts +3 -3
  633. package/out/zero-cache/src/services/view-syncer/snapshotter.d.ts.map +1 -1
  634. package/out/zero-cache/src/services/view-syncer/snapshotter.js +322 -331
  635. package/out/zero-cache/src/services/view-syncer/snapshotter.js.map +1 -1
  636. package/out/zero-cache/src/services/view-syncer/tracer.js +7 -6
  637. package/out/zero-cache/src/services/view-syncer/tracer.js.map +1 -1
  638. package/out/zero-cache/src/services/view-syncer/ttl-clock.js +9 -11
  639. package/out/zero-cache/src/services/view-syncer/ttl-clock.js.map +1 -1
  640. package/out/zero-cache/src/services/view-syncer/view-syncer.js +1067 -1603
  641. package/out/zero-cache/src/services/view-syncer/view-syncer.js.map +1 -1
  642. package/out/zero-cache/src/types/error-with-level.js +19 -25
  643. package/out/zero-cache/src/types/error-with-level.js.map +1 -1
  644. package/out/zero-cache/src/types/http.js +17 -26
  645. package/out/zero-cache/src/types/http.js.map +1 -1
  646. package/out/zero-cache/src/types/lexi-version.js +28 -42
  647. package/out/zero-cache/src/types/lexi-version.js.map +1 -1
  648. package/out/zero-cache/src/types/lite.js +101 -121
  649. package/out/zero-cache/src/types/lite.js.map +1 -1
  650. package/out/zero-cache/src/types/names.js +6 -5
  651. package/out/zero-cache/src/types/names.js.map +1 -1
  652. package/out/zero-cache/src/types/pg-data-type.d.ts +1 -0
  653. package/out/zero-cache/src/types/pg-data-type.d.ts.map +1 -1
  654. package/out/zero-cache/src/types/pg-data-type.js +58 -73
  655. package/out/zero-cache/src/types/pg-data-type.js.map +1 -1
  656. package/out/zero-cache/src/types/pg-types.js +12 -19
  657. package/out/zero-cache/src/types/pg-types.js.map +1 -1
  658. package/out/zero-cache/src/types/pg.js +144 -218
  659. package/out/zero-cache/src/types/pg.js.map +1 -1
  660. package/out/zero-cache/src/types/processes.js +95 -90
  661. package/out/zero-cache/src/types/processes.js.map +1 -1
  662. package/out/zero-cache/src/types/profiler.js +32 -27
  663. package/out/zero-cache/src/types/profiler.js.map +1 -1
  664. package/out/zero-cache/src/types/row-key.js +42 -30
  665. package/out/zero-cache/src/types/row-key.js.map +1 -1
  666. package/out/zero-cache/src/types/shards.js +36 -45
  667. package/out/zero-cache/src/types/shards.js.map +1 -1
  668. package/out/zero-cache/src/types/sql.js +20 -9
  669. package/out/zero-cache/src/types/sql.js.map +1 -1
  670. package/out/zero-cache/src/types/state-version.js +17 -23
  671. package/out/zero-cache/src/types/state-version.js.map +1 -1
  672. package/out/zero-cache/src/types/streams.js +234 -270
  673. package/out/zero-cache/src/types/streams.js.map +1 -1
  674. package/out/zero-cache/src/types/strings.js +10 -13
  675. package/out/zero-cache/src/types/strings.js.map +1 -1
  676. package/out/zero-cache/src/types/subscription.d.ts +3 -1
  677. package/out/zero-cache/src/types/subscription.d.ts.map +1 -1
  678. package/out/zero-cache/src/types/subscription.js +266 -214
  679. package/out/zero-cache/src/types/subscription.js.map +1 -1
  680. package/out/zero-cache/src/types/url-params.js +30 -39
  681. package/out/zero-cache/src/types/url-params.js.map +1 -1
  682. package/out/zero-cache/src/types/websocket-handoff.js +62 -75
  683. package/out/zero-cache/src/types/websocket-handoff.js.map +1 -1
  684. package/out/zero-cache/src/types/ws.js +43 -53
  685. package/out/zero-cache/src/types/ws.js.map +1 -1
  686. package/out/zero-cache/src/workers/connect-params.js +42 -43
  687. package/out/zero-cache/src/workers/connect-params.js.map +1 -1
  688. package/out/zero-cache/src/workers/connection.js +213 -282
  689. package/out/zero-cache/src/workers/connection.js.map +1 -1
  690. package/out/zero-cache/src/workers/mutator.js +22 -21
  691. package/out/zero-cache/src/workers/mutator.js.map +1 -1
  692. package/out/zero-cache/src/workers/replicator.d.ts +7 -0
  693. package/out/zero-cache/src/workers/replicator.d.ts.map +1 -1
  694. package/out/zero-cache/src/workers/replicator.js +92 -97
  695. package/out/zero-cache/src/workers/replicator.js.map +1 -1
  696. package/out/zero-cache/src/workers/syncer-ws-message-handler.js +121 -203
  697. package/out/zero-cache/src/workers/syncer-ws-message-handler.js.map +1 -1
  698. package/out/zero-cache/src/workers/syncer.js +147 -201
  699. package/out/zero-cache/src/workers/syncer.js.map +1 -1
  700. package/out/zero-client/src/client/active-clients-manager.js +178 -187
  701. package/out/zero-client/src/client/active-clients-manager.js.map +1 -1
  702. package/out/zero-client/src/client/bindings.js +11 -0
  703. package/out/zero-client/src/client/client-error-kind-enum.js +18 -29
  704. package/out/zero-client/src/client/client-error-kind-enum.js.map +1 -1
  705. package/out/zero-client/src/client/connection-manager.js +291 -346
  706. package/out/zero-client/src/client/connection-manager.js.map +1 -1
  707. package/out/zero-client/src/client/connection-status-enum.js +20 -15
  708. package/out/zero-client/src/client/connection-status-enum.js.map +1 -1
  709. package/out/zero-client/src/client/connection.js +92 -110
  710. package/out/zero-client/src/client/connection.js.map +1 -1
  711. package/out/zero-client/src/client/context.js +84 -100
  712. package/out/zero-client/src/client/context.js.map +1 -1
  713. package/out/zero-client/src/client/crud-impl.js +56 -88
  714. package/out/zero-client/src/client/crud-impl.js.map +1 -1
  715. package/out/zero-client/src/client/crud.js +127 -129
  716. package/out/zero-client/src/client/crud.js.map +1 -1
  717. package/out/zero-client/src/client/custom.d.ts.map +1 -1
  718. package/out/zero-client/src/client/custom.js +50 -74
  719. package/out/zero-client/src/client/custom.js.map +1 -1
  720. package/out/zero-client/src/client/delete-clients-manager.js +72 -93
  721. package/out/zero-client/src/client/delete-clients-manager.js.map +1 -1
  722. package/out/zero-client/src/client/enable-analytics.js +8 -16
  723. package/out/zero-client/src/client/enable-analytics.js.map +1 -1
  724. package/out/zero-client/src/client/error.js +118 -133
  725. package/out/zero-client/src/client/error.js.map +1 -1
  726. package/out/zero-client/src/client/http-string.js +7 -7
  727. package/out/zero-client/src/client/http-string.js.map +1 -1
  728. package/out/zero-client/src/client/inspector/client-group.js +21 -26
  729. package/out/zero-client/src/client/inspector/client-group.js.map +1 -1
  730. package/out/zero-client/src/client/inspector/client.js +23 -26
  731. package/out/zero-client/src/client/inspector/client.js.map +1 -1
  732. package/out/zero-client/src/client/inspector/html-dialog-prompt.js +72 -73
  733. package/out/zero-client/src/client/inspector/html-dialog-prompt.js.map +1 -1
  734. package/out/zero-client/src/client/inspector/inspector.js +46 -51
  735. package/out/zero-client/src/client/inspector/inspector.js.map +1 -1
  736. package/out/zero-client/src/client/inspector/lazy-inspector.js +132 -192
  737. package/out/zero-client/src/client/inspector/lazy-inspector.js.map +1 -1
  738. package/out/zero-client/src/client/inspector/query.js +72 -77
  739. package/out/zero-client/src/client/inspector/query.js.map +1 -1
  740. package/out/zero-client/src/client/ivm-branch.js +118 -145
  741. package/out/zero-client/src/client/ivm-branch.js.map +1 -1
  742. package/out/zero-client/src/client/keys.js +15 -31
  743. package/out/zero-client/src/client/keys.js.map +1 -1
  744. package/out/zero-client/src/client/log-options.js +43 -57
  745. package/out/zero-client/src/client/log-options.js.map +1 -1
  746. package/out/zero-client/src/client/make-mutate-property.js +46 -29
  747. package/out/zero-client/src/client/make-mutate-property.js.map +1 -1
  748. package/out/zero-client/src/client/make-replicache-mutators.js +80 -96
  749. package/out/zero-client/src/client/make-replicache-mutators.js.map +1 -1
  750. package/out/zero-client/src/client/metric-name-enum.js +11 -15
  751. package/out/zero-client/src/client/metric-name-enum.js.map +1 -1
  752. package/out/zero-client/src/client/metrics.js +210 -237
  753. package/out/zero-client/src/client/metrics.js.map +1 -1
  754. package/out/zero-client/src/client/mutation-tracker.js +264 -354
  755. package/out/zero-client/src/client/mutation-tracker.js.map +1 -1
  756. package/out/zero-client/src/client/mutator-proxy.js +122 -151
  757. package/out/zero-client/src/client/mutator-proxy.js.map +1 -1
  758. package/out/zero-client/src/client/options.js +7 -10
  759. package/out/zero-client/src/client/options.js.map +1 -1
  760. package/out/zero-client/src/client/query-manager.js +305 -373
  761. package/out/zero-client/src/client/query-manager.js.map +1 -1
  762. package/out/zero-client/src/client/reload-error-handler.js +80 -101
  763. package/out/zero-client/src/client/reload-error-handler.js.map +1 -1
  764. package/out/zero-client/src/client/server-option.js +30 -59
  765. package/out/zero-client/src/client/server-option.js.map +1 -1
  766. package/out/zero-client/src/client/update-needed-reason-type-enum.js +27 -9
  767. package/out/zero-client/src/client/update-needed-reason-type-enum.js.map +1 -1
  768. package/out/zero-client/src/client/version.js +9 -5
  769. package/out/zero-client/src/client/version.js.map +1 -1
  770. package/out/zero-client/src/client/zero-poke-handler.d.ts +1 -1
  771. package/out/zero-client/src/client/zero-poke-handler.d.ts.map +1 -1
  772. package/out/zero-client/src/client/zero-poke-handler.js +205 -293
  773. package/out/zero-client/src/client/zero-poke-handler.js.map +1 -1
  774. package/out/zero-client/src/client/zero-rep.js +61 -68
  775. package/out/zero-client/src/client/zero-rep.js.map +1 -1
  776. package/out/zero-client/src/client/zero.d.ts.map +1 -1
  777. package/out/zero-client/src/client/zero.js +1367 -1834
  778. package/out/zero-client/src/client/zero.js.map +1 -1
  779. package/out/zero-client/src/mod.js +21 -0
  780. package/out/zero-client/src/util/nanoid.js +13 -18
  781. package/out/zero-client/src/util/nanoid.js.map +1 -1
  782. package/out/zero-client/src/util/socket.js +6 -5
  783. package/out/zero-client/src/util/socket.js.map +1 -1
  784. package/out/zero-pg/src/mod.js +10 -0
  785. package/out/zero-protocol/src/analyze-query-result.js +108 -148
  786. package/out/zero-protocol/src/analyze-query-result.js.map +1 -1
  787. package/out/zero-protocol/src/application-error.js +36 -34
  788. package/out/zero-protocol/src/application-error.js.map +1 -1
  789. package/out/zero-protocol/src/ast.js +236 -309
  790. package/out/zero-protocol/src/ast.js.map +1 -1
  791. package/out/zero-protocol/src/change-desired-queries.js +8 -13
  792. package/out/zero-protocol/src/change-desired-queries.js.map +1 -1
  793. package/out/zero-protocol/src/client-schema.js +21 -42
  794. package/out/zero-protocol/src/client-schema.js.map +1 -1
  795. package/out/zero-protocol/src/close-connection.js +20 -12
  796. package/out/zero-protocol/src/close-connection.js.map +1 -1
  797. package/out/zero-protocol/src/connect.js +37 -52
  798. package/out/zero-protocol/src/connect.js.map +1 -1
  799. package/out/zero-protocol/src/custom-queries.js +34 -65
  800. package/out/zero-protocol/src/custom-queries.js.map +1 -1
  801. package/out/zero-protocol/src/data.js +6 -9
  802. package/out/zero-protocol/src/data.js.map +1 -1
  803. package/out/zero-protocol/src/delete-clients.js +11 -17
  804. package/out/zero-protocol/src/delete-clients.js.map +1 -1
  805. package/out/zero-protocol/src/down.js +11 -23
  806. package/out/zero-protocol/src/down.js.map +1 -1
  807. package/out/zero-protocol/src/error-kind-enum.js +24 -41
  808. package/out/zero-protocol/src/error-kind-enum.js.map +1 -1
  809. package/out/zero-protocol/src/error-origin-enum.js +8 -9
  810. package/out/zero-protocol/src/error-origin-enum.js.map +1 -1
  811. package/out/zero-protocol/src/error-reason-enum.js +12 -17
  812. package/out/zero-protocol/src/error-reason-enum.js.map +1 -1
  813. package/out/zero-protocol/src/error.js +76 -152
  814. package/out/zero-protocol/src/error.js.map +1 -1
  815. package/out/zero-protocol/src/inspect-down.js +51 -74
  816. package/out/zero-protocol/src/inspect-down.js.map +1 -1
  817. package/out/zero-protocol/src/inspect-up.js +28 -46
  818. package/out/zero-protocol/src/inspect-up.js.map +1 -1
  819. package/out/zero-protocol/src/mutation-id.js +9 -9
  820. package/out/zero-protocol/src/mutation-id.js.map +1 -1
  821. package/out/zero-protocol/src/mutation-type-enum.js +7 -7
  822. package/out/zero-protocol/src/mutation-type-enum.js.map +1 -1
  823. package/out/zero-protocol/src/mutations-patch.js +21 -16
  824. package/out/zero-protocol/src/mutations-patch.js.map +1 -1
  825. package/out/zero-protocol/src/ping.js +8 -9
  826. package/out/zero-protocol/src/ping.js.map +1 -1
  827. package/out/zero-protocol/src/poke.js +53 -59
  828. package/out/zero-protocol/src/poke.js.map +1 -1
  829. package/out/zero-protocol/src/pong.js +8 -9
  830. package/out/zero-protocol/src/pong.js.map +1 -1
  831. package/out/zero-protocol/src/primary-key.js +9 -19
  832. package/out/zero-protocol/src/primary-key.js.map +1 -1
  833. package/out/zero-protocol/src/protocol-version.js +5 -11
  834. package/out/zero-protocol/src/protocol-version.js.map +1 -1
  835. package/out/zero-protocol/src/pull.js +16 -28
  836. package/out/zero-protocol/src/pull.js.map +1 -1
  837. package/out/zero-protocol/src/push.js +162 -209
  838. package/out/zero-protocol/src/push.js.map +1 -1
  839. package/out/zero-protocol/src/queries-patch.js +22 -30
  840. package/out/zero-protocol/src/queries-patch.js.map +1 -1
  841. package/out/zero-protocol/src/query-hash.js +14 -17
  842. package/out/zero-protocol/src/query-hash.js.map +1 -1
  843. package/out/zero-protocol/src/row-patch.js +23 -30
  844. package/out/zero-protocol/src/row-patch.js.map +1 -1
  845. package/out/zero-protocol/src/up.js +11 -22
  846. package/out/zero-protocol/src/up.js.map +1 -1
  847. package/out/zero-protocol/src/update-auth.js +8 -13
  848. package/out/zero-protocol/src/update-auth.js.map +1 -1
  849. package/out/zero-protocol/src/version.js +8 -9
  850. package/out/zero-protocol/src/version.js.map +1 -1
  851. package/out/zero-react/src/bindings.js +12 -0
  852. package/out/zero-react/src/mod.js +5 -0
  853. package/out/zero-react/src/use-connection-state.js +14 -11
  854. package/out/zero-react/src/use-connection-state.js.map +1 -1
  855. package/out/zero-react/src/use-query.js +283 -281
  856. package/out/zero-react/src/use-query.js.map +1 -1
  857. package/out/zero-react/src/use-zero-online.js +17 -11
  858. package/out/zero-react/src/use-zero-online.js.map +1 -1
  859. package/out/zero-react/src/zero-provider.js +53 -69
  860. package/out/zero-react/src/zero-provider.js.map +1 -1
  861. package/out/zero-react/src/zero.js +22 -0
  862. package/out/zero-schema/src/builder/relationship-builder.js +25 -21
  863. package/out/zero-schema/src/builder/relationship-builder.js.map +1 -1
  864. package/out/zero-schema/src/builder/schema-builder.js +51 -79
  865. package/out/zero-schema/src/builder/schema-builder.js.map +1 -1
  866. package/out/zero-schema/src/builder/table-builder.js +99 -116
  867. package/out/zero-schema/src/builder/table-builder.js.map +1 -1
  868. package/out/zero-schema/src/compiled-permissions.js +21 -25
  869. package/out/zero-schema/src/compiled-permissions.js.map +1 -1
  870. package/out/zero-schema/src/name-mapper.js +31 -47
  871. package/out/zero-schema/src/name-mapper.js.map +1 -1
  872. package/out/zero-schema/src/permissions.js +94 -181
  873. package/out/zero-schema/src/permissions.js.map +1 -1
  874. package/out/zero-schema/src/schema-config.js +26 -32
  875. package/out/zero-schema/src/schema-config.js.map +1 -1
  876. package/out/zero-server/src/adapters/drizzle.d.ts.map +1 -1
  877. package/out/zero-server/src/adapters/drizzle.js +79 -76
  878. package/out/zero-server/src/adapters/drizzle.js.map +1 -1
  879. package/out/zero-server/src/adapters/pg.d.ts.map +1 -1
  880. package/out/zero-server/src/adapters/pg.js +79 -55
  881. package/out/zero-server/src/adapters/pg.js.map +1 -1
  882. package/out/zero-server/src/adapters/postgresjs.d.ts.map +1 -1
  883. package/out/zero-server/src/adapters/postgresjs.js +66 -40
  884. package/out/zero-server/src/adapters/postgresjs.js.map +1 -1
  885. package/out/zero-server/src/adapters/prisma.d.ts.map +1 -1
  886. package/out/zero-server/src/adapters/prisma.js +75 -55
  887. package/out/zero-server/src/adapters/prisma.js.map +1 -1
  888. package/out/zero-server/src/custom.d.ts.map +1 -1
  889. package/out/zero-server/src/custom.js +188 -265
  890. package/out/zero-server/src/custom.js.map +1 -1
  891. package/out/zero-server/src/logging.js +6 -5
  892. package/out/zero-server/src/logging.js.map +1 -1
  893. package/out/zero-server/src/mod.js +8 -0
  894. package/out/zero-server/src/pg-query-executor.js +14 -17
  895. package/out/zero-server/src/pg-query-executor.js.map +1 -1
  896. package/out/zero-server/src/process-mutations.js +293 -365
  897. package/out/zero-server/src/process-mutations.js.map +1 -1
  898. package/out/zero-server/src/push-processor.js +33 -49
  899. package/out/zero-server/src/push-processor.js.map +1 -1
  900. package/out/zero-server/src/queries/process-queries.js +106 -96
  901. package/out/zero-server/src/queries/process-queries.js.map +1 -1
  902. package/out/zero-server/src/schema.js +98 -144
  903. package/out/zero-server/src/schema.js.map +1 -1
  904. package/out/zero-server/src/zql-database.d.ts.map +1 -1
  905. package/out/zero-server/src/zql-database.js +54 -69
  906. package/out/zero-server/src/zql-database.js.map +1 -1
  907. package/out/zero-solid/src/bindings.js +12 -0
  908. package/out/zero-solid/src/mod.js +5 -0
  909. package/out/zero-solid/src/solid-view.js +135 -227
  910. package/out/zero-solid/src/solid-view.js.map +1 -1
  911. package/out/zero-solid/src/use-connection-state.js +18 -14
  912. package/out/zero-solid/src/use-connection-state.js.map +1 -1
  913. package/out/zero-solid/src/use-query.js +55 -100
  914. package/out/zero-solid/src/use-query.js.map +1 -1
  915. package/out/zero-solid/src/use-zero-online.js +18 -12
  916. package/out/zero-solid/src/use-zero-online.js.map +1 -1
  917. package/out/zero-solid/src/use-zero.js +65 -77
  918. package/out/zero-solid/src/use-zero.js.map +1 -1
  919. package/out/zero-solid/src/zero.js +22 -0
  920. package/out/zero-types/src/format.js +8 -7
  921. package/out/zero-types/src/format.js.map +1 -1
  922. package/out/zero-types/src/name-mapper.js +34 -47
  923. package/out/zero-types/src/name-mapper.js.map +1 -1
  924. package/out/zql/src/builder/builder.d.ts.map +1 -1
  925. package/out/zql/src/builder/builder.js +315 -476
  926. package/out/zql/src/builder/builder.js.map +1 -1
  927. package/out/zql/src/builder/debug-delegate.js +69 -74
  928. package/out/zql/src/builder/debug-delegate.js.map +1 -1
  929. package/out/zql/src/builder/filter.js +116 -140
  930. package/out/zql/src/builder/filter.js.map +1 -1
  931. package/out/zql/src/builder/like.js +41 -46
  932. package/out/zql/src/builder/like.js.map +1 -1
  933. package/out/zql/src/error.js +10 -9
  934. package/out/zql/src/error.js.map +1 -1
  935. package/out/zql/src/ivm/array-view.js +89 -91
  936. package/out/zql/src/ivm/array-view.js.map +1 -1
  937. package/out/zql/src/ivm/constraint.js +65 -74
  938. package/out/zql/src/ivm/constraint.js.map +1 -1
  939. package/out/zql/src/ivm/data.js +61 -48
  940. package/out/zql/src/ivm/data.js.map +1 -1
  941. package/out/zql/src/ivm/exists.js +164 -213
  942. package/out/zql/src/ivm/exists.js.map +1 -1
  943. package/out/zql/src/ivm/fan-in.js +62 -59
  944. package/out/zql/src/ivm/fan-in.js.map +1 -1
  945. package/out/zql/src/ivm/fan-out.js +52 -61
  946. package/out/zql/src/ivm/fan-out.js.map +1 -1
  947. package/out/zql/src/ivm/filter-operators.js +91 -96
  948. package/out/zql/src/ivm/filter-operators.js.map +1 -1
  949. package/out/zql/src/ivm/filter-push.js +22 -26
  950. package/out/zql/src/ivm/filter-push.js.map +1 -1
  951. package/out/zql/src/ivm/filter.js +41 -35
  952. package/out/zql/src/ivm/filter.js.map +1 -1
  953. package/out/zql/src/ivm/flipped-join.js +282 -391
  954. package/out/zql/src/ivm/flipped-join.js.map +1 -1
  955. package/out/zql/src/ivm/join-utils.js +85 -115
  956. package/out/zql/src/ivm/join-utils.js.map +1 -1
  957. package/out/zql/src/ivm/join.js +162 -231
  958. package/out/zql/src/ivm/join.js.map +1 -1
  959. package/out/zql/src/ivm/maybe-split-and-push-edit-change.js +21 -25
  960. package/out/zql/src/ivm/maybe-split-and-push-edit-change.js.map +1 -1
  961. package/out/zql/src/ivm/memory-source.js +364 -503
  962. package/out/zql/src/ivm/memory-source.js.map +1 -1
  963. package/out/zql/src/ivm/memory-storage.js +33 -34
  964. package/out/zql/src/ivm/memory-storage.js.map +1 -1
  965. package/out/zql/src/ivm/operator.js +13 -15
  966. package/out/zql/src/ivm/operator.js.map +1 -1
  967. package/out/zql/src/ivm/push-accumulated.js +267 -270
  968. package/out/zql/src/ivm/push-accumulated.js.map +1 -1
  969. package/out/zql/src/ivm/skip.js +91 -104
  970. package/out/zql/src/ivm/skip.js.map +1 -1
  971. package/out/zql/src/ivm/stream.js +10 -10
  972. package/out/zql/src/ivm/stream.js.map +1 -1
  973. package/out/zql/src/ivm/take.js +422 -569
  974. package/out/zql/src/ivm/take.js.map +1 -1
  975. package/out/zql/src/ivm/union-fan-in.js +157 -231
  976. package/out/zql/src/ivm/union-fan-in.js.map +1 -1
  977. package/out/zql/src/ivm/union-fan-out.js +38 -43
  978. package/out/zql/src/ivm/union-fan-out.js.map +1 -1
  979. package/out/zql/src/ivm/view-apply-change.js +166 -255
  980. package/out/zql/src/ivm/view-apply-change.js.map +1 -1
  981. package/out/zql/src/mutate/crud.js +35 -34
  982. package/out/zql/src/mutate/crud.js.map +1 -1
  983. package/out/zql/src/mutate/custom.d.ts.map +1 -1
  984. package/out/zql/src/mutate/custom.js +7 -11
  985. package/out/zql/src/mutate/custom.js.map +1 -1
  986. package/out/zql/src/mutate/mutator-registry.js +67 -71
  987. package/out/zql/src/mutate/mutator-registry.js.map +1 -1
  988. package/out/zql/src/mutate/mutator.js +26 -25
  989. package/out/zql/src/mutate/mutator.js.map +1 -1
  990. package/out/zql/src/planner/planner-builder.js +134 -239
  991. package/out/zql/src/planner/planner-builder.js.map +1 -1
  992. package/out/zql/src/planner/planner-connection.js +222 -212
  993. package/out/zql/src/planner/planner-connection.js.map +1 -1
  994. package/out/zql/src/planner/planner-constraint.js +15 -7
  995. package/out/zql/src/planner/planner-constraint.js.map +1 -1
  996. package/out/zql/src/planner/planner-debug.js +199 -224
  997. package/out/zql/src/planner/planner-debug.js.map +1 -1
  998. package/out/zql/src/planner/planner-fan-in.js +146 -162
  999. package/out/zql/src/planner/planner-fan-in.js.map +1 -1
  1000. package/out/zql/src/planner/planner-fan-out.js +62 -74
  1001. package/out/zql/src/planner/planner-fan-out.js.map +1 -1
  1002. package/out/zql/src/planner/planner-graph.js +302 -334
  1003. package/out/zql/src/planner/planner-graph.js.map +1 -1
  1004. package/out/zql/src/planner/planner-join.js +255 -240
  1005. package/out/zql/src/planner/planner-join.js.map +1 -1
  1006. package/out/zql/src/planner/planner-node.js +10 -6
  1007. package/out/zql/src/planner/planner-node.js.map +1 -1
  1008. package/out/zql/src/planner/planner-source.js +15 -22
  1009. package/out/zql/src/planner/planner-source.js.map +1 -1
  1010. package/out/zql/src/planner/planner-terminus.js +28 -28
  1011. package/out/zql/src/planner/planner-terminus.js.map +1 -1
  1012. package/out/zql/src/query/complete-ordering.js +37 -61
  1013. package/out/zql/src/query/complete-ordering.js.map +1 -1
  1014. package/out/zql/src/query/create-builder.js +14 -22
  1015. package/out/zql/src/query/create-builder.js.map +1 -1
  1016. package/out/zql/src/query/error.js +10 -12
  1017. package/out/zql/src/query/error.js.map +1 -1
  1018. package/out/zql/src/query/escape-like.js +6 -5
  1019. package/out/zql/src/query/escape-like.js.map +1 -1
  1020. package/out/zql/src/query/expression.js +138 -157
  1021. package/out/zql/src/query/expression.js.map +1 -1
  1022. package/out/zql/src/query/measure-push-operator.js +35 -38
  1023. package/out/zql/src/query/measure-push-operator.js.map +1 -1
  1024. package/out/zql/src/query/metrics-delegate.js +7 -7
  1025. package/out/zql/src/query/metrics-delegate.js.map +1 -1
  1026. package/out/zql/src/query/named.js +52 -51
  1027. package/out/zql/src/query/named.js.map +1 -1
  1028. package/out/zql/src/query/query-delegate-base.js +190 -238
  1029. package/out/zql/src/query/query-delegate-base.js.map +1 -1
  1030. package/out/zql/src/query/query-impl.d.ts.map +1 -1
  1031. package/out/zql/src/query/query-impl.js +271 -405
  1032. package/out/zql/src/query/query-impl.js.map +1 -1
  1033. package/out/zql/src/query/query-internals.js +16 -8
  1034. package/out/zql/src/query/query-internals.js.map +1 -1
  1035. package/out/zql/src/query/query-registry.js +83 -98
  1036. package/out/zql/src/query/query-registry.js.map +1 -1
  1037. package/out/zql/src/query/query.d.ts.map +1 -1
  1038. package/out/zql/src/query/query.js +2 -0
  1039. package/out/zql/src/query/runnable-query-impl.d.ts.map +1 -1
  1040. package/out/zql/src/query/runnable-query-impl.js +30 -55
  1041. package/out/zql/src/query/runnable-query-impl.js.map +1 -1
  1042. package/out/zql/src/query/static-query.js +7 -14
  1043. package/out/zql/src/query/static-query.js.map +1 -1
  1044. package/out/zql/src/query/ttl.js +45 -67
  1045. package/out/zql/src/query/ttl.js.map +1 -1
  1046. package/out/zql/src/query/validate-input.js +23 -20
  1047. package/out/zql/src/query/validate-input.js.map +1 -1
  1048. package/out/zqlite/src/database-storage.js +99 -103
  1049. package/out/zqlite/src/database-storage.js.map +1 -1
  1050. package/out/zqlite/src/db.js +206 -249
  1051. package/out/zqlite/src/db.js.map +1 -1
  1052. package/out/zqlite/src/explain-queries.js +11 -13
  1053. package/out/zqlite/src/explain-queries.js.map +1 -1
  1054. package/out/zqlite/src/internal/sql-inline.js +54 -37
  1055. package/out/zqlite/src/internal/sql-inline.js.map +1 -1
  1056. package/out/zqlite/src/internal/sql.js +17 -15
  1057. package/out/zqlite/src/internal/sql.js.map +1 -1
  1058. package/out/zqlite/src/internal/statement-cache.js +117 -92
  1059. package/out/zqlite/src/internal/statement-cache.js.map +1 -1
  1060. package/out/zqlite/src/mod.js +5 -0
  1061. package/out/zqlite/src/query-builder.js +81 -172
  1062. package/out/zqlite/src/query-builder.js.map +1 -1
  1063. package/out/zqlite/src/query-delegate.js +45 -55
  1064. package/out/zqlite/src/query-delegate.js.map +1 -1
  1065. package/out/zqlite/src/resolve-scalar-subqueries.js +134 -124
  1066. package/out/zqlite/src/resolve-scalar-subqueries.js.map +1 -1
  1067. package/out/zqlite/src/sqlite-cost-model.js +92 -97
  1068. package/out/zqlite/src/sqlite-cost-model.js.map +1 -1
  1069. package/out/zqlite/src/sqlite-stat-fanout.js +304 -286
  1070. package/out/zqlite/src/sqlite-stat-fanout.js.map +1 -1
  1071. package/out/zqlite/src/table-source.js +281 -455
  1072. package/out/zqlite/src/table-source.js.map +1 -1
  1073. package/package.json +8 -7
  1074. package/out/replicache/src/db/index-operation-enum.js +0 -7
  1075. package/out/replicache/src/db/index-operation-enum.js.map +0 -1
  1076. package/out/replicache/src/db/meta-type-enum.js +0 -7
  1077. package/out/replicache/src/db/meta-type-enum.js.map +0 -1
  1078. package/out/replicache/src/format-version-enum.js +0 -11
  1079. package/out/replicache/src/format-version-enum.js.map +0 -1
  1080. package/out/replicache/src/http-status-unauthorized.js +0 -5
  1081. package/out/replicache/src/http-status-unauthorized.js.map +0 -1
  1082. package/out/replicache/src/invoke-kind-enum.js +0 -7
  1083. package/out/replicache/src/invoke-kind-enum.js.map +0 -1
  1084. package/out/replicache/src/sync/handle-pull-response-result-type-enum.js +0 -9
  1085. package/out/replicache/src/sync/handle-pull-response-result-type-enum.js.map +0 -1
  1086. package/out/zero/package.json.js +0 -9
  1087. package/out/zero/package.json.js.map +0 -1
  1088. package/out/zero/src/adapters/drizzle.js.map +0 -1
  1089. package/out/zero/src/adapters/pg.js.map +0 -1
  1090. package/out/zero/src/adapters/postgresjs.js.map +0 -1
  1091. package/out/zero/src/adapters/prisma.js.map +0 -1
  1092. package/out/zero/src/analyze-query.js.map +0 -1
  1093. package/out/zero/src/ast-to-zql.js.map +0 -1
  1094. package/out/zero/src/bindings.js.map +0 -1
  1095. package/out/zero/src/change-protocol/v0.js.map +0 -1
  1096. package/out/zero/src/cli.js.map +0 -1
  1097. package/out/zero/src/deploy-permissions.js.map +0 -1
  1098. package/out/zero/src/expo-sqlite.js.map +0 -1
  1099. package/out/zero/src/op-sqlite.js.map +0 -1
  1100. package/out/zero/src/pg.js.map +0 -1
  1101. package/out/zero/src/react.js.map +0 -1
  1102. package/out/zero/src/server.js.map +0 -1
  1103. package/out/zero/src/solid.js.map +0 -1
  1104. package/out/zero/src/sqlite.js.map +0 -1
  1105. package/out/zero/src/transform-query.js.map +0 -1
  1106. package/out/zero/src/zero.js.map +0 -1
  1107. package/out/zero/src/zqlite.js.map +0 -1
  1108. package/out/zero-cache/src/db/postgres-replica-identity-enum.js +0 -11
  1109. package/out/zero-cache/src/db/postgres-replica-identity-enum.js.map +0 -1
  1110. package/out/zero-cache/src/db/postgres-type-class-enum.js +0 -17
  1111. package/out/zero-cache/src/db/postgres-type-class-enum.js.map +0 -1
  1112. package/out/zero-cache/src/services/change-streamer/error-type-enum.js +0 -9
  1113. package/out/zero-cache/src/services/change-streamer/error-type-enum.js.map +0 -1
@@ -1,837 +1,774 @@
1
- import { timingSafeEqual } from "node:crypto";
1
+ import { literalUnion, valita_exports } from "../../../shared/src/valita.js";
2
+ import { singleProcessMode } from "../types/processes.js";
3
+ import { DEFAULT_PREFERRED_PREFIXES } from "./network.js";
4
+ import { assertNormalized, isDevelopmentMode } from "./normalize.js";
2
5
  import { logOptions } from "../../../otel/src/log-options.js";
3
6
  import { flagToEnv, parseOptions } from "../../../shared/src/options.js";
4
- import { literalUnion } from "../../../shared/src/valita.js";
5
- import packageJson from "../../../zero/package.json.js";
7
+ import package_default from "../../../zero/package.js";
6
8
  import { runtimeDebugFlags } from "../../../zql/src/builder/debug-delegate.js";
7
- import { singleProcessMode } from "../types/processes.js";
8
9
  import { ALLOWED_APP_ID_CHARACTERS, INVALID_APP_ID_MESSAGE } from "../types/shards.js";
9
- import { DEFAULT_PREFERRED_PREFIXES } from "./network.js";
10
- import { assertNormalized, isDevelopmentMode } from "./normalize.js";
11
- import { array, string, number, boolean } from "@badrap/valita";
12
- const ZERO_ENV_VAR_PREFIX = "ZERO_";
13
- const appOptions = {
14
- id: {
15
- type: string().default("zero").assert((id) => ALLOWED_APP_ID_CHARACTERS.test(id), INVALID_APP_ID_MESSAGE),
16
- desc: [
17
- "Unique identifier for the app.",
18
- "",
19
- "Multiple zero-cache apps can run on a single upstream database, each of which",
20
- "is isolated from the others, with its own permissions, sharding (future feature),",
21
- "and change/cvr databases.",
22
- "",
23
- "The metadata of an app is stored in an upstream schema with the same name,",
24
- 'e.g. "zero", and the metadata for each app shard, e.g. client and mutation',
25
- 'ids, is stored in the "\\{app-id\\}_\\{#\\}" schema. (Currently there is only a single',
26
- '"0" shard, but this will change with sharding).',
27
- "",
28
- 'The CVR and Change data are managed in schemas named "\\{app-id\\}_\\{shard-num\\}/cvr"',
29
- 'and "\\{app-id\\}_\\{shard-num\\}/cdc", respectively, allowing multiple apps and shards',
30
- 'to share the same database instance (e.g. a Postgres "cluster") for CVR and Change management.',
31
- "",
32
- "Due to constraints on replication slot names, an App ID may only consist of",
33
- "lower-case letters, numbers, and the underscore character.",
34
- "",
35
- "Note that this option is used by both {bold zero-cache} and {bold zero-deploy-permissions}."
36
- ]
37
- },
38
- publications: {
39
- type: array(string()).optional(() => []),
40
- desc: [
41
- `Postgres {bold PUBLICATION}s that define the tables and columns to`,
42
- `replicate. Publication names may not begin with an underscore,`,
43
- `as zero reserves that prefix for internal use.`,
44
- ``,
45
- `If unspecified, zero-cache will create and use an internal publication that`,
46
- `publishes all tables in the {bold public} schema, i.e.:`,
47
- ``,
48
- `CREATE PUBLICATION _\\{app-id\\}_public_0 FOR TABLES IN SCHEMA public;`,
49
- ``,
50
- `Note that changing the set of publications will result in resyncing the replica,`,
51
- `which may involve downtime (replication lag) while the new replica is initializing.`,
52
- `To change the set of publications without disrupting an existing app, a new app`,
53
- `should be created.`
54
- ]
55
- }
10
+ import { timingSafeEqual } from "node:crypto";
11
+ //#region ../zero-cache/src/config/zero-config.ts
12
+ var ZERO_ENV_VAR_PREFIX = "ZERO_";
13
+ var appOptions = {
14
+ id: {
15
+ type: valita_exports.string().default("zero").assert((id) => ALLOWED_APP_ID_CHARACTERS.test(id), INVALID_APP_ID_MESSAGE),
16
+ desc: [
17
+ "Unique identifier for the app.",
18
+ "",
19
+ "Multiple zero-cache apps can run on a single upstream database, each of which",
20
+ "is isolated from the others, with its own permissions, sharding (future feature),",
21
+ "and change/cvr databases.",
22
+ "",
23
+ "The metadata of an app is stored in an upstream schema with the same name,",
24
+ "e.g. \"zero\", and the metadata for each app shard, e.g. client and mutation",
25
+ "ids, is stored in the \"\\{app-id\\}_\\{#\\}\" schema. (Currently there is only a single",
26
+ "\"0\" shard, but this will change with sharding).",
27
+ "",
28
+ "The CVR and Change data are managed in schemas named \"\\{app-id\\}_\\{shard-num\\}/cvr\"",
29
+ "and \"\\{app-id\\}_\\{shard-num\\}/cdc\", respectively, allowing multiple apps and shards",
30
+ "to share the same database instance (e.g. a Postgres \"cluster\") for CVR and Change management.",
31
+ "",
32
+ "Due to constraints on replication slot names, an App ID may only consist of",
33
+ "lower-case letters, numbers, and the underscore character.",
34
+ "",
35
+ "Note that this option is used by both {bold zero-cache} and {bold zero-deploy-permissions}."
36
+ ]
37
+ },
38
+ publications: {
39
+ type: valita_exports.array(valita_exports.string()).optional(() => []),
40
+ desc: [
41
+ `Postgres {bold PUBLICATION}s that define the tables and columns to`,
42
+ `replicate. Publication names may not begin with an underscore,`,
43
+ `as zero reserves that prefix for internal use.`,
44
+ ``,
45
+ `If unspecified, zero-cache will create and use an internal publication that`,
46
+ `publishes all tables in the {bold public} schema, i.e.:`,
47
+ ``,
48
+ `CREATE PUBLICATION _\\{app-id\\}_public_0 FOR TABLES IN SCHEMA public;`,
49
+ ``,
50
+ `Note that changing the set of publications will result in resyncing the replica,`,
51
+ `which may involve downtime (replication lag) while the new replica is initializing.`,
52
+ `To change the set of publications without disrupting an existing app, a new app`,
53
+ `should be created.`
54
+ ]
55
+ }
56
56
  };
57
- const shardOptions = {
58
- id: {
59
- type: string().assert(() => {
60
- throw new Error(
61
- `ZERO_SHARD_ID is no longer an option. Please use ZERO_APP_ID instead.`
62
- // TODO: Link to release / migration notes?
63
- );
64
- }).optional(),
65
- hidden: true
66
- },
67
- num: {
68
- type: number().default(0),
69
- desc: [
70
- `The shard number (from 0 to NUM_SHARDS) of the App. zero will eventually`,
71
- `support data sharding as a first-class primitive; until then, deploying`,
72
- `multiple shard-nums creates functionally identical shards. Until sharding is`,
73
- `actually meaningful, this flag is hidden but available for testing.`
74
- ],
75
- hidden: true
76
- }
57
+ var shardOptions = {
58
+ id: {
59
+ type: valita_exports.string().assert(() => {
60
+ throw new Error(`ZERO_SHARD_ID is no longer an option. Please use ZERO_APP_ID instead.`);
61
+ }).optional(),
62
+ hidden: true
63
+ },
64
+ num: {
65
+ type: valita_exports.number().default(0),
66
+ desc: [
67
+ `The shard number (from 0 to NUM_SHARDS) of the App. zero will eventually`,
68
+ `support data sharding as a first-class primitive; until then, deploying`,
69
+ `multiple shard-nums creates functionally identical shards. Until sharding is`,
70
+ `actually meaningful, this flag is hidden but available for testing.`
71
+ ],
72
+ hidden: true
73
+ }
77
74
  };
78
- const replicaOptions = {
79
- file: {
80
- type: string().default("zero.db"),
81
- desc: [
82
- `File path to the SQLite replica that zero-cache maintains.`,
83
- `This can be lost, but if it is, zero-cache will have to re-replicate next`,
84
- `time it starts up.`
85
- ]
86
- },
87
- vacuumIntervalHours: {
88
- type: number().optional(),
89
- desc: [
90
- `Performs a VACUUM at server startup if the specified number of hours has elapsed`,
91
- `since the last VACUUM (or initial-sync). The VACUUM operation is heavyweight`,
92
- `and requires double the size of the db in disk space. If unspecified, VACUUM`,
93
- `operations are not performed.`
94
- ]
95
- }
75
+ var replicaOptions = {
76
+ file: {
77
+ type: valita_exports.string().default("zero.db"),
78
+ desc: [
79
+ `File path to the SQLite replica that zero-cache maintains.`,
80
+ `This can be lost, but if it is, zero-cache will have to re-replicate next`,
81
+ `time it starts up.`
82
+ ]
83
+ },
84
+ vacuumIntervalHours: {
85
+ type: valita_exports.number().optional(),
86
+ desc: [
87
+ `Performs a VACUUM at server startup if the specified number of hours has elapsed`,
88
+ `since the last VACUUM (or initial-sync). The VACUUM operation is heavyweight`,
89
+ `and requires double the size of the db in disk space. If unspecified, VACUUM`,
90
+ `operations are not performed.`
91
+ ]
92
+ }
96
93
  };
97
- const perUserMutationLimit = {
98
- max: {
99
- type: number().optional(),
100
- desc: [
101
- `The maximum mutations per user within the specified {bold windowMs}.`,
102
- `If unset, no rate limiting is enforced.`
103
- ]
104
- },
105
- windowMs: {
106
- type: number().default(6e4),
107
- desc: [
108
- `The sliding window over which the {bold perUserMutationLimitMax} is enforced.`
109
- ]
110
- }
94
+ var perUserMutationLimit = {
95
+ max: {
96
+ type: valita_exports.number().optional(),
97
+ desc: [`The maximum mutations per user within the specified {bold windowMs}.`, `If unset, no rate limiting is enforced.`]
98
+ },
99
+ windowMs: {
100
+ type: valita_exports.number().default(6e4),
101
+ desc: [`The sliding window over which the {bold perUserMutationLimitMax} is enforced.`]
102
+ }
111
103
  };
112
- const authOptions = {
113
- jwk: {
114
- type: string().optional(),
115
- desc: [
116
- `A public key in JWK format used to verify JWTs. Only one of {bold jwk}, {bold jwksUrl} and {bold secret} may be set.`
117
- ],
118
- deprecated: [
119
- `Use cookie-based authentication or an auth token instead - see https://zero.rocicorp.dev/docs/auth.`
120
- ]
121
- },
122
- jwksUrl: {
123
- type: string().optional(),
124
- desc: [
125
- `A URL that returns a JWK set used to verify JWTs. Only one of {bold jwk}, {bold jwksUrl} and {bold secret} may be set.`
126
- ],
127
- deprecated: [
128
- `Use cookie-based authentication or an auth token instead - see https://zero.rocicorp.dev/docs/auth.`
129
- ]
130
- },
131
- secret: {
132
- type: string().optional(),
133
- desc: [
134
- `A symmetric key used to verify JWTs. Only one of {bold jwk}, {bold jwksUrl} and {bold secret} may be set.`
135
- ],
136
- deprecated: [
137
- `Use cookie-based authentication or an auth token instead - see https://zero.rocicorp.dev/docs/auth.`
138
- ]
139
- },
140
- issuer: {
141
- type: string().optional(),
142
- desc: [
143
- `Expected issuer ({bold iss} claim) for JWT validation.`,
144
- `If set, tokens with a different or missing issuer will be rejected.`
145
- ],
146
- deprecated: [
147
- `Use cookie-based authentication or an auth token instead - see https://zero.rocicorp.dev/docs/auth.`
148
- ]
149
- },
150
- audience: {
151
- type: string().optional(),
152
- desc: [
153
- `Expected audience ({bold aud} claim) for JWT validation.`,
154
- `If set, tokens with a different or missing audience will be rejected.`
155
- ],
156
- deprecated: [
157
- `Use cookie-based authentication or an auth token instead - see https://zero.rocicorp.dev/docs/auth.`
158
- ]
159
- }
104
+ var authOptions = {
105
+ jwk: {
106
+ type: valita_exports.string().optional(),
107
+ desc: [`A public key in JWK format used to verify JWTs. Only one of {bold jwk}, {bold jwksUrl} and {bold secret} may be set.`],
108
+ deprecated: [`Use cookie-based authentication or an auth token instead - see https://zero.rocicorp.dev/docs/auth.`]
109
+ },
110
+ jwksUrl: {
111
+ type: valita_exports.string().optional(),
112
+ desc: [`A URL that returns a JWK set used to verify JWTs. Only one of {bold jwk}, {bold jwksUrl} and {bold secret} may be set.`],
113
+ deprecated: [`Use cookie-based authentication or an auth token instead - see https://zero.rocicorp.dev/docs/auth.`]
114
+ },
115
+ secret: {
116
+ type: valita_exports.string().optional(),
117
+ desc: [`A symmetric key used to verify JWTs. Only one of {bold jwk}, {bold jwksUrl} and {bold secret} may be set.`],
118
+ deprecated: [`Use cookie-based authentication or an auth token instead - see https://zero.rocicorp.dev/docs/auth.`]
119
+ },
120
+ issuer: {
121
+ type: valita_exports.string().optional(),
122
+ desc: [`Expected issuer ({bold iss} claim) for JWT validation.`, `If set, tokens with a different or missing issuer will be rejected.`],
123
+ deprecated: [`Use cookie-based authentication or an auth token instead - see https://zero.rocicorp.dev/docs/auth.`]
124
+ },
125
+ audience: {
126
+ type: valita_exports.string().optional(),
127
+ desc: [`Expected audience ({bold aud} claim) for JWT validation.`, `If set, tokens with a different or missing audience will be rejected.`],
128
+ deprecated: [`Use cookie-based authentication or an auth token instead - see https://zero.rocicorp.dev/docs/auth.`]
129
+ }
160
130
  };
161
- const makeDeprecationMessage = (flag) => `Use {bold ${flagToEnv(ZERO_ENV_VAR_PREFIX, flag)}} (or {bold --${flag}}) instead.`;
162
- const makeMutatorQueryOptions = (replacement, suffix) => ({
163
- url: {
164
- type: array(string()).optional(),
165
- // optional until we remove CRUD mutations
166
- desc: [
167
- `The URL of the API server to which zero-cache will ${suffix}.`,
168
- ``,
169
- `{bold IMPORTANT:} URLs are matched using {bold URLPattern}, a standard Web API.`,
170
- ``,
171
- `{bold Pattern Syntax:}`,
172
- ` URLPattern uses a simple and intuitive syntax similar to Express routes.`,
173
- ` Wildcards and named parameters make it easy to match multiple URLs.`,
174
- ``,
175
- `{bold Basic Examples:}`,
176
- ` Exact URL match:`,
177
- ` "https://api.example.com/mutate"`,
178
- ` `,
179
- ` Any subdomain using wildcard:`,
180
- ` "https://*.example.com/mutate"`,
181
- ` `,
182
- ` Multiple subdomain levels:`,
183
- ` "https://*.*.example.com/mutate"`,
184
- ` `,
185
- ` Any path under a domain:`,
186
- ` "https://api.example.com/*"`,
187
- ` `,
188
- ` Named path parameters:`,
189
- ` "https://api.example.com/:version/mutate"`,
190
- ` ↳ Matches "https://api.example.com/v1/mutate", "https://api.example.com/v2/mutate", etc.`,
191
- ``,
192
- `{bold Advanced Patterns:}`,
193
- ` Optional path segments:`,
194
- ` "https://api.example.com/:path?"`,
195
- ` `,
196
- ` Regex in segments (for specific patterns):`,
197
- ` "https://api.example.com/:version(v\\\\d+)/mutate"`,
198
- ` ↳ Matches only "v" followed by digits`,
199
- ``,
200
- `{bold Multiple patterns:}`,
201
- ` ["https://api1.example.com/mutate", "https://api2.example.com/mutate"]`,
202
- ``,
203
- `{bold Note:} Query parameters and URL fragments (#) are automatically ignored during matching.`,
204
- ``,
205
- `For full URLPattern syntax, see: https://developer.mozilla.org/en-US/docs/Web/API/URLPattern`
206
- ],
207
- ...replacement ? { deprecated: [makeDeprecationMessage(`${replacement}-url`)] } : {}
208
- },
209
- apiKey: {
210
- type: string().optional(),
211
- desc: [
212
- `An optional secret used to authorize zero-cache to call the API server handling writes.`
213
- ],
214
- ...replacement ? { deprecated: [makeDeprecationMessage(`${replacement}-api-key`)] } : {}
215
- },
216
- forwardCookies: {
217
- type: boolean().default(false),
218
- desc: [
219
- `If true, zero-cache will forward cookies from the request.`,
220
- `This is useful for passing authentication cookies to the API server.`,
221
- `If false, cookies are not forwarded.`
222
- ],
223
- ...replacement ? { deprecated: [makeDeprecationMessage(`${replacement}-forward-cookies`)] } : {}
224
- },
225
- allowedClientHeaders: {
226
- type: array(string()).optional(),
227
- desc: [
228
- `A list of header names that clients are allowed to set via custom headers.`,
229
- `If specified, only headers in this list will be forwarded to the ${suffix === "push mutations" ? "push" : "query"} URL.`,
230
- `Header names are case-insensitive.`,
231
- `If not specified, no client-provided headers are forwarded (secure by default).`,
232
- `Example: ZERO_${replacement ? replacement.toUpperCase() : suffix === "push mutations" ? "MUTATE" : "QUERY"}_ALLOWED_CLIENT_HEADERS=x-request-id,x-correlation-id`
233
- ],
234
- ...replacement ? {
235
- deprecated: [
236
- makeDeprecationMessage(`${replacement}-allowed-client-headers`)
237
- ]
238
- } : {}
239
- }
131
+ var makeDeprecationMessage = (flag) => `Use {bold ${flagToEnv(ZERO_ENV_VAR_PREFIX, flag)}} (or {bold --${flag}}) instead.`;
132
+ var makeMutatorQueryOptions = (replacement, suffix) => ({
133
+ url: {
134
+ type: valita_exports.array(valita_exports.string()).optional(),
135
+ desc: [
136
+ `The URL of the API server to which zero-cache will ${suffix}.`,
137
+ ``,
138
+ `{bold IMPORTANT:} URLs are matched using {bold URLPattern}, a standard Web API.`,
139
+ ``,
140
+ `{bold Pattern Syntax:}`,
141
+ ` URLPattern uses a simple and intuitive syntax similar to Express routes.`,
142
+ ` Wildcards and named parameters make it easy to match multiple URLs.`,
143
+ ``,
144
+ `{bold Basic Examples:}`,
145
+ ` Exact URL match:`,
146
+ ` "https://api.example.com/mutate"`,
147
+ ` `,
148
+ ` Any subdomain using wildcard:`,
149
+ ` "https://*.example.com/mutate"`,
150
+ ` `,
151
+ ` Multiple subdomain levels:`,
152
+ ` "https://*.*.example.com/mutate"`,
153
+ ` `,
154
+ ` Any path under a domain:`,
155
+ ` "https://api.example.com/*"`,
156
+ ` `,
157
+ ` Named path parameters:`,
158
+ ` "https://api.example.com/:version/mutate"`,
159
+ ` ↳ Matches "https://api.example.com/v1/mutate", "https://api.example.com/v2/mutate", etc.`,
160
+ ``,
161
+ `{bold Advanced Patterns:}`,
162
+ ` Optional path segments:`,
163
+ ` "https://api.example.com/:path?"`,
164
+ ` `,
165
+ ` Regex in segments (for specific patterns):`,
166
+ ` "https://api.example.com/:version(v\\\\d+)/mutate"`,
167
+ ` ↳ Matches only "v" followed by digits`,
168
+ ``,
169
+ `{bold Multiple patterns:}`,
170
+ ` ["https://api1.example.com/mutate", "https://api2.example.com/mutate"]`,
171
+ ``,
172
+ `{bold Note:} Query parameters and URL fragments (#) are automatically ignored during matching.`,
173
+ ``,
174
+ `For full URLPattern syntax, see: https://developer.mozilla.org/en-US/docs/Web/API/URLPattern`
175
+ ],
176
+ ...replacement ? { deprecated: [makeDeprecationMessage(`${replacement}-url`)] } : {}
177
+ },
178
+ apiKey: {
179
+ type: valita_exports.string().optional(),
180
+ desc: [`An optional secret used to authorize zero-cache to call the API server handling writes.`],
181
+ ...replacement ? { deprecated: [makeDeprecationMessage(`${replacement}-api-key`)] } : {}
182
+ },
183
+ forwardCookies: {
184
+ type: valita_exports.boolean().default(false),
185
+ desc: [
186
+ `If true, zero-cache will forward cookies from the request.`,
187
+ `This is useful for passing authentication cookies to the API server.`,
188
+ `If false, cookies are not forwarded.`
189
+ ],
190
+ ...replacement ? { deprecated: [makeDeprecationMessage(`${replacement}-forward-cookies`)] } : {}
191
+ },
192
+ allowedClientHeaders: {
193
+ type: valita_exports.array(valita_exports.string()).optional(),
194
+ desc: [
195
+ `A list of header names that clients are allowed to set via custom headers.`,
196
+ `If specified, only headers in this list will be forwarded to the ${suffix === "push mutations" ? "push" : "query"} URL.`,
197
+ `Header names are case-insensitive.`,
198
+ `If not specified, no client-provided headers are forwarded (secure by default).`,
199
+ `Example: ZERO_${replacement ? replacement.toUpperCase() : suffix === "push mutations" ? "MUTATE" : "QUERY"}_ALLOWED_CLIENT_HEADERS=x-request-id,x-correlation-id`
200
+ ],
201
+ ...replacement ? { deprecated: [makeDeprecationMessage(`${replacement}-allowed-client-headers`)] } : {}
202
+ }
240
203
  });
241
- const mutateOptions = makeMutatorQueryOptions(void 0, "push mutations");
242
- const pushOptions = makeMutatorQueryOptions("mutate", "push mutations");
243
- const queryOptions = makeMutatorQueryOptions(void 0, "send synced queries");
244
- const getQueriesOptions = makeMutatorQueryOptions(
245
- "query",
246
- "send synced queries"
247
- );
248
- const zeroOptions = {
249
- upstream: {
250
- db: {
251
- type: string(),
252
- desc: [
253
- `The "upstream" authoritative postgres database.`,
254
- `In the future we will support other types of upstream besides PG.`
255
- ]
256
- },
257
- type: {
258
- type: literalUnion("pg", "custom").default("pg"),
259
- desc: [
260
- `The meaning of the {bold upstream-db} depends on the upstream type:`,
261
- `* {bold pg}: The connection database string, e.g. "postgres://..."`,
262
- `* {bold custom}: The base URI of the change source "endpoint, e.g.`,
263
- ` "https://my-change-source.dev/changes/v0/stream?apiKey=..."`
264
- ],
265
- hidden: true
266
- // TODO: Unhide when ready to officially support.
267
- },
268
- maxConns: {
269
- type: number().default(20),
270
- desc: [
271
- `The maximum number of connections to open to the upstream database`,
272
- `for committing mutations. This is divided evenly amongst sync workers.`,
273
- `In addition to this number, zero-cache uses one connection for the`,
274
- `replication stream.`,
275
- ``,
276
- `Note that this number must allow for at least one connection per`,
277
- `sync worker, or zero-cache will fail to start. See {bold num-sync-workers}`
278
- ]
279
- },
280
- maxConnsPerWorker: {
281
- type: number().optional(),
282
- hidden: true
283
- // Passed from main thread to sync workers
284
- }
285
- },
286
- /** @deprecated */
287
- push: pushOptions,
288
- mutate: mutateOptions,
289
- /** @deprecated */
290
- getQueries: getQueriesOptions,
291
- query: queryOptions,
292
- cvr: {
293
- db: {
294
- type: string().optional(),
295
- desc: [
296
- `The Postgres database used to store CVRs. CVRs (client view records) keep track`,
297
- `of the data synced to clients in order to determine the diff to send on reconnect.`,
298
- `If unspecified, the {bold upstream-db} will be used.`
299
- ]
300
- },
301
- maxConns: {
302
- type: number().default(30),
303
- desc: [
304
- `The maximum number of connections to open to the CVR database.`,
305
- `This is divided evenly amongst sync workers.`,
306
- ``,
307
- `Note that this number must allow for at least one connection per`,
308
- `sync worker, or zero-cache will fail to start. See {bold num-sync-workers}`
309
- ]
310
- },
311
- maxConnsPerWorker: {
312
- type: number().optional(),
313
- hidden: true
314
- // Passed from main thread to sync workers
315
- },
316
- garbageCollectionInactivityThresholdHours: {
317
- type: number().default(48),
318
- desc: [
319
- `The duration after which an inactive CVR is eligible for garbage collection.`,
320
- `Note that garbage collection is an incremental, periodic process which does not`,
321
- `necessarily purge all eligible CVRs immediately.`
322
- ]
323
- },
324
- garbageCollectionInitialIntervalSeconds: {
325
- type: number().default(60),
326
- desc: [
327
- `The initial interval at which to check and garbage collect inactive CVRs.`,
328
- `This interval is increased exponentially (up to 16 minutes) when there is`,
329
- `nothing to purge.`
330
- ]
331
- },
332
- garbageCollectionInitialBatchSize: {
333
- type: number().default(25),
334
- desc: [
335
- `The initial number of CVRs to purge per garbage collection interval.`,
336
- `This number is increased linearly if the rate of new CVRs exceeds the rate of`,
337
- `purged CVRs, in order to reach a steady state.`,
338
- ``,
339
- `Setting this to 0 effectively disables CVR garbage collection.`
340
- ]
341
- }
342
- },
343
- queryHydrationStats: {
344
- type: boolean().optional(),
345
- desc: [
346
- `Track and log the number of rows considered by query hydrations which`,
347
- `take longer than {bold log-slow-hydrate-threshold} milliseconds.`,
348
- `This is useful for debugging and performance tuning.`
349
- ]
350
- },
351
- enableQueryPlanner: {
352
- type: boolean().default(true),
353
- desc: [
354
- `Enable the query planner for optimizing ZQL queries.`,
355
- ``,
356
- `The query planner analyzes and optimizes query execution by determining`,
357
- `the most efficient join strategies.`,
358
- ``,
359
- `You can disable the planner if it is picking bad strategies.`
360
- ]
361
- },
362
- yieldThresholdMs: {
363
- type: number().default(10),
364
- desc: [
365
- `The maximum amount of time in milliseconds that a sync worker will`,
366
- `spend in IVM (processing query hydration and advancement) before yielding`,
367
- `to the event loop. Lower values increase responsiveness and fairness at`,
368
- `the cost of reduced throughput.`
369
- ]
370
- },
371
- change: {
372
- db: {
373
- type: string().optional(),
374
- desc: [
375
- `The Postgres database used to store recent replication log entries, in order`,
376
- `to sync multiple view-syncers without requiring multiple replication slots on`,
377
- `the upstream database. If unspecified, the {bold upstream-db} will be used.`
378
- ]
379
- },
380
- maxConns: {
381
- type: number().default(5),
382
- desc: [
383
- `The maximum number of connections to open to the change database.`,
384
- `This is used by the {bold change-streamer} for catching up`,
385
- `{bold zero-cache} replication subscriptions.`
386
- ]
387
- }
388
- },
389
- replica: replicaOptions,
390
- log: logOptions,
391
- app: appOptions,
392
- shard: shardOptions,
393
- /** @deprecated */
394
- auth: authOptions,
395
- port: {
396
- type: number().default(4848),
397
- desc: [`The port for sync connections.`]
398
- },
399
- changeStreamer: {
400
- uri: {
401
- type: string().optional(),
402
- desc: [
403
- `When set, connects to the {bold change-streamer} at the given URI.`,
404
- `In a multi-node setup, this should be specified in {bold view-syncer} options,`,
405
- `pointing to the {bold replication-manager} URI, which runs a {bold change-streamer}`,
406
- `on port 4849.`
407
- ]
408
- },
409
- mode: {
410
- type: literalUnion("dedicated", "discover").default("dedicated"),
411
- desc: [
412
- `As an alternative to {bold ZERO_CHANGE_STREAMER_URI}, the {bold ZERO_CHANGE_STREAMER_MODE}`,
413
- `can be set to "{bold discover}" to instruct the {bold view-syncer} to connect to the `,
414
- `ip address registered by the {bold replication-manager} upon startup.`,
415
- ``,
416
- `This may not work in all networking configurations, e.g. certain private `,
417
- `networking or port forwarding configurations. Using the {bold ZERO_CHANGE_STREAMER_URI}`,
418
- `with an explicit routable hostname is recommended instead.`,
419
- ``,
420
- `Note: This option is ignored if the {bold ZERO_CHANGE_STREAMER_URI} is set.`
421
- ]
422
- },
423
- port: {
424
- type: number().optional(),
425
- desc: [
426
- `The port on which the {bold change-streamer} runs. This is an internal`,
427
- `protocol between the {bold replication-manager} and {bold view-syncers}, which`,
428
- `runs in the same process tree in local development or a single-node configuration.`,
429
- ``,
430
- `If unspecified, defaults to {bold --port} + 1.`
431
- ]
432
- },
433
- /** @deprecated */
434
- address: {
435
- type: string().optional(),
436
- deprecated: [
437
- `Set the {bold ZERO_CHANGE_STREAMER_URI} on view-syncers instead.`
438
- ],
439
- hidden: true
440
- },
441
- /** @deprecated */
442
- protocol: {
443
- type: literalUnion("ws", "wss").default("ws"),
444
- deprecated: [
445
- `Set the {bold ZERO_CHANGE_STREAMER_URI} on view-syncers instead.`
446
- ],
447
- hidden: true
448
- },
449
- discoveryInterfacePreferences: {
450
- type: array(string()).default([...DEFAULT_PREFERRED_PREFIXES]),
451
- desc: [
452
- `The name prefixes to prefer when introspecting the network interfaces to determine`,
453
- `the externally reachable IP address for change-streamer discovery. This defaults`,
454
- `to commonly used names for standard ethernet interfaces in order to prevent selecting`,
455
- `special interfaces such as those for VPNs.`
456
- ],
457
- // More confusing than it's worth to advertise this. The default list should be
458
- // adjusted to make things work for all environments; it is controlled as a
459
- // hidden flag as an emergency to unblock people with outlier network configs.
460
- hidden: true
461
- },
462
- startupDelayMs: {
463
- type: number().default(15e3),
464
- desc: [
465
- `The delay to wait before the change-streamer takes over the replication stream`,
466
- `(i.e. the handoff during replication-manager updates), to allow loadbalancers to register`,
467
- `the task as healthy based on healthcheck parameters. Note that if a change stream request`,
468
- `is received during this interval, the delay will be canceled and the takeover will happen`,
469
- `immediately, since the incoming request indicates that the task is registered as a target.`
470
- ]
471
- },
472
- backPressureLimitHeapProportion: {
473
- type: number().default(0.04),
474
- desc: [
475
- `The percentage of {bold --max-old-space-size} to use as a buffer for absorbing replication`,
476
- `stream spikes. When the estimated amount of queued data exceeds this threshold, back pressure`,
477
- `is applied to the replication stream, delaying downstream sync as a result.`,
478
- ``,
479
- `The threshold was determined empirically with load testing. Higher thresholds have resulted`,
480
- `in OOMs. Note also that the byte-counting logic in the queue is strictly an underestimate of`,
481
- `actual memory usage (but importantly, proportionally correct), so the queue is actually`,
482
- `using more than what this proportion suggests.`,
483
- ``,
484
- `This parameter is exported as an emergency knob to reduce the size of the buffer in the`,
485
- `event that the server OOMs from back pressure. Resist the urge to {italic increase} this`,
486
- `proportion, as it is mainly useful for absorbing periodic spikes and does not meaningfully`,
487
- `affect steady-state replication throughput; the latter is determined by other factors such`,
488
- `as object serialization and PG throughput`,
489
- ``,
490
- `In other words, the back pressure limit does not constrain replication throughput;`,
491
- `rather, it protects the system when the upstream throughput exceeds the downstream`,
492
- `throughput.`
493
- ]
494
- }
495
- },
496
- taskID: {
497
- type: string().optional(),
498
- desc: [
499
- `Globally unique identifier for the zero-cache instance.`,
500
- ``,
501
- `Setting this to a platform specific task identifier can be useful for debugging.`,
502
- `If unspecified, zero-cache will attempt to extract the TaskARN if run from within`,
503
- `an AWS ECS container, and otherwise use a random string.`
504
- ]
505
- },
506
- perUserMutationLimit,
507
- numSyncWorkers: {
508
- type: number().optional(),
509
- desc: [
510
- `The number of processes to use for view syncing.`,
511
- `Leave this unset to use the maximum available parallelism.`,
512
- `If set to 0, the server runs without sync workers, which is the`,
513
- `configuration for running the {bold replication-manager}.`
514
- ]
515
- },
516
- autoReset: {
517
- type: boolean().default(true),
518
- desc: [
519
- `Automatically wipe and resync the replica when replication is halted.`,
520
- `This situation can occur for configurations in which the upstream database`,
521
- `provider prohibits event trigger creation, preventing the zero-cache from`,
522
- `being able to correctly replicate schema changes. For such configurations,`,
523
- `an upstream schema change will instead result in halting replication with an`,
524
- `error indicating that the replica needs to be reset.`,
525
- ``,
526
- `When {bold auto-reset} is enabled, zero-cache will respond to such situations`,
527
- `by shutting down, and when restarted, resetting the replica and all synced `,
528
- `clients. This is a heavy-weight operation and can result in user-visible`,
529
- `slowness or downtime if compute resources are scarce.`
530
- ]
531
- },
532
- adminPassword: {
533
- type: string().optional(),
534
- desc: [
535
- `A password used to administer zero-cache server, for example to access the`,
536
- `/statz endpoint.`,
537
- "",
538
- "A password is optional in development mode but {bold required in production} mode."
539
- ]
540
- },
541
- websocketCompression: {
542
- type: boolean().default(false),
543
- desc: [
544
- "Enable WebSocket per-message deflate compression.",
545
- "",
546
- "Compression can reduce bandwidth usage for sync traffic but",
547
- "increases CPU usage on both client and server. Disabled by default.",
548
- "",
549
- "See: https://github.com/websockets/ws#websocket-compression"
550
- ]
551
- },
552
- websocketCompressionOptions: {
553
- type: string().optional(),
554
- desc: [
555
- "JSON string containing WebSocket compression options.",
556
- "",
557
- "Only used if websocketCompression is enabled.",
558
- "",
559
- 'Example: \\{"zlibDeflateOptions":\\{"level":3\\},"threshold":1024\\}',
560
- "",
561
- "See https://github.com/websockets/ws/blob/master/doc/ws.md#new-websocketserveroptions-callback for available options."
562
- ]
563
- },
564
- websocketMaxPayloadBytes: {
565
- type: number().default(10 * 1024 * 1024),
566
- desc: [
567
- "Maximum size of incoming WebSocket messages in bytes.",
568
- "",
569
- "Messages exceeding this limit are rejected before parsing.",
570
- "Default: 10MB (10 * 1024 * 1024 = 10485760)"
571
- ]
572
- },
573
- litestream: {
574
- executable: {
575
- type: string().optional(),
576
- desc: [`Path to the {bold litestream} executable.`]
577
- },
578
- configPath: {
579
- type: string().default("./src/services/litestream/config.yml"),
580
- desc: [
581
- `Path to the litestream yaml config file. zero-cache will run this with its`,
582
- `environment variables, which can be referenced in the file via $\\{ENV\\}`,
583
- `substitution, for example:`,
584
- `* {bold ZERO_REPLICA_FILE} for the db path`,
585
- `* {bold ZERO_LITESTREAM_BACKUP_LOCATION} for the db replica url`,
586
- `* {bold ZERO_LITESTREAM_LOG_LEVEL} for the log level`,
587
- `* {bold ZERO_LOG_FORMAT} for the log type`
588
- ]
589
- },
590
- logLevel: {
591
- type: literalUnion("debug", "info", "warn", "error").default("warn")
592
- },
593
- backupURL: {
594
- type: string().optional(),
595
- desc: [
596
- `The location of the litestream backup, usually an {bold s3://} URL.`,
597
- `This is only consulted by the {bold replication-manager}.`,
598
- `{bold view-syncers} receive this information from the {bold replication-manager}.`
599
- ]
600
- },
601
- endpoint: {
602
- type: string().optional(),
603
- desc: [
604
- `The S3-compatible endpoint URL to use for the litestream backup. Only required for non-AWS services.`,
605
- `The {bold replication-manager} and {bold view-syncers} must have the same endpoint.`
606
- ]
607
- },
608
- port: {
609
- type: number().optional(),
610
- desc: [
611
- `Port on which litestream exports metrics, used to determine the replication`,
612
- `watermark up to which it is safe to purge change log records.`,
613
- ``,
614
- `If unspecified, defaults to {bold --port} + 2.`
615
- ]
616
- },
617
- checkpointThresholdMB: {
618
- type: number().default(40),
619
- desc: [
620
- `The size of the WAL file at which to perform an SQlite checkpoint to apply`,
621
- `the writes in the WAL to the main database file. Each checkpoint creates`,
622
- `a new WAL segment file that will be backed up by litestream. Smaller thresholds`,
623
- `may improve read performance, at the expense of creating more files to download`,
624
- `when restoring the replica from the backup.`
625
- ]
626
- },
627
- minCheckpointPageCount: {
628
- type: number().optional(),
629
- desc: [
630
- `The WAL page count at which SQLite attempts a PASSIVE checkpoint, which`,
631
- `transfers pages to the main database file without blocking writers.`,
632
- `Defaults to {bold checkpointThresholdMB * 250} (since SQLite page size is 4KB).`
633
- ]
634
- },
635
- maxCheckpointPageCount: {
636
- type: number().optional(),
637
- desc: [
638
- `The WAL page count at which SQLite performs a RESTART checkpoint, which`,
639
- `blocks writers until complete. Defaults to {bold minCheckpointPageCount * 10}.`,
640
- `Set to {bold 0} to disable RESTART checkpoints entirely.`
641
- ]
642
- },
643
- incrementalBackupIntervalMinutes: {
644
- type: number().default(15),
645
- desc: [
646
- `The interval between incremental backups of the replica. Shorter intervals`,
647
- `reduce the amount of change history that needs to be replayed when catching`,
648
- `up a new view-syncer, at the expense of increasing the number of files needed`,
649
- `to download for the initial litestream restore.`
650
- ]
651
- },
652
- snapshotBackupIntervalHours: {
653
- type: number().default(12),
654
- desc: [
655
- `The interval between snapshot backups of the replica. Snapshot backups`,
656
- `make a full copy of the database to a new litestream generation. This`,
657
- `improves restore time at the expense of bandwidth. Applications with a`,
658
- `large database and low write rate can increase this interval to reduce`,
659
- `network usage for backups (litestream defaults to 24 hours).`
660
- ]
661
- },
662
- restoreParallelism: {
663
- type: number().default(48),
664
- desc: [
665
- `The number of WAL files to download in parallel when performing the`,
666
- `initial restore of the replica from the backup.`
667
- ]
668
- },
669
- multipartConcurrency: {
670
- type: number().default(48),
671
- desc: [
672
- `The number of parts (of size {bold --litestream-multipart-size} bytes)`,
673
- `to upload or download in parallel when backing up or restoring the snapshot.`
674
- ]
675
- },
676
- multipartSize: {
677
- type: number().default(16 * 1024 * 1024),
678
- desc: [
679
- `The size of each part when uploading or downloading the snapshot with`,
680
- `{bold --multipart-concurrency}. Note that up to {bold concurrency * size}`,
681
- `bytes of memory are used when backing up or restoring the snapshot.`
682
- ]
683
- }
684
- },
685
- storageDBTmpDir: {
686
- type: string().optional(),
687
- desc: [
688
- `tmp directory for IVM operator storage. Leave unset to use os.tmpdir()`
689
- ]
690
- },
691
- initialSync: {
692
- tableCopyWorkers: {
693
- type: number().default(5),
694
- desc: [
695
- `The number of parallel workers used to copy tables during initial sync.`,
696
- `Each worker uses a database connection and will buffer up to (approximately)`,
697
- `10 MB of table data in memory during initial sync. Increasing the number of`,
698
- `workers may improve initial sync speed; however, note that local disk throughput`,
699
- `(i.e. IOPS), upstream CPU, and network bandwidth may also be bottlenecks.`
700
- ]
701
- },
702
- profileCopy: {
703
- type: boolean().optional(),
704
- hidden: true,
705
- desc: [
706
- `Takes a cpu profile during the copy phase initial-sync, storing it as a JSON file`,
707
- `initial-copy.cpuprofile in the tmp directory.`
708
- ]
709
- }
710
- },
711
- /** @deprecated */
712
- targetClientRowCount: {
713
- type: number().default(2e4),
714
- deprecated: [
715
- "This option is no longer used and will be removed in a future version.",
716
- "The client-side cache no longer enforces a row limit. Instead, TTL-based expiration",
717
- "automatically manages cache size to prevent unbounded growth."
718
- ],
719
- hidden: true
720
- },
721
- lazyStartup: {
722
- type: boolean().default(false),
723
- desc: [
724
- "Delay starting the majority of zero-cache until first request.",
725
- "",
726
- "This is mainly intended to avoid connecting to Postgres replication stream",
727
- "until the first request is received, which can be useful i.e., for preview instances.",
728
- "",
729
- "Currently only supported in single-node mode."
730
- ]
731
- },
732
- serverVersion: {
733
- type: string().optional(),
734
- desc: [`The version string outputted to logs when the server starts up.`]
735
- },
736
- enableTelemetry: {
737
- type: boolean().default(true),
738
- desc: [
739
- `Set to false to opt out of telemetry collection.`,
740
- ``,
741
- `This helps us improve Zero by collecting anonymous usage data.`,
742
- `Setting the DO_NOT_TRACK environment variable also disables telemetry.`
743
- ]
744
- },
745
- cloudEvent: {
746
- sinkEnv: {
747
- type: string().optional(),
748
- desc: [
749
- `ENV variable containing a URI to a CloudEvents sink. When set, ZeroEvents`,
750
- `will be published to the sink as the {bold data} field of CloudEvents.`,
751
- `The {bold source} field of the CloudEvents will be set to the {bold ZERO_TASK_ID},`,
752
- `along with any extension attributes specified by the {bold ZERO_CLOUD_EVENT_EXTENSION_OVERRIDES_ENV}.`,
753
- ``,
754
- `This configuration is modeled to easily integrate with a knative K_SINK binding,`,
755
- `(i.e. https://github.com/knative/eventing/blob/main/docs/spec/sources.md#sinkbinding).`,
756
- `However, any CloudEvents sink can be used.`
757
- ]
758
- },
759
- extensionOverridesEnv: {
760
- type: string().optional(),
761
- desc: [
762
- `ENV variable containing a JSON stringified object with an {bold extensions} field`,
763
- `containing attributes that should be added or overridden on outbound CloudEvents.`,
764
- ``,
765
- `This configuration is modeled to easily integrate with a knative K_CE_OVERRIDES binding,`,
766
- `(i.e. https://github.com/knative/eventing/blob/main/docs/spec/sources.md#sinkbinding).`
767
- ]
768
- }
769
- }
204
+ var mutateOptions = makeMutatorQueryOptions(void 0, "push mutations");
205
+ var pushOptions = makeMutatorQueryOptions("mutate", "push mutations");
206
+ var queryOptions = makeMutatorQueryOptions(void 0, "send synced queries");
207
+ var getQueriesOptions = makeMutatorQueryOptions("query", "send synced queries");
208
+ var zeroOptions = {
209
+ upstream: {
210
+ db: {
211
+ type: valita_exports.string(),
212
+ desc: [`The "upstream" authoritative postgres database.`, `In the future we will support other types of upstream besides PG.`]
213
+ },
214
+ type: {
215
+ type: literalUnion("pg", "custom").default("pg"),
216
+ desc: [
217
+ `The meaning of the {bold upstream-db} depends on the upstream type:`,
218
+ `* {bold pg}: The connection database string, e.g. "postgres://..."`,
219
+ `* {bold custom}: The base URI of the change source "endpoint, e.g.`,
220
+ ` "https://my-change-source.dev/changes/v0/stream?apiKey=..."`
221
+ ],
222
+ hidden: true
223
+ },
224
+ maxConns: {
225
+ type: valita_exports.number().default(20),
226
+ desc: [
227
+ `The maximum number of connections to open to the upstream database`,
228
+ `for committing mutations. This is divided evenly amongst sync workers.`,
229
+ `In addition to this number, zero-cache uses one connection for the`,
230
+ `replication stream.`,
231
+ ``,
232
+ `Note that this number must allow for at least one connection per`,
233
+ `sync worker, or zero-cache will fail to start. See {bold num-sync-workers}`
234
+ ]
235
+ },
236
+ maxConnsPerWorker: {
237
+ type: valita_exports.number().optional(),
238
+ hidden: true
239
+ }
240
+ },
241
+ push: pushOptions,
242
+ mutate: mutateOptions,
243
+ getQueries: getQueriesOptions,
244
+ query: queryOptions,
245
+ cvr: {
246
+ db: {
247
+ type: valita_exports.string().optional(),
248
+ desc: [
249
+ `The Postgres database used to store CVRs. CVRs (client view records) keep track`,
250
+ `of the data synced to clients in order to determine the diff to send on reconnect.`,
251
+ `If unspecified, the {bold upstream-db} will be used.`
252
+ ]
253
+ },
254
+ maxConns: {
255
+ type: valita_exports.number().default(30),
256
+ desc: [
257
+ `The maximum number of connections to open to the CVR database.`,
258
+ `This is divided evenly amongst sync workers.`,
259
+ ``,
260
+ `Note that this number must allow for at least one connection per`,
261
+ `sync worker, or zero-cache will fail to start. See {bold num-sync-workers}`
262
+ ]
263
+ },
264
+ maxConnsPerWorker: {
265
+ type: valita_exports.number().optional(),
266
+ hidden: true
267
+ },
268
+ garbageCollectionInactivityThresholdHours: {
269
+ type: valita_exports.number().default(48),
270
+ desc: [
271
+ `The duration after which an inactive CVR is eligible for garbage collection.`,
272
+ `Note that garbage collection is an incremental, periodic process which does not`,
273
+ `necessarily purge all eligible CVRs immediately.`
274
+ ]
275
+ },
276
+ garbageCollectionInitialIntervalSeconds: {
277
+ type: valita_exports.number().default(60),
278
+ desc: [
279
+ `The initial interval at which to check and garbage collect inactive CVRs.`,
280
+ `This interval is increased exponentially (up to 16 minutes) when there is`,
281
+ `nothing to purge.`
282
+ ]
283
+ },
284
+ garbageCollectionInitialBatchSize: {
285
+ type: valita_exports.number().default(25),
286
+ desc: [
287
+ `The initial number of CVRs to purge per garbage collection interval.`,
288
+ `This number is increased linearly if the rate of new CVRs exceeds the rate of`,
289
+ `purged CVRs, in order to reach a steady state.`,
290
+ ``,
291
+ `Setting this to 0 effectively disables CVR garbage collection.`
292
+ ]
293
+ }
294
+ },
295
+ queryHydrationStats: {
296
+ type: valita_exports.boolean().optional(),
297
+ desc: [
298
+ `Track and log the number of rows considered by query hydrations which`,
299
+ `take longer than {bold log-slow-hydrate-threshold} milliseconds.`,
300
+ `This is useful for debugging and performance tuning.`
301
+ ]
302
+ },
303
+ enableQueryPlanner: {
304
+ type: valita_exports.boolean().default(true),
305
+ desc: [
306
+ `Enable the query planner for optimizing ZQL queries.`,
307
+ ``,
308
+ `The query planner analyzes and optimizes query execution by determining`,
309
+ `the most efficient join strategies.`,
310
+ ``,
311
+ `You can disable the planner if it is picking bad strategies.`
312
+ ]
313
+ },
314
+ yieldThresholdMs: {
315
+ type: valita_exports.number().default(10),
316
+ desc: [
317
+ `The maximum amount of time in milliseconds that a sync worker will`,
318
+ `spend in IVM (processing query hydration and advancement) before yielding`,
319
+ `to the event loop. Lower values increase responsiveness and fairness at`,
320
+ `the cost of reduced throughput.`
321
+ ]
322
+ },
323
+ change: {
324
+ db: {
325
+ type: valita_exports.string().optional(),
326
+ desc: [
327
+ `The Postgres database used to store recent replication log entries, in order`,
328
+ `to sync multiple view-syncers without requiring multiple replication slots on`,
329
+ `the upstream database. If unspecified, the {bold upstream-db} will be used.`
330
+ ]
331
+ },
332
+ maxConns: {
333
+ type: valita_exports.number().default(5),
334
+ desc: [
335
+ `The maximum number of connections to open to the change database.`,
336
+ `This is used by the {bold change-streamer} for catching up`,
337
+ `{bold zero-cache} replication subscriptions.`
338
+ ]
339
+ }
340
+ },
341
+ replica: replicaOptions,
342
+ log: logOptions,
343
+ app: appOptions,
344
+ shard: shardOptions,
345
+ auth: authOptions,
346
+ port: {
347
+ type: valita_exports.number().default(4848),
348
+ desc: [`The port for sync connections.`]
349
+ },
350
+ changeStreamer: {
351
+ uri: {
352
+ type: valita_exports.string().optional(),
353
+ desc: [
354
+ `When set, connects to the {bold change-streamer} at the given URI.`,
355
+ `In a multi-node setup, this should be specified in {bold view-syncer} options,`,
356
+ `pointing to the {bold replication-manager} URI, which runs a {bold change-streamer}`,
357
+ `on port 4849.`
358
+ ]
359
+ },
360
+ mode: {
361
+ type: literalUnion("dedicated", "discover").default("dedicated"),
362
+ desc: [
363
+ `As an alternative to {bold ZERO_CHANGE_STREAMER_URI}, the {bold ZERO_CHANGE_STREAMER_MODE}`,
364
+ `can be set to "{bold discover}" to instruct the {bold view-syncer} to connect to the `,
365
+ `ip address registered by the {bold replication-manager} upon startup.`,
366
+ ``,
367
+ `This may not work in all networking configurations, e.g. certain private `,
368
+ `networking or port forwarding configurations. Using the {bold ZERO_CHANGE_STREAMER_URI}`,
369
+ `with an explicit routable hostname is recommended instead.`,
370
+ ``,
371
+ `Note: This option is ignored if the {bold ZERO_CHANGE_STREAMER_URI} is set.`
372
+ ]
373
+ },
374
+ port: {
375
+ type: valita_exports.number().optional(),
376
+ desc: [
377
+ `The port on which the {bold change-streamer} runs. This is an internal`,
378
+ `protocol between the {bold replication-manager} and {bold view-syncers}, which`,
379
+ `runs in the same process tree in local development or a single-node configuration.`,
380
+ ``,
381
+ `If unspecified, defaults to {bold --port} + 1.`
382
+ ]
383
+ },
384
+ address: {
385
+ type: valita_exports.string().optional(),
386
+ deprecated: [`Set the {bold ZERO_CHANGE_STREAMER_URI} on view-syncers instead.`],
387
+ hidden: true
388
+ },
389
+ protocol: {
390
+ type: literalUnion("ws", "wss").default("ws"),
391
+ deprecated: [`Set the {bold ZERO_CHANGE_STREAMER_URI} on view-syncers instead.`],
392
+ hidden: true
393
+ },
394
+ discoveryInterfacePreferences: {
395
+ type: valita_exports.array(valita_exports.string()).default([...DEFAULT_PREFERRED_PREFIXES]),
396
+ desc: [
397
+ `The name prefixes to prefer when introspecting the network interfaces to determine`,
398
+ `the externally reachable IP address for change-streamer discovery. This defaults`,
399
+ `to commonly used names for standard ethernet interfaces in order to prevent selecting`,
400
+ `special interfaces such as those for VPNs.`
401
+ ],
402
+ hidden: true
403
+ },
404
+ startupDelayMs: {
405
+ type: valita_exports.number().default(15e3),
406
+ desc: [
407
+ `The delay to wait before the change-streamer takes over the replication stream`,
408
+ `(i.e. the handoff during replication-manager updates), to allow loadbalancers to register`,
409
+ `the task as healthy based on healthcheck parameters. Note that if a change stream request`,
410
+ `is received during this interval, the delay will be canceled and the takeover will happen`,
411
+ `immediately, since the incoming request indicates that the task is registered as a target.`
412
+ ]
413
+ },
414
+ backPressureLimitHeapProportion: {
415
+ type: valita_exports.number().default(.04),
416
+ desc: [
417
+ `The percentage of {bold --max-old-space-size} to use as a buffer for absorbing replication`,
418
+ `stream spikes. When the estimated amount of queued data exceeds this threshold, back pressure`,
419
+ `is applied to the replication stream, delaying downstream sync as a result.`,
420
+ ``,
421
+ `The threshold was determined empirically with load testing. Higher thresholds have resulted`,
422
+ `in OOMs. Note also that the byte-counting logic in the queue is strictly an underestimate of`,
423
+ `actual memory usage (but importantly, proportionally correct), so the queue is actually`,
424
+ `using more than what this proportion suggests.`,
425
+ ``,
426
+ `This parameter is exported as an emergency knob to reduce the size of the buffer in the`,
427
+ `event that the server OOMs from back pressure. Resist the urge to {italic increase} this`,
428
+ `proportion, as it is mainly useful for absorbing periodic spikes and does not meaningfully`,
429
+ `affect steady-state replication throughput; the latter is determined by other factors such`,
430
+ `as object serialization and PG throughput`,
431
+ ``,
432
+ `In other words, the back pressure limit does not constrain replication throughput;`,
433
+ `rather, it protects the system when the upstream throughput exceeds the downstream`,
434
+ `throughput.`
435
+ ]
436
+ },
437
+ flowControlConsensusPaddingSeconds: {
438
+ type: valita_exports.number().default(1),
439
+ desc: [
440
+ `During periodic flow control checks (every 64kb), the amount of time to wait after the`,
441
+ `majority of subscribers have acked, after which replication will continue even if`,
442
+ `some subscribers have yet to ack. (Note that this is not a timeout for the {italic entire} send,`,
443
+ `but a timeout that starts {italic after} the majority of receivers have acked.)`,
444
+ ``,
445
+ `This allows a bounded amount of time for backlogged subscribers to catch up on each flush`,
446
+ `without forcing all subscribers to wait for the entire backlog to be processed. It is also`,
447
+ `useful for mitigating the effect of unresponsive subscribers due to severed websocket`,
448
+ `connections (until liveness checks disconnect them).`,
449
+ ``,
450
+ `Set this to a negative number to disable early flow control releases. (Not recommended, but`,
451
+ `available as an emergency measure.)`
452
+ ]
453
+ }
454
+ },
455
+ taskID: {
456
+ type: valita_exports.string().optional(),
457
+ desc: [
458
+ `Globally unique identifier for the zero-cache instance.`,
459
+ ``,
460
+ `Setting this to a platform specific task identifier can be useful for debugging.`,
461
+ `If unspecified, zero-cache will attempt to extract the TaskARN if run from within`,
462
+ `an AWS ECS container, and otherwise use a random string.`
463
+ ]
464
+ },
465
+ perUserMutationLimit,
466
+ numSyncWorkers: {
467
+ type: valita_exports.number().optional(),
468
+ desc: [
469
+ `The number of processes to use for view syncing.`,
470
+ `Leave this unset to use the maximum available parallelism.`,
471
+ `If set to 0, the server runs without sync workers, which is the`,
472
+ `configuration for running the {bold replication-manager}.`
473
+ ]
474
+ },
475
+ autoReset: {
476
+ type: valita_exports.boolean().default(true),
477
+ desc: [
478
+ `Automatically wipe and resync the replica when replication is halted.`,
479
+ `This situation can occur for configurations in which the upstream database`,
480
+ `provider prohibits event trigger creation, preventing the zero-cache from`,
481
+ `being able to correctly replicate schema changes. For such configurations,`,
482
+ `an upstream schema change will instead result in halting replication with an`,
483
+ `error indicating that the replica needs to be reset.`,
484
+ ``,
485
+ `When {bold auto-reset} is enabled, zero-cache will respond to such situations`,
486
+ `by shutting down, and when restarted, resetting the replica and all synced `,
487
+ `clients. This is a heavy-weight operation and can result in user-visible`,
488
+ `slowness or downtime if compute resources are scarce.`
489
+ ]
490
+ },
491
+ adminPassword: {
492
+ type: valita_exports.string().optional(),
493
+ desc: [
494
+ `A password used to administer zero-cache server, for example to access the`,
495
+ `/statz endpoint.`,
496
+ "",
497
+ "A password is optional in development mode but {bold required in production} mode."
498
+ ]
499
+ },
500
+ websocketCompression: {
501
+ type: valita_exports.boolean().default(false),
502
+ desc: [
503
+ "Enable WebSocket per-message deflate compression.",
504
+ "",
505
+ "Compression can reduce bandwidth usage for sync traffic but",
506
+ "increases CPU usage on both client and server. Disabled by default.",
507
+ "",
508
+ "See: https://github.com/websockets/ws#websocket-compression"
509
+ ]
510
+ },
511
+ websocketCompressionOptions: {
512
+ type: valita_exports.string().optional(),
513
+ desc: [
514
+ "JSON string containing WebSocket compression options.",
515
+ "",
516
+ "Only used if websocketCompression is enabled.",
517
+ "",
518
+ "Example: \\{\"zlibDeflateOptions\":\\{\"level\":3\\},\"threshold\":1024\\}",
519
+ "",
520
+ "See https://github.com/websockets/ws/blob/master/doc/ws.md#new-websocketserveroptions-callback for available options."
521
+ ]
522
+ },
523
+ websocketMaxPayloadBytes: {
524
+ type: valita_exports.number().default(10 * 1024 * 1024),
525
+ desc: [
526
+ "Maximum size of incoming WebSocket messages in bytes.",
527
+ "",
528
+ "Messages exceeding this limit are rejected before parsing.",
529
+ "Default: 10MB (10 * 1024 * 1024 = 10485760)"
530
+ ]
531
+ },
532
+ litestream: {
533
+ executable: {
534
+ type: valita_exports.string().optional(),
535
+ desc: [`Path to the {bold litestream} executable.`]
536
+ },
537
+ configPath: {
538
+ type: valita_exports.string().default("./src/services/litestream/config.yml"),
539
+ desc: [
540
+ `Path to the litestream yaml config file. zero-cache will run this with its`,
541
+ `environment variables, which can be referenced in the file via $\\{ENV\\}`,
542
+ `substitution, for example:`,
543
+ `* {bold ZERO_REPLICA_FILE} for the db path`,
544
+ `* {bold ZERO_LITESTREAM_BACKUP_LOCATION} for the db replica url`,
545
+ `* {bold ZERO_LITESTREAM_LOG_LEVEL} for the log level`,
546
+ `* {bold ZERO_LOG_FORMAT} for the log type`
547
+ ]
548
+ },
549
+ logLevel: { type: literalUnion("debug", "info", "warn", "error").default("warn") },
550
+ backupURL: {
551
+ type: valita_exports.string().optional(),
552
+ desc: [
553
+ `The location of the litestream backup, usually an {bold s3://} URL.`,
554
+ `This is only consulted by the {bold replication-manager}.`,
555
+ `{bold view-syncers} receive this information from the {bold replication-manager}.`
556
+ ]
557
+ },
558
+ endpoint: {
559
+ type: valita_exports.string().optional(),
560
+ desc: [`The S3-compatible endpoint URL to use for the litestream backup. Only required for non-AWS services.`, `The {bold replication-manager} and {bold view-syncers} must have the same endpoint.`]
561
+ },
562
+ port: {
563
+ type: valita_exports.number().optional(),
564
+ desc: [
565
+ `Port on which litestream exports metrics, used to determine the replication`,
566
+ `watermark up to which it is safe to purge change log records.`,
567
+ ``,
568
+ `If unspecified, defaults to {bold --port} + 2.`
569
+ ]
570
+ },
571
+ checkpointThresholdMB: {
572
+ type: valita_exports.number().default(40),
573
+ desc: [
574
+ `The size of the WAL file at which to perform an SQlite checkpoint to apply`,
575
+ `the writes in the WAL to the main database file. Each checkpoint creates`,
576
+ `a new WAL segment file that will be backed up by litestream. Smaller thresholds`,
577
+ `may improve read performance, at the expense of creating more files to download`,
578
+ `when restoring the replica from the backup.`
579
+ ]
580
+ },
581
+ minCheckpointPageCount: {
582
+ type: valita_exports.number().optional(),
583
+ desc: [
584
+ `The WAL page count at which SQLite attempts a PASSIVE checkpoint, which`,
585
+ `transfers pages to the main database file without blocking writers.`,
586
+ `Defaults to {bold checkpointThresholdMB * 250} (since SQLite page size is 4KB).`
587
+ ]
588
+ },
589
+ maxCheckpointPageCount: {
590
+ type: valita_exports.number().optional(),
591
+ desc: [
592
+ `The WAL page count at which SQLite performs a RESTART checkpoint, which`,
593
+ `blocks writers until complete. Defaults to {bold minCheckpointPageCount * 10}.`,
594
+ `Set to {bold 0} to disable RESTART checkpoints entirely.`
595
+ ]
596
+ },
597
+ incrementalBackupIntervalMinutes: {
598
+ type: valita_exports.number().default(15),
599
+ desc: [
600
+ `The interval between incremental backups of the replica. Shorter intervals`,
601
+ `reduce the amount of change history that needs to be replayed when catching`,
602
+ `up a new view-syncer, at the expense of increasing the number of files needed`,
603
+ `to download for the initial litestream restore.`
604
+ ]
605
+ },
606
+ snapshotBackupIntervalHours: {
607
+ type: valita_exports.number().default(12),
608
+ desc: [
609
+ `The interval between snapshot backups of the replica. Snapshot backups`,
610
+ `make a full copy of the database to a new litestream generation. This`,
611
+ `improves restore time at the expense of bandwidth. Applications with a`,
612
+ `large database and low write rate can increase this interval to reduce`,
613
+ `network usage for backups (litestream defaults to 24 hours).`
614
+ ]
615
+ },
616
+ restoreParallelism: {
617
+ type: valita_exports.number().default(48),
618
+ desc: [`The number of WAL files to download in parallel when performing the`, `initial restore of the replica from the backup.`]
619
+ },
620
+ multipartConcurrency: {
621
+ type: valita_exports.number().default(48),
622
+ desc: [`The number of parts (of size {bold --litestream-multipart-size} bytes)`, `to upload or download in parallel when backing up or restoring the snapshot.`]
623
+ },
624
+ multipartSize: {
625
+ type: valita_exports.number().default(16 * 1024 * 1024),
626
+ desc: [
627
+ `The size of each part when uploading or downloading the snapshot with`,
628
+ `{bold --multipart-concurrency}. Note that up to {bold concurrency * size}`,
629
+ `bytes of memory are used when backing up or restoring the snapshot.`
630
+ ]
631
+ }
632
+ },
633
+ storageDBTmpDir: {
634
+ type: valita_exports.string().optional(),
635
+ desc: [`tmp directory for IVM operator storage. Leave unset to use os.tmpdir()`]
636
+ },
637
+ initialSync: {
638
+ tableCopyWorkers: {
639
+ type: valita_exports.number().default(5),
640
+ desc: [
641
+ `The number of parallel workers used to copy tables during initial sync.`,
642
+ `Each worker uses a database connection and will buffer up to (approximately)`,
643
+ `10 MB of table data in memory during initial sync. Increasing the number of`,
644
+ `workers may improve initial sync speed; however, note that local disk throughput`,
645
+ `(i.e. IOPS), upstream CPU, and network bandwidth may also be bottlenecks.`
646
+ ]
647
+ },
648
+ profileCopy: {
649
+ type: valita_exports.boolean().optional(),
650
+ hidden: true,
651
+ desc: [`Takes a cpu profile during the copy phase initial-sync, storing it as a JSON file`, `initial-copy.cpuprofile in the tmp directory.`]
652
+ }
653
+ },
654
+ targetClientRowCount: {
655
+ type: valita_exports.number().default(2e4),
656
+ deprecated: [
657
+ "This option is no longer used and will be removed in a future version.",
658
+ "The client-side cache no longer enforces a row limit. Instead, TTL-based expiration",
659
+ "automatically manages cache size to prevent unbounded growth."
660
+ ],
661
+ hidden: true
662
+ },
663
+ lazyStartup: {
664
+ type: valita_exports.boolean().default(false),
665
+ desc: [
666
+ "Delay starting the majority of zero-cache until first request.",
667
+ "",
668
+ "This is mainly intended to avoid connecting to Postgres replication stream",
669
+ "until the first request is received, which can be useful i.e., for preview instances.",
670
+ "",
671
+ "Currently only supported in single-node mode."
672
+ ]
673
+ },
674
+ serverVersion: {
675
+ type: valita_exports.string().optional(),
676
+ desc: [`The version string outputted to logs when the server starts up.`]
677
+ },
678
+ enableTelemetry: {
679
+ type: valita_exports.boolean().default(true),
680
+ desc: [
681
+ `Set to false to opt out of telemetry collection.`,
682
+ ``,
683
+ `This helps us improve Zero by collecting anonymous usage data.`,
684
+ `Setting the DO_NOT_TRACK environment variable also disables telemetry.`
685
+ ]
686
+ },
687
+ cloudEvent: {
688
+ sinkEnv: {
689
+ type: valita_exports.string().optional(),
690
+ desc: [
691
+ `ENV variable containing a URI to a CloudEvents sink. When set, ZeroEvents`,
692
+ `will be published to the sink as the {bold data} field of CloudEvents.`,
693
+ `The {bold source} field of the CloudEvents will be set to the {bold ZERO_TASK_ID},`,
694
+ `along with any extension attributes specified by the {bold ZERO_CLOUD_EVENT_EXTENSION_OVERRIDES_ENV}.`,
695
+ ``,
696
+ `This configuration is modeled to easily integrate with a knative K_SINK binding,`,
697
+ `(i.e. https://github.com/knative/eventing/blob/main/docs/spec/sources.md#sinkbinding).`,
698
+ `However, any CloudEvents sink can be used.`
699
+ ]
700
+ },
701
+ extensionOverridesEnv: {
702
+ type: valita_exports.string().optional(),
703
+ desc: [
704
+ `ENV variable containing a JSON stringified object with an {bold extensions} field`,
705
+ `containing attributes that should be added or overridden on outbound CloudEvents.`,
706
+ ``,
707
+ `This configuration is modeled to easily integrate with a knative K_CE_OVERRIDES binding,`,
708
+ `(i.e. https://github.com/knative/eventing/blob/main/docs/spec/sources.md#sinkbinding).`
709
+ ]
710
+ }
711
+ }
770
712
  };
771
- let loadedConfig;
713
+ var loadedConfig;
772
714
  function getZeroConfig(opts = {}) {
773
- if (!loadedConfig || singleProcessMode()) {
774
- loadedConfig = parseOptions(zeroOptions, {
775
- envNamePrefix: ZERO_ENV_VAR_PREFIX,
776
- emitDeprecationWarnings: false,
777
- // overridden at the top level parse
778
- ...opts
779
- });
780
- if (loadedConfig.queryHydrationStats) {
781
- runtimeDebugFlags.trackRowCountsVended = true;
782
- }
783
- }
784
- return loadedConfig;
715
+ if (!loadedConfig || singleProcessMode()) {
716
+ loadedConfig = parseOptions(zeroOptions, {
717
+ envNamePrefix: ZERO_ENV_VAR_PREFIX,
718
+ emitDeprecationWarnings: false,
719
+ ...opts
720
+ });
721
+ if (loadedConfig.queryHydrationStats) runtimeDebugFlags.trackRowCountsVended = true;
722
+ }
723
+ return loadedConfig;
785
724
  }
725
+ /**
726
+ * Same as {@link getZeroConfig}, with an additional check that the
727
+ * config has already been normalized (i.e. by the top level server/runner).
728
+ */
786
729
  function getNormalizedZeroConfig(opts = {}) {
787
- const config = getZeroConfig(opts);
788
- assertNormalized(config);
789
- return config;
730
+ const config = getZeroConfig(opts);
731
+ assertNormalized(config);
732
+ return config;
790
733
  }
734
+ /**
735
+ * Gets the server version from the config if provided. Otherwise it gets it
736
+ * from the Zero package.json.
737
+ */
791
738
  function getServerVersion(config) {
792
- return config?.serverVersion ?? packageJson.version;
739
+ return config?.serverVersion ?? package_default.version;
793
740
  }
794
741
  function isAdminPasswordValid(lc, config, password) {
795
- if (!password && !config.adminPassword && isDevelopmentMode()) {
796
- warnOnce(
797
- lc,
798
- "No admin password set; allowing access in development mode only"
799
- );
800
- return true;
801
- }
802
- if (!config.adminPassword) {
803
- lc.warn?.("No admin password set; denying access");
804
- return false;
805
- }
806
- const passwordBuffer = Buffer.from(password ?? "");
807
- const configBuffer = Buffer.from(config.adminPassword);
808
- if (passwordBuffer.length !== configBuffer.length) {
809
- timingSafeEqual(configBuffer, configBuffer);
810
- lc.warn?.("Invalid admin password");
811
- return false;
812
- }
813
- if (!timingSafeEqual(passwordBuffer, configBuffer)) {
814
- lc.warn?.("Invalid admin password");
815
- return false;
816
- }
817
- lc.debug?.("Admin password accepted");
818
- return true;
742
+ if (!password && !config.adminPassword && isDevelopmentMode()) {
743
+ warnOnce(lc, "No admin password set; allowing access in development mode only");
744
+ return true;
745
+ }
746
+ if (!config.adminPassword) {
747
+ lc.warn?.("No admin password set; denying access");
748
+ return false;
749
+ }
750
+ const passwordBuffer = Buffer.from(password ?? "");
751
+ const configBuffer = Buffer.from(config.adminPassword);
752
+ if (passwordBuffer.length !== configBuffer.length) {
753
+ timingSafeEqual(configBuffer, configBuffer);
754
+ lc.warn?.("Invalid admin password");
755
+ return false;
756
+ }
757
+ if (!timingSafeEqual(passwordBuffer, configBuffer)) {
758
+ lc.warn?.("Invalid admin password");
759
+ return false;
760
+ }
761
+ lc.debug?.("Admin password accepted");
762
+ return true;
819
763
  }
820
- let hasWarned = false;
764
+ var hasWarned = false;
821
765
  function warnOnce(lc, msg) {
822
- if (!hasWarned) {
823
- lc.warn?.(msg);
824
- hasWarned = true;
825
- }
766
+ if (!hasWarned) {
767
+ lc.warn?.(msg);
768
+ hasWarned = true;
769
+ }
826
770
  }
827
- export {
828
- ZERO_ENV_VAR_PREFIX,
829
- appOptions,
830
- getNormalizedZeroConfig,
831
- getServerVersion,
832
- getZeroConfig,
833
- isAdminPasswordValid,
834
- shardOptions,
835
- zeroOptions
836
- };
837
- //# sourceMappingURL=zero-config.js.map
771
+ //#endregion
772
+ export { ZERO_ENV_VAR_PREFIX, appOptions, getNormalizedZeroConfig, getServerVersion, getZeroConfig, isAdminPasswordValid, shardOptions, zeroOptions };
773
+
774
+ //# sourceMappingURL=zero-config.js.map