convex 1.29.3 → 1.30.0

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 (374) hide show
  1. package/CHANGELOG.md +24 -1
  2. package/dist/browser.bundle.js +504 -19
  3. package/dist/browser.bundle.js.map +4 -4
  4. package/dist/cjs/browser/index.js.map +2 -2
  5. package/dist/cjs/browser/simple_client.js +120 -15
  6. package/dist/cjs/browser/simple_client.js.map +3 -3
  7. package/dist/cjs/browser/sync/client.js +2 -2
  8. package/dist/cjs/browser/sync/client.js.map +2 -2
  9. package/dist/cjs/browser/sync/local_state.js.map +2 -2
  10. package/dist/cjs/browser/sync/optimistic_updates_impl.js +8 -1
  11. package/dist/cjs/browser/sync/optimistic_updates_impl.js.map +2 -2
  12. package/dist/cjs/browser/sync/paginated_query_client.js +381 -0
  13. package/dist/cjs/browser/sync/paginated_query_client.js.map +7 -0
  14. package/dist/cjs/browser/sync/pagination.js +37 -0
  15. package/dist/cjs/browser/sync/pagination.js.map +7 -0
  16. package/dist/cjs/browser/sync/udf_path_utils.js +16 -1
  17. package/dist/cjs/browser/sync/udf_path_utils.js.map +2 -2
  18. package/dist/cjs/bundler/fs.js +5 -5
  19. package/dist/cjs/bundler/fs.js.map +3 -3
  20. package/dist/cjs/bundler/index.js +17 -15
  21. package/dist/cjs/bundler/index.js.map +3 -3
  22. package/dist/cjs/bundler/log.js +3 -3
  23. package/dist/cjs/bundler/log.js.map +3 -3
  24. package/dist/cjs/cli/configure.js +11 -13
  25. package/dist/cjs/cli/configure.js.map +3 -3
  26. package/dist/cjs/cli/convexExport.js +2 -12
  27. package/dist/cjs/cli/convexExport.js.map +3 -3
  28. package/dist/cjs/cli/convexImport.js +2 -12
  29. package/dist/cjs/cli/convexImport.js.map +3 -3
  30. package/dist/cjs/cli/dashboard.js +4 -4
  31. package/dist/cjs/cli/dashboard.js.map +3 -3
  32. package/dist/cjs/cli/data.js +2 -12
  33. package/dist/cjs/cli/data.js.map +3 -3
  34. package/dist/cjs/cli/deploy.js +13 -15
  35. package/dist/cjs/cli/deploy.js.map +3 -3
  36. package/dist/cjs/cli/docs.js +3 -3
  37. package/dist/cjs/cli/docs.js.map +3 -3
  38. package/dist/cjs/cli/env.js +2 -12
  39. package/dist/cjs/cli/env.js.map +3 -3
  40. package/dist/cjs/cli/index.js +9 -9
  41. package/dist/cjs/cli/index.js.map +3 -3
  42. package/dist/cjs/cli/integration.js +2 -12
  43. package/dist/cjs/cli/integration.js.map +3 -3
  44. package/dist/cjs/cli/lib/checkForLargeIndexDeletion.js +7 -17
  45. package/dist/cjs/cli/lib/checkForLargeIndexDeletion.js.map +3 -3
  46. package/dist/cjs/cli/lib/codegen.js +5 -3
  47. package/dist/cjs/cli/lib/codegen.js.map +2 -2
  48. package/dist/cjs/cli/lib/components/definition/bundle.js +3 -3
  49. package/dist/cjs/cli/lib/components/definition/bundle.js.map +3 -3
  50. package/dist/cjs/cli/lib/components.js +2 -2
  51. package/dist/cjs/cli/lib/components.js.map +3 -3
  52. package/dist/cjs/cli/lib/config.js +13 -13
  53. package/dist/cjs/cli/lib/config.js.map +3 -3
  54. package/dist/cjs/cli/lib/convexExport.js +9 -7
  55. package/dist/cjs/cli/lib/convexExport.js.map +3 -3
  56. package/dist/cjs/cli/lib/convexImport.js +8 -8
  57. package/dist/cjs/cli/lib/convexImport.js.map +3 -3
  58. package/dist/cjs/cli/lib/cursorRules.js +2 -2
  59. package/dist/cjs/cli/lib/cursorRules.js.map +3 -3
  60. package/dist/cjs/cli/lib/data.js +3 -13
  61. package/dist/cjs/cli/lib/data.js.map +3 -3
  62. package/dist/cjs/cli/lib/deploy2.js +2 -2
  63. package/dist/cjs/cli/lib/deploy2.js.map +3 -3
  64. package/dist/cjs/cli/lib/dev.js +2 -2
  65. package/dist/cjs/cli/lib/dev.js.map +3 -3
  66. package/dist/cjs/cli/lib/env.js +4 -14
  67. package/dist/cjs/cli/lib/env.js.map +3 -3
  68. package/dist/cjs/cli/lib/envvars.js +5 -3
  69. package/dist/cjs/cli/lib/envvars.js.map +3 -3
  70. package/dist/cjs/cli/lib/functionSpec.js.map +2 -2
  71. package/dist/cjs/cli/lib/indexes.js +6 -16
  72. package/dist/cjs/cli/lib/indexes.js.map +3 -3
  73. package/dist/cjs/cli/lib/init.js +3 -13
  74. package/dist/cjs/cli/lib/init.js.map +3 -3
  75. package/dist/cjs/cli/lib/localDeployment/anonymous.js +1 -1
  76. package/dist/cjs/cli/lib/localDeployment/anonymous.js.map +2 -2
  77. package/dist/cjs/cli/lib/localDeployment/utils.js +4 -4
  78. package/dist/cjs/cli/lib/localDeployment/utils.js.map +3 -3
  79. package/dist/cjs/cli/lib/login.js +6 -4
  80. package/dist/cjs/cli/lib/login.js.map +3 -3
  81. package/dist/cjs/cli/lib/logs.js +19 -13
  82. package/dist/cjs/cli/lib/logs.js.map +2 -2
  83. package/dist/cjs/cli/lib/networkTest.js +11 -7
  84. package/dist/cjs/cli/lib/networkTest.js.map +3 -3
  85. package/dist/cjs/cli/lib/run.js +6 -6
  86. package/dist/cjs/cli/lib/run.js.map +3 -3
  87. package/dist/cjs/cli/lib/typecheck.js +7 -5
  88. package/dist/cjs/cli/lib/typecheck.js.map +3 -3
  89. package/dist/cjs/cli/lib/usage.js +4 -14
  90. package/dist/cjs/cli/lib/usage.js.map +3 -3
  91. package/dist/cjs/cli/lib/utils/globalConfig.js +4 -4
  92. package/dist/cjs/cli/lib/utils/globalConfig.js.map +3 -3
  93. package/dist/cjs/cli/lib/utils/utils.js +12 -8
  94. package/dist/cjs/cli/lib/utils/utils.js.map +3 -3
  95. package/dist/cjs/cli/typecheck.js +3 -13
  96. package/dist/cjs/cli/typecheck.js.map +3 -3
  97. package/dist/cjs/cli/update.js +2 -12
  98. package/dist/cjs/cli/update.js.map +3 -3
  99. package/dist/cjs/index.js +1 -1
  100. package/dist/cjs/index.js.map +1 -1
  101. package/dist/cjs/react/client.js +82 -1
  102. package/dist/cjs/react/client.js.map +2 -2
  103. package/dist/cjs/react/index.js +4 -0
  104. package/dist/cjs/react/index.js.map +2 -2
  105. package/dist/cjs/react/queries_observer.js +36 -11
  106. package/dist/cjs/react/queries_observer.js.map +2 -2
  107. package/dist/cjs/react/use_paginated_query2.js +124 -0
  108. package/dist/cjs/react/use_paginated_query2.js.map +7 -0
  109. package/dist/cjs/react/use_queries.js +9 -2
  110. package/dist/cjs/react/use_queries.js.map +2 -2
  111. package/dist/cjs/values/validator.js.map +2 -2
  112. package/dist/cjs-types/browser/index.d.ts +1 -0
  113. package/dist/cjs-types/browser/index.d.ts.map +1 -1
  114. package/dist/cjs-types/browser/simple_client.d.ts +22 -1
  115. package/dist/cjs-types/browser/simple_client.d.ts.map +1 -1
  116. package/dist/cjs-types/browser/sync/client.d.ts.map +1 -1
  117. package/dist/cjs-types/browser/sync/client_node_test_helpers.d.ts +5 -4
  118. package/dist/cjs-types/browser/sync/client_node_test_helpers.d.ts.map +1 -1
  119. package/dist/cjs-types/browser/sync/local_state.d.ts +12 -1
  120. package/dist/cjs-types/browser/sync/local_state.d.ts.map +1 -1
  121. package/dist/cjs-types/browser/sync/optimistic_updates_impl.d.ts.map +1 -1
  122. package/dist/cjs-types/browser/sync/paginated_query_client.d.ts +71 -0
  123. package/dist/cjs-types/browser/sync/paginated_query_client.d.ts.map +1 -0
  124. package/dist/cjs-types/browser/sync/paginated_query_client.test.d.ts +2 -0
  125. package/dist/cjs-types/browser/sync/paginated_query_client.test.d.ts.map +1 -0
  126. package/dist/cjs-types/browser/sync/pagination.d.ts +23 -0
  127. package/dist/cjs-types/browser/sync/pagination.d.ts.map +1 -0
  128. package/dist/cjs-types/browser/sync/udf_path_utils.d.ts +20 -1
  129. package/dist/cjs-types/browser/sync/udf_path_utils.d.ts.map +1 -1
  130. package/dist/cjs-types/bundler/index.d.ts.map +1 -1
  131. package/dist/cjs-types/cli/configure.d.ts.map +1 -1
  132. package/dist/cjs-types/cli/deploy.d.ts.map +1 -1
  133. package/dist/cjs-types/cli/lib/codegen.d.ts +3 -1
  134. package/dist/cjs-types/cli/lib/codegen.d.ts.map +1 -1
  135. package/dist/cjs-types/cli/lib/convexExport.d.ts.map +1 -1
  136. package/dist/cjs-types/cli/lib/convexImport.d.ts.map +1 -1
  137. package/dist/cjs-types/cli/lib/envvars.d.ts.map +1 -1
  138. package/dist/cjs-types/cli/lib/functionSpec.d.ts.map +1 -1
  139. package/dist/cjs-types/cli/lib/login.d.ts.map +1 -1
  140. package/dist/cjs-types/cli/lib/logs.d.ts +2 -1
  141. package/dist/cjs-types/cli/lib/logs.d.ts.map +1 -1
  142. package/dist/cjs-types/cli/lib/networkTest.d.ts.map +1 -1
  143. package/dist/cjs-types/cli/lib/typecheck.d.ts.map +1 -1
  144. package/dist/cjs-types/cli/lib/utils/utils.d.ts.map +1 -1
  145. package/dist/cjs-types/index.d.ts +1 -1
  146. package/dist/cjs-types/react/client.d.ts +37 -1
  147. package/dist/cjs-types/react/client.d.ts.map +1 -1
  148. package/dist/cjs-types/react/index.d.ts +2 -0
  149. package/dist/cjs-types/react/index.d.ts.map +1 -1
  150. package/dist/cjs-types/react/queries_observer.d.ts +12 -6
  151. package/dist/cjs-types/react/queries_observer.d.ts.map +1 -1
  152. package/dist/cjs-types/react/use_paginated_query2.d.ts +51 -0
  153. package/dist/cjs-types/react/use_paginated_query2.d.ts.map +1 -0
  154. package/dist/cjs-types/react/use_queries.d.ts.map +1 -1
  155. package/dist/cjs-types/values/validator.d.ts +1 -1
  156. package/dist/cli.bundle.cjs +201 -162
  157. package/dist/cli.bundle.cjs.map +2 -2
  158. package/dist/esm/browser/index.js.map +2 -2
  159. package/dist/esm/browser/simple_client.js +122 -15
  160. package/dist/esm/browser/simple_client.js.map +3 -3
  161. package/dist/esm/browser/sync/client.js +2 -2
  162. package/dist/esm/browser/sync/client.js.map +2 -2
  163. package/dist/esm/browser/sync/local_state.js.map +2 -2
  164. package/dist/esm/browser/sync/optimistic_updates_impl.js +8 -1
  165. package/dist/esm/browser/sync/optimistic_updates_impl.js.map +2 -2
  166. package/dist/esm/browser/sync/paginated_query_client.js +365 -0
  167. package/dist/esm/browser/sync/paginated_query_client.js.map +7 -0
  168. package/dist/esm/browser/sync/pagination.js +14 -0
  169. package/dist/esm/browser/sync/pagination.js.map +7 -0
  170. package/dist/esm/browser/sync/udf_path_utils.js +13 -0
  171. package/dist/esm/browser/sync/udf_path_utils.js.map +2 -2
  172. package/dist/esm/bundler/fs.js +5 -5
  173. package/dist/esm/bundler/fs.js.map +2 -2
  174. package/dist/esm/bundler/index.js +17 -15
  175. package/dist/esm/bundler/index.js.map +2 -2
  176. package/dist/esm/bundler/log.js +3 -3
  177. package/dist/esm/bundler/log.js.map +2 -2
  178. package/dist/esm/cli/configure.js +12 -14
  179. package/dist/esm/cli/configure.js.map +2 -2
  180. package/dist/esm/cli/convexExport.js +2 -2
  181. package/dist/esm/cli/convexExport.js.map +2 -2
  182. package/dist/esm/cli/convexImport.js +2 -2
  183. package/dist/esm/cli/convexImport.js.map +2 -2
  184. package/dist/esm/cli/dashboard.js +4 -4
  185. package/dist/esm/cli/dashboard.js.map +2 -2
  186. package/dist/esm/cli/data.js +2 -2
  187. package/dist/esm/cli/data.js.map +2 -2
  188. package/dist/esm/cli/deploy.js +13 -5
  189. package/dist/esm/cli/deploy.js.map +2 -2
  190. package/dist/esm/cli/docs.js +3 -3
  191. package/dist/esm/cli/docs.js.map +2 -2
  192. package/dist/esm/cli/env.js +2 -2
  193. package/dist/esm/cli/env.js.map +2 -2
  194. package/dist/esm/cli/index.js +9 -9
  195. package/dist/esm/cli/index.js.map +2 -2
  196. package/dist/esm/cli/integration.js +2 -2
  197. package/dist/esm/cli/integration.js.map +2 -2
  198. package/dist/esm/cli/lib/checkForLargeIndexDeletion.js +7 -7
  199. package/dist/esm/cli/lib/checkForLargeIndexDeletion.js.map +2 -2
  200. package/dist/esm/cli/lib/codegen.js +4 -2
  201. package/dist/esm/cli/lib/codegen.js.map +2 -2
  202. package/dist/esm/cli/lib/components/definition/bundle.js +3 -3
  203. package/dist/esm/cli/lib/components/definition/bundle.js.map +2 -2
  204. package/dist/esm/cli/lib/components.js +2 -2
  205. package/dist/esm/cli/lib/components.js.map +2 -2
  206. package/dist/esm/cli/lib/config.js +13 -13
  207. package/dist/esm/cli/lib/config.js.map +2 -2
  208. package/dist/esm/cli/lib/convexExport.js +9 -7
  209. package/dist/esm/cli/lib/convexExport.js.map +2 -2
  210. package/dist/esm/cli/lib/convexImport.js +8 -8
  211. package/dist/esm/cli/lib/convexImport.js.map +2 -2
  212. package/dist/esm/cli/lib/cursorRules.js +2 -2
  213. package/dist/esm/cli/lib/cursorRules.js.map +2 -2
  214. package/dist/esm/cli/lib/data.js +3 -3
  215. package/dist/esm/cli/lib/data.js.map +2 -2
  216. package/dist/esm/cli/lib/deploy2.js +2 -2
  217. package/dist/esm/cli/lib/deploy2.js.map +2 -2
  218. package/dist/esm/cli/lib/dev.js +2 -2
  219. package/dist/esm/cli/lib/dev.js.map +2 -2
  220. package/dist/esm/cli/lib/env.js +4 -4
  221. package/dist/esm/cli/lib/env.js.map +2 -2
  222. package/dist/esm/cli/lib/envvars.js +5 -3
  223. package/dist/esm/cli/lib/envvars.js.map +2 -2
  224. package/dist/esm/cli/lib/functionSpec.js.map +2 -2
  225. package/dist/esm/cli/lib/indexes.js +6 -6
  226. package/dist/esm/cli/lib/indexes.js.map +2 -2
  227. package/dist/esm/cli/lib/init.js +3 -3
  228. package/dist/esm/cli/lib/init.js.map +2 -2
  229. package/dist/esm/cli/lib/localDeployment/anonymous.js +2 -2
  230. package/dist/esm/cli/lib/localDeployment/anonymous.js.map +2 -2
  231. package/dist/esm/cli/lib/localDeployment/utils.js +4 -4
  232. package/dist/esm/cli/lib/localDeployment/utils.js.map +2 -2
  233. package/dist/esm/cli/lib/login.js +6 -4
  234. package/dist/esm/cli/lib/login.js.map +2 -2
  235. package/dist/esm/cli/lib/logs.js +20 -14
  236. package/dist/esm/cli/lib/logs.js.map +2 -2
  237. package/dist/esm/cli/lib/networkTest.js +11 -7
  238. package/dist/esm/cli/lib/networkTest.js.map +2 -2
  239. package/dist/esm/cli/lib/run.js +6 -6
  240. package/dist/esm/cli/lib/run.js.map +2 -2
  241. package/dist/esm/cli/lib/typecheck.js +7 -5
  242. package/dist/esm/cli/lib/typecheck.js.map +2 -2
  243. package/dist/esm/cli/lib/usage.js +4 -4
  244. package/dist/esm/cli/lib/usage.js.map +2 -2
  245. package/dist/esm/cli/lib/utils/globalConfig.js +4 -4
  246. package/dist/esm/cli/lib/utils/globalConfig.js.map +2 -2
  247. package/dist/esm/cli/lib/utils/utils.js +12 -8
  248. package/dist/esm/cli/lib/utils/utils.js.map +2 -2
  249. package/dist/esm/cli/typecheck.js +3 -3
  250. package/dist/esm/cli/typecheck.js.map +2 -2
  251. package/dist/esm/cli/update.js +2 -2
  252. package/dist/esm/cli/update.js.map +2 -2
  253. package/dist/esm/index.js +1 -1
  254. package/dist/esm/index.js.map +1 -1
  255. package/dist/esm/react/client.js +84 -1
  256. package/dist/esm/react/client.js.map +2 -2
  257. package/dist/esm/react/index.js +2 -0
  258. package/dist/esm/react/index.js.map +2 -2
  259. package/dist/esm/react/queries_observer.js +36 -11
  260. package/dist/esm/react/queries_observer.js.map +2 -2
  261. package/dist/esm/react/use_paginated_query2.js +101 -0
  262. package/dist/esm/react/use_paginated_query2.js.map +7 -0
  263. package/dist/esm/react/use_queries.js +9 -2
  264. package/dist/esm/react/use_queries.js.map +2 -2
  265. package/dist/esm/values/validator.js.map +2 -2
  266. package/dist/esm-types/browser/index.d.ts +1 -0
  267. package/dist/esm-types/browser/index.d.ts.map +1 -1
  268. package/dist/esm-types/browser/simple_client.d.ts +22 -1
  269. package/dist/esm-types/browser/simple_client.d.ts.map +1 -1
  270. package/dist/esm-types/browser/sync/client.d.ts.map +1 -1
  271. package/dist/esm-types/browser/sync/client_node_test_helpers.d.ts +5 -4
  272. package/dist/esm-types/browser/sync/client_node_test_helpers.d.ts.map +1 -1
  273. package/dist/esm-types/browser/sync/local_state.d.ts +12 -1
  274. package/dist/esm-types/browser/sync/local_state.d.ts.map +1 -1
  275. package/dist/esm-types/browser/sync/optimistic_updates_impl.d.ts.map +1 -1
  276. package/dist/esm-types/browser/sync/paginated_query_client.d.ts +71 -0
  277. package/dist/esm-types/browser/sync/paginated_query_client.d.ts.map +1 -0
  278. package/dist/esm-types/browser/sync/paginated_query_client.test.d.ts +2 -0
  279. package/dist/esm-types/browser/sync/paginated_query_client.test.d.ts.map +1 -0
  280. package/dist/esm-types/browser/sync/pagination.d.ts +23 -0
  281. package/dist/esm-types/browser/sync/pagination.d.ts.map +1 -0
  282. package/dist/esm-types/browser/sync/udf_path_utils.d.ts +20 -1
  283. package/dist/esm-types/browser/sync/udf_path_utils.d.ts.map +1 -1
  284. package/dist/esm-types/bundler/index.d.ts.map +1 -1
  285. package/dist/esm-types/cli/configure.d.ts.map +1 -1
  286. package/dist/esm-types/cli/deploy.d.ts.map +1 -1
  287. package/dist/esm-types/cli/lib/codegen.d.ts +3 -1
  288. package/dist/esm-types/cli/lib/codegen.d.ts.map +1 -1
  289. package/dist/esm-types/cli/lib/convexExport.d.ts.map +1 -1
  290. package/dist/esm-types/cli/lib/convexImport.d.ts.map +1 -1
  291. package/dist/esm-types/cli/lib/envvars.d.ts.map +1 -1
  292. package/dist/esm-types/cli/lib/functionSpec.d.ts.map +1 -1
  293. package/dist/esm-types/cli/lib/login.d.ts.map +1 -1
  294. package/dist/esm-types/cli/lib/logs.d.ts +2 -1
  295. package/dist/esm-types/cli/lib/logs.d.ts.map +1 -1
  296. package/dist/esm-types/cli/lib/networkTest.d.ts.map +1 -1
  297. package/dist/esm-types/cli/lib/typecheck.d.ts.map +1 -1
  298. package/dist/esm-types/cli/lib/utils/utils.d.ts.map +1 -1
  299. package/dist/esm-types/index.d.ts +1 -1
  300. package/dist/esm-types/react/client.d.ts +37 -1
  301. package/dist/esm-types/react/client.d.ts.map +1 -1
  302. package/dist/esm-types/react/index.d.ts +2 -0
  303. package/dist/esm-types/react/index.d.ts.map +1 -1
  304. package/dist/esm-types/react/queries_observer.d.ts +12 -6
  305. package/dist/esm-types/react/queries_observer.d.ts.map +1 -1
  306. package/dist/esm-types/react/use_paginated_query2.d.ts +51 -0
  307. package/dist/esm-types/react/use_paginated_query2.d.ts.map +1 -0
  308. package/dist/esm-types/react/use_queries.d.ts.map +1 -1
  309. package/dist/esm-types/values/validator.d.ts +1 -1
  310. package/dist/react.bundle.js +620 -35
  311. package/dist/react.bundle.js.map +4 -4
  312. package/package.json +1 -1
  313. package/src/browser/index.ts +3 -0
  314. package/src/browser/simple_client.ts +164 -21
  315. package/src/browser/sync/client.ts +12 -3
  316. package/src/browser/sync/client_node_test_helpers.ts +29 -8
  317. package/src/browser/sync/local_state.ts +13 -1
  318. package/src/browser/sync/optimistic_updates_impl.ts +9 -2
  319. package/src/browser/sync/paginated_query_client.test.ts +389 -0
  320. package/src/browser/sync/paginated_query_client.ts +564 -0
  321. package/src/browser/sync/pagination.ts +50 -0
  322. package/src/browser/sync/udf_path_utils.ts +34 -2
  323. package/src/bundler/fs.ts +5 -5
  324. package/src/bundler/index.ts +17 -15
  325. package/src/bundler/log.ts +3 -3
  326. package/src/cli/configure.ts +13 -18
  327. package/src/cli/convexExport.ts +2 -2
  328. package/src/cli/convexImport.ts +2 -2
  329. package/src/cli/dashboard.ts +4 -4
  330. package/src/cli/data.ts +2 -2
  331. package/src/cli/deploy.ts +21 -5
  332. package/src/cli/docs.ts +3 -3
  333. package/src/cli/env.ts +2 -2
  334. package/src/cli/index.ts +9 -9
  335. package/src/cli/integration.ts +2 -2
  336. package/src/cli/lib/checkForLargeIndexDeletion.ts +7 -7
  337. package/src/cli/lib/codegen.ts +7 -2
  338. package/src/cli/lib/components/definition/bundle.ts +3 -3
  339. package/src/cli/lib/components.ts +2 -2
  340. package/src/cli/lib/config.ts +13 -13
  341. package/src/cli/lib/convexExport.ts +9 -7
  342. package/src/cli/lib/convexImport.ts +10 -8
  343. package/src/cli/lib/cursorRules.ts +2 -2
  344. package/src/cli/lib/data.ts +3 -3
  345. package/src/cli/lib/deploy2.ts +2 -2
  346. package/src/cli/lib/dev.ts +2 -2
  347. package/src/cli/lib/env.ts +4 -4
  348. package/src/cli/lib/envvars.ts +5 -3
  349. package/src/cli/lib/functionSpec.ts +1 -0
  350. package/src/cli/lib/indexes.test.ts +6 -6
  351. package/src/cli/lib/indexes.ts +8 -6
  352. package/src/cli/lib/init.ts +3 -3
  353. package/src/cli/lib/localDeployment/anonymous.ts +2 -2
  354. package/src/cli/lib/localDeployment/utils.ts +4 -4
  355. package/src/cli/lib/login.ts +6 -4
  356. package/src/cli/lib/logs.ts +21 -10
  357. package/src/cli/lib/networkTest.ts +11 -7
  358. package/src/cli/lib/run.ts +6 -6
  359. package/src/cli/lib/typecheck.ts +7 -5
  360. package/src/cli/lib/usage.ts +4 -4
  361. package/src/cli/lib/utils/globalConfig.ts +4 -4
  362. package/src/cli/lib/utils/utils.ts +12 -8
  363. package/src/cli/network_test.ts +2 -2
  364. package/src/cli/typecheck.ts +3 -3
  365. package/src/cli/update.ts +2 -2
  366. package/src/index.ts +1 -1
  367. package/src/react/client.ts +163 -4
  368. package/src/react/index.ts +2 -0
  369. package/src/react/queries_observer.test.ts +1 -1
  370. package/src/react/queries_observer.ts +75 -24
  371. package/src/react/use_paginated_query.test.tsx +963 -947
  372. package/src/react/use_paginated_query2.ts +234 -0
  373. package/src/react/use_queries.ts +15 -2
  374. package/src/values/validator.ts +1 -1
package/CHANGELOG.md CHANGED
@@ -1,12 +1,35 @@
1
1
  # Changelog
2
2
 
3
- ## Unreleased
3
+ ## 1.30.0
4
+
5
+ - The `--preview-create` parameter for `npx convex deploy` will now error if
6
+ used with a deploy key that is not a preview deploy key. Previously, the flag
7
+ would be ignored in this situation, and `npx convex deploy` would deploy to
8
+ the production deployment. If you were depending on this behavior, make sure
9
+ to remove the `--preview-create` flag when deploying to production.
10
+
11
+ ## 1.29.3
12
+
13
+ - Revert ApiFromModules type changes introduced in 1.29.0 which sometimes caused
14
+ type mismatches due to `FunctionReference` sometimes missing properties.
15
+
16
+ - Don't warn when `"$schema"` is present in convex.json.
17
+
18
+ - Replace ProxyAgent with EnvHttpProxyAgent in the CLI so the `NO_PROXY`
19
+ environment variable is respected.
20
+
21
+ ## 1.29.2
4
22
 
5
23
  - When running `npx convex deploy`, the CLI will now ask for explicit
6
24
  confirmation before deleting large indexes. This change is helpful for
7
25
  avoiding situations where an index is accidentally deleted and backfilling it
8
26
  takes a long time.
9
27
 
28
+ ## 1.29.1
29
+
30
+ - Support for special error and no-op values of `CONVEX_DEPLOY_KEY` environment
31
+ variable used by the Convex Vercel integration.
32
+
10
33
  ## 1.29.0
11
34
 
12
35
  - Code generation changes: modules and functions are sorted in more situations,
@@ -28,7 +28,7 @@ var convex = (() => {
28
28
  });
29
29
 
30
30
  // src/index.ts
31
- var version = "1.29.3";
31
+ var version = "1.30.0";
32
32
 
33
33
  // src/values/base64.ts
34
34
  var base64_exports = {};
@@ -624,6 +624,19 @@ var convex = (() => {
624
624
  args: convexToJson(args)
625
625
  });
626
626
  }
627
+ function serializePaginatedPathAndArgs(udfPath, args, options) {
628
+ const { initialNumItems, id } = options;
629
+ const result = JSON.stringify({
630
+ type: "paginated",
631
+ udfPath: canonicalizeUdfPath(udfPath),
632
+ args: convexToJson(args),
633
+ options: convexToJson({ initialNumItems, id })
634
+ });
635
+ return result;
636
+ }
637
+ function serializedQueryTokenIsPaginated(token) {
638
+ return JSON.parse(token).type === "paginated";
639
+ }
627
640
 
628
641
  // src/browser/sync/local_state.ts
629
642
  var LocalSyncState = class {
@@ -1309,10 +1322,17 @@ var convex = (() => {
1309
1322
  return localStore.modifiedQueries;
1310
1323
  }
1311
1324
  /**
1325
+ * "Raw" with respect to errors vs values, but query results still have
1326
+ * optimistic updates applied.
1327
+ *
1312
1328
  * @internal
1313
1329
  */
1314
1330
  rawQueryResult(queryToken) {
1315
- return this.queryResults.get(queryToken);
1331
+ const query = this.queryResults.get(queryToken);
1332
+ if (query === void 0) {
1333
+ return void 0;
1334
+ }
1335
+ return query.result;
1316
1336
  }
1317
1337
  queryResult(queryToken) {
1318
1338
  const query = this.queryResults.get(queryToken);
@@ -2825,7 +2845,7 @@ var convex = (() => {
2825
2845
  token,
2826
2846
  modification: {
2827
2847
  kind: "Updated",
2828
- result: optimisticResult.result
2848
+ result: optimisticResult
2829
2849
  }
2830
2850
  };
2831
2851
  }),
@@ -2955,7 +2975,7 @@ var convex = (() => {
2955
2975
  return this.optimisticQueryResults.queryResult(queryToken);
2956
2976
  }
2957
2977
  /**
2958
- * Whether local query result is available for a toke.
2978
+ * Whether local query result is available for a token.
2959
2979
  *
2960
2980
  * This method does not throw if the result is an error.
2961
2981
  *
@@ -3256,11 +3276,374 @@ var convex = (() => {
3256
3276
  }
3257
3277
  };
3258
3278
 
3279
+ // src/browser/sync/pagination.ts
3280
+ function asPaginationResult(value) {
3281
+ if (typeof value !== "object" || value === null || !Array.isArray(value.page) || typeof value.isDone !== "boolean" || typeof value.continueCursor !== "string") {
3282
+ throw new Error(`Not a valid paginated query result: ${value?.toString()}`);
3283
+ }
3284
+ return value;
3285
+ }
3286
+
3287
+ // src/browser/sync/paginated_query_client.ts
3288
+ var PaginatedQueryClient = class {
3289
+ constructor(client, onTransition) {
3290
+ this.client = client;
3291
+ this.onTransition = onTransition;
3292
+ this.lastTransitionTs = Long.fromNumber(0);
3293
+ this.client.addOnTransitionHandler(
3294
+ (transition) => this.onBaseTransition(transition)
3295
+ );
3296
+ }
3297
+ paginatedQuerySet = /* @__PURE__ */ new Map();
3298
+ // hold onto a real Transition so we can construct synthetic ones with that timestamp
3299
+ lastTransitionTs;
3300
+ /**
3301
+ * Subscribe to a paginated query.
3302
+ *
3303
+ * @param name - The name of the paginated query function
3304
+ * @param args - Arguments for the query (excluding paginationOpts)
3305
+ * @param options - Pagination options including initialNumItems
3306
+ * @returns Object with paginatedQueryToken and unsubscribe function
3307
+ */
3308
+ subscribe(name, args, options) {
3309
+ const canonicalizedUdfPath = canonicalizeUdfPath(name);
3310
+ const token = serializePaginatedPathAndArgs(
3311
+ canonicalizedUdfPath,
3312
+ args,
3313
+ options
3314
+ );
3315
+ const unsubscribe = () => this.removePaginatedQuerySubscriber(token);
3316
+ const existingEntry = this.paginatedQuerySet.get(token);
3317
+ if (existingEntry) {
3318
+ existingEntry.numSubscribers += 1;
3319
+ return {
3320
+ paginatedQueryToken: token,
3321
+ unsubscribe
3322
+ };
3323
+ }
3324
+ this.paginatedQuerySet.set(token, {
3325
+ token,
3326
+ canonicalizedUdfPath,
3327
+ args,
3328
+ numSubscribers: 1,
3329
+ options: { initialNumItems: options.initialNumItems },
3330
+ nextPageKey: 0,
3331
+ pageKeys: [],
3332
+ pageKeyToQuery: /* @__PURE__ */ new Map(),
3333
+ ongoingSplits: /* @__PURE__ */ new Map(),
3334
+ skip: false,
3335
+ id: options.id
3336
+ });
3337
+ this.addPageToPaginatedQuery(token, null, options.initialNumItems);
3338
+ return {
3339
+ paginatedQueryToken: token,
3340
+ unsubscribe
3341
+ };
3342
+ }
3343
+ /**
3344
+ * Get current results for a paginated query based on local state.
3345
+ *
3346
+ * Throws an error when one of the pages has errored.
3347
+ */
3348
+ localQueryResult(name, args, options) {
3349
+ const canonicalizedUdfPath = canonicalizeUdfPath(name);
3350
+ const token = serializePaginatedPathAndArgs(
3351
+ canonicalizedUdfPath,
3352
+ args,
3353
+ options
3354
+ );
3355
+ return this.localQueryResultByToken(token);
3356
+ }
3357
+ /**
3358
+ * @internal
3359
+ */
3360
+ localQueryResultByToken(token) {
3361
+ const paginatedQuery = this.paginatedQuerySet.get(token);
3362
+ if (!paginatedQuery) {
3363
+ return void 0;
3364
+ }
3365
+ const activePages = this.activePageQueryTokens(paginatedQuery);
3366
+ if (activePages.length === 0) {
3367
+ return {
3368
+ results: [],
3369
+ status: "LoadingFirstPage",
3370
+ loadMore: (numItems) => {
3371
+ return this.loadMoreOfPaginatedQuery(token, numItems);
3372
+ }
3373
+ };
3374
+ }
3375
+ let allResults = [];
3376
+ let hasUndefined = false;
3377
+ let isDone = false;
3378
+ for (const pageToken of activePages) {
3379
+ const result = this.client.localQueryResultByToken(pageToken);
3380
+ if (result === void 0) {
3381
+ hasUndefined = true;
3382
+ isDone = false;
3383
+ continue;
3384
+ }
3385
+ const paginationResult = asPaginationResult(result);
3386
+ allResults = allResults.concat(paginationResult.page);
3387
+ isDone = !!paginationResult.isDone;
3388
+ }
3389
+ let status;
3390
+ if (hasUndefined) {
3391
+ status = allResults.length === 0 ? "LoadingFirstPage" : "LoadingMore";
3392
+ } else if (isDone) {
3393
+ status = "Exhausted";
3394
+ } else {
3395
+ status = "CanLoadMore";
3396
+ }
3397
+ return {
3398
+ results: allResults,
3399
+ status,
3400
+ loadMore: (numItems) => {
3401
+ return this.loadMoreOfPaginatedQuery(token, numItems);
3402
+ }
3403
+ };
3404
+ }
3405
+ onBaseTransition(transition) {
3406
+ const changedBaseTokens = transition.queries.map((q) => q.token);
3407
+ const changed = this.queriesContainingTokens(changedBaseTokens);
3408
+ let paginatedQueries = [];
3409
+ if (changed.length > 0) {
3410
+ this.processPaginatedQuerySplits(
3411
+ changed,
3412
+ (token) => this.client.localQueryResultByToken(token)
3413
+ );
3414
+ paginatedQueries = changed.map((token) => ({
3415
+ token,
3416
+ modification: {
3417
+ kind: "Updated",
3418
+ result: this.localQueryResultByToken(token)
3419
+ }
3420
+ }));
3421
+ }
3422
+ const extendedTransition = {
3423
+ ...transition,
3424
+ paginatedQueries
3425
+ };
3426
+ this.onTransition(extendedTransition);
3427
+ }
3428
+ /**
3429
+ * Load more items for a paginated query.
3430
+ *
3431
+ * This *always* causes a transition, the status of the query
3432
+ * has probably changed from "CanLoadMore" to "LoadingMore".
3433
+ * Data might have changed too: maybe a subscription to this page
3434
+ * query already exists (unlikely but possible) or this page query
3435
+ * has an optimistic update providing some initial data.
3436
+ *
3437
+ * @internal
3438
+ */
3439
+ loadMoreOfPaginatedQuery(token, numItems) {
3440
+ this.mustGetPaginatedQuery(token);
3441
+ const lastPageToken = this.queryTokenForLastPageOfPaginatedQuery(token);
3442
+ const lastPageResult = this.client.localQueryResultByToken(lastPageToken);
3443
+ if (!lastPageResult) {
3444
+ return false;
3445
+ }
3446
+ const paginationResult = asPaginationResult(lastPageResult);
3447
+ if (paginationResult.isDone) {
3448
+ return false;
3449
+ }
3450
+ this.addPageToPaginatedQuery(
3451
+ token,
3452
+ paginationResult.continueCursor,
3453
+ numItems
3454
+ );
3455
+ const loadMoreTransition = {
3456
+ timestamp: this.lastTransitionTs,
3457
+ reflectedMutations: [],
3458
+ queries: [],
3459
+ paginatedQueries: [
3460
+ {
3461
+ token,
3462
+ modification: {
3463
+ kind: "Updated",
3464
+ result: this.localQueryResultByToken(token)
3465
+ }
3466
+ }
3467
+ ]
3468
+ };
3469
+ this.onTransition(loadMoreTransition);
3470
+ return true;
3471
+ }
3472
+ /**
3473
+ * @internal
3474
+ */
3475
+ queriesContainingTokens(queryTokens) {
3476
+ if (queryTokens.length === 0) {
3477
+ return [];
3478
+ }
3479
+ const changed = [];
3480
+ const queryTokenSet = new Set(queryTokens);
3481
+ for (const [paginatedToken, paginatedQuery] of this.paginatedQuerySet) {
3482
+ for (const pageToken of this.allQueryTokens(paginatedQuery)) {
3483
+ if (queryTokenSet.has(pageToken)) {
3484
+ changed.push(paginatedToken);
3485
+ break;
3486
+ }
3487
+ }
3488
+ }
3489
+ return changed;
3490
+ }
3491
+ /**
3492
+ * @internal
3493
+ */
3494
+ processPaginatedQuerySplits(changed, getResult) {
3495
+ for (const paginatedQueryToken of changed) {
3496
+ const paginatedQuery = this.mustGetPaginatedQuery(paginatedQueryToken);
3497
+ const { ongoingSplits, pageKeyToQuery, pageKeys } = paginatedQuery;
3498
+ for (const [pageKey, [splitKey1, splitKey2]] of ongoingSplits) {
3499
+ const bothNewPagesLoaded = getResult(pageKeyToQuery.get(splitKey1).queryToken) !== void 0 && getResult(pageKeyToQuery.get(splitKey2).queryToken) !== void 0;
3500
+ if (bothNewPagesLoaded) {
3501
+ this.completePaginatedQuerySplit(
3502
+ paginatedQuery,
3503
+ pageKey,
3504
+ splitKey1,
3505
+ splitKey2
3506
+ );
3507
+ }
3508
+ }
3509
+ for (const pageKey of pageKeys) {
3510
+ if (ongoingSplits.has(pageKey)) {
3511
+ continue;
3512
+ }
3513
+ const pageToken = pageKeyToQuery.get(pageKey).queryToken;
3514
+ const pageResult = getResult(pageToken);
3515
+ if (!pageResult) {
3516
+ continue;
3517
+ }
3518
+ const result = asPaginationResult(pageResult);
3519
+ const shouldSplit = result.splitCursor && (result.pageStatus === "SplitRecommended" || result.pageStatus === "SplitRequired" || // This client-driven page splitting condition will change in the future.
3520
+ result.page.length > paginatedQuery.options.initialNumItems * 2);
3521
+ if (shouldSplit) {
3522
+ this.splitPaginatedQueryPage(
3523
+ paginatedQuery,
3524
+ pageKey,
3525
+ result.splitCursor,
3526
+ // we just checked
3527
+ result.continueCursor
3528
+ );
3529
+ }
3530
+ }
3531
+ }
3532
+ }
3533
+ splitPaginatedQueryPage(paginatedQuery, pageKey, splitCursor, continueCursor) {
3534
+ const splitKey1 = paginatedQuery.nextPageKey++;
3535
+ const splitKey2 = paginatedQuery.nextPageKey++;
3536
+ const paginationOpts = {
3537
+ cursor: continueCursor,
3538
+ numItems: paginatedQuery.options.initialNumItems,
3539
+ id: paginatedQuery.id
3540
+ };
3541
+ const firstSubscription = this.client.subscribe(
3542
+ paginatedQuery.canonicalizedUdfPath,
3543
+ {
3544
+ ...paginatedQuery.args,
3545
+ paginationOpts: {
3546
+ ...paginationOpts,
3547
+ cursor: null,
3548
+ // Start from beginning for first split
3549
+ endCursor: splitCursor
3550
+ }
3551
+ }
3552
+ );
3553
+ paginatedQuery.pageKeyToQuery.set(splitKey1, firstSubscription);
3554
+ const secondSubscription = this.client.subscribe(
3555
+ paginatedQuery.canonicalizedUdfPath,
3556
+ {
3557
+ ...paginatedQuery.args,
3558
+ paginationOpts: {
3559
+ ...paginationOpts,
3560
+ cursor: splitCursor,
3561
+ endCursor: continueCursor
3562
+ }
3563
+ }
3564
+ );
3565
+ paginatedQuery.pageKeyToQuery.set(splitKey2, secondSubscription);
3566
+ paginatedQuery.ongoingSplits.set(pageKey, [splitKey1, splitKey2]);
3567
+ }
3568
+ /**
3569
+ * @internal
3570
+ */
3571
+ addPageToPaginatedQuery(token, continueCursor, numItems) {
3572
+ const paginatedQuery = this.mustGetPaginatedQuery(token);
3573
+ const pageKey = paginatedQuery.nextPageKey++;
3574
+ const paginationOpts = {
3575
+ cursor: continueCursor,
3576
+ numItems,
3577
+ id: paginatedQuery.id
3578
+ };
3579
+ const pageArgs = {
3580
+ ...paginatedQuery.args,
3581
+ paginationOpts
3582
+ };
3583
+ const subscription = this.client.subscribe(
3584
+ paginatedQuery.canonicalizedUdfPath,
3585
+ pageArgs
3586
+ );
3587
+ paginatedQuery.pageKeys.push(pageKey);
3588
+ paginatedQuery.pageKeyToQuery.set(pageKey, subscription);
3589
+ return subscription;
3590
+ }
3591
+ removePaginatedQuerySubscriber(token) {
3592
+ const paginatedQuery = this.paginatedQuerySet.get(token);
3593
+ if (!paginatedQuery) {
3594
+ return;
3595
+ }
3596
+ paginatedQuery.numSubscribers -= 1;
3597
+ if (paginatedQuery.numSubscribers > 0) {
3598
+ return;
3599
+ }
3600
+ for (const subscription of paginatedQuery.pageKeyToQuery.values()) {
3601
+ subscription.unsubscribe();
3602
+ }
3603
+ this.paginatedQuerySet.delete(token);
3604
+ }
3605
+ completePaginatedQuerySplit(paginatedQuery, pageKey, splitKey1, splitKey2) {
3606
+ const originalQuery = paginatedQuery.pageKeyToQuery.get(pageKey);
3607
+ paginatedQuery.pageKeyToQuery.delete(pageKey);
3608
+ const pageIndex = paginatedQuery.pageKeys.indexOf(pageKey);
3609
+ paginatedQuery.pageKeys.splice(pageIndex, 1, splitKey1, splitKey2);
3610
+ paginatedQuery.ongoingSplits.delete(pageKey);
3611
+ originalQuery.unsubscribe();
3612
+ }
3613
+ /** The query tokens for all active pages, in result order */
3614
+ activePageQueryTokens(paginatedQuery) {
3615
+ return paginatedQuery.pageKeys.map(
3616
+ (pageKey) => paginatedQuery.pageKeyToQuery.get(pageKey).queryToken
3617
+ );
3618
+ }
3619
+ allQueryTokens(paginatedQuery) {
3620
+ return Array.from(paginatedQuery.pageKeyToQuery.values()).map(
3621
+ (sub) => sub.queryToken
3622
+ );
3623
+ }
3624
+ queryTokenForLastPageOfPaginatedQuery(token) {
3625
+ const paginatedQuery = this.mustGetPaginatedQuery(token);
3626
+ const lastPageKey = paginatedQuery.pageKeys[paginatedQuery.pageKeys.length - 1];
3627
+ if (lastPageKey === void 0) {
3628
+ throw new Error(`No pages for paginated query ${token}`);
3629
+ }
3630
+ return paginatedQuery.pageKeyToQuery.get(lastPageKey).queryToken;
3631
+ }
3632
+ mustGetPaginatedQuery(token) {
3633
+ const paginatedQuery = this.paginatedQuerySet.get(token);
3634
+ if (!paginatedQuery) {
3635
+ throw new Error("paginated query no longer exists for token " + token);
3636
+ }
3637
+ return paginatedQuery;
3638
+ }
3639
+ };
3640
+
3259
3641
  // src/browser/simple_client.ts
3260
3642
  var defaultWebSocketConstructor;
3261
3643
  var ConvexClient = class {
3262
3644
  listeners;
3263
3645
  _client;
3646
+ _paginatedClient;
3264
3647
  // A synthetic server event to run callbacks the first time
3265
3648
  callNewListenersWithCurrentValuesTimer;
3266
3649
  _closed;
@@ -3275,6 +3658,13 @@ var convex = (() => {
3275
3658
  if (this._client) return this._client;
3276
3659
  throw new Error("ConvexClient is disabled");
3277
3660
  }
3661
+ /**
3662
+ * @internal
3663
+ */
3664
+ get paginatedClient() {
3665
+ if (this._paginatedClient) return this._paginatedClient;
3666
+ throw new Error("ConvexClient is disabled");
3667
+ }
3278
3668
  get disabled() {
3279
3669
  return this._disabled;
3280
3670
  }
@@ -3299,9 +3689,15 @@ var convex = (() => {
3299
3689
  if (!this.disabled) {
3300
3690
  this._client = new BaseConvexClient(
3301
3691
  address,
3302
- (updatedQueries) => this._transition(updatedQueries),
3692
+ () => {
3693
+ },
3694
+ // NOP, let the paginated query client do it all
3303
3695
  baseOptions
3304
3696
  );
3697
+ this._paginatedClient = new PaginatedQueryClient(
3698
+ this._client,
3699
+ (transition) => this._transition(transition)
3700
+ );
3305
3701
  }
3306
3702
  this.listeners = /* @__PURE__ */ new Set();
3307
3703
  }
@@ -3339,15 +3735,7 @@ var convex = (() => {
3339
3735
  */
3340
3736
  onUpdate(query, args, callback, onError) {
3341
3737
  if (this.disabled) {
3342
- const disabledUnsubscribe = () => {
3343
- };
3344
- const unsubscribeProps2 = {
3345
- unsubscribe: disabledUnsubscribe,
3346
- getCurrentValue: () => void 0,
3347
- getQueryLogs: () => void 0
3348
- };
3349
- Object.assign(disabledUnsubscribe, unsubscribeProps2);
3350
- return disabledUnsubscribe;
3738
+ return this.createDisabledUnsubscribe();
3351
3739
  }
3352
3740
  const { queryToken, unsubscribe } = this.client.subscribe(
3353
3741
  getFunctionName(query),
@@ -3360,7 +3748,8 @@ var convex = (() => {
3360
3748
  unsubscribe,
3361
3749
  hasEverRun: false,
3362
3750
  query,
3363
- args
3751
+ args,
3752
+ paginationOptions: void 0
3364
3753
  };
3365
3754
  this.listeners.add(queryInfo);
3366
3755
  if (this.queryResultReady(queryToken) && this.callNewListenersWithCurrentValuesTimer === void 0) {
@@ -3384,19 +3773,102 @@ var convex = (() => {
3384
3773
  Object.assign(ret, unsubscribeProps);
3385
3774
  return ret;
3386
3775
  }
3776
+ /**
3777
+ * Call a callback whenever a new result for a paginated query is received.
3778
+ *
3779
+ * This is an experimental preview: the final API may change.
3780
+ * In particular, caching behavior, page splitting, and required paginated query options
3781
+ * may change.
3782
+ *
3783
+ * @param query - A {@link server.FunctionReference} for the public query to run.
3784
+ * @param args - The arguments to run the query with.
3785
+ * @param options - Options for the paginated query including initialNumItems and id.
3786
+ * @param callback - Function to call when the query result updates.
3787
+ * @param onError - Function to call when the query result updates with an error.
3788
+ *
3789
+ * @return an {@link Unsubscribe} function to stop calling the callback.
3790
+ */
3791
+ onPaginatedUpdate_experimental(query, args, options, callback, onError) {
3792
+ if (this.disabled) {
3793
+ return this.createDisabledUnsubscribe();
3794
+ }
3795
+ const paginationOptions = {
3796
+ initialNumItems: options.initialNumItems,
3797
+ id: -1
3798
+ };
3799
+ const { paginatedQueryToken, unsubscribe } = this.paginatedClient.subscribe(
3800
+ getFunctionName(query),
3801
+ args,
3802
+ // Simple client doesn't use IDs, there's no expectation that these queries remain separate.
3803
+ paginationOptions
3804
+ );
3805
+ const queryInfo = {
3806
+ queryToken: paginatedQueryToken,
3807
+ callback,
3808
+ onError,
3809
+ unsubscribe,
3810
+ hasEverRun: false,
3811
+ query,
3812
+ args,
3813
+ paginationOptions
3814
+ };
3815
+ this.listeners.add(queryInfo);
3816
+ if (!!this.paginatedClient.localQueryResultByToken(paginatedQueryToken) && this.callNewListenersWithCurrentValuesTimer === void 0) {
3817
+ this.callNewListenersWithCurrentValuesTimer = setTimeout(
3818
+ () => this.callNewListenersWithCurrentValues(),
3819
+ 0
3820
+ );
3821
+ }
3822
+ const unsubscribeProps = {
3823
+ unsubscribe: () => {
3824
+ if (this.closed) {
3825
+ return;
3826
+ }
3827
+ this.listeners.delete(queryInfo);
3828
+ unsubscribe();
3829
+ },
3830
+ getCurrentValue: () => {
3831
+ const result = this.paginatedClient.localQueryResult(
3832
+ getFunctionName(query),
3833
+ args,
3834
+ paginationOptions
3835
+ );
3836
+ return result;
3837
+ },
3838
+ getQueryLogs: () => []
3839
+ // Paginated queries don't aggregate their logs
3840
+ };
3841
+ const ret = unsubscribeProps.unsubscribe;
3842
+ Object.assign(ret, unsubscribeProps);
3843
+ return ret;
3844
+ }
3387
3845
  // Run all callbacks that have never been run before if they have a query
3388
3846
  // result available now.
3389
3847
  callNewListenersWithCurrentValues() {
3390
3848
  this.callNewListenersWithCurrentValuesTimer = void 0;
3391
- this._transition([], true);
3849
+ this._transition({ queries: [], paginatedQueries: [] }, true);
3392
3850
  }
3393
3851
  queryResultReady(queryToken) {
3394
3852
  return this.client.hasLocalQueryResultByToken(queryToken);
3395
3853
  }
3854
+ createDisabledUnsubscribe() {
3855
+ const disabledUnsubscribe = () => {
3856
+ };
3857
+ const unsubscribeProps = {
3858
+ unsubscribe: disabledUnsubscribe,
3859
+ getCurrentValue: () => void 0,
3860
+ getQueryLogs: () => void 0
3861
+ };
3862
+ Object.assign(disabledUnsubscribe, unsubscribeProps);
3863
+ return disabledUnsubscribe;
3864
+ }
3396
3865
  async close() {
3397
3866
  if (this.disabled) return;
3398
3867
  this.listeners.clear();
3399
3868
  this._closed = true;
3869
+ if (this._paginatedClient) {
3870
+ this._paginatedClient = void 0;
3871
+ }
3400
3872
  return this.client.close();
3401
3873
  }
3402
3874
  /**
@@ -3435,14 +3907,27 @@ var convex = (() => {
3435
3907
  /**
3436
3908
  * @internal
3437
3909
  */
3438
- _transition(updatedQueries, callNewListeners = false) {
3910
+ _transition({
3911
+ queries,
3912
+ paginatedQueries
3913
+ }, callNewListeners = false) {
3914
+ const updatedQueries = [
3915
+ ...queries.map((q) => q.token),
3916
+ ...paginatedQueries.map((q) => q.token)
3917
+ ];
3439
3918
  for (const queryInfo of this.listeners) {
3440
3919
  const { callback, queryToken, onError, hasEverRun } = queryInfo;
3441
- if (updatedQueries.includes(queryToken) || callNewListeners && !hasEverRun && this.client.hasLocalQueryResultByToken(queryToken)) {
3920
+ const isPaginatedQuery = serializedQueryTokenIsPaginated(queryToken);
3921
+ const hasResultReady = isPaginatedQuery ? !!this.paginatedClient.localQueryResultByToken(queryToken) : this.client.hasLocalQueryResultByToken(queryToken);
3922
+ if (updatedQueries.includes(queryToken) || callNewListeners && !hasEverRun && hasResultReady) {
3442
3923
  queryInfo.hasEverRun = true;
3443
3924
  let newValue;
3444
3925
  try {
3445
- newValue = this.client.localQueryResultByToken(queryToken);
3926
+ if (isPaginatedQuery) {
3927
+ newValue = this.paginatedClient.localQueryResultByToken(queryToken);
3928
+ } else {
3929
+ newValue = this.client.localQueryResultByToken(queryToken);
3930
+ }
3446
3931
  } catch (error) {
3447
3932
  if (!(error instanceof Error)) throw error;
3448
3933
  if (onError) {