convex 1.45.0 → 1.46.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 (319) hide show
  1. package/CHANGELOG.md +48 -6
  2. package/dist/browser.bundle.js +1 -1
  3. package/dist/browser.bundle.js.map +2 -2
  4. package/dist/cjs/browser/http_client.js.map +2 -2
  5. package/dist/cjs/browser/query_options.js.map +2 -2
  6. package/dist/cjs/browser/simple_client.js.map +2 -2
  7. package/dist/cjs/browser/sync/optimistic_updates.js.map +1 -1
  8. package/dist/cjs/browser/sync/optimistic_updates_impl.js.map +2 -2
  9. package/dist/cjs/cli/codegen.js +2 -0
  10. package/dist/cjs/cli/codegen.js.map +2 -2
  11. package/dist/cjs/cli/deploy.js +1 -0
  12. package/dist/cjs/cli/deploy.js.map +2 -2
  13. package/dist/cjs/cli/docs.js +3 -36
  14. package/dist/cjs/cli/docs.js.map +2 -2
  15. package/dist/cjs/cli/lib/checkForLargeIndexDeletion.js +101 -60
  16. package/dist/cjs/cli/lib/checkForLargeIndexDeletion.js.map +2 -2
  17. package/dist/cjs/cli/lib/checkForSlowSchemaValidation.js +107 -0
  18. package/dist/cjs/cli/lib/checkForSlowSchemaValidation.js.map +7 -0
  19. package/dist/cjs/cli/lib/codegen.js.map +2 -2
  20. package/dist/cjs/cli/lib/components.js +12 -0
  21. package/dist/cjs/cli/lib/components.js.map +2 -2
  22. package/dist/cjs/cli/lib/deploy2.js +29 -2
  23. package/dist/cjs/cli/lib/deploy2.js.map +2 -2
  24. package/dist/cjs/cli/lib/deployApi/evaluateSchema.js +73 -0
  25. package/dist/cjs/cli/lib/deployApi/evaluateSchema.js.map +7 -0
  26. package/dist/cjs/cli/lib/deployApi/finishPush.js +1 -0
  27. package/dist/cjs/cli/lib/deployApi/finishPush.js.map +2 -2
  28. package/dist/cjs/cli/lib/deployApi/startPush.js +1 -1
  29. package/dist/cjs/cli/lib/deployApi/startPush.js.map +2 -2
  30. package/dist/cjs/cli/lib/dev.js +1 -0
  31. package/dist/cjs/cli/lib/dev.js.map +2 -2
  32. package/dist/cjs/cli/lib/generatedFunctionLogsApi.js.map +1 -1
  33. package/dist/cjs/cli/lib/localDeployment/run.js +30 -1
  34. package/dist/cjs/cli/lib/localDeployment/run.js.map +2 -2
  35. package/dist/cjs/cli/lib/localDeployment/upgrade.js +6 -5
  36. package/dist/cjs/cli/lib/localDeployment/upgrade.js.map +2 -2
  37. package/dist/cjs/cli/lib/localDeployment/utils.js +5 -1
  38. package/dist/cjs/cli/lib/localDeployment/utils.js.map +2 -2
  39. package/dist/cjs/cli/lib/run.js +1 -0
  40. package/dist/cjs/cli/lib/run.js.map +2 -2
  41. package/dist/cjs/cli/lib/utils/utils.js +36 -29
  42. package/dist/cjs/cli/lib/utils/utils.js.map +2 -2
  43. package/dist/cjs/index.js +1 -1
  44. package/dist/cjs/index.js.map +1 -1
  45. package/dist/cjs/nextjs/index.js.map +2 -2
  46. package/dist/cjs/react/client.js.map +2 -2
  47. package/dist/cjs/react/hydration.js.map +2 -2
  48. package/dist/cjs/react/queries_observer.js.map +2 -2
  49. package/dist/cjs/react/use_paginated_query2.js.map +2 -2
  50. package/dist/cjs/react/use_queries.js.map +2 -2
  51. package/dist/cjs/server/api.js.map +2 -2
  52. package/dist/cjs/server/components/index.js.map +2 -2
  53. package/dist/cjs/server/cron.js +10 -10
  54. package/dist/cjs/server/cron.js.map +2 -2
  55. package/dist/cjs/server/impl/actions_impl.js.map +2 -2
  56. package/dist/cjs/server/impl/meta_impl.js +8 -2
  57. package/dist/cjs/server/impl/meta_impl.js.map +2 -2
  58. package/dist/cjs/server/impl/scheduler_impl.js.map +2 -2
  59. package/dist/cjs/server/index.js.map +2 -2
  60. package/dist/cjs/server/meta.js.map +1 -1
  61. package/dist/cjs/server/registration.js.map +1 -1
  62. package/dist/cjs/server/scheduler.js.map +1 -1
  63. package/dist/cjs/server/schema.js +50 -3
  64. package/dist/cjs/server/schema.js.map +2 -2
  65. package/dist/cjs/values/validator.js +1 -1
  66. package/dist/cjs/values/validator.js.map +2 -2
  67. package/dist/cjs/values/validators.js +81 -25
  68. package/dist/cjs/values/validators.js.map +2 -2
  69. package/dist/cjs-types/browser/http_client.d.ts +5 -5
  70. package/dist/cjs-types/browser/http_client.d.ts.map +1 -1
  71. package/dist/cjs-types/browser/query_options.d.ts +2 -2
  72. package/dist/cjs-types/browser/query_options.d.ts.map +1 -1
  73. package/dist/cjs-types/browser/simple_client.d.ts +6 -6
  74. package/dist/cjs-types/browser/simple_client.d.ts.map +1 -1
  75. package/dist/cjs-types/browser/sync/optimistic_updates.d.ts +4 -4
  76. package/dist/cjs-types/browser/sync/optimistic_updates.d.ts.map +1 -1
  77. package/dist/cjs-types/browser/sync/optimistic_updates_impl.d.ts.map +1 -1
  78. package/dist/cjs-types/cli/codegen.d.ts.map +1 -1
  79. package/dist/cjs-types/cli/docs.d.ts.map +1 -1
  80. package/dist/cjs-types/cli/lib/checkForLargeIndexDeletion.d.ts +26 -5
  81. package/dist/cjs-types/cli/lib/checkForLargeIndexDeletion.d.ts.map +1 -1
  82. package/dist/cjs-types/cli/lib/checkForSlowSchemaValidation.d.ts +14 -0
  83. package/dist/cjs-types/cli/lib/checkForSlowSchemaValidation.d.ts.map +1 -0
  84. package/dist/cjs-types/cli/lib/codegen.d.ts +1 -0
  85. package/dist/cjs-types/cli/lib/codegen.d.ts.map +1 -1
  86. package/dist/cjs-types/cli/lib/components.d.ts +1 -0
  87. package/dist/cjs-types/cli/lib/components.d.ts.map +1 -1
  88. package/dist/cjs-types/cli/lib/deploy2.d.ts +6 -0
  89. package/dist/cjs-types/cli/lib/deploy2.d.ts.map +1 -1
  90. package/dist/cjs-types/cli/lib/deployApi/evaluateSchema.d.ts +453 -0
  91. package/dist/cjs-types/cli/lib/deployApi/evaluateSchema.d.ts.map +1 -0
  92. package/dist/cjs-types/cli/lib/deployApi/finishPush.d.ts +1 -2
  93. package/dist/cjs-types/cli/lib/deployApi/finishPush.d.ts.map +1 -1
  94. package/dist/cjs-types/cli/lib/dev.d.ts.map +1 -1
  95. package/dist/cjs-types/cli/lib/generatedFunctionLogsApi.d.ts +2 -0
  96. package/dist/cjs-types/cli/lib/generatedFunctionLogsApi.d.ts.map +1 -1
  97. package/dist/cjs-types/cli/lib/localDeployment/run.d.ts +2 -0
  98. package/dist/cjs-types/cli/lib/localDeployment/run.d.ts.map +1 -1
  99. package/dist/cjs-types/cli/lib/localDeployment/upgrade.d.ts.map +1 -1
  100. package/dist/cjs-types/cli/lib/localDeployment/utils.d.ts +1 -0
  101. package/dist/cjs-types/cli/lib/localDeployment/utils.d.ts.map +1 -1
  102. package/dist/cjs-types/cli/lib/run.d.ts.map +1 -1
  103. package/dist/cjs-types/cli/lib/utils/utils.d.ts +5 -5
  104. package/dist/cjs-types/cli/lib/utils/utils.d.ts.map +1 -1
  105. package/dist/cjs-types/index.d.ts +1 -1
  106. package/dist/cjs-types/nextjs/index.d.ts +6 -6
  107. package/dist/cjs-types/nextjs/index.d.ts.map +1 -1
  108. package/dist/cjs-types/react/client.d.ts +15 -15
  109. package/dist/cjs-types/react/client.d.ts.map +1 -1
  110. package/dist/cjs-types/react/hydration.d.ts +3 -3
  111. package/dist/cjs-types/react/hydration.d.ts.map +1 -1
  112. package/dist/cjs-types/react/queries_observer.d.ts +9 -9
  113. package/dist/cjs-types/react/queries_observer.d.ts.map +1 -1
  114. package/dist/cjs-types/react/use_paginated_query2.d.ts.map +1 -1
  115. package/dist/cjs-types/react/use_queries.d.ts +14 -6
  116. package/dist/cjs-types/react/use_queries.d.ts.map +1 -1
  117. package/dist/cjs-types/server/api.d.ts +157 -7
  118. package/dist/cjs-types/server/api.d.ts.map +1 -1
  119. package/dist/cjs-types/server/components/index.d.ts +2 -2
  120. package/dist/cjs-types/server/components/index.d.ts.map +1 -1
  121. package/dist/cjs-types/server/cron.d.ts +21 -20
  122. package/dist/cjs-types/server/cron.d.ts.map +1 -1
  123. package/dist/cjs-types/server/impl/actions_impl.d.ts +4 -4
  124. package/dist/cjs-types/server/impl/actions_impl.d.ts.map +1 -1
  125. package/dist/cjs-types/server/impl/meta_impl.d.ts.map +1 -1
  126. package/dist/cjs-types/server/impl/scheduler_impl.d.ts.map +1 -1
  127. package/dist/cjs-types/server/index.d.ts +1 -1
  128. package/dist/cjs-types/server/index.d.ts.map +1 -1
  129. package/dist/cjs-types/server/meta.d.ts.map +1 -1
  130. package/dist/cjs-types/server/registration.d.ts +7 -7
  131. package/dist/cjs-types/server/registration.d.ts.map +1 -1
  132. package/dist/cjs-types/server/scheduler.d.ts +9 -7
  133. package/dist/cjs-types/server/scheduler.d.ts.map +1 -1
  134. package/dist/cjs-types/server/schema.d.ts +1 -0
  135. package/dist/cjs-types/server/schema.d.ts.map +1 -1
  136. package/dist/cjs-types/values/validator.d.ts.map +1 -1
  137. package/dist/cjs-types/values/validators.d.ts +30 -0
  138. package/dist/cjs-types/values/validators.d.ts.map +1 -1
  139. package/dist/cli.bundle.cjs +347 -133
  140. package/dist/cli.bundle.cjs.map +4 -4
  141. package/dist/esm/browser/http_client.js.map +2 -2
  142. package/dist/esm/browser/query_options.js.map +2 -2
  143. package/dist/esm/browser/simple_client.js.map +2 -2
  144. package/dist/esm/browser/sync/optimistic_updates_impl.js.map +2 -2
  145. package/dist/esm/cli/codegen.js +2 -0
  146. package/dist/esm/cli/codegen.js.map +2 -2
  147. package/dist/esm/cli/deploy.js +1 -0
  148. package/dist/esm/cli/deploy.js.map +2 -2
  149. package/dist/esm/cli/docs.js +3 -43
  150. package/dist/esm/cli/docs.js.map +2 -2
  151. package/dist/esm/cli/lib/checkForLargeIndexDeletion.js +100 -60
  152. package/dist/esm/cli/lib/checkForLargeIndexDeletion.js.map +2 -2
  153. package/dist/esm/cli/lib/checkForSlowSchemaValidation.js +85 -0
  154. package/dist/esm/cli/lib/checkForSlowSchemaValidation.js.map +7 -0
  155. package/dist/esm/cli/lib/codegen.js.map +2 -2
  156. package/dist/esm/cli/lib/components.js +12 -0
  157. package/dist/esm/cli/lib/components.js.map +2 -2
  158. package/dist/esm/cli/lib/deploy2.js +30 -2
  159. package/dist/esm/cli/lib/deploy2.js.map +2 -2
  160. package/dist/esm/cli/lib/deployApi/evaluateSchema.js +46 -0
  161. package/dist/esm/cli/lib/deployApi/evaluateSchema.js.map +7 -0
  162. package/dist/esm/cli/lib/deployApi/finishPush.js +1 -1
  163. package/dist/esm/cli/lib/deployApi/finishPush.js.map +2 -2
  164. package/dist/esm/cli/lib/deployApi/startPush.js +1 -1
  165. package/dist/esm/cli/lib/deployApi/startPush.js.map +2 -2
  166. package/dist/esm/cli/lib/dev.js +1 -0
  167. package/dist/esm/cli/lib/dev.js.map +2 -2
  168. package/dist/esm/cli/lib/localDeployment/run.js +30 -2
  169. package/dist/esm/cli/lib/localDeployment/run.js.map +2 -2
  170. package/dist/esm/cli/lib/localDeployment/upgrade.js +4 -3
  171. package/dist/esm/cli/lib/localDeployment/upgrade.js.map +2 -2
  172. package/dist/esm/cli/lib/localDeployment/utils.js +3 -0
  173. package/dist/esm/cli/lib/localDeployment/utils.js.map +2 -2
  174. package/dist/esm/cli/lib/run.js +1 -0
  175. package/dist/esm/cli/lib/run.js.map +2 -2
  176. package/dist/esm/cli/lib/utils/utils.js +36 -30
  177. package/dist/esm/cli/lib/utils/utils.js.map +2 -2
  178. package/dist/esm/index.js +1 -1
  179. package/dist/esm/index.js.map +1 -1
  180. package/dist/esm/nextjs/index.js.map +2 -2
  181. package/dist/esm/react/client.js.map +2 -2
  182. package/dist/esm/react/hydration.js +3 -1
  183. package/dist/esm/react/hydration.js.map +2 -2
  184. package/dist/esm/react/queries_observer.js +3 -1
  185. package/dist/esm/react/queries_observer.js.map +2 -2
  186. package/dist/esm/react/use_paginated_query2.js +3 -1
  187. package/dist/esm/react/use_paginated_query2.js.map +2 -2
  188. package/dist/esm/react/use_queries.js.map +2 -2
  189. package/dist/esm/server/api.js.map +2 -2
  190. package/dist/esm/server/components/index.js.map +2 -2
  191. package/dist/esm/server/cron.js +13 -11
  192. package/dist/esm/server/cron.js.map +2 -2
  193. package/dist/esm/server/impl/actions_impl.js.map +2 -2
  194. package/dist/esm/server/impl/meta_impl.js +9 -3
  195. package/dist/esm/server/impl/meta_impl.js.map +2 -2
  196. package/dist/esm/server/impl/scheduler_impl.js.map +2 -2
  197. package/dist/esm/server/index.js.map +2 -2
  198. package/dist/esm/server/schema.js +50 -3
  199. package/dist/esm/server/schema.js.map +2 -2
  200. package/dist/esm/values/validator.js +1 -1
  201. package/dist/esm/values/validator.js.map +2 -2
  202. package/dist/esm/values/validators.js +81 -25
  203. package/dist/esm/values/validators.js.map +2 -2
  204. package/dist/esm-types/browser/http_client.d.ts +5 -5
  205. package/dist/esm-types/browser/http_client.d.ts.map +1 -1
  206. package/dist/esm-types/browser/query_options.d.ts +2 -2
  207. package/dist/esm-types/browser/query_options.d.ts.map +1 -1
  208. package/dist/esm-types/browser/simple_client.d.ts +6 -6
  209. package/dist/esm-types/browser/simple_client.d.ts.map +1 -1
  210. package/dist/esm-types/browser/sync/optimistic_updates.d.ts +4 -4
  211. package/dist/esm-types/browser/sync/optimistic_updates.d.ts.map +1 -1
  212. package/dist/esm-types/browser/sync/optimistic_updates_impl.d.ts.map +1 -1
  213. package/dist/esm-types/cli/codegen.d.ts.map +1 -1
  214. package/dist/esm-types/cli/docs.d.ts.map +1 -1
  215. package/dist/esm-types/cli/lib/checkForLargeIndexDeletion.d.ts +26 -5
  216. package/dist/esm-types/cli/lib/checkForLargeIndexDeletion.d.ts.map +1 -1
  217. package/dist/esm-types/cli/lib/checkForSlowSchemaValidation.d.ts +14 -0
  218. package/dist/esm-types/cli/lib/checkForSlowSchemaValidation.d.ts.map +1 -0
  219. package/dist/esm-types/cli/lib/codegen.d.ts +1 -0
  220. package/dist/esm-types/cli/lib/codegen.d.ts.map +1 -1
  221. package/dist/esm-types/cli/lib/components.d.ts +1 -0
  222. package/dist/esm-types/cli/lib/components.d.ts.map +1 -1
  223. package/dist/esm-types/cli/lib/deploy2.d.ts +6 -0
  224. package/dist/esm-types/cli/lib/deploy2.d.ts.map +1 -1
  225. package/dist/esm-types/cli/lib/deployApi/evaluateSchema.d.ts +453 -0
  226. package/dist/esm-types/cli/lib/deployApi/evaluateSchema.d.ts.map +1 -0
  227. package/dist/esm-types/cli/lib/deployApi/finishPush.d.ts +1 -2
  228. package/dist/esm-types/cli/lib/deployApi/finishPush.d.ts.map +1 -1
  229. package/dist/esm-types/cli/lib/dev.d.ts.map +1 -1
  230. package/dist/esm-types/cli/lib/generatedFunctionLogsApi.d.ts +2 -0
  231. package/dist/esm-types/cli/lib/generatedFunctionLogsApi.d.ts.map +1 -1
  232. package/dist/esm-types/cli/lib/localDeployment/run.d.ts +2 -0
  233. package/dist/esm-types/cli/lib/localDeployment/run.d.ts.map +1 -1
  234. package/dist/esm-types/cli/lib/localDeployment/upgrade.d.ts.map +1 -1
  235. package/dist/esm-types/cli/lib/localDeployment/utils.d.ts +1 -0
  236. package/dist/esm-types/cli/lib/localDeployment/utils.d.ts.map +1 -1
  237. package/dist/esm-types/cli/lib/run.d.ts.map +1 -1
  238. package/dist/esm-types/cli/lib/utils/utils.d.ts +5 -5
  239. package/dist/esm-types/cli/lib/utils/utils.d.ts.map +1 -1
  240. package/dist/esm-types/index.d.ts +1 -1
  241. package/dist/esm-types/nextjs/index.d.ts +6 -6
  242. package/dist/esm-types/nextjs/index.d.ts.map +1 -1
  243. package/dist/esm-types/react/client.d.ts +15 -15
  244. package/dist/esm-types/react/client.d.ts.map +1 -1
  245. package/dist/esm-types/react/hydration.d.ts +3 -3
  246. package/dist/esm-types/react/hydration.d.ts.map +1 -1
  247. package/dist/esm-types/react/queries_observer.d.ts +9 -9
  248. package/dist/esm-types/react/queries_observer.d.ts.map +1 -1
  249. package/dist/esm-types/react/use_paginated_query2.d.ts.map +1 -1
  250. package/dist/esm-types/react/use_queries.d.ts +14 -6
  251. package/dist/esm-types/react/use_queries.d.ts.map +1 -1
  252. package/dist/esm-types/server/api.d.ts +157 -7
  253. package/dist/esm-types/server/api.d.ts.map +1 -1
  254. package/dist/esm-types/server/components/index.d.ts +2 -2
  255. package/dist/esm-types/server/components/index.d.ts.map +1 -1
  256. package/dist/esm-types/server/cron.d.ts +21 -20
  257. package/dist/esm-types/server/cron.d.ts.map +1 -1
  258. package/dist/esm-types/server/impl/actions_impl.d.ts +4 -4
  259. package/dist/esm-types/server/impl/actions_impl.d.ts.map +1 -1
  260. package/dist/esm-types/server/impl/meta_impl.d.ts.map +1 -1
  261. package/dist/esm-types/server/impl/scheduler_impl.d.ts.map +1 -1
  262. package/dist/esm-types/server/index.d.ts +1 -1
  263. package/dist/esm-types/server/index.d.ts.map +1 -1
  264. package/dist/esm-types/server/meta.d.ts.map +1 -1
  265. package/dist/esm-types/server/registration.d.ts +7 -7
  266. package/dist/esm-types/server/registration.d.ts.map +1 -1
  267. package/dist/esm-types/server/scheduler.d.ts +9 -7
  268. package/dist/esm-types/server/scheduler.d.ts.map +1 -1
  269. package/dist/esm-types/server/schema.d.ts +1 -0
  270. package/dist/esm-types/server/schema.d.ts.map +1 -1
  271. package/dist/esm-types/values/validator.d.ts.map +1 -1
  272. package/dist/esm-types/values/validators.d.ts +30 -0
  273. package/dist/esm-types/values/validators.d.ts.map +1 -1
  274. package/dist/react.bundle.js +1 -1
  275. package/dist/react.bundle.js.map +2 -2
  276. package/package.json +5 -5
  277. package/src/browser/http_client.ts +43 -10
  278. package/src/browser/query_options.ts +11 -5
  279. package/src/browser/simple_client.ts +35 -14
  280. package/src/browser/sync/optimistic_updates.ts +17 -4
  281. package/src/browser/sync/optimistic_updates_impl.ts +17 -4
  282. package/src/cli/codegen.ts +1 -0
  283. package/src/cli/deploy.ts +1 -0
  284. package/src/cli/docs.ts +3 -44
  285. package/src/cli/lib/checkForLargeIndexDeletion.ts +154 -82
  286. package/src/cli/lib/checkForSlowSchemaValidation.ts +130 -0
  287. package/src/cli/lib/codegen.ts +1 -0
  288. package/src/cli/lib/components.ts +17 -0
  289. package/src/cli/lib/deploy2.ts +56 -1
  290. package/src/cli/lib/deployApi/evaluateSchema.ts +62 -0
  291. package/src/cli/lib/deployApi/finishPush.ts +1 -1
  292. package/src/cli/lib/deployApi/startPush.ts +1 -1
  293. package/src/cli/lib/dev.ts +1 -0
  294. package/src/cli/lib/generatedFunctionLogsApi.ts +2 -0
  295. package/src/cli/lib/localDeployment/run.ts +44 -2
  296. package/src/cli/lib/localDeployment/upgrade.ts +4 -6
  297. package/src/cli/lib/localDeployment/utils.ts +6 -0
  298. package/src/cli/lib/run.ts +1 -0
  299. package/src/cli/lib/utils/utils.ts +63 -35
  300. package/src/index.ts +1 -1
  301. package/src/nextjs/index.ts +19 -8
  302. package/src/react/client.ts +73 -30
  303. package/src/react/hydration.tsx +14 -6
  304. package/src/react/queries_observer.ts +19 -16
  305. package/src/react/use_paginated_query2.ts +10 -6
  306. package/src/react/use_queries.ts +23 -7
  307. package/src/server/api.ts +220 -14
  308. package/src/server/components/index.ts +4 -6
  309. package/src/server/cron.ts +34 -24
  310. package/src/server/impl/actions_impl.ts +13 -4
  311. package/src/server/impl/meta_impl.ts +8 -1
  312. package/src/server/impl/scheduler_impl.ts +13 -6
  313. package/src/server/index.ts +1 -0
  314. package/src/server/meta.ts +25 -0
  315. package/src/server/registration.ts +28 -7
  316. package/src/server/scheduler.ts +22 -7
  317. package/src/server/schema.ts +55 -0
  318. package/src/values/validator.ts +3 -1
  319. package/src/values/validators.ts +84 -26
@@ -2,7 +2,10 @@ import { convexToJson, jsonToConvex, Value } from "../../values/index.js";
2
2
  import { version } from "../../index.js";
3
3
  import { performAsyncSyscall } from "./syscall.js";
4
4
  import { parseArgs } from "../../common/index.js";
5
- import { FunctionReference } from "../../server/api.js";
5
+ import {
6
+ FunctionReference,
7
+ FunctionReference_future,
8
+ } from "../../server/api.js";
6
9
  import { getFunctionAddress } from "../components/paths.js";
7
10
  import { validateArg } from "./validate.js";
8
11
 
@@ -23,7 +26,9 @@ function syscallArgs(
23
26
  export function setupActionCalls(requestId: string) {
24
27
  return {
25
28
  runQuery: async (
26
- query: FunctionReference<"query", "public" | "internal">,
29
+ query:
30
+ | FunctionReference<"query", "public" | "internal">
31
+ | FunctionReference_future<"query", "public" | "internal">,
27
32
  args?: Record<string, Value>,
28
33
  ): Promise<any> => {
29
34
  const result = await performAsyncSyscall(
@@ -33,7 +38,9 @@ export function setupActionCalls(requestId: string) {
33
38
  return jsonToConvex(result);
34
39
  },
35
40
  runMutation: async (
36
- mutation: FunctionReference<"mutation", "public" | "internal">,
41
+ mutation:
42
+ | FunctionReference<"mutation", "public" | "internal">
43
+ | FunctionReference_future<"mutation", "public" | "internal">,
37
44
  args?: Record<string, Value>,
38
45
  ): Promise<any> => {
39
46
  const result = await performAsyncSyscall(
@@ -43,7 +50,9 @@ export function setupActionCalls(requestId: string) {
43
50
  return jsonToConvex(result);
44
51
  },
45
52
  runAction: async (
46
- action: FunctionReference<"action", "public" | "internal">,
53
+ action:
54
+ | FunctionReference<"action", "public" | "internal">
55
+ | FunctionReference_future<"action", "public" | "internal">,
47
56
  args?: Record<string, Value>,
48
57
  ): Promise<any> => {
49
58
  const result = await performAsyncSyscall(
@@ -8,7 +8,7 @@ import {
8
8
  TransactionMetrics,
9
9
  DeploymentMetadata,
10
10
  } from "../meta.js";
11
- import { performAsyncSyscall } from "./syscall.js";
11
+ import { performAsyncSyscall, performSyscall } from "./syscall.js";
12
12
 
13
13
  async function getTransactionMetrics(): Promise<TransactionMetrics> {
14
14
  let syscallJSON;
@@ -53,6 +53,11 @@ async function getDeploymentMetadata(): Promise<DeploymentMetadata> {
53
53
  };
54
54
  }
55
55
 
56
+ function getSnapshotTs(): bigint {
57
+ const syscallJSON = performSyscall("1.0/getSnapshotTs", {});
58
+ return jsonToConvex(syscallJSON) as bigint;
59
+ }
60
+
56
61
  async function getRequestMetadata(): Promise<RequestMetadata> {
57
62
  const { ip, userAgent, requestId, scheduledFunctionId, authToken } =
58
63
  await performAsyncSyscall("1.0/getRequestMetadata", {});
@@ -70,6 +75,7 @@ export function setupQueryMeta(
70
75
  }),
71
76
  getTransactionMetrics,
72
77
  getDeploymentMetadata,
78
+ getSnapshotTs,
73
79
  };
74
80
  }
75
81
 
@@ -85,6 +91,7 @@ export function setupMutationMeta(
85
91
  getTransactionMetrics,
86
92
  getDeploymentMetadata,
87
93
  getRequestMetadata,
94
+ getSnapshotTs,
88
95
  };
89
96
  }
90
97
 
@@ -3,15 +3,22 @@ import { version } from "../../index.js";
3
3
  import { performAsyncSyscall } from "./syscall.js";
4
4
  import { parseArgs } from "../../common/index.js";
5
5
  import { SchedulableFunctionReference, Scheduler } from "../scheduler.js";
6
+ import { FunctionReference_future } from "../api.js";
6
7
  import { Id } from "../../values/value.js";
7
8
  import { validateArg } from "./validate.js";
8
9
  import { getFunctionAddress } from "../components/paths.js";
9
10
 
11
+ // Mirrors the constraint on `Scheduler.runAfter` and `Scheduler.runAt`, which
12
+ // is module-local to `scheduler.ts`.
13
+ type SchedulableFunctionReferenceCompat =
14
+ | SchedulableFunctionReference
15
+ | FunctionReference_future<"mutation" | "action", "public" | "internal">;
16
+
10
17
  export function setupMutationScheduler(): Scheduler {
11
18
  return {
12
19
  runAfter: async (
13
20
  delayMs: number,
14
- functionReference: SchedulableFunctionReference,
21
+ functionReference: SchedulableFunctionReferenceCompat,
15
22
  args?: Record<string, Value>,
16
23
  ) => {
17
24
  const syscallArgs = runAfterSyscallArgs(delayMs, functionReference, args);
@@ -19,7 +26,7 @@ export function setupMutationScheduler(): Scheduler {
19
26
  },
20
27
  runAt: async (
21
28
  ms_since_epoch_or_date: number | Date,
22
- functionReference: SchedulableFunctionReference,
29
+ functionReference: SchedulableFunctionReferenceCompat,
23
30
  args?: Record<string, Value>,
24
31
  ) => {
25
32
  const syscallArgs = runAtSyscallArgs(
@@ -41,7 +48,7 @@ export function setupActionScheduler(requestId: string): Scheduler {
41
48
  return {
42
49
  runAfter: async (
43
50
  delayMs: number,
44
- functionReference: SchedulableFunctionReference,
51
+ functionReference: SchedulableFunctionReferenceCompat,
45
52
  args?: Record<string, Value>,
46
53
  ) => {
47
54
  const syscallArgs = {
@@ -52,7 +59,7 @@ export function setupActionScheduler(requestId: string): Scheduler {
52
59
  },
53
60
  runAt: async (
54
61
  ms_since_epoch_or_date: number | Date,
55
- functionReference: SchedulableFunctionReference,
62
+ functionReference: SchedulableFunctionReferenceCompat,
56
63
  args?: Record<string, Value>,
57
64
  ) => {
58
65
  const syscallArgs = {
@@ -74,7 +81,7 @@ export function setupActionScheduler(requestId: string): Scheduler {
74
81
 
75
82
  function runAfterSyscallArgs(
76
83
  delayMs: number,
77
- functionReference: SchedulableFunctionReference,
84
+ functionReference: SchedulableFunctionReferenceCompat,
78
85
  args?: Record<string, Value>,
79
86
  ) {
80
87
  if (typeof delayMs !== "number") {
@@ -100,7 +107,7 @@ function runAfterSyscallArgs(
100
107
 
101
108
  function runAtSyscallArgs(
102
109
  ms_since_epoch_or_date: number | Date,
103
- functionReference: SchedulableFunctionReference,
110
+ functionReference: SchedulableFunctionReferenceCompat,
104
111
  args?: Record<string, Value>,
105
112
  ) {
106
113
  let ts;
@@ -174,6 +174,7 @@ export {
174
174
  export type {
175
175
  ApiFromModules,
176
176
  AnyApi,
177
+ FunctionReference_future,
177
178
  FilterApi,
178
179
  FunctionType,
179
180
  FunctionReference,
@@ -133,6 +133,31 @@ export interface QueryMeta {
133
133
  getFunctionMetadata(): Promise<FunctionMetadata>;
134
134
  getTransactionMetrics(): Promise<TransactionMetrics>;
135
135
  getDeploymentMetadata(): Promise<DeploymentMetadata>;
136
+ /**
137
+ * @internal
138
+ * Returns the timestamp of the database snapshot this transaction reads
139
+ * from, in nanoseconds.
140
+ *
141
+ * All commits at or before this timestamp are observable within the
142
+ * transaction, and no later commits are. The value is fixed for the
143
+ * lifetime of the transaction and shared with all nested `runMutation` and
144
+ * `runQuery` calls.
145
+ *
146
+ * It is on the same clock as `db.vars.commitTs`: documents observable in
147
+ * this transaction have `commitTs` values at or before this timestamp, and
148
+ * no new documents will be written with a `commitTs` at or below this,
149
+ * including from the current transaction. When reading documents with an
150
+ * index in commitTs order, you can use this as an upper bound to prevent
151
+ * conflicting with racing inserts.
152
+ *
153
+ * Since the timestamp differs on every execution, calling this in a query
154
+ * limits caching of the query's result the same way `Date.now()` does.
155
+ *
156
+ * Note: this should not be compared to `_creationTime` or `Date.now()`, as
157
+ * those are based on wall-clock time rather than the database clock, and
158
+ * aren't guaranteed to follow commit order.
159
+ */
160
+ getSnapshotTs(): bigint;
136
161
  }
137
162
 
138
163
  /**
@@ -16,10 +16,11 @@ import {
16
16
  } from "./meta.js";
17
17
  import {
18
18
  ArgsAndOptions,
19
- FunctionReference,
20
19
  FunctionReturnType,
21
20
  OptionalRestArgs,
22
21
  ValidatorTypeToReturnType,
22
+ FunctionReference,
23
+ FunctionReference_future,
23
24
  } from "../server/api.js";
24
25
  import {
25
26
  GenericValidator,
@@ -133,7 +134,11 @@ export interface GenericMutationCtx<DataModel extends GenericDataModel> {
133
134
  * const user = await ctx.runQuery(internal.users.getUser, { userId });
134
135
  * ```
135
136
  */
136
- runQuery: <Query extends FunctionReference<"query", "public" | "internal">>(
137
+ runQuery: <
138
+ Query extends
139
+ | FunctionReference<"query", "public" | "internal">
140
+ | FunctionReference_future<"query", "public" | "internal">,
141
+ >(
137
142
  query: Query,
138
143
  ...args: ArgsAndOptions<Query, AdvancedRunQueryOptions>
139
144
  ) => Promise<FunctionReturnType<Query>>;
@@ -149,7 +154,9 @@ export interface GenericMutationCtx<DataModel extends GenericDataModel> {
149
154
  * validation, and creating a new isolated JS context.
150
155
  */
151
156
  runMutation: <
152
- Mutation extends FunctionReference<"mutation", "public" | "internal">,
157
+ Mutation extends
158
+ | FunctionReference<"mutation", "public" | "internal">
159
+ | FunctionReference_future<"mutation", "public" | "internal">,
153
160
  >(
154
161
  mutation: Mutation,
155
162
  ...args: ArgsAndOptions<Mutation, { transactionLimits?: TransactionLimits }>
@@ -243,7 +250,11 @@ export interface GenericQueryCtx<DataModel extends GenericDataModel> {
243
250
  * `runQuery` incurs overhead of running argument and return value validation,
244
251
  * and creating a new isolated JS context.
245
252
  */
246
- runQuery: <Query extends FunctionReference<"query", "public" | "internal">>(
253
+ runQuery: <
254
+ Query extends
255
+ | FunctionReference<"query", "public" | "internal">
256
+ | FunctionReference_future<"query", "public" | "internal">,
257
+ >(
247
258
  query: Query,
248
259
  ...args: ArgsAndOptions<Query, { transactionLimits?: TransactionLimits }>
249
260
  ) => Promise<FunctionReturnType<Query>>;
@@ -326,7 +337,11 @@ export interface GenericActionCtx<DataModel extends GenericDataModel> {
326
337
  * @param args - The arguments to the query function.
327
338
  * @returns A promise of the query's result.
328
339
  */
329
- runQuery<Query extends FunctionReference<"query", "public" | "internal">>(
340
+ runQuery<
341
+ Query extends
342
+ | FunctionReference<"query", "public" | "internal">
343
+ | FunctionReference_future<"query", "public" | "internal">,
344
+ >(
330
345
  query: Query,
331
346
  ...args: OptionalRestArgs<Query>
332
347
  ): Promise<FunctionReturnType<Query>>;
@@ -347,7 +362,9 @@ export interface GenericActionCtx<DataModel extends GenericDataModel> {
347
362
  * @returns A promise of the mutation's result.
348
363
  */
349
364
  runMutation<
350
- Mutation extends FunctionReference<"mutation", "public" | "internal">,
365
+ Mutation extends
366
+ | FunctionReference<"mutation", "public" | "internal">
367
+ | FunctionReference_future<"mutation", "public" | "internal">,
351
368
  >(
352
369
  mutation: Mutation,
353
370
  ...args: OptionalRestArgs<Mutation>
@@ -369,7 +386,11 @@ export interface GenericActionCtx<DataModel extends GenericDataModel> {
369
386
  * @param args - The arguments to the action function.
370
387
  * @returns A promise of the action's result.
371
388
  */
372
- runAction<Action extends FunctionReference<"action", "public" | "internal">>(
389
+ runAction<
390
+ Action extends
391
+ | FunctionReference<"action", "public" | "internal">
392
+ | FunctionReference_future<"action", "public" | "internal">,
393
+ >(
373
394
  action: Action,
374
395
  ...args: OptionalRestArgs<Action>
375
396
  ): Promise<FunctionReturnType<Action>>;
@@ -1,4 +1,8 @@
1
- import { FunctionReference, OptionalRestArgs } from "../server/api.js";
1
+ import {
2
+ FunctionReference,
3
+ FunctionReference_future,
4
+ OptionalRestArgs,
5
+ } from "../server/api.js";
2
6
  import { Id } from "../values/value.js";
3
7
 
4
8
  /**
@@ -13,6 +17,17 @@ export type SchedulableFunctionReference = FunctionReference<
13
17
  "public" | "internal"
14
18
  >;
15
19
 
20
+ // What the scheduling methods accept. This is kept separate from the exported
21
+ // `SchedulableFunctionReference` so that alias keeps describing a plain
22
+ // reference. Existing code depending on it can still forward it to anything
23
+ // typed with `FunctionReference` or read its `_args`. This alias is
24
+ // module-local so that a consumer's declaration file inlines it instead of
25
+ // importing it from a path that is not part of the package's public entry
26
+ // points.
27
+ type SchedulableFunctionReferenceCompat =
28
+ | SchedulableFunctionReference
29
+ | FunctionReference_future<"mutation" | "action", "public" | "internal">;
30
+
16
31
  /**
17
32
  * An interface to schedule Convex functions to run in the future.
18
33
  *
@@ -78,13 +93,13 @@ export interface Scheduler {
78
93
  * @param delayMs - Delay in milliseconds. Must be non-negative. If the delay
79
94
  * is zero, the scheduled function will be due to execute immediately after the
80
95
  * scheduling one completes.
81
- * @param functionReference - A {@link FunctionReference} for the function
82
- * to schedule.
96
+ * @param functionReference - A {@link FunctionReference} or
97
+ * {@link FunctionReference_future} for the function to schedule.
83
98
  * @param args - Arguments to call the scheduled functions with.
84
99
  * @returns The ID of the scheduled function in the `_scheduled_functions`
85
100
  * system table. Use this to cancel it later if needed.
86
101
  **/
87
- runAfter<FuncRef extends SchedulableFunctionReference>(
102
+ runAfter<FuncRef extends SchedulableFunctionReferenceCompat>(
88
103
  delayMs: number,
89
104
  functionReference: FuncRef,
90
105
  ...args: OptionalRestArgs<FuncRef>
@@ -110,13 +125,13 @@ export interface Scheduler {
110
125
  * If the timestamp is in the past, the scheduled function will be due to
111
126
  * execute immediately after the scheduling one completes. The timestamp can't
112
127
  * be more than five years in the past or more than five years in the future.
113
- * @param functionReference - A {@link FunctionReference} for the function
114
- * to schedule.
128
+ * @param functionReference - A {@link FunctionReference} or
129
+ * {@link FunctionReference_future} for the function to schedule.
115
130
  * @param args - Arguments to call the scheduled functions with.
116
131
  * @returns The ID of the scheduled function in the `_scheduled_functions`
117
132
  * system table.
118
133
  **/
119
- runAt<FuncRef extends SchedulableFunctionReference>(
134
+ runAt<FuncRef extends SchedulableFunctionReferenceCompat>(
120
135
  timestamp: number | Date,
121
136
  functionReference: FuncRef,
122
137
  ...args: OptionalRestArgs<FuncRef>
@@ -204,6 +204,9 @@ export class TableDefinition<
204
204
  private stagedVectorIndexes: VectorIndex[];
205
205
  // The type of documents stored in this table.
206
206
  validator: DocumentType;
207
+ // The proposed next validator for this table, validated against existing
208
+ // documents in the background while `validator` remains enforced.
209
+ private stagedValidator: Validator<any, any, any> | undefined;
207
210
 
208
211
  /**
209
212
  * @internal
@@ -557,6 +560,45 @@ export class TableDefinition<
557
560
  return this;
558
561
  }
559
562
 
563
+ /**
564
+ * Stage a new document validator for this table.
565
+ *
566
+ * Convex validates the staged validator against the table's existing
567
+ * documents in the background, while the validator passed to
568
+ * {@link defineTable} remains the one enforced on reads and writes. Once
569
+ * the background validation succeeds, make the staged validator the
570
+ * table's validator and remove `.staged()`.
571
+ *
572
+ * ```ts
573
+ * defineTable({
574
+ * author: v.string(),
575
+ * }).staged({
576
+ * author: v.array(v.string()),
577
+ * })
578
+ * ```
579
+ *
580
+ * TODO: link a worked staged-schema example from the docs once one exists.
581
+ *
582
+ * @param documentSchema - The proposed next type of documents stored in
583
+ * this table, as an object of field validators or a schema validator.
584
+ * @returns A {@link TableDefinition} with the staged validator attached.
585
+ *
586
+ * @internal
587
+ */
588
+ staged(
589
+ documentSchema:
590
+ | Validator<Record<string, any>, "required", any>
591
+ | Record<string, GenericValidator>,
592
+ ): TableDefinition<DocumentType, Indexes, SearchIndexes, VectorIndexes> {
593
+ if (this.stagedValidator !== undefined) {
594
+ throw new Error("Table cannot have more than one staged validator.");
595
+ }
596
+ this.stagedValidator = isValidator(documentSchema)
597
+ ? documentSchema
598
+ : v.object(documentSchema);
599
+ return this.self();
600
+ }
601
+
560
602
  /**
561
603
  * Work around for https://github.com/microsoft/TypeScript/issues/57035
562
604
  */
@@ -582,6 +624,16 @@ export class TableDefinition<
582
624
  );
583
625
  }
584
626
 
627
+ let stagedDocumentType = undefined;
628
+ if (this.stagedValidator !== undefined) {
629
+ stagedDocumentType = this.stagedValidator.json;
630
+ if (typeof stagedDocumentType !== "object") {
631
+ throw new Error(
632
+ "Invalid staged validator: please make sure that the parameter of `.staged()` is valid (see https://docs.convex.dev/database/schemas)",
633
+ );
634
+ }
635
+ }
636
+
585
637
  return {
586
638
  indexes: this.indexes,
587
639
  stagedDbIndexes: this.stagedDbIndexes,
@@ -590,6 +642,7 @@ export class TableDefinition<
590
642
  vectorIndexes: this.vectorIndexes,
591
643
  stagedVectorIndexes: this.stagedVectorIndexes,
592
644
  documentType,
645
+ stagedDocumentType,
593
646
  };
594
647
  }
595
648
  }
@@ -884,6 +937,7 @@ export class SchemaDefinition<
884
937
  vectorIndexes,
885
938
  stagedVectorIndexes,
886
939
  documentType,
940
+ stagedDocumentType,
887
941
  } = definition.export();
888
942
  return {
889
943
  tableName,
@@ -894,6 +948,7 @@ export class SchemaDefinition<
894
948
  vectorIndexes,
895
949
  stagedVectorIndexes,
896
950
  documentType,
951
+ stagedDocumentType,
897
952
  };
898
953
  }),
899
954
  schemaValidation: this.schemaValidation,
@@ -28,7 +28,9 @@ import {
28
28
  export type GenericValidator = Validator<any, any, any>;
29
29
 
30
30
  export function isValidator(v: any): v is GenericValidator {
31
- return !!v.isConvexValidator;
31
+ // Check for the literal `true` marker: a field map can contain a field
32
+ // *named* `isConvexValidator` whose value is a (truthy) validator object.
33
+ return v?.isConvexValidator === true;
32
34
  }
33
35
 
34
36
  /**