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