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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (272) hide show
  1. package/out/shared/src/deep-merge.d.ts +20 -3
  2. package/out/shared/src/deep-merge.d.ts.map +1 -1
  3. package/out/shared/src/deep-merge.js +27 -0
  4. package/out/shared/src/deep-merge.js.map +1 -0
  5. package/out/shared/src/logging.d.ts.map +1 -1
  6. package/out/shared/src/logging.js +25 -9
  7. package/out/shared/src/logging.js.map +1 -1
  8. package/out/shared/src/object-traversal.d.ts +19 -0
  9. package/out/shared/src/object-traversal.d.ts.map +1 -0
  10. package/out/shared/src/object-traversal.js +27 -0
  11. package/out/shared/src/object-traversal.js.map +1 -0
  12. package/out/zero/package.json.js +1 -1
  13. package/out/zero/src/pg.js +0 -2
  14. package/out/zero/src/pg.js.map +1 -1
  15. package/out/zero/src/server.js +0 -2
  16. package/out/zero/src/server.js.map +1 -1
  17. package/out/zero/src/zero.js +19 -3
  18. package/out/zero/src/zero.js.map +1 -1
  19. package/out/zero-cache/src/auth/jwt.d.ts +3 -0
  20. package/out/zero-cache/src/auth/jwt.d.ts.map +1 -1
  21. package/out/zero-cache/src/auth/jwt.js.map +1 -1
  22. package/out/zero-cache/src/auth/write-authorizer.d.ts +2 -1
  23. package/out/zero-cache/src/auth/write-authorizer.d.ts.map +1 -1
  24. package/out/zero-cache/src/auth/write-authorizer.js +1 -11
  25. package/out/zero-cache/src/auth/write-authorizer.js.map +1 -1
  26. package/out/zero-cache/src/config/zero-config.d.ts +27 -0
  27. package/out/zero-cache/src/config/zero-config.d.ts.map +1 -1
  28. package/out/zero-cache/src/config/zero-config.js +35 -7
  29. package/out/zero-cache/src/config/zero-config.js.map +1 -1
  30. package/out/zero-cache/src/custom/fetch.d.ts +5 -5
  31. package/out/zero-cache/src/custom/fetch.d.ts.map +1 -1
  32. package/out/zero-cache/src/custom/fetch.js +14 -11
  33. package/out/zero-cache/src/custom/fetch.js.map +1 -1
  34. package/out/zero-cache/src/custom-queries/transform-query.d.ts.map +1 -1
  35. package/out/zero-cache/src/custom-queries/transform-query.js +2 -4
  36. package/out/zero-cache/src/custom-queries/transform-query.js.map +1 -1
  37. package/out/zero-cache/src/db/specs.d.ts +1 -1
  38. package/out/zero-cache/src/server/change-streamer.d.ts.map +1 -1
  39. package/out/zero-cache/src/server/change-streamer.js +9 -9
  40. package/out/zero-cache/src/server/change-streamer.js.map +1 -1
  41. package/out/zero-cache/src/server/syncer.d.ts.map +1 -1
  42. package/out/zero-cache/src/server/syncer.js +20 -8
  43. package/out/zero-cache/src/server/syncer.js.map +1 -1
  44. package/out/zero-cache/src/services/analyze.d.ts +1 -1
  45. package/out/zero-cache/src/services/analyze.d.ts.map +1 -1
  46. package/out/zero-cache/src/services/analyze.js +10 -1
  47. package/out/zero-cache/src/services/analyze.js.map +1 -1
  48. package/out/zero-cache/src/services/change-source/pg/schema/ddl.d.ts +5 -5
  49. package/out/zero-cache/src/services/change-source/pg/schema/published.d.ts +2 -2
  50. package/out/zero-cache/src/services/change-source/pg/schema/shard.d.ts +1 -1
  51. package/out/zero-cache/src/services/change-streamer/change-streamer-http.d.ts +11 -2
  52. package/out/zero-cache/src/services/change-streamer/change-streamer-http.d.ts.map +1 -1
  53. package/out/zero-cache/src/services/change-streamer/change-streamer-http.js +36 -0
  54. package/out/zero-cache/src/services/change-streamer/change-streamer-http.js.map +1 -1
  55. package/out/zero-cache/src/services/http-service.d.ts +5 -4
  56. package/out/zero-cache/src/services/http-service.d.ts.map +1 -1
  57. package/out/zero-cache/src/services/http-service.js +15 -10
  58. package/out/zero-cache/src/services/http-service.js.map +1 -1
  59. package/out/zero-cache/src/services/mutagen/mutagen.d.ts +2 -1
  60. package/out/zero-cache/src/services/mutagen/mutagen.d.ts.map +1 -1
  61. package/out/zero-cache/src/services/mutagen/mutagen.js +3 -2
  62. package/out/zero-cache/src/services/mutagen/mutagen.js.map +1 -1
  63. package/out/zero-cache/src/services/mutagen/pusher.d.ts +198 -0
  64. package/out/zero-cache/src/services/mutagen/pusher.d.ts.map +1 -1
  65. package/out/zero-cache/src/services/mutagen/pusher.js +5 -5
  66. package/out/zero-cache/src/services/mutagen/pusher.js.map +1 -1
  67. package/out/zero-cache/src/services/run-ast.d.ts +4 -0
  68. package/out/zero-cache/src/services/run-ast.d.ts.map +1 -1
  69. package/out/zero-cache/src/services/run-ast.js +8 -1
  70. package/out/zero-cache/src/services/run-ast.js.map +1 -1
  71. package/out/zero-cache/src/services/view-syncer/inspect-handler.d.ts.map +1 -1
  72. package/out/zero-cache/src/services/view-syncer/inspect-handler.js +2 -1
  73. package/out/zero-cache/src/services/view-syncer/inspect-handler.js.map +1 -1
  74. package/out/zero-cache/src/services/view-syncer/pipeline-driver.d.ts.map +1 -1
  75. package/out/zero-cache/src/services/view-syncer/pipeline-driver.js +15 -8
  76. package/out/zero-cache/src/services/view-syncer/pipeline-driver.js.map +1 -1
  77. package/out/zero-cache/src/services/view-syncer/schema/types.d.ts +4 -4
  78. package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts.map +1 -1
  79. package/out/zero-cache/src/services/view-syncer/view-syncer.js +48 -25
  80. package/out/zero-cache/src/services/view-syncer/view-syncer.js.map +1 -1
  81. package/out/zero-cache/src/workers/connection.js +20 -15
  82. package/out/zero-cache/src/workers/connection.js.map +1 -1
  83. package/out/zero-cache/src/workers/syncer.d.ts.map +1 -1
  84. package/out/zero-cache/src/workers/syncer.js +3 -3
  85. package/out/zero-cache/src/workers/syncer.js.map +1 -1
  86. package/out/zero-client/src/client/bindings.d.ts +4 -4
  87. package/out/zero-client/src/client/bindings.d.ts.map +1 -1
  88. package/out/zero-client/src/client/bindings.js.map +1 -1
  89. package/out/zero-client/src/client/connection.d.ts +1 -1
  90. package/out/zero-client/src/client/connection.d.ts.map +1 -1
  91. package/out/zero-client/src/client/connection.js +1 -1
  92. package/out/zero-client/src/client/connection.js.map +1 -1
  93. package/out/zero-client/src/client/crud.d.ts +7 -5
  94. package/out/zero-client/src/client/crud.d.ts.map +1 -1
  95. package/out/zero-client/src/client/crud.js +7 -7
  96. package/out/zero-client/src/client/crud.js.map +1 -1
  97. package/out/zero-client/src/client/custom.d.ts +7 -5
  98. package/out/zero-client/src/client/custom.d.ts.map +1 -1
  99. package/out/zero-client/src/client/custom.js +12 -7
  100. package/out/zero-client/src/client/custom.js.map +1 -1
  101. package/out/zero-client/src/client/inspector/inspector.d.ts +5 -1
  102. package/out/zero-client/src/client/inspector/inspector.d.ts.map +1 -1
  103. package/out/zero-client/src/client/inspector/inspector.js +7 -0
  104. package/out/zero-client/src/client/inspector/inspector.js.map +1 -1
  105. package/out/zero-client/src/client/inspector/lazy-inspector.d.ts.map +1 -1
  106. package/out/zero-client/src/client/inspector/lazy-inspector.js +13 -13
  107. package/out/zero-client/src/client/inspector/lazy-inspector.js.map +1 -1
  108. package/out/zero-client/src/client/make-mutate-property.d.ts +43 -0
  109. package/out/zero-client/src/client/make-mutate-property.d.ts.map +1 -0
  110. package/out/zero-client/src/client/make-mutate-property.js +38 -0
  111. package/out/zero-client/src/client/make-mutate-property.js.map +1 -0
  112. package/out/zero-client/src/client/make-replicache-mutators.d.ts +34 -0
  113. package/out/zero-client/src/client/make-replicache-mutators.d.ts.map +1 -0
  114. package/out/zero-client/src/client/make-replicache-mutators.js +103 -0
  115. package/out/zero-client/src/client/make-replicache-mutators.js.map +1 -0
  116. package/out/zero-client/src/client/options.d.ts +39 -27
  117. package/out/zero-client/src/client/options.d.ts.map +1 -1
  118. package/out/zero-client/src/client/options.js.map +1 -1
  119. package/out/zero-client/src/client/version.js +1 -1
  120. package/out/zero-client/src/client/zero.d.ts +23 -33
  121. package/out/zero-client/src/client/zero.d.ts.map +1 -1
  122. package/out/zero-client/src/client/zero.js +52 -118
  123. package/out/zero-client/src/client/zero.js.map +1 -1
  124. package/out/zero-client/src/mod.d.ts +12 -7
  125. package/out/zero-client/src/mod.d.ts.map +1 -1
  126. package/out/zero-protocol/src/analyze-query-result.d.ts +236 -0
  127. package/out/zero-protocol/src/analyze-query-result.d.ts.map +1 -1
  128. package/out/zero-protocol/src/analyze-query-result.js +128 -2
  129. package/out/zero-protocol/src/analyze-query-result.js.map +1 -1
  130. package/out/zero-protocol/src/ast.d.ts +1 -1
  131. package/out/zero-protocol/src/connect.d.ts.map +1 -1
  132. package/out/zero-protocol/src/connect.js +4 -0
  133. package/out/zero-protocol/src/connect.js.map +1 -1
  134. package/out/zero-protocol/src/custom-queries.d.ts +1 -1
  135. package/out/zero-protocol/src/down.d.ts +99 -0
  136. package/out/zero-protocol/src/down.d.ts.map +1 -1
  137. package/out/zero-protocol/src/error.d.ts +4 -4
  138. package/out/zero-protocol/src/inspect-down.d.ts +297 -0
  139. package/out/zero-protocol/src/inspect-down.d.ts.map +1 -1
  140. package/out/zero-protocol/src/inspect-up.d.ts +4 -0
  141. package/out/zero-protocol/src/inspect-up.d.ts.map +1 -1
  142. package/out/zero-protocol/src/inspect-up.js +2 -1
  143. package/out/zero-protocol/src/inspect-up.js.map +1 -1
  144. package/out/zero-protocol/src/protocol-version.d.ts +1 -1
  145. package/out/zero-protocol/src/protocol-version.d.ts.map +1 -1
  146. package/out/zero-protocol/src/protocol-version.js +1 -1
  147. package/out/zero-protocol/src/protocol-version.js.map +1 -1
  148. package/out/zero-protocol/src/push.d.ts +1 -1
  149. package/out/zero-protocol/src/up.d.ts +1 -0
  150. package/out/zero-protocol/src/up.d.ts.map +1 -1
  151. package/out/zero-react/src/components/inspector.d.ts +3 -2
  152. package/out/zero-react/src/components/inspector.d.ts.map +1 -1
  153. package/out/zero-react/src/components/inspector.js.map +1 -1
  154. package/out/zero-react/src/components/zero-inspector.d.ts +3 -2
  155. package/out/zero-react/src/components/zero-inspector.d.ts.map +1 -1
  156. package/out/zero-react/src/components/zero-inspector.js.map +1 -1
  157. package/out/zero-react/src/use-query.d.ts +5 -4
  158. package/out/zero-react/src/use-query.d.ts.map +1 -1
  159. package/out/zero-react/src/use-query.js +4 -3
  160. package/out/zero-react/src/use-query.js.map +1 -1
  161. package/out/zero-react/src/zero-provider.d.ts +7 -7
  162. package/out/zero-react/src/zero-provider.d.ts.map +1 -1
  163. package/out/zero-react/src/zero-provider.js.map +1 -1
  164. package/out/zero-schema/src/builder/schema-builder.js +1 -1
  165. package/out/zero-schema/src/builder/schema-builder.js.map +1 -1
  166. package/out/zero-server/src/custom.d.ts +4 -5
  167. package/out/zero-server/src/custom.d.ts.map +1 -1
  168. package/out/zero-server/src/custom.js.map +1 -1
  169. package/out/zero-server/src/mod.d.ts +0 -1
  170. package/out/zero-server/src/mod.d.ts.map +1 -1
  171. package/out/zero-server/src/process-mutations.d.ts +9 -14
  172. package/out/zero-server/src/process-mutations.d.ts.map +1 -1
  173. package/out/zero-server/src/process-mutations.js +151 -105
  174. package/out/zero-server/src/process-mutations.js.map +1 -1
  175. package/out/zero-server/src/push-processor.d.ts +5 -3
  176. package/out/zero-server/src/push-processor.d.ts.map +1 -1
  177. package/out/zero-server/src/push-processor.js +17 -25
  178. package/out/zero-server/src/push-processor.js.map +1 -1
  179. package/out/zero-server/src/queries/process-queries.js +1 -1
  180. package/out/zero-server/src/queries/process-queries.js.map +1 -1
  181. package/out/zero-server/src/zql-database.d.ts.map +1 -1
  182. package/out/zero-server/src/zql-database.js +1 -1
  183. package/out/zero-server/src/zql-database.js.map +1 -1
  184. package/out/zero-solid/src/use-query.d.ts +3 -3
  185. package/out/zero-solid/src/use-query.d.ts.map +1 -1
  186. package/out/zero-solid/src/use-query.js +27 -38
  187. package/out/zero-solid/src/use-query.js.map +1 -1
  188. package/out/zero-solid/src/use-zero-connection-state.d.ts.map +1 -1
  189. package/out/zero-solid/src/use-zero-connection-state.js +7 -5
  190. package/out/zero-solid/src/use-zero-connection-state.js.map +1 -1
  191. package/out/zero-solid/src/use-zero-online.d.ts.map +1 -1
  192. package/out/zero-solid/src/use-zero-online.js +7 -5
  193. package/out/zero-solid/src/use-zero-online.js.map +1 -1
  194. package/out/zero-solid/src/use-zero.d.ts +6 -5
  195. package/out/zero-solid/src/use-zero.d.ts.map +1 -1
  196. package/out/zero-solid/src/use-zero.js +2 -6
  197. package/out/zero-solid/src/use-zero.js.map +1 -1
  198. package/out/zql/src/builder/builder.d.ts +2 -1
  199. package/out/zql/src/builder/builder.d.ts.map +1 -1
  200. package/out/zql/src/builder/builder.js +4 -3
  201. package/out/zql/src/builder/builder.js.map +1 -1
  202. package/out/zql/src/mutate/custom.d.ts +15 -6
  203. package/out/zql/src/mutate/custom.d.ts.map +1 -1
  204. package/out/zql/src/mutate/custom.js +6 -6
  205. package/out/zql/src/mutate/custom.js.map +1 -1
  206. package/out/zql/src/mutate/mutator-registry.d.ts +142 -0
  207. package/out/zql/src/mutate/mutator-registry.d.ts.map +1 -0
  208. package/out/zql/src/mutate/mutator-registry.js +97 -0
  209. package/out/zql/src/mutate/mutator-registry.js.map +1 -0
  210. package/out/zql/src/mutate/mutator.d.ts +98 -0
  211. package/out/zql/src/mutate/mutator.d.ts.map +1 -0
  212. package/out/zql/src/mutate/mutator.js +35 -0
  213. package/out/zql/src/mutate/mutator.js.map +1 -0
  214. package/out/zql/src/planner/planner-connection.d.ts +7 -15
  215. package/out/zql/src/planner/planner-connection.d.ts.map +1 -1
  216. package/out/zql/src/planner/planner-connection.js +30 -24
  217. package/out/zql/src/planner/planner-connection.js.map +1 -1
  218. package/out/zql/src/planner/planner-debug.d.ts +37 -43
  219. package/out/zql/src/planner/planner-debug.d.ts.map +1 -1
  220. package/out/zql/src/planner/planner-debug.js +242 -0
  221. package/out/zql/src/planner/planner-debug.js.map +1 -0
  222. package/out/zql/src/planner/planner-fan-in.d.ts.map +1 -1
  223. package/out/zql/src/planner/planner-fan-in.js +11 -8
  224. package/out/zql/src/planner/planner-fan-in.js.map +1 -1
  225. package/out/zql/src/planner/planner-fan-out.d.ts.map +1 -1
  226. package/out/zql/src/planner/planner-fan-out.js +11 -8
  227. package/out/zql/src/planner/planner-fan-out.js.map +1 -1
  228. package/out/zql/src/planner/planner-graph.d.ts.map +1 -1
  229. package/out/zql/src/planner/planner-graph.js +13 -5
  230. package/out/zql/src/planner/planner-graph.js.map +1 -1
  231. package/out/zql/src/planner/planner-join.d.ts.map +1 -1
  232. package/out/zql/src/planner/planner-join.js +12 -9
  233. package/out/zql/src/planner/planner-join.js.map +1 -1
  234. package/out/zql/src/planner/planner-node.d.ts +4 -0
  235. package/out/zql/src/planner/planner-node.d.ts.map +1 -1
  236. package/out/zql/src/planner/planner-node.js +8 -0
  237. package/out/zql/src/planner/planner-node.js.map +1 -0
  238. package/out/zql/src/query/create-builder.d.ts +7 -0
  239. package/out/zql/src/query/create-builder.d.ts.map +1 -0
  240. package/out/zql/src/query/create-builder.js +44 -0
  241. package/out/zql/src/query/create-builder.js.map +1 -0
  242. package/out/zql/src/query/named.d.ts +1 -7
  243. package/out/zql/src/query/named.d.ts.map +1 -1
  244. package/out/zql/src/query/named.js +0 -21
  245. package/out/zql/src/query/named.js.map +1 -1
  246. package/out/zql/src/query/query-impl.d.ts +4 -3
  247. package/out/zql/src/query/query-impl.d.ts.map +1 -1
  248. package/out/zql/src/query/query-impl.js +3 -0
  249. package/out/zql/src/query/query-impl.js.map +1 -1
  250. package/out/zql/src/query/query-internals.js +0 -4
  251. package/out/zql/src/query/query-internals.js.map +1 -1
  252. package/out/zql/src/query/query-registry.d.ts +253 -0
  253. package/out/zql/src/query/query-registry.d.ts.map +1 -0
  254. package/out/zql/src/query/query-registry.js +131 -0
  255. package/out/zql/src/query/query-registry.js.map +1 -0
  256. package/out/zql/src/query/query.d.ts +16 -1
  257. package/out/zql/src/query/query.d.ts.map +1 -1
  258. package/out/zql/src/query/schema-query.d.ts +6 -0
  259. package/out/zql/src/query/schema-query.d.ts.map +1 -0
  260. package/out/zql/src/query/validate-input.js +12 -13
  261. package/out/zql/src/query/validate-input.js.map +1 -1
  262. package/package.json +2 -1
  263. package/out/zero-server/src/query-registry.d.ts +0 -10
  264. package/out/zero-server/src/query-registry.d.ts.map +0 -1
  265. package/out/zero-server/src/query-registry.js +0 -35
  266. package/out/zero-server/src/query-registry.js.map +0 -1
  267. package/out/zql/src/query/define-query.d.ts +0 -75
  268. package/out/zql/src/query/define-query.d.ts.map +0 -1
  269. package/out/zql/src/query/define-query.js +0 -47
  270. package/out/zql/src/query/define-query.js.map +0 -1
  271. package/out/zql/src/query/query-definitions.d.ts +0 -32
  272. package/out/zql/src/query/query-definitions.d.ts.map +0 -1
@@ -84,6 +84,7 @@ export declare const zeroOptions: {
84
84
  hidden: boolean;
85
85
  };
86
86
  };
87
+ /** @deprecated */
87
88
  push: {
88
89
  url: {
89
90
  type: v.Optional<string[]>;
@@ -112,6 +113,7 @@ export declare const zeroOptions: {
112
113
  desc: string[];
113
114
  };
114
115
  };
116
+ /** @deprecated */
115
117
  getQueries: {
116
118
  url: {
117
119
  type: v.Optional<string[]>;
@@ -126,6 +128,20 @@ export declare const zeroOptions: {
126
128
  desc: string[];
127
129
  };
128
130
  };
131
+ query: {
132
+ url: {
133
+ type: v.Optional<string[]>;
134
+ desc: string[];
135
+ };
136
+ apiKey: {
137
+ type: v.Optional<string>;
138
+ desc: string[];
139
+ };
140
+ forwardCookies: {
141
+ type: v.Type<boolean>;
142
+ desc: string[];
143
+ };
144
+ };
129
145
  cvr: {
130
146
  db: {
131
147
  type: v.Optional<string>;
@@ -251,11 +267,13 @@ export declare const zeroOptions: {
251
267
  type: v.Optional<number>;
252
268
  desc: string[];
253
269
  };
270
+ /** @deprecated */
254
271
  address: {
255
272
  type: v.Optional<string>;
256
273
  deprecated: string[];
257
274
  hidden: boolean;
258
275
  };
276
+ /** @deprecated */
259
277
  protocol: {
260
278
  type: v.Type<"ws" | "wss">;
261
279
  deprecated: string[];
@@ -266,6 +284,14 @@ export declare const zeroOptions: {
266
284
  desc: string[];
267
285
  hidden: boolean;
268
286
  };
287
+ startupDelayKeepalives: {
288
+ type: v.Type<number>;
289
+ desc: string[];
290
+ };
291
+ startupDelayMs: {
292
+ type: v.Type<number>;
293
+ desc: string[];
294
+ };
269
295
  };
270
296
  taskID: {
271
297
  type: v.Optional<string>;
@@ -361,6 +387,7 @@ export declare const zeroOptions: {
361
387
  desc: string[];
362
388
  };
363
389
  };
390
+ /** @deprecated */
364
391
  targetClientRowCount: {
365
392
  type: v.Type<number>;
366
393
  deprecated: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"zero-config.d.ts","sourceRoot":"","sources":["../../../../../zero-cache/src/config/zero-config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAEL,KAAK,MAAM,EACX,KAAK,YAAY,EAClB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,CAAC,MAAM,+BAA+B,CAAC;AASnD,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAC,SAAS,EAAC,MAAM,kCAAkC,CAAC;AAEhE,eAAO,MAAM,UAAU;;;;;;;;;CA+CtB,CAAC;AAEF,eAAO,MAAM,YAAY;;;;;;;;;;CAwBxB,CAAC;AAEF,QAAA,MAAM,cAAc;;;;;;;;;CAmBnB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,cAAc,CAAC,CAAC;AAE3D,QAAA,MAAM,oBAAoB;;;;;;;;;CAczB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAE5D,QAAA,MAAM,WAAW;;;;;;;;;;;;;CAmBhB,CAAC;AAuEF,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,WAAW,CAAC,CAAC;AAKpD,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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GAGG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,GAAE,IAAI,CAAC,YAAY,EAAE,eAAe,CAAM,GAC7C,oBAAoB,CAItB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,eAAe,CAAC,GAAG,SAAS,GACpD,MAAM,CAER;AAED,wBAAgB,oBAAoB,CAClC,EAAE,EAAE,UAAU,EACd,MAAM,EAAE,IAAI,CAAC,oBAAoB,EAAE,eAAe,CAAC,EACnD,QAAQ,EAAE,MAAM,GAAG,SAAS,WA4B7B;AAYD,wBAAgB,kBAAkB,SAEjC"}
@@ -74,7 +74,7 @@ const shardOptions = {
74
74
  };
75
75
  const replicaOptions = {
76
76
  file: {
77
- type: string(),
77
+ type: string().default("zero.db"),
78
78
  desc: [
79
79
  `File path to the SQLite replica that zero-cache maintains.`,
80
80
  `This can be lost, but if it is, zero-cache will have to re-replicate next`,
@@ -191,6 +191,10 @@ const makeMutatorQueryOptions = (replacement, suffix) => ({
191
191
  const mutateOptions = makeMutatorQueryOptions(void 0, "push mutations");
192
192
  const pushOptions = makeMutatorQueryOptions("mutate-url", "push mutations");
193
193
  const queryOptions = makeMutatorQueryOptions(void 0, "send synced queries");
194
+ const getQueriesOptions = makeMutatorQueryOptions(
195
+ "query-url",
196
+ "send synced queries"
197
+ );
194
198
  const zeroOptions = {
195
199
  upstream: {
196
200
  db: {
@@ -229,9 +233,12 @@ const zeroOptions = {
229
233
  // Passed from main thread to sync workers
230
234
  }
231
235
  },
236
+ /** @deprecated */
232
237
  push: pushOptions,
233
238
  mutate: mutateOptions,
234
- getQueries: queryOptions,
239
+ /** @deprecated */
240
+ getQueries: getQueriesOptions,
241
+ query: queryOptions,
235
242
  cvr: {
236
243
  db: {
237
244
  type: string().optional(),
@@ -292,16 +299,14 @@ const zeroOptions = {
292
299
  ]
293
300
  },
294
301
  enableQueryPlanner: {
295
- type: boolean().default(false),
302
+ type: boolean().default(true),
296
303
  desc: [
297
304
  `Enable the query planner for optimizing ZQL queries.`,
298
305
  ``,
299
306
  `The query planner analyzes and optimizes query execution by determining`,
300
- `the most efficient join strategies. This feature`,
301
- `is being gradually rolled out and may improve performance for complex`,
302
- `queries that make use of WHERE EXISTS.`,
307
+ `the most efficient join strategies.`,
303
308
  ``,
304
- `When disabled (default), queries use the standard execution path.`
309
+ `You can disable the planner if it is picking bad strategies.`
305
310
  ]
306
311
  },
307
312
  change: {
@@ -365,6 +370,7 @@ const zeroOptions = {
365
370
  `If unspecified, defaults to {bold --port} + 1.`
366
371
  ]
367
372
  },
373
+ /** @deprecated */
368
374
  address: {
369
375
  type: string().optional(),
370
376
  deprecated: [
@@ -372,6 +378,7 @@ const zeroOptions = {
372
378
  ],
373
379
  hidden: true
374
380
  },
381
+ /** @deprecated */
375
382
  protocol: {
376
383
  type: literalUnion("ws", "wss").default("ws"),
377
384
  deprecated: [
@@ -396,6 +403,26 @@ const zeroOptions = {
396
403
  // adjusted to make things work for all environments; it is controlled as a
397
404
  // hidden flag as an emergency to unblock people with outlier network configs.
398
405
  hidden: true
406
+ },
407
+ startupDelayKeepalives: {
408
+ type: number().default(3),
409
+ desc: [
410
+ `The number of /keepalive requests to wait for before the change-streamer takes over`,
411
+ `the replication stream (i.e. the handoff during replication-manager updates). This`,
412
+ `delay is used to verify that the task is recognized by the load balancer as a healthy`,
413
+ `target before the shutdown signal is sent to the previous replication-manager.`
414
+ ]
415
+ },
416
+ startupDelayMs: {
417
+ type: number().default(15e3),
418
+ desc: [
419
+ `The maximum delay to wait before the change-streamer takes over the replication`,
420
+ `stream (i.e. the handoff during replication-manager updates). The takeover will thus`,
421
+ `happen when (1) {bold ZERO_CHANGE_STREAMER_STARTUP_DELAY_KEEPALIVES} are received,`,
422
+ `(2) when {bold ZERO_CHANGE_STREAMER_STARTUP_DELAY_MS} has elapsed since the change-streamer`,
423
+ `service started (i.e. after the replica has been initialized or restored), or (3) when`,
424
+ `a change stream request is received by a view-syncer (i.e. serving-replicator).`
425
+ ]
399
426
  }
400
427
  },
401
428
  taskID: {
@@ -581,6 +608,7 @@ const zeroOptions = {
581
608
  ]
582
609
  }
583
610
  },
611
+ /** @deprecated */
584
612
  targetClientRowCount: {
585
613
  type: number().default(2e4),
586
614
  deprecated: [
@@ -1 +1 @@
1
- {"version":3,"file":"zero-config.js","sources":["../../../../../zero-cache/src/config/zero-config.ts"],"sourcesContent":["/**\n * These types represent the _compiled_ config whereas `define-config` types represent the _source_ config.\n */\n\nimport type {LogContext} from '@rocicorp/logger';\nimport {logOptions} from '../../../otel/src/log-options.ts';\nimport {\n parseOptions,\n type Config,\n type ParseOptions,\n} from '../../../shared/src/options.ts';\nimport * as v from '../../../shared/src/valita.ts';\n// @circular-dep-ignore - importing package.json for version info only\nimport packageJson from '../../../zero/package.json' with {type: 'json'};\nimport {runtimeDebugFlags} from '../../../zql/src/builder/debug-delegate.ts';\nimport {singleProcessMode} from '../types/processes.ts';\nimport {\n ALLOWED_APP_ID_CHARACTERS,\n INVALID_APP_ID_MESSAGE,\n} from '../types/shards.ts';\nimport {\n assertNormalized,\n isDevelopmentMode,\n type NormalizedZeroConfig,\n} from './normalize.ts';\nexport type {LogConfig} from '../../../otel/src/log-options.ts';\n\nexport const appOptions = {\n id: {\n type: v\n .string()\n .default('zero')\n .assert(id => ALLOWED_APP_ID_CHARACTERS.test(id), INVALID_APP_ID_MESSAGE),\n desc: [\n 'Unique identifier for the app.',\n '',\n 'Multiple zero-cache apps can run on a single upstream database, each of which',\n 'is isolated from the others, with its own permissions, sharding (future feature),',\n 'and change/cvr databases.',\n '',\n 'The metadata of an app is stored in an upstream schema with the same name,',\n 'e.g. \"zero\", and the metadata for each app shard, e.g. client and mutation',\n 'ids, is stored in the \"\\\\{app-id\\\\}_\\\\{#\\\\}\" schema. (Currently there is only a single',\n '\"0\" shard, but this will change with sharding).',\n '',\n 'The CVR and Change data are managed in schemas named \"\\\\{app-id\\\\}_\\\\{shard-num\\\\}/cvr\"',\n 'and \"\\\\{app-id\\\\}_\\\\{shard-num\\\\}/cdc\", respectively, allowing multiple apps and shards',\n 'to share the same database instance (e.g. a Postgres \"cluster\") for CVR and Change management.',\n '',\n 'Due to constraints on replication slot names, an App ID may only consist of',\n 'lower-case letters, numbers, and the underscore character.',\n '',\n 'Note that this option is used by both {bold zero-cache} and {bold zero-deploy-permissions}.',\n ],\n },\n\n publications: {\n type: v.array(v.string()).optional(() => []),\n desc: [\n `Postgres {bold PUBLICATION}s that define the tables and columns to`,\n `replicate. Publication names may not begin with an underscore,`,\n `as zero reserves that prefix for internal use.`,\n ``,\n `If unspecified, zero-cache will create and use an internal publication that`,\n `publishes all tables in the {bold public} schema, i.e.:`,\n ``,\n `CREATE PUBLICATION _\\\\{app-id\\\\}_public_0 FOR TABLES IN SCHEMA public;`,\n ``,\n `Note that changing the set of publications will result in resyncing the replica,`,\n `which may involve downtime (replication lag) while the new replica is initializing.`,\n `To change the set of publications without disrupting an existing app, a new app`,\n `should be created.`,\n ],\n },\n};\n\nexport const shardOptions = {\n id: {\n type: v\n .string()\n .assert(() => {\n throw new Error(\n `ZERO_SHARD_ID is no longer an option. Please use ZERO_APP_ID instead.`,\n // TODO: Link to release / migration notes?\n );\n })\n .optional(),\n hidden: true,\n },\n\n num: {\n type: v.number().default(0),\n desc: [\n `The shard number (from 0 to NUM_SHARDS) of the App. zero will eventually`,\n `support data sharding as a first-class primitive; until then, deploying`,\n `multiple shard-nums creates functionally identical shards. Until sharding is`,\n `actually meaningful, this flag is hidden but available for testing.`,\n ],\n hidden: true,\n },\n};\n\nconst replicaOptions = {\n file: {\n type: v.string(),\n desc: [\n `File path to the SQLite replica that zero-cache maintains.`,\n `This can be lost, but if it is, zero-cache will have to re-replicate next`,\n `time it starts up.`,\n ],\n },\n\n vacuumIntervalHours: {\n type: v.number().optional(),\n desc: [\n `Performs a VACUUM at server startup if the specified number of hours has elapsed`,\n `since the last VACUUM (or initial-sync). The VACUUM operation is heavyweight`,\n `and requires double the size of the db in disk space. If unspecified, VACUUM`,\n `operations are not performed.`,\n ],\n },\n};\n\nexport type ReplicaOptions = Config<typeof replicaOptions>;\n\nconst perUserMutationLimit = {\n max: {\n type: v.number().optional(),\n desc: [\n `The maximum mutations per user within the specified {bold windowMs}.`,\n `If unset, no rate limiting is enforced.`,\n ],\n },\n windowMs: {\n type: v.number().default(60_000),\n desc: [\n `The sliding window over which the {bold perUserMutationLimitMax} is enforced.`,\n ],\n },\n};\n\nexport type RateLimit = Config<typeof perUserMutationLimit>;\n\nconst authOptions = {\n jwk: {\n type: v.string().optional(),\n desc: [\n `A public key in JWK format used to verify JWTs. Only one of {bold jwk}, {bold jwksUrl} and {bold secret} may be set.`,\n ],\n },\n jwksUrl: {\n type: v.string().optional(),\n desc: [\n `A URL that returns a JWK set used to verify JWTs. Only one of {bold jwk}, {bold jwksUrl} and {bold secret} may be set.`,\n ],\n },\n secret: {\n type: v.string().optional(),\n desc: [\n `A symmetric key used to verify JWTs. Only one of {bold jwk}, {bold jwksUrl} and {bold secret} may be set.`,\n ],\n },\n};\n\nconst makeMutatorQueryOptions = (\n replacement: string | undefined,\n suffix: string,\n) => ({\n url: {\n type: v.array(v.string()).optional(), // optional until we remove CRUD mutations\n desc: [\n replacement ? `DEPRECATED. Use ${replacement} instead.` : ``,\n `The URL of the API server to which zero-cache will ${suffix}.`,\n ``,\n `{bold IMPORTANT:} URLs are matched using {bold URLPattern}, a standard Web API.`,\n ``,\n `{bold Pattern Syntax:}`,\n ` URLPattern uses a simple and intuitive syntax similar to Express routes.`,\n ` Wildcards and named parameters make it easy to match multiple URLs.`,\n ``,\n `{bold Basic Examples:}`,\n ` Exact URL match:`,\n ` \"https://api.example.com/mutate\"`,\n ` `,\n ` Any subdomain using wildcard:`,\n ` \"https://*.example.com/mutate\"`,\n ` `,\n ` Multiple subdomain levels:`,\n ` \"https://*.*.example.com/mutate\"`,\n ` `,\n ` Any path under a domain:`,\n ` \"https://api.example.com/*\"`,\n ` `,\n ` Named path parameters:`,\n ` \"https://api.example.com/:version/mutate\"`,\n ` ↳ Matches \"https://api.example.com/v1/mutate\", \"https://api.example.com/v2/mutate\", etc.`,\n ``,\n `{bold Advanced Patterns:}`,\n ` Optional path segments:`,\n ` \"https://api.example.com/:path?\"`,\n ` `,\n ` Regex in segments (for specific patterns):`,\n ` \"https://api.example.com/:version(v\\\\\\\\d+)/mutate\"`,\n ` ↳ Matches only \"v\" followed by digits`,\n ``,\n `{bold Multiple patterns:}`,\n ` [\"https://api1.example.com/mutate\", \"https://api2.example.com/mutate\"]`,\n ``,\n `{bold Note:} Query parameters and URL fragments (#) are automatically ignored during matching.`,\n ``,\n `For full URLPattern syntax, see: https://developer.mozilla.org/en-US/docs/Web/API/URLPattern`,\n ],\n },\n apiKey: {\n type: v.string().optional(),\n desc: [\n `An optional secret used to authorize zero-cache to call the API server handling writes.`,\n ],\n },\n forwardCookies: {\n type: v.boolean().default(false),\n desc: [\n `If true, zero-cache will forward cookies from the request.`,\n `This is useful for passing authentication cookies to the API server.`,\n `If false, cookies are not forwarded.`,\n ],\n },\n});\n\nconst mutateOptions = makeMutatorQueryOptions(undefined, 'push mutations');\nconst pushOptions = makeMutatorQueryOptions('mutate-url', 'push mutations');\nconst queryOptions = makeMutatorQueryOptions(undefined, 'send synced queries');\n\nexport type AuthConfig = Config<typeof authOptions>;\n\n// Note: --help will list flags in the order in which they are defined here,\n// so order the fields such that the important (e.g. required) ones are first.\n// (Exported for testing)\nexport const zeroOptions = {\n upstream: {\n db: {\n type: v.string(),\n desc: [\n `The \"upstream\" authoritative postgres database.`,\n `In the future we will support other types of upstream besides PG.`,\n ],\n },\n\n type: {\n type: v.literalUnion('pg', 'custom').default('pg'),\n desc: [\n `The meaning of the {bold upstream-db} depends on the upstream type:`,\n `* {bold pg}: The connection database string, e.g. \"postgres://...\"`,\n `* {bold custom}: The base URI of the change source \"endpoint, e.g.`,\n ` \"https://my-change-source.dev/changes/v0/stream?apiKey=...\"`,\n ],\n hidden: true, // TODO: Unhide when ready to officially support.\n },\n\n maxConns: {\n type: v.number().default(20),\n desc: [\n `The maximum number of connections to open to the upstream database`,\n `for committing mutations. This is divided evenly amongst sync workers.`,\n `In addition to this number, zero-cache uses one connection for the`,\n `replication stream.`,\n ``,\n `Note that this number must allow for at least one connection per`,\n `sync worker, or zero-cache will fail to start. See {bold num-sync-workers}`,\n ],\n },\n\n maxConnsPerWorker: {\n type: v.number().optional(),\n hidden: true, // Passed from main thread to sync workers\n },\n },\n\n push: pushOptions,\n mutate: mutateOptions,\n getQueries: queryOptions,\n\n cvr: {\n db: {\n type: v.string().optional(),\n desc: [\n `The Postgres database used to store CVRs. CVRs (client view records) keep track`,\n `of the data synced to clients in order to determine the diff to send on reconnect.`,\n `If unspecified, the {bold upstream-db} will be used.`,\n ],\n },\n\n maxConns: {\n type: v.number().default(30),\n desc: [\n `The maximum number of connections to open to the CVR database.`,\n `This is divided evenly amongst sync workers.`,\n ``,\n `Note that this number must allow for at least one connection per`,\n `sync worker, or zero-cache will fail to start. See {bold num-sync-workers}`,\n ],\n },\n\n maxConnsPerWorker: {\n type: v.number().optional(),\n hidden: true, // Passed from main thread to sync workers\n },\n\n garbageCollectionInactivityThresholdHours: {\n type: v.number().default(48),\n desc: [\n `The duration after which an inactive CVR is eligible for garbage collection.`,\n `Note that garbage collection is an incremental, periodic process which does not`,\n `necessarily purge all eligible CVRs immediately.`,\n ],\n },\n\n garbageCollectionInitialIntervalSeconds: {\n type: v.number().default(60),\n desc: [\n `The initial interval at which to check and garbage collect inactive CVRs.`,\n `This interval is increased exponentially (up to 16 minutes) when there is`,\n `nothing to purge.`,\n ],\n },\n\n garbageCollectionInitialBatchSize: {\n type: v.number().default(25),\n desc: [\n `The initial number of CVRs to purge per garbage collection interval.`,\n `This number is increased linearly if the rate of new CVRs exceeds the rate of`,\n `purged CVRs, in order to reach a steady state.`,\n ``,\n `Setting this to 0 effectively disables CVR garbage collection.`,\n ],\n },\n },\n\n queryHydrationStats: {\n type: v.boolean().optional(),\n desc: [\n `Track and log the number of rows considered by query hydrations which`,\n `take longer than {bold log-slow-hydrate-threshold} milliseconds.`,\n `This is useful for debugging and performance tuning.`,\n ],\n },\n\n enableQueryPlanner: {\n type: v.boolean().default(false),\n desc: [\n `Enable the query planner for optimizing ZQL queries.`,\n ``,\n `The query planner analyzes and optimizes query execution by determining`,\n `the most efficient join strategies. This feature`,\n `is being gradually rolled out and may improve performance for complex`,\n `queries that make use of WHERE EXISTS.`,\n ``,\n `When disabled (default), queries use the standard execution path.`,\n ],\n },\n\n change: {\n db: {\n type: v.string().optional(),\n desc: [\n `The Postgres database used to store recent replication log entries, in order`,\n `to sync multiple view-syncers without requiring multiple replication slots on`,\n `the upstream database. If unspecified, the {bold upstream-db} will be used.`,\n ],\n },\n\n maxConns: {\n type: v.number().default(5),\n desc: [\n `The maximum number of connections to open to the change database.`,\n `This is used by the {bold change-streamer} for catching up`,\n `{bold zero-cache} replication subscriptions.`,\n ],\n },\n },\n\n replica: replicaOptions,\n\n log: logOptions,\n\n app: appOptions,\n\n shard: shardOptions,\n\n auth: authOptions,\n\n port: {\n type: v.number().default(4848),\n desc: [`The port for sync connections.`],\n },\n\n changeStreamer: {\n uri: {\n type: v.string().optional(),\n desc: [\n `When set, connects to the {bold change-streamer} at the given URI.`,\n `In a multi-node setup, this should be specified in {bold view-syncer} options,`,\n `pointing to the {bold replication-manager} URI, which runs a {bold change-streamer}`,\n `on port 4849.`,\n ],\n },\n\n mode: {\n type: v.literalUnion('dedicated', 'discover').default('dedicated'),\n desc: [\n `As an alternative to {bold ZERO_CHANGE_STREAMER_URI}, the {bold ZERO_CHANGE_STREAMER_MODE}`,\n `can be set to \"{bold discover}\" to instruct the {bold view-syncer} to connect to the `,\n `ip address registered by the {bold replication-manager} upon startup.`,\n ``,\n `This may not work in all networking configurations, e.g. certain private `,\n `networking or port forwarding configurations. Using the {bold ZERO_CHANGE_STREAMER_URI}`,\n `with an explicit routable hostname is recommended instead.`,\n ``,\n `Note: This option is ignored if the {bold ZERO_CHANGE_STREAMER_URI} is set.`,\n ],\n },\n\n port: {\n type: v.number().optional(),\n desc: [\n `The port on which the {bold change-streamer} runs. This is an internal`,\n `protocol between the {bold replication-manager} and {bold view-syncers}, which`,\n `runs in the same process tree in local development or a single-node configuration.`,\n ``,\n `If unspecified, defaults to {bold --port} + 1.`,\n ],\n },\n\n address: {\n type: v.string().optional(),\n deprecated: [\n `Set the {bold ZERO_CHANGE_STREAMER_URI} on view-syncers instead.`,\n ],\n hidden: true,\n },\n\n protocol: {\n type: v.literalUnion('ws', 'wss').default('ws'),\n deprecated: [\n `Set the {bold ZERO_CHANGE_STREAMER_URI} on view-syncers instead.`,\n ],\n hidden: true,\n },\n\n discoveryInterfacePreferences: {\n type: v.array(v.string()).default([\n 'eth', // linux\n 'en', // macbooks\n ]),\n desc: [\n `The name prefixes to prefer when introspecting the network interfaces to determine`,\n `the externally reachable IP address for change-streamer discovery. This defaults`,\n `to commonly used names for standard ethernet interfaces in order to prevent selecting`,\n `special interfaces such as those for VPNs.`,\n ],\n // More confusing than it's worth to advertise this. The default list should be\n // adjusted to make things work for all environments; it is controlled as a\n // hidden flag as an emergency to unblock people with outlier network configs.\n hidden: true,\n },\n },\n\n taskID: {\n type: v.string().optional(),\n desc: [\n `Globally unique identifier for the zero-cache instance.`,\n ``,\n `Setting this to a platform specific task identifier can be useful for debugging.`,\n `If unspecified, zero-cache will attempt to extract the TaskARN if run from within`,\n `an AWS ECS container, and otherwise use a random string.`,\n ],\n },\n\n perUserMutationLimit,\n\n numSyncWorkers: {\n type: v.number().optional(),\n desc: [\n `The number of processes to use for view syncing.`,\n `Leave this unset to use the maximum available parallelism.`,\n `If set to 0, the server runs without sync workers, which is the`,\n `configuration for running the {bold replication-manager}.`,\n ],\n },\n\n autoReset: {\n type: v.boolean().default(true),\n desc: [\n `Automatically wipe and resync the replica when replication is halted.`,\n `This situation can occur for configurations in which the upstream database`,\n `provider prohibits event trigger creation, preventing the zero-cache from`,\n `being able to correctly replicate schema changes. For such configurations,`,\n `an upstream schema change will instead result in halting replication with an`,\n `error indicating that the replica needs to be reset.`,\n ``,\n `When {bold auto-reset} is enabled, zero-cache will respond to such situations`,\n `by shutting down, and when restarted, resetting the replica and all synced `,\n `clients. This is a heavy-weight operation and can result in user-visible`,\n `slowness or downtime if compute resources are scarce.`,\n ],\n },\n\n adminPassword: {\n type: v.string().optional(),\n desc: [\n `A password used to administer zero-cache server, for example to access the`,\n `/statz endpoint.`,\n '',\n 'A password is optional in development mode but {bold required in production} mode.',\n ],\n },\n\n websocketCompression: {\n type: v.boolean().default(false),\n desc: [\n 'Enable WebSocket per-message deflate compression.',\n '',\n 'Compression can reduce bandwidth usage for sync traffic but',\n 'increases CPU usage on both client and server. Disabled by default.',\n '',\n 'See: https://github.com/websockets/ws#websocket-compression',\n ],\n },\n\n websocketCompressionOptions: {\n type: v.string().optional(),\n desc: [\n 'JSON string containing WebSocket compression options.',\n '',\n 'Only used if websocketCompression is enabled.',\n '',\n 'Example: \\\\{\"zlibDeflateOptions\":\\\\{\"level\":3\\\\},\"threshold\":1024\\\\}',\n '',\n 'See https://github.com/websockets/ws/blob/master/doc/ws.md#new-websocketserveroptions-callback for available options.',\n ],\n },\n\n litestream: {\n executable: {\n type: v.string().optional(),\n desc: [`Path to the {bold litestream} executable.`],\n },\n\n configPath: {\n type: v.string().default('./src/services/litestream/config.yml'),\n desc: [\n `Path to the litestream yaml config file. zero-cache will run this with its`,\n `environment variables, which can be referenced in the file via $\\\\{ENV\\\\}`,\n `substitution, for example:`,\n `* {bold ZERO_REPLICA_FILE} for the db path`,\n `* {bold ZERO_LITESTREAM_BACKUP_LOCATION} for the db replica url`,\n `* {bold ZERO_LITESTREAM_LOG_LEVEL} for the log level`,\n `* {bold ZERO_LOG_FORMAT} for the log type`,\n ],\n },\n\n logLevel: {\n type: v.literalUnion('debug', 'info', 'warn', 'error').default('warn'),\n },\n\n backupURL: {\n type: v.string().optional(),\n desc: [\n `The location of the litestream backup, usually an {bold s3://} URL.`,\n `This is only consulted by the {bold replication-manager}.`,\n `{bold view-syncers} receive this information from the {bold replication-manager}.`,\n ],\n },\n\n port: {\n type: v.number().optional(),\n desc: [\n `Port on which litestream exports metrics, used to determine the replication`,\n `watermark up to which it is safe to purge change log records.`,\n ``,\n `If unspecified, defaults to {bold --port} + 2.`,\n ],\n },\n\n checkpointThresholdMB: {\n type: v.number().default(40),\n desc: [\n `The size of the WAL file at which to perform an SQlite checkpoint to apply`,\n `the writes in the WAL to the main database file. Each checkpoint creates`,\n `a new WAL segment file that will be backed up by litestream. Smaller thresholds`,\n `may improve read performance, at the expense of creating more files to download`,\n `when restoring the replica from the backup.`,\n ],\n },\n\n incrementalBackupIntervalMinutes: {\n type: v.number().default(15),\n desc: [\n `The interval between incremental backups of the replica. Shorter intervals`,\n `reduce the amount of change history that needs to be replayed when catching`,\n `up a new view-syncer, at the expense of increasing the number of files needed`,\n `to download for the initial litestream restore.`,\n ],\n },\n\n snapshotBackupIntervalHours: {\n type: v.number().default(12),\n desc: [\n `The interval between snapshot backups of the replica. Snapshot backups`,\n `make a full copy of the database to a new litestream generation. This`,\n `improves restore time at the expense of bandwidth. Applications with a`,\n `large database and low write rate can increase this interval to reduce`,\n `network usage for backups (litestream defaults to 24 hours).`,\n ],\n },\n\n restoreParallelism: {\n type: v.number().default(48),\n desc: [\n `The number of WAL files to download in parallel when performing the`,\n `initial restore of the replica from the backup.`,\n ],\n },\n\n multipartConcurrency: {\n type: v.number().default(48),\n desc: [\n `The number of parts (of size {bold --litestream-multipart-size} bytes)`,\n `to upload or download in parallel when backing up or restoring the snapshot.`,\n ],\n },\n\n multipartSize: {\n type: v.number().default(16 * 1024 * 1024),\n desc: [\n `The size of each part when uploading or downloading the snapshot with`,\n `{bold --multipart-concurrency}. Note that up to {bold concurrency * size}`,\n `bytes of memory are used when backing up or restoring the snapshot.`,\n ],\n },\n },\n\n storageDBTmpDir: {\n type: v.string().optional(),\n desc: [\n `tmp directory for IVM operator storage. Leave unset to use os.tmpdir()`,\n ],\n },\n\n initialSync: {\n tableCopyWorkers: {\n type: v.number().default(5),\n desc: [\n `The number of parallel workers used to copy tables during initial sync.`,\n `Each worker uses a database connection and will buffer up to (approximately)`,\n `10 MB of table data in memory during initial sync. Increasing the number of`,\n `workers may improve initial sync speed; however, note that local disk throughput`,\n `(i.e. IOPS), upstream CPU, and network bandwidth may also be bottlenecks.`,\n ],\n },\n\n profileCopy: {\n type: v.boolean().optional(),\n hidden: true,\n desc: [\n `Takes a cpu profile during the copy phase initial-sync, storing it as a JSON file`,\n `initial-copy.cpuprofile in the tmp directory.`,\n ],\n },\n },\n\n targetClientRowCount: {\n type: v.number().default(20_000),\n deprecated: [\n 'This option is no longer used and will be removed in a future version.',\n 'The client-side cache no longer enforces a row limit. Instead, TTL-based expiration',\n 'automatically manages cache size to prevent unbounded growth.',\n ],\n hidden: true,\n },\n\n lazyStartup: {\n type: v.boolean().default(false),\n desc: [\n 'Delay starting the majority of zero-cache until first request.',\n '',\n 'This is mainly intended to avoid connecting to Postgres replication stream',\n 'until the first request is received, which can be useful i.e., for preview instances.',\n '',\n 'Currently only supported in single-node mode.',\n ],\n },\n\n serverVersion: {\n type: v.string().optional(),\n desc: [`The version string outputted to logs when the server starts up.`],\n },\n\n enableTelemetry: {\n type: v.boolean().default(true),\n desc: [\n `Set to false to opt out of telemetry collection.`,\n ``,\n `This helps us improve Zero by collecting anonymous usage data.`,\n `Setting the DO_NOT_TRACK environment variable also disables telemetry.`,\n ],\n },\n\n cloudEvent: {\n sinkEnv: {\n type: v.string().optional(),\n desc: [\n `ENV variable containing a URI to a CloudEvents sink. When set, ZeroEvents`,\n `will be published to the sink as the {bold data} field of CloudEvents.`,\n `The {bold source} field of the CloudEvents will be set to the {bold ZERO_TASK_ID},`,\n `along with any extension attributes specified by the {bold ZERO_CLOUD_EVENT_EXTENSION_OVERRIDES_ENV}.`,\n ``,\n `This configuration is modeled to easily integrate with a knative K_SINK binding,`,\n `(i.e. https://github.com/knative/eventing/blob/main/docs/spec/sources.md#sinkbinding).`,\n `However, any CloudEvents sink can be used.`,\n ],\n },\n\n extensionOverridesEnv: {\n type: v.string().optional(),\n desc: [\n `ENV variable containing a JSON stringified object with an {bold extensions} field`,\n `containing attributes that should be added or overridden on outbound CloudEvents.`,\n ``,\n `This configuration is modeled to easily integrate with a knative K_CE_OVERRIDES binding,`,\n `(i.e. https://github.com/knative/eventing/blob/main/docs/spec/sources.md#sinkbinding).`,\n ],\n },\n },\n};\n\nexport type ZeroConfig = Config<typeof zeroOptions>;\n\nexport const ZERO_ENV_VAR_PREFIX = 'ZERO_';\n\nlet loadedConfig: Config<typeof zeroOptions> | undefined;\n\nexport function getZeroConfig(\n opts: Omit<ParseOptions, 'envNamePrefix'> = {},\n): ZeroConfig {\n if (!loadedConfig || singleProcessMode()) {\n loadedConfig = parseOptions(zeroOptions, {\n envNamePrefix: ZERO_ENV_VAR_PREFIX,\n emitDeprecationWarnings: false, // overridden at the top level parse\n ...opts,\n });\n\n if (loadedConfig.queryHydrationStats) {\n runtimeDebugFlags.trackRowCountsVended = true;\n }\n }\n return loadedConfig;\n}\n\n/**\n * Same as {@link getZeroConfig}, with an additional check that the\n * config has already been normalized (i.e. by the top level server/runner).\n */\nexport function getNormalizedZeroConfig(\n opts: Omit<ParseOptions, 'envNamePrefix'> = {},\n): NormalizedZeroConfig {\n const config = getZeroConfig(opts);\n assertNormalized(config);\n return config;\n}\n\n/**\n * Gets the server version from the config if provided. Otherwise it gets it\n * from the Zero package.json.\n */\nexport function getServerVersion(\n config: Pick<ZeroConfig, 'serverVersion'> | undefined,\n): string {\n return config?.serverVersion ?? packageJson.version;\n}\n\nexport function isAdminPasswordValid(\n lc: LogContext,\n config: Pick<NormalizedZeroConfig, 'adminPassword'>,\n password: string | undefined,\n) {\n // If development mode, password is optional\n // We use process.env.NODE_ENV === 'development' as a sign that we're in\n // development mode, rather than a custom env var like ZERO_DEVELOPMENT_MODE,\n // because NODE_ENV is more standard and is already used by many tools.\n // Note that if NODE_ENV is not set, we assume production mode.\n\n if (!password && !config.adminPassword && isDevelopmentMode()) {\n warnOnce(\n lc,\n 'No admin password set; allowing access in development mode only',\n );\n return true;\n }\n\n if (!config.adminPassword) {\n lc.warn?.('No admin password set; denying access');\n return false;\n }\n\n if (password !== config.adminPassword) {\n lc.warn?.('Invalid admin password');\n return false;\n }\n\n lc.debug?.('Admin password accepted');\n return true;\n}\n\nlet hasWarned = false;\n\nfunction warnOnce(lc: LogContext, msg: string) {\n if (!hasWarned) {\n lc.warn?.(msg);\n hasWarned = true;\n }\n}\n\n// For testing purposes - reset the warning state\nexport function resetWarnOnceState() {\n hasWarned = false;\n}\n"],"names":["v.string","v.array","v.number","v.boolean","v.literalUnion"],"mappings":";;;;;;;;;AA2BO,MAAM,aAAa;AAAA,EACxB,IAAI;AAAA,IACF,MAAMA,OACH,EACA,QAAQ,MAAM,EACd,OAAO,CAAA,OAAM,0BAA0B,KAAK,EAAE,GAAG,sBAAsB;AAAA,IAC1E,MAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EACF;AAAA,EAGF,cAAc;AAAA,IACZ,MAAMC,MAAQD,OAAE,CAAQ,EAAE,SAAS,MAAM,CAAA,CAAE;AAAA,IAC3C,MAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EACF;AAEJ;AAEO,MAAM,eAAe;AAAA,EAC1B,IAAI;AAAA,IACF,MAAMA,SAEH,OAAO,MAAM;AACZ,YAAM,IAAI;AAAA,QACR;AA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tB,QAAM,SAAS,cAAc,IAAI;AACjC,mBAAiB,MAAM;AACvB,SAAO;AACT;AAMO,SAAS,iBACd,QACQ;AACR,SAAO,QAAQ,iBAAiB,YAAY;AAC9C;AAEO,SAAS,qBACd,IACA,QACA,UACA;AAOA,MAAI,CAAC,YAAY,CAAC,OAAO,iBAAiB,qBAAqB;AAC7D;AAAA,MACE;AAAA,MACA;AAAA,IAAA;AAEF,WAAO;AAAA,EACT;AAEA,MAAI,CAAC,OAAO,eAAe;AACzB,OAAG,OAAO,uCAAuC;AACjD,WAAO;AAAA,EACT;AAEA,MAAI,aAAa,OAAO,eAAe;AACrC,OAAG,OAAO,wBAAwB;AAClC,WAAO;AAAA,EACT;AAEA,KAAG,QAAQ,yBAAyB;AACpC,SAAO;AACT;AAEA,IAAI,YAAY;AAEhB,SAAS,SAAS,IAAgB,KAAa;AAC7C,MAAI,CAAC,WAAW;AACd,OAAG,OAAO,GAAG;AACb,gBAAY;AAAA,EACd;AACF;"}
1
+ {"version":3,"file":"zero-config.js","sources":["../../../../../zero-cache/src/config/zero-config.ts"],"sourcesContent":["/**\n * These types represent the _compiled_ config whereas `define-config` types represent the _source_ config.\n */\n\nimport type {LogContext} from '@rocicorp/logger';\nimport {logOptions} from '../../../otel/src/log-options.ts';\nimport {\n parseOptions,\n type Config,\n type ParseOptions,\n} from '../../../shared/src/options.ts';\nimport * as v from '../../../shared/src/valita.ts';\n// @circular-dep-ignore - importing package.json for version info only\nimport packageJson from '../../../zero/package.json' with {type: 'json'};\nimport {runtimeDebugFlags} from '../../../zql/src/builder/debug-delegate.ts';\nimport {singleProcessMode} from '../types/processes.ts';\nimport {\n ALLOWED_APP_ID_CHARACTERS,\n INVALID_APP_ID_MESSAGE,\n} from '../types/shards.ts';\nimport {\n assertNormalized,\n isDevelopmentMode,\n type NormalizedZeroConfig,\n} from './normalize.ts';\nexport type {LogConfig} from '../../../otel/src/log-options.ts';\n\nexport const appOptions = {\n id: {\n type: v\n .string()\n .default('zero')\n .assert(id => ALLOWED_APP_ID_CHARACTERS.test(id), INVALID_APP_ID_MESSAGE),\n desc: [\n 'Unique identifier for the app.',\n '',\n 'Multiple zero-cache apps can run on a single upstream database, each of which',\n 'is isolated from the others, with its own permissions, sharding (future feature),',\n 'and change/cvr databases.',\n '',\n 'The metadata of an app is stored in an upstream schema with the same name,',\n 'e.g. \"zero\", and the metadata for each app shard, e.g. client and mutation',\n 'ids, is stored in the \"\\\\{app-id\\\\}_\\\\{#\\\\}\" schema. (Currently there is only a single',\n '\"0\" shard, but this will change with sharding).',\n '',\n 'The CVR and Change data are managed in schemas named \"\\\\{app-id\\\\}_\\\\{shard-num\\\\}/cvr\"',\n 'and \"\\\\{app-id\\\\}_\\\\{shard-num\\\\}/cdc\", respectively, allowing multiple apps and shards',\n 'to share the same database instance (e.g. a Postgres \"cluster\") for CVR and Change management.',\n '',\n 'Due to constraints on replication slot names, an App ID may only consist of',\n 'lower-case letters, numbers, and the underscore character.',\n '',\n 'Note that this option is used by both {bold zero-cache} and {bold zero-deploy-permissions}.',\n ],\n },\n\n publications: {\n type: v.array(v.string()).optional(() => []),\n desc: [\n `Postgres {bold PUBLICATION}s that define the tables and columns to`,\n `replicate. Publication names may not begin with an underscore,`,\n `as zero reserves that prefix for internal use.`,\n ``,\n `If unspecified, zero-cache will create and use an internal publication that`,\n `publishes all tables in the {bold public} schema, i.e.:`,\n ``,\n `CREATE PUBLICATION _\\\\{app-id\\\\}_public_0 FOR TABLES IN SCHEMA public;`,\n ``,\n `Note that changing the set of publications will result in resyncing the replica,`,\n `which may involve downtime (replication lag) while the new replica is initializing.`,\n `To change the set of publications without disrupting an existing app, a new app`,\n `should be created.`,\n ],\n },\n};\n\nexport const shardOptions = {\n id: {\n type: v\n .string()\n .assert(() => {\n throw new Error(\n `ZERO_SHARD_ID is no longer an option. Please use ZERO_APP_ID instead.`,\n // TODO: Link to release / migration notes?\n );\n })\n .optional(),\n hidden: true,\n },\n\n num: {\n type: v.number().default(0),\n desc: [\n `The shard number (from 0 to NUM_SHARDS) of the App. zero will eventually`,\n `support data sharding as a first-class primitive; until then, deploying`,\n `multiple shard-nums creates functionally identical shards. Until sharding is`,\n `actually meaningful, this flag is hidden but available for testing.`,\n ],\n hidden: true,\n },\n};\n\nconst replicaOptions = {\n file: {\n type: v.string().default('zero.db'),\n desc: [\n `File path to the SQLite replica that zero-cache maintains.`,\n `This can be lost, but if it is, zero-cache will have to re-replicate next`,\n `time it starts up.`,\n ],\n },\n\n vacuumIntervalHours: {\n type: v.number().optional(),\n desc: [\n `Performs a VACUUM at server startup if the specified number of hours has elapsed`,\n `since the last VACUUM (or initial-sync). The VACUUM operation is heavyweight`,\n `and requires double the size of the db in disk space. If unspecified, VACUUM`,\n `operations are not performed.`,\n ],\n },\n};\n\nexport type ReplicaOptions = Config<typeof replicaOptions>;\n\nconst perUserMutationLimit = {\n max: {\n type: v.number().optional(),\n desc: [\n `The maximum mutations per user within the specified {bold windowMs}.`,\n `If unset, no rate limiting is enforced.`,\n ],\n },\n windowMs: {\n type: v.number().default(60_000),\n desc: [\n `The sliding window over which the {bold perUserMutationLimitMax} is enforced.`,\n ],\n },\n};\n\nexport type RateLimit = Config<typeof perUserMutationLimit>;\n\nconst authOptions = {\n jwk: {\n type: v.string().optional(),\n desc: [\n `A public key in JWK format used to verify JWTs. Only one of {bold jwk}, {bold jwksUrl} and {bold secret} may be set.`,\n ],\n },\n jwksUrl: {\n type: v.string().optional(),\n desc: [\n `A URL that returns a JWK set used to verify JWTs. Only one of {bold jwk}, {bold jwksUrl} and {bold secret} may be set.`,\n ],\n },\n secret: {\n type: v.string().optional(),\n desc: [\n `A symmetric key used to verify JWTs. Only one of {bold jwk}, {bold jwksUrl} and {bold secret} may be set.`,\n ],\n },\n};\n\nconst makeMutatorQueryOptions = (\n replacement: string | undefined,\n suffix: string,\n) => ({\n url: {\n type: v.array(v.string()).optional(), // optional until we remove CRUD mutations\n desc: [\n replacement ? `DEPRECATED. Use ${replacement} instead.` : ``,\n `The URL of the API server to which zero-cache will ${suffix}.`,\n ``,\n `{bold IMPORTANT:} URLs are matched using {bold URLPattern}, a standard Web API.`,\n ``,\n `{bold Pattern Syntax:}`,\n ` URLPattern uses a simple and intuitive syntax similar to Express routes.`,\n ` Wildcards and named parameters make it easy to match multiple URLs.`,\n ``,\n `{bold Basic Examples:}`,\n ` Exact URL match:`,\n ` \"https://api.example.com/mutate\"`,\n ` `,\n ` Any subdomain using wildcard:`,\n ` \"https://*.example.com/mutate\"`,\n ` `,\n ` Multiple subdomain levels:`,\n ` \"https://*.*.example.com/mutate\"`,\n ` `,\n ` Any path under a domain:`,\n ` \"https://api.example.com/*\"`,\n ` `,\n ` Named path parameters:`,\n ` \"https://api.example.com/:version/mutate\"`,\n ` ↳ Matches \"https://api.example.com/v1/mutate\", \"https://api.example.com/v2/mutate\", etc.`,\n ``,\n `{bold Advanced Patterns:}`,\n ` Optional path segments:`,\n ` \"https://api.example.com/:path?\"`,\n ` `,\n ` Regex in segments (for specific patterns):`,\n ` \"https://api.example.com/:version(v\\\\\\\\d+)/mutate\"`,\n ` ↳ Matches only \"v\" followed by digits`,\n ``,\n `{bold Multiple patterns:}`,\n ` [\"https://api1.example.com/mutate\", \"https://api2.example.com/mutate\"]`,\n ``,\n `{bold Note:} Query parameters and URL fragments (#) are automatically ignored during matching.`,\n ``,\n `For full URLPattern syntax, see: https://developer.mozilla.org/en-US/docs/Web/API/URLPattern`,\n ],\n },\n apiKey: {\n type: v.string().optional(),\n desc: [\n `An optional secret used to authorize zero-cache to call the API server handling writes.`,\n ],\n },\n forwardCookies: {\n type: v.boolean().default(false),\n desc: [\n `If true, zero-cache will forward cookies from the request.`,\n `This is useful for passing authentication cookies to the API server.`,\n `If false, cookies are not forwarded.`,\n ],\n },\n});\n\nconst mutateOptions = makeMutatorQueryOptions(undefined, 'push mutations');\nconst pushOptions = makeMutatorQueryOptions('mutate-url', 'push mutations');\nconst queryOptions = makeMutatorQueryOptions(undefined, 'send synced queries');\nconst getQueriesOptions = makeMutatorQueryOptions(\n 'query-url',\n 'send synced queries',\n);\n\nexport type AuthConfig = Config<typeof authOptions>;\n\n// Note: --help will list flags in the order in which they are defined here,\n// so order the fields such that the important (e.g. required) ones are first.\n// (Exported for testing)\nexport const zeroOptions = {\n upstream: {\n db: {\n type: v.string(),\n desc: [\n `The \"upstream\" authoritative postgres database.`,\n `In the future we will support other types of upstream besides PG.`,\n ],\n },\n\n type: {\n type: v.literalUnion('pg', 'custom').default('pg'),\n desc: [\n `The meaning of the {bold upstream-db} depends on the upstream type:`,\n `* {bold pg}: The connection database string, e.g. \"postgres://...\"`,\n `* {bold custom}: The base URI of the change source \"endpoint, e.g.`,\n ` \"https://my-change-source.dev/changes/v0/stream?apiKey=...\"`,\n ],\n hidden: true, // TODO: Unhide when ready to officially support.\n },\n\n maxConns: {\n type: v.number().default(20),\n desc: [\n `The maximum number of connections to open to the upstream database`,\n `for committing mutations. This is divided evenly amongst sync workers.`,\n `In addition to this number, zero-cache uses one connection for the`,\n `replication stream.`,\n ``,\n `Note that this number must allow for at least one connection per`,\n `sync worker, or zero-cache will fail to start. See {bold num-sync-workers}`,\n ],\n },\n\n maxConnsPerWorker: {\n type: v.number().optional(),\n hidden: true, // Passed from main thread to sync workers\n },\n },\n\n /** @deprecated */\n push: pushOptions,\n mutate: mutateOptions,\n /** @deprecated */\n getQueries: getQueriesOptions,\n query: queryOptions,\n\n cvr: {\n db: {\n type: v.string().optional(),\n desc: [\n `The Postgres database used to store CVRs. CVRs (client view records) keep track`,\n `of the data synced to clients in order to determine the diff to send on reconnect.`,\n `If unspecified, the {bold upstream-db} will be used.`,\n ],\n },\n\n maxConns: {\n type: v.number().default(30),\n desc: [\n `The maximum number of connections to open to the CVR database.`,\n `This is divided evenly amongst sync workers.`,\n ``,\n `Note that this number must allow for at least one connection per`,\n `sync worker, or zero-cache will fail to start. See {bold num-sync-workers}`,\n ],\n },\n\n maxConnsPerWorker: {\n type: v.number().optional(),\n hidden: true, // Passed from main thread to sync workers\n },\n\n garbageCollectionInactivityThresholdHours: {\n type: v.number().default(48),\n desc: [\n `The duration after which an inactive CVR is eligible for garbage collection.`,\n `Note that garbage collection is an incremental, periodic process which does not`,\n `necessarily purge all eligible CVRs immediately.`,\n ],\n },\n\n garbageCollectionInitialIntervalSeconds: {\n type: v.number().default(60),\n desc: [\n `The initial interval at which to check and garbage collect inactive CVRs.`,\n `This interval is increased exponentially (up to 16 minutes) when there is`,\n `nothing to purge.`,\n ],\n },\n\n garbageCollectionInitialBatchSize: {\n type: v.number().default(25),\n desc: [\n `The initial number of CVRs to purge per garbage collection interval.`,\n `This number is increased linearly if the rate of new CVRs exceeds the rate of`,\n `purged CVRs, in order to reach a steady state.`,\n ``,\n `Setting this to 0 effectively disables CVR garbage collection.`,\n ],\n },\n },\n\n queryHydrationStats: {\n type: v.boolean().optional(),\n desc: [\n `Track and log the number of rows considered by query hydrations which`,\n `take longer than {bold log-slow-hydrate-threshold} milliseconds.`,\n `This is useful for debugging and performance tuning.`,\n ],\n },\n\n enableQueryPlanner: {\n type: v.boolean().default(true),\n desc: [\n `Enable the query planner for optimizing ZQL queries.`,\n ``,\n `The query planner analyzes and optimizes query execution by determining`,\n `the most efficient join strategies.`,\n ``,\n `You can disable the planner if it is picking bad strategies.`,\n ],\n },\n\n change: {\n db: {\n type: v.string().optional(),\n desc: [\n `The Postgres database used to store recent replication log entries, in order`,\n `to sync multiple view-syncers without requiring multiple replication slots on`,\n `the upstream database. If unspecified, the {bold upstream-db} will be used.`,\n ],\n },\n\n maxConns: {\n type: v.number().default(5),\n desc: [\n `The maximum number of connections to open to the change database.`,\n `This is used by the {bold change-streamer} for catching up`,\n `{bold zero-cache} replication subscriptions.`,\n ],\n },\n },\n\n replica: replicaOptions,\n\n log: logOptions,\n\n app: appOptions,\n\n shard: shardOptions,\n\n auth: authOptions,\n\n port: {\n type: v.number().default(4848),\n desc: [`The port for sync connections.`],\n },\n\n changeStreamer: {\n uri: {\n type: v.string().optional(),\n desc: [\n `When set, connects to the {bold change-streamer} at the given URI.`,\n `In a multi-node setup, this should be specified in {bold view-syncer} options,`,\n `pointing to the {bold replication-manager} URI, which runs a {bold change-streamer}`,\n `on port 4849.`,\n ],\n },\n\n mode: {\n type: v.literalUnion('dedicated', 'discover').default('dedicated'),\n desc: [\n `As an alternative to {bold ZERO_CHANGE_STREAMER_URI}, the {bold ZERO_CHANGE_STREAMER_MODE}`,\n `can be set to \"{bold discover}\" to instruct the {bold view-syncer} to connect to the `,\n `ip address registered by the {bold replication-manager} upon startup.`,\n ``,\n `This may not work in all networking configurations, e.g. certain private `,\n `networking or port forwarding configurations. Using the {bold ZERO_CHANGE_STREAMER_URI}`,\n `with an explicit routable hostname is recommended instead.`,\n ``,\n `Note: This option is ignored if the {bold ZERO_CHANGE_STREAMER_URI} is set.`,\n ],\n },\n\n port: {\n type: v.number().optional(),\n desc: [\n `The port on which the {bold change-streamer} runs. This is an internal`,\n `protocol between the {bold replication-manager} and {bold view-syncers}, which`,\n `runs in the same process tree in local development or a single-node configuration.`,\n ``,\n `If unspecified, defaults to {bold --port} + 1.`,\n ],\n },\n\n /** @deprecated */\n address: {\n type: v.string().optional(),\n deprecated: [\n `Set the {bold ZERO_CHANGE_STREAMER_URI} on view-syncers instead.`,\n ],\n hidden: true,\n },\n\n /** @deprecated */\n protocol: {\n type: v.literalUnion('ws', 'wss').default('ws'),\n deprecated: [\n `Set the {bold ZERO_CHANGE_STREAMER_URI} on view-syncers instead.`,\n ],\n hidden: true,\n },\n\n discoveryInterfacePreferences: {\n type: v.array(v.string()).default([\n 'eth', // linux\n 'en', // macbooks\n ]),\n desc: [\n `The name prefixes to prefer when introspecting the network interfaces to determine`,\n `the externally reachable IP address for change-streamer discovery. This defaults`,\n `to commonly used names for standard ethernet interfaces in order to prevent selecting`,\n `special interfaces such as those for VPNs.`,\n ],\n // More confusing than it's worth to advertise this. The default list should be\n // adjusted to make things work for all environments; it is controlled as a\n // hidden flag as an emergency to unblock people with outlier network configs.\n hidden: true,\n },\n\n startupDelayKeepalives: {\n type: v.number().default(3),\n desc: [\n `The number of /keepalive requests to wait for before the change-streamer takes over`,\n `the replication stream (i.e. the handoff during replication-manager updates). This`,\n `delay is used to verify that the task is recognized by the load balancer as a healthy`,\n `target before the shutdown signal is sent to the previous replication-manager.`,\n ],\n },\n\n startupDelayMs: {\n type: v.number().default(15000),\n desc: [\n `The maximum delay to wait before the change-streamer takes over the replication`,\n `stream (i.e. the handoff during replication-manager updates). The takeover will thus`,\n `happen when (1) {bold ZERO_CHANGE_STREAMER_STARTUP_DELAY_KEEPALIVES} are received,`,\n `(2) when {bold ZERO_CHANGE_STREAMER_STARTUP_DELAY_MS} has elapsed since the change-streamer`,\n `service started (i.e. after the replica has been initialized or restored), or (3) when`,\n `a change stream request is received by a view-syncer (i.e. serving-replicator).`,\n ],\n },\n },\n\n taskID: {\n type: v.string().optional(),\n desc: [\n `Globally unique identifier for the zero-cache instance.`,\n ``,\n `Setting this to a platform specific task identifier can be useful for debugging.`,\n `If unspecified, zero-cache will attempt to extract the TaskARN if run from within`,\n `an AWS ECS container, and otherwise use a random string.`,\n ],\n },\n\n perUserMutationLimit,\n\n numSyncWorkers: {\n type: v.number().optional(),\n desc: [\n `The number of processes to use for view syncing.`,\n `Leave this unset to use the maximum available parallelism.`,\n `If set to 0, the server runs without sync workers, which is the`,\n `configuration for running the {bold replication-manager}.`,\n ],\n },\n\n autoReset: {\n type: v.boolean().default(true),\n desc: [\n `Automatically wipe and resync the replica when replication is halted.`,\n `This situation can occur for configurations in which the upstream database`,\n `provider prohibits event trigger creation, preventing the zero-cache from`,\n `being able to correctly replicate schema changes. For such configurations,`,\n `an upstream schema change will instead result in halting replication with an`,\n `error indicating that the replica needs to be reset.`,\n ``,\n `When {bold auto-reset} is enabled, zero-cache will respond to such situations`,\n `by shutting down, and when restarted, resetting the replica and all synced `,\n `clients. This is a heavy-weight operation and can result in user-visible`,\n `slowness or downtime if compute resources are scarce.`,\n ],\n },\n\n adminPassword: {\n type: v.string().optional(),\n desc: [\n `A password used to administer zero-cache server, for example to access the`,\n `/statz endpoint.`,\n '',\n 'A password is optional in development mode but {bold required in production} mode.',\n ],\n },\n\n websocketCompression: {\n type: v.boolean().default(false),\n desc: [\n 'Enable WebSocket per-message deflate compression.',\n '',\n 'Compression can reduce bandwidth usage for sync traffic but',\n 'increases CPU usage on both client and server. Disabled by default.',\n '',\n 'See: https://github.com/websockets/ws#websocket-compression',\n ],\n },\n\n websocketCompressionOptions: {\n type: v.string().optional(),\n desc: [\n 'JSON string containing WebSocket compression options.',\n '',\n 'Only used if websocketCompression is enabled.',\n '',\n 'Example: \\\\{\"zlibDeflateOptions\":\\\\{\"level\":3\\\\},\"threshold\":1024\\\\}',\n '',\n 'See https://github.com/websockets/ws/blob/master/doc/ws.md#new-websocketserveroptions-callback for available options.',\n ],\n },\n\n litestream: {\n executable: {\n type: v.string().optional(),\n desc: [`Path to the {bold litestream} executable.`],\n },\n\n configPath: {\n type: v.string().default('./src/services/litestream/config.yml'),\n desc: [\n `Path to the litestream yaml config file. zero-cache will run this with its`,\n `environment variables, which can be referenced in the file via $\\\\{ENV\\\\}`,\n `substitution, for example:`,\n `* {bold ZERO_REPLICA_FILE} for the db path`,\n `* {bold ZERO_LITESTREAM_BACKUP_LOCATION} for the db replica url`,\n `* {bold ZERO_LITESTREAM_LOG_LEVEL} for the log level`,\n `* {bold ZERO_LOG_FORMAT} for the log type`,\n ],\n },\n\n logLevel: {\n type: v.literalUnion('debug', 'info', 'warn', 'error').default('warn'),\n },\n\n backupURL: {\n type: v.string().optional(),\n desc: [\n `The location of the litestream backup, usually an {bold s3://} URL.`,\n `This is only consulted by the {bold replication-manager}.`,\n `{bold view-syncers} receive this information from the {bold replication-manager}.`,\n ],\n },\n\n port: {\n type: v.number().optional(),\n desc: [\n `Port on which litestream exports metrics, used to determine the replication`,\n `watermark up to which it is safe to purge change log records.`,\n ``,\n `If unspecified, defaults to {bold --port} + 2.`,\n ],\n },\n\n checkpointThresholdMB: {\n type: v.number().default(40),\n desc: [\n `The size of the WAL file at which to perform an SQlite checkpoint to apply`,\n `the writes in the WAL to the main database file. Each checkpoint creates`,\n `a new WAL segment file that will be backed up by litestream. Smaller thresholds`,\n `may improve read performance, at the expense of creating more files to download`,\n `when restoring the replica from the backup.`,\n ],\n },\n\n incrementalBackupIntervalMinutes: {\n type: v.number().default(15),\n desc: [\n `The interval between incremental backups of the replica. Shorter intervals`,\n `reduce the amount of change history that needs to be replayed when catching`,\n `up a new view-syncer, at the expense of increasing the number of files needed`,\n `to download for the initial litestream restore.`,\n ],\n },\n\n snapshotBackupIntervalHours: {\n type: v.number().default(12),\n desc: [\n `The interval between snapshot backups of the replica. Snapshot backups`,\n `make a full copy of the database to a new litestream generation. This`,\n `improves restore time at the expense of bandwidth. Applications with a`,\n `large database and low write rate can increase this interval to reduce`,\n `network usage for backups (litestream defaults to 24 hours).`,\n ],\n },\n\n restoreParallelism: {\n type: v.number().default(48),\n desc: [\n `The number of WAL files to download in parallel when performing the`,\n `initial restore of the replica from the backup.`,\n ],\n },\n\n multipartConcurrency: {\n type: v.number().default(48),\n desc: [\n `The number of parts (of size {bold --litestream-multipart-size} bytes)`,\n `to upload or download in parallel when backing up or restoring the snapshot.`,\n ],\n },\n\n multipartSize: {\n type: v.number().default(16 * 1024 * 1024),\n desc: [\n `The size of each part when uploading or downloading the snapshot with`,\n `{bold --multipart-concurrency}. Note that up to {bold concurrency * size}`,\n `bytes of memory are used when backing up or restoring the snapshot.`,\n ],\n },\n },\n\n storageDBTmpDir: {\n type: v.string().optional(),\n desc: [\n `tmp directory for IVM operator storage. Leave unset to use os.tmpdir()`,\n ],\n },\n\n initialSync: {\n tableCopyWorkers: {\n type: v.number().default(5),\n desc: [\n `The number of parallel workers used to copy tables during initial sync.`,\n `Each worker uses a database connection and will buffer up to (approximately)`,\n `10 MB of table data in memory during initial sync. Increasing the number of`,\n `workers may improve initial sync speed; however, note that local disk throughput`,\n `(i.e. IOPS), upstream CPU, and network bandwidth may also be bottlenecks.`,\n ],\n },\n\n profileCopy: {\n type: v.boolean().optional(),\n hidden: true,\n desc: [\n `Takes a cpu profile during the copy phase initial-sync, storing it as a JSON file`,\n `initial-copy.cpuprofile in the tmp directory.`,\n ],\n },\n },\n\n /** @deprecated */\n targetClientRowCount: {\n type: v.number().default(20_000),\n deprecated: [\n 'This option is no longer used and will be removed in a future version.',\n 'The client-side cache no longer enforces a row limit. Instead, TTL-based expiration',\n 'automatically manages cache size to prevent unbounded growth.',\n ],\n hidden: true,\n },\n\n lazyStartup: {\n type: v.boolean().default(false),\n desc: [\n 'Delay starting the majority of zero-cache until first request.',\n '',\n 'This is mainly intended to avoid connecting to Postgres replication stream',\n 'until the first request is received, which can be useful i.e., for preview instances.',\n '',\n 'Currently only supported in single-node mode.',\n ],\n },\n\n serverVersion: {\n type: v.string().optional(),\n desc: [`The version string outputted to logs when the server starts up.`],\n },\n\n enableTelemetry: {\n type: v.boolean().default(true),\n desc: [\n `Set to false to opt out of telemetry collection.`,\n ``,\n `This helps us improve Zero by collecting anonymous usage data.`,\n `Setting the DO_NOT_TRACK environment variable also disables telemetry.`,\n ],\n },\n\n cloudEvent: {\n sinkEnv: {\n type: v.string().optional(),\n desc: [\n `ENV variable containing a URI to a CloudEvents sink. When set, ZeroEvents`,\n `will be published to the sink as the {bold data} field of CloudEvents.`,\n `The {bold source} field of the CloudEvents will be set to the {bold ZERO_TASK_ID},`,\n `along with any extension attributes specified by the {bold ZERO_CLOUD_EVENT_EXTENSION_OVERRIDES_ENV}.`,\n ``,\n `This configuration is modeled to easily integrate with a knative K_SINK binding,`,\n `(i.e. https://github.com/knative/eventing/blob/main/docs/spec/sources.md#sinkbinding).`,\n `However, any CloudEvents sink can be used.`,\n ],\n },\n\n extensionOverridesEnv: {\n type: v.string().optional(),\n desc: [\n `ENV variable containing a JSON stringified object with an {bold extensions} field`,\n `containing attributes that should be added or overridden on outbound CloudEvents.`,\n ``,\n `This configuration is modeled to easily integrate with a knative K_CE_OVERRIDES binding,`,\n `(i.e. https://github.com/knative/eventing/blob/main/docs/spec/sources.md#sinkbinding).`,\n ],\n },\n },\n};\n\nexport type ZeroConfig = Config<typeof zeroOptions>;\n\nexport const ZERO_ENV_VAR_PREFIX = 'ZERO_';\n\nlet loadedConfig: Config<typeof zeroOptions> | undefined;\n\nexport function getZeroConfig(\n opts: Omit<ParseOptions, 'envNamePrefix'> = {},\n): ZeroConfig {\n if (!loadedConfig || singleProcessMode()) {\n loadedConfig = parseOptions(zeroOptions, {\n envNamePrefix: ZERO_ENV_VAR_PREFIX,\n emitDeprecationWarnings: false, // overridden at the top level parse\n ...opts,\n });\n\n if (loadedConfig.queryHydrationStats) {\n runtimeDebugFlags.trackRowCountsVended = true;\n }\n }\n return loadedConfig;\n}\n\n/**\n * Same as {@link getZeroConfig}, with an additional check that the\n * config has already been normalized (i.e. by the top level server/runner).\n */\nexport function getNormalizedZeroConfig(\n opts: Omit<ParseOptions, 'envNamePrefix'> = {},\n): NormalizedZeroConfig {\n const config = getZeroConfig(opts);\n assertNormalized(config);\n return config;\n}\n\n/**\n * Gets the server version from the config if provided. Otherwise it gets it\n * from the Zero package.json.\n */\nexport function getServerVersion(\n config: Pick<ZeroConfig, 'serverVersion'> | undefined,\n): string {\n return config?.serverVersion ?? packageJson.version;\n}\n\nexport function isAdminPasswordValid(\n lc: LogContext,\n config: Pick<NormalizedZeroConfig, 'adminPassword'>,\n password: string | undefined,\n) {\n // If development mode, password is optional\n // We use process.env.NODE_ENV === 'development' as a sign that we're in\n // development mode, rather than a custom env var like ZERO_DEVELOPMENT_MODE,\n // because NODE_ENV is more standard and is already used by many tools.\n // Note that if NODE_ENV is not set, we assume production mode.\n\n if (!password && !config.adminPassword && isDevelopmentMode()) {\n warnOnce(\n lc,\n 'No admin password set; allowing access in development mode only',\n );\n return true;\n }\n\n if (!config.adminPassword) {\n lc.warn?.('No admin password set; denying access');\n return false;\n }\n\n if (password !== config.adminPassword) {\n lc.warn?.('Invalid admin password');\n return false;\n }\n\n lc.debug?.('Admin password accepted');\n return true;\n}\n\nlet hasWarned = false;\n\nfunction warnOnce(lc: LogContext, msg: string) {\n if (!hasWarned) {\n lc.warn?.(msg);\n hasWarned = true;\n }\n}\n\n// For testing purposes - reset the warning state\nexport function resetWarnOnceState() {\n hasWarned = false;\n}\n"],"names":["v.string","v.array","v.number","v.boolean","v.literalUnion"],"mappings":";;;;;;;;;AA2BO,MAAM,aAAa;AAAA,EACxB,IAAI;AAAA,IACF,MAAMA,OACH,EACA,QAAQ,MAAM,EACd,OAAO,CAAA,OAAM,0BAA0B,KAAK,EAAE,GAAG,sBAAsB;AAAA,IAC1E,MAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EACF;AAAA,EAGF,cAAc;AAAA,IACZ,MAAMC,MAAQD,OAAE,CAAQ,EAAE,SAAS,MAAM,CAAA,CAAE;AAAA,IAC3C,MAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EACF;AAEJ;AAEO,MAAM,eAAe;AAAA,EAC1B,IAAI;AAAA,IACF,MAAMA,SAEH,OAAO,MAAM;AACZ,YAAM,IAAI;AAAA,QACR;AAAA;AAAA,MAAA;AAAA,IAGJ,CAAC,EACA,SAAA;AAAA,IACH,QAAQ;AAAA,EAAA;AAAA,EAGV,KAAK;AAAA,IACH,MAAME,OAAE,EAAS,QAAQ,CAAC;AAAA,IAC1B,MAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;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Aa;AAAA,MACvC,eAAe;AAAA,MACf,yBAAyB;AAAA;AAAA,MACzB,GAAG;AAAA,IAAA,CACJ;AAED,QAAI,aAAa,qBAAqB;AACpC,wBAAkB,uBAAuB;AAAA,IAC3C;AAAA,EACF;AACA,SAAO;AACT;AAMO,SAAS,wBACd,OAA4C,IACtB;AACtB,QAAM,SAAS,cAAc,IAAI;AACjC,mBAAiB,MAAM;AACvB,SAAO;AACT;AAMO,SAAS,iBACd,QACQ;AACR,SAAO,QAAQ,iBAAiB,YAAY;AAC9C;AAEO,SAAS,qBACd,IACA,QACA,UACA;AAOA,MAAI,CAAC,YAAY,CAAC,OAAO,iBAAiB,qBAAqB;AAC7D;AAAA,MACE;AAAA,MACA;AAAA,IAAA;AAEF,WAAO;AAAA,EACT;AAEA,MAAI,CAAC,OAAO,eAAe;AACzB,OAAG,OAAO,uCAAuC;AACjD,WAAO;AAAA,EACT;AAEA,MAAI,aAAa,OAAO,eAAe;AACrC,OAAG,OAAO,wBAAwB;AAClC,WAAO;AAAA,EACT;AAEA,KAAG,QAAQ,yBAAyB;AACpC,SAAO;AACT;AAEA,IAAI,YAAY;AAEhB,SAAS,SAAS,IAAgB,KAAa;AAC7C,MAAI,CAAC,WAAW;AACd,OAAG,OAAO,GAAG;AACb,gBAAY;AAAA,EACd;AACF;"}
@@ -1,8 +1,8 @@
1
+ import type { LogContext, LogLevel } from '@rocicorp/logger';
1
2
  import 'urlpattern-polyfill';
2
- import type { LogContext } from '@rocicorp/logger';
3
- import { type ShardID } from '../types/shards.ts';
4
3
  import type { ReadonlyJSONValue } from '../../../shared/src/json.ts';
5
- import type { Type } from '../../../shared/src/valita.ts';
4
+ import { type Type } from '../../../shared/src/valita.ts';
5
+ import { type ShardID } from '../types/shards.ts';
6
6
  /**
7
7
  * Compiles and validates a URLPattern from configuration.
8
8
  *
@@ -18,8 +18,8 @@ export type HeaderOptions = {
18
18
  token?: string | undefined;
19
19
  cookie?: string | undefined;
20
20
  };
21
- export declare const getBodyPreview: (res: Response, lc: LogContext) => Promise<string | undefined>;
22
- export declare function fetchFromAPIServer<TValidator extends Type>(validator: TValidator, source: 'push' | 'transform', lc: LogContext, url: string, allowedUrlPatterns: URLPattern[], shard: ShardID, headerOptions: HeaderOptions, body: ReadonlyJSONValue): Promise<import("../../../shared/src/valita.ts").Infer<TValidator>>;
21
+ export declare const getBodyPreview: (res: Response, lc: LogContext, level: LogLevel) => Promise<string | undefined>;
22
+ export declare function fetchFromAPIServer<TValidator extends Type>(validator: TValidator, source: 'push' | 'transform', lc: LogContext, url: string, isUserUrl: boolean, allowedUrlPatterns: URLPattern[], shard: ShardID, headerOptions: HeaderOptions, body: ReadonlyJSONValue): Promise<import("../../../shared/src/valita.ts").Infer<TValidator>>;
23
23
  /**
24
24
  * Returns true if the url matches one of the allowedUrlPatterns.
25
25
  *
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../../../zero-cache/src/custom/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAiB,KAAK,OAAO,EAAC,MAAM,oBAAoB,CAAC;AAChE,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,+BAA+B,CAAC;AAUxD;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,CAQ7D;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B,CAAC;AAEF,eAAO,MAAM,cAAc,GACzB,KAAK,QAAQ,EACb,IAAI,UAAU,KACb,OAAO,CAAC,MA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EAC9D,SAAS,EAAE,UAAU,EACrB,MAAM,EAAE,MAAM,GAAG,WAAW,EAC5B,EAAE,EAAE,UAAU,EACd,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,OAAO,EAClB,kBAAkB,EAAE,UAAU,EAAE,EAChC,KAAK,EAAE,OAAO,EACd,aAAa,EAAE,aAAa,EAC5B,IAAI,EAAE,iBAAiB,sEAkKxB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,QAAQ,CACtB,GAAG,EAAE,MAAM,EACX,kBAAkB,EAAE,UAAU,EAAE,GAC/B,OAAO,CAOT"}
@@ -1,12 +1,13 @@
1
1
  import "urlpattern-polyfill";
2
2
  import { assert } from "../../../shared/src/asserts.js";
3
- import { upstreamSchema } from "../types/shards.js";
4
- import { isProtocolError } from "../../../zero-protocol/src/error.js";
3
+ import { getErrorMessage } from "../../../shared/src/error.js";
4
+ import "../../../shared/src/valita.js";
5
5
  import { PushFailed, TransformFailed } from "../../../zero-protocol/src/error-kind-enum.js";
6
6
  import { ZeroCache } from "../../../zero-protocol/src/error-origin-enum.js";
7
7
  import { Internal, HTTP, Parse } from "../../../zero-protocol/src/error-reason-enum.js";
8
- import { getErrorMessage } from "../../../shared/src/error.js";
8
+ import { isProtocolError } from "../../../zero-protocol/src/error.js";
9
9
  import { ProtocolErrorWithLevel } from "../types/error-with-level.js";
10
+ import { upstreamSchema } from "../types/shards.js";
10
11
  const reservedParams = ["schema", "appID"];
11
12
  function compileUrlPattern(pattern) {
12
13
  try {
@@ -17,7 +18,7 @@ function compileUrlPattern(pattern) {
17
18
  );
18
19
  }
19
20
  }
20
- const getBodyPreview = async (res, lc) => {
21
+ const getBodyPreview = async (res, lc, level) => {
21
22
  try {
22
23
  const body = await res.clone().text();
23
24
  if (body.length > 512) {
@@ -25,14 +26,14 @@ const getBodyPreview = async (res, lc) => {
25
26
  }
26
27
  return body;
27
28
  } catch (e) {
28
- lc.error?.("failed to get body preview", {
29
+ lc[level]?.("failed to get body preview", {
29
30
  url: res.url,
30
31
  error: e instanceof Error ? e.message : String(e)
31
32
  });
32
33
  }
33
34
  return void 0;
34
35
  };
35
- async function fetchFromAPIServer(validator, source, lc, url, allowedUrlPatterns, shard, headerOptions, body) {
36
+ async function fetchFromAPIServer(validator, source, lc, url, isUserUrl, allowedUrlPatterns, shard, headerOptions, body) {
36
37
  lc.debug?.("fetchFromAPIServer called", {
37
38
  url
38
39
  });
@@ -48,7 +49,7 @@ async function fetchFromAPIServer(validator, source, lc, url, allowedUrlPatterns
48
49
  kind: TransformFailed,
49
50
  origin: ZeroCache,
50
51
  reason: Internal,
51
- message: `URL "${url}" is not allowed by the ZERO_GET_QUERIES_URL configuration`,
52
+ message: `URL "${url}" is not allowed by the ZERO_QUERY_URL configuration`,
52
53
  queryIDs: []
53
54
  }
54
55
  );
@@ -77,6 +78,7 @@ async function fetchFromAPIServer(validator, source, lc, url, allowedUrlPatterns
77
78
  params.append("appID", shard.appID);
78
79
  urlObj.search = params.toString();
79
80
  const finalUrl = urlObj.toString();
81
+ const errLevel = isUserUrl ? "warn" : "error";
80
82
  try {
81
83
  const response = await fetch(finalUrl, {
82
84
  method: "POST",
@@ -84,8 +86,9 @@ async function fetchFromAPIServer(validator, source, lc, url, allowedUrlPatterns
84
86
  body: JSON.stringify(body)
85
87
  });
86
88
  if (!response.ok) {
87
- const bodyPreview = await getBodyPreview(response, lc);
88
- lc.info?.("fetch from API server returned non-OK status", {
89
+ const bodyPreview = await getBodyPreview(response, lc, errLevel);
90
+ const level = response.status === 502 || response.status === 504 ? errLevel : "info";
91
+ lc[level]?.("fetch from API server returned non-OK status", {
89
92
  url: finalUrl,
90
93
  status: response.status,
91
94
  bodyPreview
@@ -114,7 +117,7 @@ async function fetchFromAPIServer(validator, source, lc, url, allowedUrlPatterns
114
117
  const json = await response.json();
115
118
  return validator.parse(json);
116
119
  } catch (error) {
117
- lc.error?.("failed to parse response", {
120
+ lc[errLevel]?.("failed to parse response", {
118
121
  url: finalUrl,
119
122
  error
120
123
  });
@@ -140,7 +143,7 @@ async function fetchFromAPIServer(validator, source, lc, url, allowedUrlPatterns
140
143
  if (isProtocolError(error)) {
141
144
  throw error;
142
145
  }
143
- lc.error?.("failed to fetch from API server with unknown error", {
146
+ lc[errLevel]?.("failed to fetch from API server with unknown error", {
144
147
  url: finalUrl,
145
148
  error
146
149
  });
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.js","sources":["../../../../../zero-cache/src/custom/fetch.ts"],"sourcesContent":["import 'urlpattern-polyfill';\nimport type {LogContext} from '@rocicorp/logger';\nimport {assert} from '../../../shared/src/asserts.ts';\nimport {upstreamSchema, type ShardID} from '../types/shards.ts';\nimport type {ReadonlyJSONValue} from '../../../shared/src/json.ts';\nimport type {Type} from '../../../shared/src/valita.ts';\nimport {isProtocolError} from '../../../zero-protocol/src/error.ts';\nimport {ErrorKind} from '../../../zero-protocol/src/error-kind.ts';\nimport {ErrorOrigin} from '../../../zero-protocol/src/error-origin.ts';\nimport {ErrorReason} from '../../../zero-protocol/src/error-reason.ts';\nimport {getErrorMessage} from '../../../shared/src/error.ts';\nimport {ProtocolErrorWithLevel} from '../types/error-with-level.ts';\n\nconst reservedParams = ['schema', 'appID'];\n\n/**\n * Compiles and validates a URLPattern from configuration.\n *\n * Patterns must be full URLs (e.g., \"https://api.example.com/endpoint\").\n * URLPattern automatically sets search and hash to wildcard ('*'),\n * which means query parameters and fragments are ignored during matching.\n *\n * @throws Error if the pattern is an invalid URLPattern\n */\nexport function compileUrlPattern(pattern: string): URLPattern {\n try {\n return new URLPattern(pattern);\n } catch (e) {\n throw new Error(\n `Invalid URLPattern in URL configuration: \"${pattern}\". Error: ${e instanceof Error ? e.message : String(e)}`,\n );\n }\n}\n\nexport type HeaderOptions = {\n apiKey?: string | undefined;\n token?: string | undefined;\n cookie?: string | undefined;\n};\n\nexport const getBodyPreview = async (\n res: Response,\n lc: LogContext,\n): Promise<string | undefined> => {\n try {\n const body = await res.clone().text();\n if (body.length > 512) {\n return body.slice(0, 512) + '...';\n }\n return body;\n } catch (e) {\n lc.error?.('failed to get body preview', {\n url: res.url,\n error: e instanceof Error ? e.message : String(e),\n });\n }\n\n return undefined;\n};\n\nexport async function fetchFromAPIServer<TValidator extends Type>(\n validator: TValidator,\n source: 'push' | 'transform',\n lc: LogContext,\n url: string,\n allowedUrlPatterns: URLPattern[],\n shard: ShardID,\n headerOptions: HeaderOptions,\n body: ReadonlyJSONValue,\n) {\n lc.debug?.('fetchFromAPIServer called', {\n url,\n });\n\n if (!urlMatch(url, allowedUrlPatterns)) {\n throw new ProtocolErrorWithLevel(\n source === 'push'\n ? {\n kind: ErrorKind.PushFailed,\n origin: ErrorOrigin.ZeroCache,\n reason: ErrorReason.Internal,\n message: `URL \"${url}\" is not allowed by the ZERO_MUTATE_URL configuration`,\n mutationIDs: [],\n }\n : {\n kind: ErrorKind.TransformFailed,\n origin: ErrorOrigin.ZeroCache,\n reason: ErrorReason.Internal,\n message: `URL \"${url}\" is not allowed by the ZERO_GET_QUERIES_URL configuration`,\n queryIDs: [],\n },\n );\n }\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n };\n\n if (headerOptions.apiKey) {\n headers['X-Api-Key'] = headerOptions.apiKey;\n }\n if (headerOptions.token) {\n headers['Authorization'] = `Bearer ${headerOptions.token}`;\n }\n if (headerOptions.cookie) {\n headers['Cookie'] = headerOptions.cookie;\n }\n\n const urlObj = new URL(url);\n const params = new URLSearchParams(urlObj.search);\n\n for (const reserved of reservedParams) {\n assert(\n !params.has(reserved),\n `The push URL cannot contain the reserved query param \"${reserved}\"`,\n );\n }\n\n params.append('schema', upstreamSchema(shard));\n params.append('appID', shard.appID);\n\n urlObj.search = params.toString();\n\n const finalUrl = urlObj.toString();\n\n try {\n const response = await fetch(finalUrl, {\n method: 'POST',\n headers,\n body: JSON.stringify(body),\n });\n\n if (!response.ok) {\n const bodyPreview = await getBodyPreview(response, lc);\n\n lc.info?.('fetch from API server returned non-OK status', {\n url: finalUrl,\n status: response.status,\n bodyPreview,\n });\n\n throw new ProtocolErrorWithLevel(\n source === 'push'\n ? {\n kind: ErrorKind.PushFailed,\n origin: ErrorOrigin.ZeroCache,\n reason: ErrorReason.HTTP,\n status: response.status,\n bodyPreview,\n message: `Fetch from API server returned non-OK status ${response.status}`,\n mutationIDs: [],\n }\n : {\n kind: ErrorKind.TransformFailed,\n origin: ErrorOrigin.ZeroCache,\n reason: ErrorReason.HTTP,\n status: response.status,\n bodyPreview,\n message: `Fetch from API server returned non-OK status ${response.status}`,\n queryIDs: [],\n },\n );\n }\n\n try {\n const json = await response.json();\n\n return validator.parse(json);\n } catch (error) {\n lc.error?.('failed to parse response', {\n url: finalUrl,\n error,\n });\n\n throw new ProtocolErrorWithLevel(\n source === 'push'\n ? {\n kind: ErrorKind.PushFailed,\n origin: ErrorOrigin.ZeroCache,\n reason: ErrorReason.Parse,\n message: `Failed to parse response from API server: ${getErrorMessage(error)}`,\n mutationIDs: [],\n }\n : {\n kind: ErrorKind.TransformFailed,\n origin: ErrorOrigin.ZeroCache,\n reason: ErrorReason.Parse,\n message: `Failed to parse response from API server: ${getErrorMessage(error)}`,\n queryIDs: [],\n },\n 'error',\n {cause: error},\n );\n }\n } catch (error) {\n if (isProtocolError(error)) {\n throw error;\n }\n\n lc.error?.('failed to fetch from API server with unknown error', {\n url: finalUrl,\n error,\n });\n\n throw new ProtocolErrorWithLevel(\n source === 'push'\n ? {\n kind: ErrorKind.PushFailed,\n origin: ErrorOrigin.ZeroCache,\n reason: ErrorReason.Internal,\n message: `Fetch from API server failed with unknown error: ${getErrorMessage(error)}`,\n mutationIDs: [],\n }\n : {\n kind: ErrorKind.TransformFailed,\n origin: ErrorOrigin.ZeroCache,\n reason: ErrorReason.Internal,\n message: `Fetch from API server failed with unknown error: ${getErrorMessage(error)}`,\n queryIDs: [],\n },\n 'error',\n {cause: error},\n );\n }\n}\n\n/**\n * Returns true if the url matches one of the allowedUrlPatterns.\n *\n * URLPattern automatically ignores query parameters and hash fragments during matching\n * because it sets search and hash to wildcard ('*') by default.\n *\n * Example URLPattern patterns:\n * - \"https://api.example.com/endpoint\" - Exact match for a specific URL\n * - \"https://*.example.com/endpoint\" - Matches any single subdomain (e.g., \"https://api.example.com/endpoint\")\n * - \"https://*.*.example.com/endpoint\" - Matches two subdomains (e.g., \"https://api.v1.example.com/endpoint\")\n * - \"https://api.example.com/*\" - Matches any path under /\n * - \"https://api.example.com/:version/endpoint\" - Matches with named parameter (e.g., \"https://api.example.com/v1/endpoint\")\n */\nexport function urlMatch(\n url: string,\n allowedUrlPatterns: URLPattern[],\n): boolean {\n for (const pattern of allowedUrlPatterns) {\n if (pattern.test(url)) {\n return true;\n }\n }\n return false;\n}\n"],"names":["ErrorKind.PushFailed","ErrorOrigin.ZeroCache","ErrorReason.Internal","ErrorKind.TransformFailed","ErrorReason.HTTP","ErrorReason.Parse"],"mappings":";;;;;;;;;AAaA,MAAM,iBAAiB,CAAC,UAAU,OAAO;AAWlC,SAAS,kBAAkB,SAA6B;AAC7D,MAAI;AACF,WAAO,IAAI,WAAW,OAAO;AAAA,EAC/B,SAAS,GAAG;AACV,UAAM,IAAI;AAAA,MACR,6CAA6C,OAAO,aAAa,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC,CAAC;AAAA,IAAA;AAAA,EAE/G;AACF;AAQO,MAAM,iBAAiB,OAC5B,KACA,OACgC;AAChC,MAAI;AACF,UAAM,OAAO,MAAM,IAAI,MAAA,EAAQ,KAAA;AAC/B,QAAI,KAAK,SAAS,KAAK;AACrB,aAAO,KAAK,MAAM,GAAG,GAAG,IAAI;AAAA,IAC9B;AACA,WAAO;AAAA,EACT,SAAS,GAAG;AACV,OAAG,QAAQ,8BAA8B;AAAA,MACvC,KAAK,IAAI;AAAA,MACT,OAAO,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC;AAAA,IAAA,CACjD;AAAA,EACH;AAEA,SAAO;AACT;AAEA,eAAsB,mBACpB,WACA,QACA,IACA,KACA,oBACA,OACA,eACA,M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AM,IAAI;AAAA,MACR,WAAW,SACP;AAAA,QACE,MAAML;AAAAA,QACN,QAAQC;AAAAA,QACR,QAAQC;AAAAA,QACR,SAAS,oDAAoD,gBAAgB,KAAK,CAAC;AAAA,QACnF,aAAa,CAAA;AAAA,MAAC,IAEhB;AAAA,QACE,MAAMC;AAAAA,QACN,QAAQF;AAAAA,QACR,QAAQC;AAAAA,QACR,SAAS,oDAAoD,gBAAgB,KAAK,CAAC;AAAA,QACnF,UAAU,CAAA;AAAA,MAAC;AAAA,MAEjB;AAAA,MACA,EAAC,OAAO,MAAA;AAAA,IAAK;AAAA,EAEjB;AACF;AAeO,SAAS,SACd,KACA,oBACS;AACT,aAAW,WAAW,oBAAoB;AACxC,QAAI,QAAQ,KAAK,GAAG,GAAG;AACrB,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;"}
1
+ {"version":3,"file":"fetch.js","sources":["../../../../../zero-cache/src/custom/fetch.ts"],"sourcesContent":["import type {LogContext, LogLevel} from '@rocicorp/logger';\nimport 'urlpattern-polyfill';\nimport {assert} from '../../../shared/src/asserts.ts';\nimport {getErrorMessage} from '../../../shared/src/error.ts';\nimport type {ReadonlyJSONValue} from '../../../shared/src/json.ts';\nimport {type Type} from '../../../shared/src/valita.ts';\nimport {ErrorKind} from '../../../zero-protocol/src/error-kind.ts';\nimport {ErrorOrigin} from '../../../zero-protocol/src/error-origin.ts';\nimport {ErrorReason} from '../../../zero-protocol/src/error-reason.ts';\nimport {isProtocolError} from '../../../zero-protocol/src/error.ts';\nimport {ProtocolErrorWithLevel} from '../types/error-with-level.ts';\nimport {upstreamSchema, type ShardID} from '../types/shards.ts';\n\nconst reservedParams = ['schema', 'appID'];\n\n/**\n * Compiles and validates a URLPattern from configuration.\n *\n * Patterns must be full URLs (e.g., \"https://api.example.com/endpoint\").\n * URLPattern automatically sets search and hash to wildcard ('*'),\n * which means query parameters and fragments are ignored during matching.\n *\n * @throws Error if the pattern is an invalid URLPattern\n */\nexport function compileUrlPattern(pattern: string): URLPattern {\n try {\n return new URLPattern(pattern);\n } catch (e) {\n throw new Error(\n `Invalid URLPattern in URL configuration: \"${pattern}\". Error: ${e instanceof Error ? e.message : String(e)}`,\n );\n }\n}\n\nexport type HeaderOptions = {\n apiKey?: string | undefined;\n token?: string | undefined;\n cookie?: string | undefined;\n};\n\nexport const getBodyPreview = async (\n res: Response,\n lc: LogContext,\n level: LogLevel,\n): Promise<string | undefined> => {\n try {\n const body = await res.clone().text();\n if (body.length > 512) {\n return body.slice(0, 512) + '...';\n }\n return body;\n } catch (e) {\n lc[level]?.('failed to get body preview', {\n url: res.url,\n error: e instanceof Error ? e.message : String(e),\n });\n }\n\n return undefined;\n};\n\nexport async function fetchFromAPIServer<TValidator extends Type>(\n validator: TValidator,\n source: 'push' | 'transform',\n lc: LogContext,\n url: string,\n isUserUrl: boolean,\n allowedUrlPatterns: URLPattern[],\n shard: ShardID,\n headerOptions: HeaderOptions,\n body: ReadonlyJSONValue,\n) {\n lc.debug?.('fetchFromAPIServer called', {\n url,\n });\n\n if (!urlMatch(url, allowedUrlPatterns)) {\n throw new ProtocolErrorWithLevel(\n source === 'push'\n ? {\n kind: ErrorKind.PushFailed,\n origin: ErrorOrigin.ZeroCache,\n reason: ErrorReason.Internal,\n message: `URL \"${url}\" is not allowed by the ZERO_MUTATE_URL configuration`,\n mutationIDs: [],\n }\n : {\n kind: ErrorKind.TransformFailed,\n origin: ErrorOrigin.ZeroCache,\n reason: ErrorReason.Internal,\n message: `URL \"${url}\" is not allowed by the ZERO_QUERY_URL configuration`,\n queryIDs: [],\n },\n );\n }\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n };\n\n if (headerOptions.apiKey) {\n headers['X-Api-Key'] = headerOptions.apiKey;\n }\n if (headerOptions.token) {\n headers['Authorization'] = `Bearer ${headerOptions.token}`;\n }\n if (headerOptions.cookie) {\n headers['Cookie'] = headerOptions.cookie;\n }\n\n const urlObj = new URL(url);\n const params = new URLSearchParams(urlObj.search);\n\n for (const reserved of reservedParams) {\n assert(\n !params.has(reserved),\n `The push URL cannot contain the reserved query param \"${reserved}\"`,\n );\n }\n\n params.append('schema', upstreamSchema(shard));\n params.append('appID', shard.appID);\n\n urlObj.search = params.toString();\n\n const finalUrl = urlObj.toString();\n\n // Errors from a user-specified url are treated 4xx errors\n // (e.g. bad request) as they are developer driven and should not\n // trigger error-log based alerts.\n const errLevel: LogLevel = isUserUrl ? 'warn' : 'error';\n try {\n const response = await fetch(finalUrl, {\n method: 'POST',\n headers,\n body: JSON.stringify(body),\n });\n\n if (!response.ok) {\n const bodyPreview = await getBodyPreview(response, lc, errLevel);\n\n // Bad Gateway or Gateway Timeout indicate the server was not reached\n const level =\n response.status === 502 || response.status === 504 ? errLevel : 'info';\n lc[level]?.('fetch from API server returned non-OK status', {\n url: finalUrl,\n status: response.status,\n bodyPreview,\n });\n\n throw new ProtocolErrorWithLevel(\n source === 'push'\n ? {\n kind: ErrorKind.PushFailed,\n origin: ErrorOrigin.ZeroCache,\n reason: ErrorReason.HTTP,\n status: response.status,\n bodyPreview,\n message: `Fetch from API server returned non-OK status ${response.status}`,\n mutationIDs: [],\n }\n : {\n kind: ErrorKind.TransformFailed,\n origin: ErrorOrigin.ZeroCache,\n reason: ErrorReason.HTTP,\n status: response.status,\n bodyPreview,\n message: `Fetch from API server returned non-OK status ${response.status}`,\n queryIDs: [],\n },\n );\n }\n\n try {\n const json = await response.json();\n\n return validator.parse(json);\n } catch (error) {\n lc[errLevel]?.('failed to parse response', {\n url: finalUrl,\n error,\n });\n\n throw new ProtocolErrorWithLevel(\n source === 'push'\n ? {\n kind: ErrorKind.PushFailed,\n origin: ErrorOrigin.ZeroCache,\n reason: ErrorReason.Parse,\n message: `Failed to parse response from API server: ${getErrorMessage(error)}`,\n mutationIDs: [],\n }\n : {\n kind: ErrorKind.TransformFailed,\n origin: ErrorOrigin.ZeroCache,\n reason: ErrorReason.Parse,\n message: `Failed to parse response from API server: ${getErrorMessage(error)}`,\n queryIDs: [],\n },\n 'error',\n {cause: error},\n );\n }\n } catch (error) {\n if (isProtocolError(error)) {\n throw error;\n }\n\n lc[errLevel]?.('failed to fetch from API server with unknown error', {\n url: finalUrl,\n error,\n });\n\n throw new ProtocolErrorWithLevel(\n source === 'push'\n ? {\n kind: ErrorKind.PushFailed,\n origin: ErrorOrigin.ZeroCache,\n reason: ErrorReason.Internal,\n message: `Fetch from API server failed with unknown error: ${getErrorMessage(error)}`,\n mutationIDs: [],\n }\n : {\n kind: ErrorKind.TransformFailed,\n origin: ErrorOrigin.ZeroCache,\n reason: ErrorReason.Internal,\n message: `Fetch from API server failed with unknown error: ${getErrorMessage(error)}`,\n queryIDs: [],\n },\n 'error',\n {cause: error},\n );\n }\n}\n\n/**\n * Returns true if the url matches one of the allowedUrlPatterns.\n *\n * URLPattern automatically ignores query parameters and hash fragments during matching\n * because it sets search and hash to wildcard ('*') by default.\n *\n * Example URLPattern patterns:\n * - \"https://api.example.com/endpoint\" - Exact match for a specific URL\n * - \"https://*.example.com/endpoint\" - Matches any single subdomain (e.g., \"https://api.example.com/endpoint\")\n * - \"https://*.*.example.com/endpoint\" - Matches two subdomains (e.g., \"https://api.v1.example.com/endpoint\")\n * - \"https://api.example.com/*\" - Matches any path under /\n * - \"https://api.example.com/:version/endpoint\" - Matches with named parameter (e.g., \"https://api.example.com/v1/endpoint\")\n */\nexport function urlMatch(\n url: string,\n allowedUrlPatterns: URLPattern[],\n): boolean {\n for (const pattern of allowedUrlPatterns) {\n if (pattern.test(url)) {\n return true;\n }\n }\n return false;\n}\n"],"names":["ErrorKind.PushFailed","ErrorOrigin.ZeroCache","ErrorReason.Internal","ErrorKind.TransformFailed","ErrorReason.HTTP","ErrorReason.Parse"],"mappings":";;;;;;;;;;AAaA,MAAM,iBAAiB,CAAC,UAAU,OAAO;AAWlC,SAAS,kBAAkB,SAA6B;AAC7D,MAAI;AACF,WAAO,IAAI,WAAW,OAAO;AAAA,EAC/B,SAAS,GAAG;AACV,UAAM,IAA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query.d.ts","sourceRoot":"","sources":["../../../../../zero-cache/src/custom-queries/transform-query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAIjD,OAAO,EAEL,KAAK,YAAY,EAGlB,MAAM,8CAA8C,CAAC;AAItD,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,yCAAyC,CAAC;AAC/E,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,oBAAoB,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,sBAAsB;;gBAW/B,EAAE,EAAE,UAAU,EACd,MAAM,EAAE;QACN,GAAG,EAAE,MAAM,EAAE,CAAC;QACd,cAAc,EAAE,OAAO,CAAC;KACzB,EACD,KAAK,EAAE,OAAO;IASV,SAAS,CACb,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAE,QAAQ,CAAC,iBAAiB,CAAC,EACpC,YAAY,EAAE,MAAM,GAAG,SAAS,GAC/B,OAAO,CAAC,CAAC,oBAAoB,GAAG,YAAY,CAAC,EAAE,GAAG,mBAAmB,CAAC;CAgG1E"}
1
+ {"version":3,"file":"transform-query.d.ts","sourceRoot":"","sources":["../../../../../zero-cache/src/custom-queries/transform-query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAIjD,OAAO,EAEL,KAAK,YAAY,EAGlB,MAAM,8CAA8C,CAAC;AAItD,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,yCAAyC,CAAC;AAC/E,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,oBAAoB,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,sBAAsB;;gBAW/B,EAAE,EAAE,UAAU,EACd,MAAM,EAAE;QACN,GAAG,EAAE,MAAM,EAAE,CAAC;QACd,cAAc,EAAE,OAAO,CAAC;KACzB,EACD,KAAK,EAAE,OAAO;IASV,SAAS,CACb,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAE,QAAQ,CAAC,iBAAiB,CAAC,EACpC,YAAY,EAAE,MAAM,GAAG,SAAS,GAC/B,OAAO,CAAC,CAAC,oBAAoB,GAAG,YAAY,CAAC,EAAE,GAAG,mBAAmB,CAAC;CA8F1E"}
@@ -8,7 +8,6 @@ import { Internal } from "../../../zero-protocol/src/error-reason-enum.js";
8
8
  import { isProtocolError } from "../../../zero-protocol/src/error.js";
9
9
  import { hashOfAST } from "../../../zero-protocol/src/query-hash.js";
10
10
  import { compileUrlPattern, fetchFromAPIServer } from "../custom/fetch.js";
11
- import { getLogLevel } from "../types/error-with-level.js";
12
11
  class CustomQueryTransformer {
13
12
  #shard;
14
13
  #cache;
@@ -56,8 +55,9 @@ class CustomQueryTransformer {
56
55
  this.#lc,
57
56
  userQueryURL ?? must(
58
57
  this.#config.url[0],
59
- "A ZERO_GET_QUERIES_URL must be configured for custom queries"
58
+ "A ZERO_QUERY_URL must be configured for custom queries"
60
59
  ),
60
+ userQueryURL !== void 0,
61
61
  this.#urlPatterns,
62
62
  this.#shard,
63
63
  headerOptions,
@@ -85,8 +85,6 @@ class CustomQueryTransformer {
85
85
  }
86
86
  return newResponses.concat(cachedResponses);
87
87
  } catch (e) {
88
- const level = getLogLevel(e);
89
- this.#lc[level]?.("failed to transform queries", e);
90
88
  if (isProtocolError(e) && e.errorBody.kind === TransformFailed) {
91
89
  return {
92
90
  ...e.errorBody,