convex 1.45.0 → 1.47.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 (511) hide show
  1. package/CHANGELOG.md +105 -6
  2. package/dist/browser.bundle.js +7 -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/bundler/index.js +5 -4
  10. package/dist/cjs/bundler/index.js.map +2 -2
  11. package/dist/cjs/cli/codegen.js +0 -2
  12. package/dist/cjs/cli/codegen.js.map +2 -2
  13. package/dist/cjs/cli/configure.js +13 -4
  14. package/dist/cjs/cli/configure.js.map +2 -2
  15. package/dist/cjs/cli/deploy.js +28 -2
  16. package/dist/cjs/cli/deploy.js.map +2 -2
  17. package/dist/cjs/cli/deploymentSelect.js +2 -2
  18. package/dist/cjs/cli/deploymentSelect.js.map +2 -2
  19. package/dist/cjs/cli/dev.js +6 -0
  20. package/dist/cjs/cli/dev.js.map +2 -2
  21. package/dist/cjs/cli/docs.js +3 -36
  22. package/dist/cjs/cli/docs.js.map +2 -2
  23. package/dist/cjs/cli/env.js +10 -5
  24. package/dist/cjs/cli/env.js.map +2 -2
  25. package/dist/cjs/cli/envDefault.js +7 -2
  26. package/dist/cjs/cli/envDefault.js.map +2 -2
  27. package/dist/cjs/cli/generatedApi.js.map +1 -1
  28. package/dist/cjs/cli/lib/api.js +2 -0
  29. package/dist/cjs/cli/lib/api.js.map +2 -2
  30. package/dist/cjs/cli/lib/checkForLargeIndexBackfill.js +113 -0
  31. package/dist/cjs/cli/lib/checkForLargeIndexBackfill.js.map +7 -0
  32. package/dist/cjs/cli/lib/checkForLargeIndexDeletion.js +100 -70
  33. package/dist/cjs/cli/lib/checkForLargeIndexDeletion.js.map +2 -2
  34. package/dist/cjs/cli/lib/checkForSlowSchemaValidation.js +126 -0
  35. package/dist/cjs/cli/lib/checkForSlowSchemaValidation.js.map +7 -0
  36. package/dist/cjs/cli/lib/checkForStagedValidatorDeletion.js +90 -0
  37. package/dist/cjs/cli/lib/checkForStagedValidatorDeletion.js.map +7 -0
  38. package/dist/cjs/cli/lib/codegen.js.map +2 -2
  39. package/dist/cjs/cli/lib/command.js +2 -1
  40. package/dist/cjs/cli/lib/command.js.map +2 -2
  41. package/dist/cjs/cli/lib/components/definition/bundle.js +37 -11
  42. package/dist/cjs/cli/lib/components/definition/bundle.js.map +2 -2
  43. package/dist/cjs/cli/lib/components.js +56 -1
  44. package/dist/cjs/cli/lib/components.js.map +2 -2
  45. package/dist/cjs/cli/lib/config.js +56 -17
  46. package/dist/cjs/cli/lib/config.js.map +2 -2
  47. package/dist/cjs/cli/lib/deploy2.js +32 -3
  48. package/dist/cjs/cli/lib/deploy2.js.map +2 -2
  49. package/dist/cjs/cli/lib/deployApi/evaluateSchema.js +101 -0
  50. package/dist/cjs/cli/lib/deployApi/evaluateSchema.js.map +7 -0
  51. package/dist/cjs/cli/lib/deployApi/finishPush.js +1 -0
  52. package/dist/cjs/cli/lib/deployApi/finishPush.js.map +2 -2
  53. package/dist/cjs/cli/lib/deployApi/startPush.js +1 -1
  54. package/dist/cjs/cli/lib/deployApi/startPush.js.map +2 -2
  55. package/dist/cjs/cli/lib/dev.js +6 -0
  56. package/dist/cjs/cli/lib/dev.js.map +2 -2
  57. package/dist/cjs/cli/lib/formatValidationProgress.js +47 -0
  58. package/dist/cjs/cli/lib/formatValidationProgress.js.map +7 -0
  59. package/dist/cjs/cli/lib/generatedFunctionLogsApi.js.map +1 -1
  60. package/dist/cjs/cli/lib/indexes.js.map +1 -1
  61. package/dist/cjs/cli/lib/localDeployment/run.js +30 -1
  62. package/dist/cjs/cli/lib/localDeployment/run.js.map +2 -2
  63. package/dist/cjs/cli/lib/localDeployment/upgrade.js +6 -5
  64. package/dist/cjs/cli/lib/localDeployment/upgrade.js.map +2 -2
  65. package/dist/cjs/cli/lib/localDeployment/utils.js +5 -1
  66. package/dist/cjs/cli/lib/localDeployment/utils.js.map +2 -2
  67. package/dist/cjs/cli/lib/mcp/tools/env.js +10 -3
  68. package/dist/cjs/cli/lib/mcp/tools/env.js.map +2 -2
  69. package/dist/cjs/cli/lib/run.js +5 -0
  70. package/dist/cjs/cli/lib/run.js.map +2 -2
  71. package/dist/cjs/cli/lib/schemaEvaluation.js +62 -0
  72. package/dist/cjs/cli/lib/schemaEvaluation.js.map +7 -0
  73. package/dist/cjs/cli/lib/usageLimits.js +4 -2
  74. package/dist/cjs/cli/lib/usageLimits.js.map +2 -2
  75. package/dist/cjs/cli/lib/utils/mutex.js +9 -24
  76. package/dist/cjs/cli/lib/utils/mutex.js.map +2 -2
  77. package/dist/cjs/cli/lib/utils/utils.js +84 -47
  78. package/dist/cjs/cli/lib/utils/utils.js.map +2 -2
  79. package/dist/cjs/cli/projectCreate.js +1 -1
  80. package/dist/cjs/cli/projectCreate.js.map +1 -1
  81. package/dist/cjs/index.js +1 -1
  82. package/dist/cjs/index.js.map +1 -1
  83. package/dist/cjs/nextjs/index.js.map +2 -2
  84. package/dist/cjs/react/client.js.map +2 -2
  85. package/dist/cjs/react/hydration.js.map +2 -2
  86. package/dist/cjs/react/queries_observer.js.map +2 -2
  87. package/dist/cjs/react/use_paginated_query2.js.map +2 -2
  88. package/dist/cjs/react/use_queries.js.map +2 -2
  89. package/dist/cjs/server/api.js.map +2 -2
  90. package/dist/cjs/server/components/index.js.map +2 -2
  91. package/dist/cjs/server/cron.js +10 -10
  92. package/dist/cjs/server/cron.js.map +2 -2
  93. package/dist/cjs/server/impl/actions_impl.js +8 -3
  94. package/dist/cjs/server/impl/actions_impl.js.map +2 -2
  95. package/dist/cjs/server/impl/meta_impl.js +8 -2
  96. package/dist/cjs/server/impl/meta_impl.js.map +2 -2
  97. package/dist/cjs/server/impl/scheduler_impl.js.map +2 -2
  98. package/dist/cjs/server/impl/storage_impl.js +29 -0
  99. package/dist/cjs/server/impl/storage_impl.js.map +2 -2
  100. package/dist/cjs/server/index.js +1 -0
  101. package/dist/cjs/server/index.js.map +2 -2
  102. package/dist/cjs/server/meta.js.map +1 -1
  103. package/dist/cjs/server/registration.js.map +1 -1
  104. package/dist/cjs/server/scheduler.js.map +1 -1
  105. package/dist/cjs/server/schema.js +72 -3
  106. package/dist/cjs/server/schema.js.map +2 -2
  107. package/dist/cjs/server/storage.js.map +1 -1
  108. package/dist/cjs/values/validator.js +1 -1
  109. package/dist/cjs/values/validator.js.map +2 -2
  110. package/dist/cjs/values/validators.js +82 -26
  111. package/dist/cjs/values/validators.js.map +2 -2
  112. package/dist/cjs/values/value.js +6 -0
  113. package/dist/cjs/values/value.js.map +2 -2
  114. package/dist/cjs-types/browser/http_client.d.ts +5 -5
  115. package/dist/cjs-types/browser/http_client.d.ts.map +1 -1
  116. package/dist/cjs-types/browser/query_options.d.ts +2 -2
  117. package/dist/cjs-types/browser/query_options.d.ts.map +1 -1
  118. package/dist/cjs-types/browser/simple_client.d.ts +6 -6
  119. package/dist/cjs-types/browser/simple_client.d.ts.map +1 -1
  120. package/dist/cjs-types/browser/sync/optimistic_updates.d.ts +4 -4
  121. package/dist/cjs-types/browser/sync/optimistic_updates.d.ts.map +1 -1
  122. package/dist/cjs-types/browser/sync/optimistic_updates_impl.d.ts.map +1 -1
  123. package/dist/cjs-types/bundler/index.d.ts +9 -2
  124. package/dist/cjs-types/bundler/index.d.ts.map +1 -1
  125. package/dist/cjs-types/cli/codegen.d.ts.map +1 -1
  126. package/dist/cjs-types/cli/configure.d.ts +6 -0
  127. package/dist/cjs-types/cli/configure.d.ts.map +1 -1
  128. package/dist/cjs-types/cli/deploy.d.ts +2 -0
  129. package/dist/cjs-types/cli/deploy.d.ts.map +1 -1
  130. package/dist/cjs-types/cli/deploymentCreate.d.ts +6 -6
  131. package/dist/cjs-types/cli/deploymentSelect.d.ts.map +1 -1
  132. package/dist/cjs-types/cli/dev.d.ts +1 -0
  133. package/dist/cjs-types/cli/dev.d.ts.map +1 -1
  134. package/dist/cjs-types/cli/docs.d.ts.map +1 -1
  135. package/dist/cjs-types/cli/env.d.ts.map +1 -1
  136. package/dist/cjs-types/cli/envDefault.d.ts.map +1 -1
  137. package/dist/cjs-types/cli/generatedApi.d.ts +1 -1
  138. package/dist/cjs-types/cli/generatedApi.d.ts.map +1 -1
  139. package/dist/cjs-types/cli/lib/api.d.ts.map +1 -1
  140. package/dist/cjs-types/cli/lib/checkForLargeIndexBackfill.d.ts +30 -0
  141. package/dist/cjs-types/cli/lib/checkForLargeIndexBackfill.d.ts.map +1 -0
  142. package/dist/cjs-types/cli/lib/checkForLargeIndexDeletion.d.ts +25 -6
  143. package/dist/cjs-types/cli/lib/checkForLargeIndexDeletion.d.ts.map +1 -1
  144. package/dist/cjs-types/cli/lib/checkForSlowSchemaValidation.d.ts +8 -0
  145. package/dist/cjs-types/cli/lib/checkForSlowSchemaValidation.d.ts.map +1 -0
  146. package/dist/cjs-types/cli/lib/checkForStagedValidatorDeletion.d.ts +17 -0
  147. package/dist/cjs-types/cli/lib/checkForStagedValidatorDeletion.d.ts.map +1 -0
  148. package/dist/cjs-types/cli/lib/codegen.d.ts +0 -2
  149. package/dist/cjs-types/cli/lib/codegen.d.ts.map +1 -1
  150. package/dist/cjs-types/cli/lib/command.d.ts +2 -0
  151. package/dist/cjs-types/cli/lib/command.d.ts.map +1 -1
  152. package/dist/cjs-types/cli/lib/components/definition/bundle.d.ts +13 -0
  153. package/dist/cjs-types/cli/lib/components/definition/bundle.d.ts.map +1 -1
  154. package/dist/cjs-types/cli/lib/components.d.ts +5 -0
  155. package/dist/cjs-types/cli/lib/components.d.ts.map +1 -1
  156. package/dist/cjs-types/cli/lib/config.d.ts +2 -1
  157. package/dist/cjs-types/cli/lib/config.d.ts.map +1 -1
  158. package/dist/cjs-types/cli/lib/deploy2.d.ts +8 -0
  159. package/dist/cjs-types/cli/lib/deploy2.d.ts.map +1 -1
  160. package/dist/cjs-types/cli/lib/deployApi/evaluateSchema.d.ts +897 -0
  161. package/dist/cjs-types/cli/lib/deployApi/evaluateSchema.d.ts.map +1 -0
  162. package/dist/cjs-types/cli/lib/deployApi/finishPush.d.ts +1 -2
  163. package/dist/cjs-types/cli/lib/deployApi/finishPush.d.ts.map +1 -1
  164. package/dist/cjs-types/cli/lib/dev.d.ts +1 -0
  165. package/dist/cjs-types/cli/lib/dev.d.ts.map +1 -1
  166. package/dist/cjs-types/cli/lib/formatValidationProgress.d.ts +8 -0
  167. package/dist/cjs-types/cli/lib/formatValidationProgress.d.ts.map +1 -0
  168. package/dist/cjs-types/cli/lib/generatedFunctionLogsApi.d.ts +2 -0
  169. package/dist/cjs-types/cli/lib/generatedFunctionLogsApi.d.ts.map +1 -1
  170. package/dist/cjs-types/cli/lib/localDeployment/run.d.ts +2 -0
  171. package/dist/cjs-types/cli/lib/localDeployment/run.d.ts.map +1 -1
  172. package/dist/cjs-types/cli/lib/localDeployment/upgrade.d.ts.map +1 -1
  173. package/dist/cjs-types/cli/lib/localDeployment/utils.d.ts +1 -0
  174. package/dist/cjs-types/cli/lib/localDeployment/utils.d.ts.map +1 -1
  175. package/dist/cjs-types/cli/lib/mcp/tools/env.d.ts +8 -5
  176. package/dist/cjs-types/cli/lib/mcp/tools/env.d.ts.map +1 -1
  177. package/dist/cjs-types/cli/lib/run.d.ts.map +1 -1
  178. package/dist/cjs-types/cli/lib/schemaEvaluation.d.ts +33 -0
  179. package/dist/cjs-types/cli/lib/schemaEvaluation.d.ts.map +1 -0
  180. package/dist/cjs-types/cli/lib/usageLimits.d.ts +1 -1
  181. package/dist/cjs-types/cli/lib/usageLimits.d.ts.map +1 -1
  182. package/dist/cjs-types/cli/lib/utils/mutex.d.ts +1 -3
  183. package/dist/cjs-types/cli/lib/utils/mutex.d.ts.map +1 -1
  184. package/dist/cjs-types/cli/lib/utils/utils.d.ts +15 -7
  185. package/dist/cjs-types/cli/lib/utils/utils.d.ts.map +1 -1
  186. package/dist/cjs-types/index.d.ts +1 -1
  187. package/dist/cjs-types/nextjs/index.d.ts +6 -6
  188. package/dist/cjs-types/nextjs/index.d.ts.map +1 -1
  189. package/dist/cjs-types/react/client.d.ts +15 -15
  190. package/dist/cjs-types/react/client.d.ts.map +1 -1
  191. package/dist/cjs-types/react/hydration.d.ts +3 -3
  192. package/dist/cjs-types/react/hydration.d.ts.map +1 -1
  193. package/dist/cjs-types/react/queries_observer.d.ts +9 -9
  194. package/dist/cjs-types/react/queries_observer.d.ts.map +1 -1
  195. package/dist/cjs-types/react/use_paginated_query2.d.ts.map +1 -1
  196. package/dist/cjs-types/react/use_queries.d.ts +14 -6
  197. package/dist/cjs-types/react/use_queries.d.ts.map +1 -1
  198. package/dist/cjs-types/server/api.d.ts +157 -7
  199. package/dist/cjs-types/server/api.d.ts.map +1 -1
  200. package/dist/cjs-types/server/components/index.d.ts +2 -2
  201. package/dist/cjs-types/server/components/index.d.ts.map +1 -1
  202. package/dist/cjs-types/server/cron.d.ts +21 -20
  203. package/dist/cjs-types/server/cron.d.ts.map +1 -1
  204. package/dist/cjs-types/server/impl/actions_impl.d.ts +22 -7
  205. package/dist/cjs-types/server/impl/actions_impl.d.ts.map +1 -1
  206. package/dist/cjs-types/server/impl/meta_impl.d.ts.map +1 -1
  207. package/dist/cjs-types/server/impl/scheduler_impl.d.ts.map +1 -1
  208. package/dist/cjs-types/server/impl/storage_impl.d.ts.map +1 -1
  209. package/dist/cjs-types/server/index.d.ts +2 -2
  210. package/dist/cjs-types/server/index.d.ts.map +1 -1
  211. package/dist/cjs-types/server/meta.d.ts +63 -0
  212. package/dist/cjs-types/server/meta.d.ts.map +1 -1
  213. package/dist/cjs-types/server/registration.d.ts +17 -7
  214. package/dist/cjs-types/server/registration.d.ts.map +1 -1
  215. package/dist/cjs-types/server/scheduler.d.ts +9 -7
  216. package/dist/cjs-types/server/scheduler.d.ts.map +1 -1
  217. package/dist/cjs-types/server/schema.d.ts +34 -0
  218. package/dist/cjs-types/server/schema.d.ts.map +1 -1
  219. package/dist/cjs-types/server/storage.d.ts.map +1 -1
  220. package/dist/cjs-types/values/validator.d.ts.map +1 -1
  221. package/dist/cjs-types/values/validators.d.ts +30 -0
  222. package/dist/cjs-types/values/validators.d.ts.map +1 -1
  223. package/dist/cjs-types/values/value.d.ts.map +1 -1
  224. package/dist/cli.bundle.cjs +2728 -1627
  225. package/dist/cli.bundle.cjs.map +4 -4
  226. package/dist/esm/browser/http_client.js.map +2 -2
  227. package/dist/esm/browser/query_options.js.map +2 -2
  228. package/dist/esm/browser/simple_client.js.map +2 -2
  229. package/dist/esm/browser/sync/optimistic_updates_impl.js.map +2 -2
  230. package/dist/esm/bundler/index.js +5 -4
  231. package/dist/esm/bundler/index.js.map +2 -2
  232. package/dist/esm/cli/codegen.js +0 -2
  233. package/dist/esm/cli/codegen.js.map +2 -2
  234. package/dist/esm/cli/configure.js +12 -4
  235. package/dist/esm/cli/configure.js.map +2 -2
  236. package/dist/esm/cli/deploy.js +28 -2
  237. package/dist/esm/cli/deploy.js.map +2 -2
  238. package/dist/esm/cli/deploymentSelect.js +6 -3
  239. package/dist/esm/cli/deploymentSelect.js.map +2 -2
  240. package/dist/esm/cli/dev.js +6 -0
  241. package/dist/esm/cli/dev.js.map +2 -2
  242. package/dist/esm/cli/docs.js +3 -43
  243. package/dist/esm/cli/docs.js.map +2 -2
  244. package/dist/esm/cli/env.js +11 -6
  245. package/dist/esm/cli/env.js.map +2 -2
  246. package/dist/esm/cli/envDefault.js +7 -2
  247. package/dist/esm/cli/envDefault.js.map +2 -2
  248. package/dist/esm/cli/lib/api.js +2 -0
  249. package/dist/esm/cli/lib/api.js.map +2 -2
  250. package/dist/esm/cli/lib/checkForLargeIndexBackfill.js +95 -0
  251. package/dist/esm/cli/lib/checkForLargeIndexBackfill.js.map +7 -0
  252. package/dist/esm/cli/lib/checkForLargeIndexDeletion.js +98 -69
  253. package/dist/esm/cli/lib/checkForLargeIndexDeletion.js.map +2 -2
  254. package/dist/esm/cli/lib/checkForSlowSchemaValidation.js +107 -0
  255. package/dist/esm/cli/lib/checkForSlowSchemaValidation.js.map +7 -0
  256. package/dist/esm/cli/lib/checkForStagedValidatorDeletion.js +68 -0
  257. package/dist/esm/cli/lib/checkForStagedValidatorDeletion.js.map +7 -0
  258. package/dist/esm/cli/lib/codegen.js.map +2 -2
  259. package/dist/esm/cli/lib/command.js +2 -1
  260. package/dist/esm/cli/lib/command.js.map +2 -2
  261. package/dist/esm/cli/lib/components/definition/bundle.js +37 -11
  262. package/dist/esm/cli/lib/components/definition/bundle.js.map +2 -2
  263. package/dist/esm/cli/lib/components.js +63 -1
  264. package/dist/esm/cli/lib/components.js.map +2 -2
  265. package/dist/esm/cli/lib/config.js +55 -17
  266. package/dist/esm/cli/lib/config.js.map +2 -2
  267. package/dist/esm/cli/lib/deploy2.js +33 -3
  268. package/dist/esm/cli/lib/deploy2.js.map +2 -2
  269. package/dist/esm/cli/lib/deployApi/evaluateSchema.js +72 -0
  270. package/dist/esm/cli/lib/deployApi/evaluateSchema.js.map +7 -0
  271. package/dist/esm/cli/lib/deployApi/finishPush.js +1 -1
  272. package/dist/esm/cli/lib/deployApi/finishPush.js.map +2 -2
  273. package/dist/esm/cli/lib/deployApi/startPush.js +1 -1
  274. package/dist/esm/cli/lib/deployApi/startPush.js.map +2 -2
  275. package/dist/esm/cli/lib/dev.js +6 -0
  276. package/dist/esm/cli/lib/dev.js.map +2 -2
  277. package/dist/esm/cli/lib/formatValidationProgress.js +24 -0
  278. package/dist/esm/cli/lib/formatValidationProgress.js.map +7 -0
  279. package/dist/esm/cli/lib/indexes.js.map +1 -1
  280. package/dist/esm/cli/lib/localDeployment/run.js +30 -2
  281. package/dist/esm/cli/lib/localDeployment/run.js.map +2 -2
  282. package/dist/esm/cli/lib/localDeployment/upgrade.js +4 -3
  283. package/dist/esm/cli/lib/localDeployment/upgrade.js.map +2 -2
  284. package/dist/esm/cli/lib/localDeployment/utils.js +3 -0
  285. package/dist/esm/cli/lib/localDeployment/utils.js.map +2 -2
  286. package/dist/esm/cli/lib/mcp/tools/env.js +10 -3
  287. package/dist/esm/cli/lib/mcp/tools/env.js.map +2 -2
  288. package/dist/esm/cli/lib/run.js +5 -0
  289. package/dist/esm/cli/lib/run.js.map +2 -2
  290. package/dist/esm/cli/lib/schemaEvaluation.js +39 -0
  291. package/dist/esm/cli/lib/schemaEvaluation.js.map +7 -0
  292. package/dist/esm/cli/lib/usageLimits.js +4 -2
  293. package/dist/esm/cli/lib/usageLimits.js.map +2 -2
  294. package/dist/esm/cli/lib/utils/mutex.js +9 -24
  295. package/dist/esm/cli/lib/utils/mutex.js.map +2 -2
  296. package/dist/esm/cli/lib/utils/utils.js +84 -49
  297. package/dist/esm/cli/lib/utils/utils.js.map +2 -2
  298. package/dist/esm/cli/projectCreate.js +1 -1
  299. package/dist/esm/cli/projectCreate.js.map +1 -1
  300. package/dist/esm/index.js +1 -1
  301. package/dist/esm/index.js.map +1 -1
  302. package/dist/esm/nextjs/index.js.map +2 -2
  303. package/dist/esm/react/client.js.map +2 -2
  304. package/dist/esm/react/hydration.js +3 -1
  305. package/dist/esm/react/hydration.js.map +2 -2
  306. package/dist/esm/react/queries_observer.js +3 -1
  307. package/dist/esm/react/queries_observer.js.map +2 -2
  308. package/dist/esm/react/use_paginated_query2.js +3 -1
  309. package/dist/esm/react/use_paginated_query2.js.map +2 -2
  310. package/dist/esm/react/use_queries.js.map +2 -2
  311. package/dist/esm/server/api.js.map +2 -2
  312. package/dist/esm/server/components/index.js.map +2 -2
  313. package/dist/esm/server/cron.js +13 -11
  314. package/dist/esm/server/cron.js.map +2 -2
  315. package/dist/esm/server/impl/actions_impl.js +7 -3
  316. package/dist/esm/server/impl/actions_impl.js.map +2 -2
  317. package/dist/esm/server/impl/meta_impl.js +9 -3
  318. package/dist/esm/server/impl/meta_impl.js.map +2 -2
  319. package/dist/esm/server/impl/scheduler_impl.js.map +2 -2
  320. package/dist/esm/server/impl/storage_impl.js +29 -0
  321. package/dist/esm/server/impl/storage_impl.js.map +2 -2
  322. package/dist/esm/server/index.js +4 -1
  323. package/dist/esm/server/index.js.map +2 -2
  324. package/dist/esm/server/schema.js +72 -3
  325. package/dist/esm/server/schema.js.map +2 -2
  326. package/dist/esm/values/validator.js +1 -1
  327. package/dist/esm/values/validator.js.map +2 -2
  328. package/dist/esm/values/validators.js +82 -26
  329. package/dist/esm/values/validators.js.map +2 -2
  330. package/dist/esm/values/value.js +6 -0
  331. package/dist/esm/values/value.js.map +2 -2
  332. package/dist/esm-types/browser/http_client.d.ts +5 -5
  333. package/dist/esm-types/browser/http_client.d.ts.map +1 -1
  334. package/dist/esm-types/browser/query_options.d.ts +2 -2
  335. package/dist/esm-types/browser/query_options.d.ts.map +1 -1
  336. package/dist/esm-types/browser/simple_client.d.ts +6 -6
  337. package/dist/esm-types/browser/simple_client.d.ts.map +1 -1
  338. package/dist/esm-types/browser/sync/optimistic_updates.d.ts +4 -4
  339. package/dist/esm-types/browser/sync/optimistic_updates.d.ts.map +1 -1
  340. package/dist/esm-types/browser/sync/optimistic_updates_impl.d.ts.map +1 -1
  341. package/dist/esm-types/bundler/index.d.ts +9 -2
  342. package/dist/esm-types/bundler/index.d.ts.map +1 -1
  343. package/dist/esm-types/cli/codegen.d.ts.map +1 -1
  344. package/dist/esm-types/cli/configure.d.ts +6 -0
  345. package/dist/esm-types/cli/configure.d.ts.map +1 -1
  346. package/dist/esm-types/cli/deploy.d.ts +2 -0
  347. package/dist/esm-types/cli/deploy.d.ts.map +1 -1
  348. package/dist/esm-types/cli/deploymentCreate.d.ts +6 -6
  349. package/dist/esm-types/cli/deploymentSelect.d.ts.map +1 -1
  350. package/dist/esm-types/cli/dev.d.ts +1 -0
  351. package/dist/esm-types/cli/dev.d.ts.map +1 -1
  352. package/dist/esm-types/cli/docs.d.ts.map +1 -1
  353. package/dist/esm-types/cli/env.d.ts.map +1 -1
  354. package/dist/esm-types/cli/envDefault.d.ts.map +1 -1
  355. package/dist/esm-types/cli/generatedApi.d.ts +1 -1
  356. package/dist/esm-types/cli/generatedApi.d.ts.map +1 -1
  357. package/dist/esm-types/cli/lib/api.d.ts.map +1 -1
  358. package/dist/esm-types/cli/lib/checkForLargeIndexBackfill.d.ts +30 -0
  359. package/dist/esm-types/cli/lib/checkForLargeIndexBackfill.d.ts.map +1 -0
  360. package/dist/esm-types/cli/lib/checkForLargeIndexDeletion.d.ts +25 -6
  361. package/dist/esm-types/cli/lib/checkForLargeIndexDeletion.d.ts.map +1 -1
  362. package/dist/esm-types/cli/lib/checkForSlowSchemaValidation.d.ts +8 -0
  363. package/dist/esm-types/cli/lib/checkForSlowSchemaValidation.d.ts.map +1 -0
  364. package/dist/esm-types/cli/lib/checkForStagedValidatorDeletion.d.ts +17 -0
  365. package/dist/esm-types/cli/lib/checkForStagedValidatorDeletion.d.ts.map +1 -0
  366. package/dist/esm-types/cli/lib/codegen.d.ts +0 -2
  367. package/dist/esm-types/cli/lib/codegen.d.ts.map +1 -1
  368. package/dist/esm-types/cli/lib/command.d.ts +2 -0
  369. package/dist/esm-types/cli/lib/command.d.ts.map +1 -1
  370. package/dist/esm-types/cli/lib/components/definition/bundle.d.ts +13 -0
  371. package/dist/esm-types/cli/lib/components/definition/bundle.d.ts.map +1 -1
  372. package/dist/esm-types/cli/lib/components.d.ts +5 -0
  373. package/dist/esm-types/cli/lib/components.d.ts.map +1 -1
  374. package/dist/esm-types/cli/lib/config.d.ts +2 -1
  375. package/dist/esm-types/cli/lib/config.d.ts.map +1 -1
  376. package/dist/esm-types/cli/lib/deploy2.d.ts +8 -0
  377. package/dist/esm-types/cli/lib/deploy2.d.ts.map +1 -1
  378. package/dist/esm-types/cli/lib/deployApi/evaluateSchema.d.ts +897 -0
  379. package/dist/esm-types/cli/lib/deployApi/evaluateSchema.d.ts.map +1 -0
  380. package/dist/esm-types/cli/lib/deployApi/finishPush.d.ts +1 -2
  381. package/dist/esm-types/cli/lib/deployApi/finishPush.d.ts.map +1 -1
  382. package/dist/esm-types/cli/lib/dev.d.ts +1 -0
  383. package/dist/esm-types/cli/lib/dev.d.ts.map +1 -1
  384. package/dist/esm-types/cli/lib/formatValidationProgress.d.ts +8 -0
  385. package/dist/esm-types/cli/lib/formatValidationProgress.d.ts.map +1 -0
  386. package/dist/esm-types/cli/lib/generatedFunctionLogsApi.d.ts +2 -0
  387. package/dist/esm-types/cli/lib/generatedFunctionLogsApi.d.ts.map +1 -1
  388. package/dist/esm-types/cli/lib/localDeployment/run.d.ts +2 -0
  389. package/dist/esm-types/cli/lib/localDeployment/run.d.ts.map +1 -1
  390. package/dist/esm-types/cli/lib/localDeployment/upgrade.d.ts.map +1 -1
  391. package/dist/esm-types/cli/lib/localDeployment/utils.d.ts +1 -0
  392. package/dist/esm-types/cli/lib/localDeployment/utils.d.ts.map +1 -1
  393. package/dist/esm-types/cli/lib/mcp/tools/env.d.ts +8 -5
  394. package/dist/esm-types/cli/lib/mcp/tools/env.d.ts.map +1 -1
  395. package/dist/esm-types/cli/lib/run.d.ts.map +1 -1
  396. package/dist/esm-types/cli/lib/schemaEvaluation.d.ts +33 -0
  397. package/dist/esm-types/cli/lib/schemaEvaluation.d.ts.map +1 -0
  398. package/dist/esm-types/cli/lib/usageLimits.d.ts +1 -1
  399. package/dist/esm-types/cli/lib/usageLimits.d.ts.map +1 -1
  400. package/dist/esm-types/cli/lib/utils/mutex.d.ts +1 -3
  401. package/dist/esm-types/cli/lib/utils/mutex.d.ts.map +1 -1
  402. package/dist/esm-types/cli/lib/utils/utils.d.ts +15 -7
  403. package/dist/esm-types/cli/lib/utils/utils.d.ts.map +1 -1
  404. package/dist/esm-types/index.d.ts +1 -1
  405. package/dist/esm-types/nextjs/index.d.ts +6 -6
  406. package/dist/esm-types/nextjs/index.d.ts.map +1 -1
  407. package/dist/esm-types/react/client.d.ts +15 -15
  408. package/dist/esm-types/react/client.d.ts.map +1 -1
  409. package/dist/esm-types/react/hydration.d.ts +3 -3
  410. package/dist/esm-types/react/hydration.d.ts.map +1 -1
  411. package/dist/esm-types/react/queries_observer.d.ts +9 -9
  412. package/dist/esm-types/react/queries_observer.d.ts.map +1 -1
  413. package/dist/esm-types/react/use_paginated_query2.d.ts.map +1 -1
  414. package/dist/esm-types/react/use_queries.d.ts +14 -6
  415. package/dist/esm-types/react/use_queries.d.ts.map +1 -1
  416. package/dist/esm-types/server/api.d.ts +157 -7
  417. package/dist/esm-types/server/api.d.ts.map +1 -1
  418. package/dist/esm-types/server/components/index.d.ts +2 -2
  419. package/dist/esm-types/server/components/index.d.ts.map +1 -1
  420. package/dist/esm-types/server/cron.d.ts +21 -20
  421. package/dist/esm-types/server/cron.d.ts.map +1 -1
  422. package/dist/esm-types/server/impl/actions_impl.d.ts +22 -7
  423. package/dist/esm-types/server/impl/actions_impl.d.ts.map +1 -1
  424. package/dist/esm-types/server/impl/meta_impl.d.ts.map +1 -1
  425. package/dist/esm-types/server/impl/scheduler_impl.d.ts.map +1 -1
  426. package/dist/esm-types/server/impl/storage_impl.d.ts.map +1 -1
  427. package/dist/esm-types/server/index.d.ts +2 -2
  428. package/dist/esm-types/server/index.d.ts.map +1 -1
  429. package/dist/esm-types/server/meta.d.ts +63 -0
  430. package/dist/esm-types/server/meta.d.ts.map +1 -1
  431. package/dist/esm-types/server/registration.d.ts +17 -7
  432. package/dist/esm-types/server/registration.d.ts.map +1 -1
  433. package/dist/esm-types/server/scheduler.d.ts +9 -7
  434. package/dist/esm-types/server/scheduler.d.ts.map +1 -1
  435. package/dist/esm-types/server/schema.d.ts +34 -0
  436. package/dist/esm-types/server/schema.d.ts.map +1 -1
  437. package/dist/esm-types/server/storage.d.ts.map +1 -1
  438. package/dist/esm-types/values/validator.d.ts.map +1 -1
  439. package/dist/esm-types/values/validators.d.ts +30 -0
  440. package/dist/esm-types/values/validators.d.ts.map +1 -1
  441. package/dist/esm-types/values/value.d.ts.map +1 -1
  442. package/dist/react.bundle.js +7 -1
  443. package/dist/react.bundle.js.map +2 -2
  444. package/package.json +9 -9
  445. package/schemas/convex.schema.json +5 -5
  446. package/src/browser/http_client.ts +43 -10
  447. package/src/browser/query_options.ts +11 -5
  448. package/src/browser/simple_client.ts +35 -14
  449. package/src/browser/sync/optimistic_updates.ts +17 -4
  450. package/src/browser/sync/optimistic_updates_impl.ts +17 -4
  451. package/src/bundler/index.ts +9 -4
  452. package/src/cli/codegen.ts +0 -1
  453. package/src/cli/configure.ts +27 -7
  454. package/src/cli/deploy.ts +37 -5
  455. package/src/cli/deploymentSelect.ts +7 -4
  456. package/src/cli/dev.ts +9 -0
  457. package/src/cli/docs.ts +3 -44
  458. package/src/cli/env.ts +12 -6
  459. package/src/cli/envDefault.ts +8 -2
  460. package/src/cli/generatedApi.ts +1 -1
  461. package/src/cli/lib/api.ts +5 -1
  462. package/src/cli/lib/checkForLargeIndexBackfill.ts +173 -0
  463. package/src/cli/lib/checkForLargeIndexDeletion.ts +150 -91
  464. package/src/cli/lib/checkForSlowSchemaValidation.ts +141 -0
  465. package/src/cli/lib/checkForStagedValidatorDeletion.ts +104 -0
  466. package/src/cli/lib/codegen.ts +0 -2
  467. package/src/cli/lib/command.ts +3 -0
  468. package/src/cli/lib/components/definition/bundle.ts +68 -14
  469. package/src/cli/lib/components.ts +84 -0
  470. package/src/cli/lib/config.ts +85 -18
  471. package/src/cli/lib/deploy2.ts +66 -2
  472. package/src/cli/lib/deployApi/evaluateSchema.ts +97 -0
  473. package/src/cli/lib/deployApi/finishPush.ts +1 -1
  474. package/src/cli/lib/deployApi/startPush.ts +1 -1
  475. package/src/cli/lib/dev.ts +15 -0
  476. package/src/cli/lib/formatValidationProgress.ts +35 -0
  477. package/src/cli/lib/generatedFunctionLogsApi.ts +2 -0
  478. package/src/cli/lib/indexes.ts +1 -1
  479. package/src/cli/lib/localDeployment/run.ts +44 -2
  480. package/src/cli/lib/localDeployment/upgrade.ts +4 -6
  481. package/src/cli/lib/localDeployment/utils.ts +6 -0
  482. package/src/cli/lib/mcp/tools/env.ts +17 -3
  483. package/src/cli/lib/run.ts +3 -0
  484. package/src/cli/lib/schemaEvaluation.ts +88 -0
  485. package/src/cli/lib/usageLimits.ts +2 -0
  486. package/src/cli/lib/utils/mutex.ts +9 -27
  487. package/src/cli/lib/utils/utils.ts +127 -56
  488. package/src/cli/projectCreate.ts +1 -1
  489. package/src/index.ts +1 -1
  490. package/src/nextjs/index.ts +19 -8
  491. package/src/react/client.ts +73 -30
  492. package/src/react/hydration.tsx +14 -6
  493. package/src/react/queries_observer.ts +19 -16
  494. package/src/react/use_paginated_query2.ts +10 -6
  495. package/src/react/use_queries.ts +23 -7
  496. package/src/server/api.ts +220 -14
  497. package/src/server/components/index.ts +4 -6
  498. package/src/server/cron.ts +34 -24
  499. package/src/server/impl/actions_impl.ts +39 -10
  500. package/src/server/impl/meta_impl.ts +8 -1
  501. package/src/server/impl/scheduler_impl.ts +13 -6
  502. package/src/server/impl/storage_impl.ts +30 -0
  503. package/src/server/index.ts +6 -1
  504. package/src/server/meta.ts +79 -0
  505. package/src/server/registration.ts +38 -7
  506. package/src/server/scheduler.ts +22 -7
  507. package/src/server/schema.ts +77 -0
  508. package/src/server/storage.ts +17 -0
  509. package/src/values/validator.ts +3 -1
  510. package/src/values/validators.ts +85 -27
  511. package/src/values/value.ts +9 -5
@@ -6,6 +6,7 @@ import {
6
6
  StorageWriter,
7
7
  } from "../storage.js";
8
8
  import { version } from "../../index.js";
9
+ import { fromByteArray, toByteArray } from "../../values/base64.js";
9
10
  import { performAsyncSyscall, performJsSyscall } from "./syscall.js";
10
11
  import { validateArg } from "./validate.js";
11
12
 
@@ -45,6 +46,35 @@ export function setupStorageWriter(requestId: string): StorageWriter {
45
46
  storageId,
46
47
  });
47
48
  },
49
+ store: async (blob: Blob, options?: { sha256?: string }) => {
50
+ if (!(blob instanceof Blob)) {
51
+ throw new Error(
52
+ "store() expects a Blob. If you are trying to store a Request, `await request.blob()` will give you the correct input.",
53
+ );
54
+ }
55
+ const bytes = new Uint8Array(await blob.arrayBuffer());
56
+ return await performAsyncSyscall("1.0/storageStore", {
57
+ requestId,
58
+ version,
59
+ blob: fromByteArray(bytes),
60
+ contentType: blob.type,
61
+ sha256: options?.sha256,
62
+ });
63
+ },
64
+ get: async (storageId: FileStorageId) => {
65
+ const result: { blob: string; contentType: string | null } | null =
66
+ await performAsyncSyscall("1.0/storageGet", {
67
+ requestId,
68
+ version,
69
+ storageId,
70
+ });
71
+ if (result === null) {
72
+ return null;
73
+ }
74
+ return new Blob([toByteArray(result.blob)], {
75
+ type: result.contentType ?? "",
76
+ });
77
+ },
48
78
  getUrl: reader.getUrl,
49
79
  getMetadata: reader.getMetadata,
50
80
  };
@@ -103,7 +103,11 @@ export {
103
103
  internalMutationGeneric,
104
104
  internalQueryGeneric,
105
105
  } from "./impl/registration_impl.js";
106
- export { getServiceToken } from "./impl/actions_impl.js";
106
+ export {
107
+ getServiceToken,
108
+ getServiceUrl,
109
+ type ServiceName,
110
+ } from "./impl/actions_impl.js";
107
111
  export type {
108
112
  TransactionMetric,
109
113
  TransactionMetrics,
@@ -174,6 +178,7 @@ export {
174
178
  export type {
175
179
  ApiFromModules,
176
180
  AnyApi,
181
+ FunctionReference_future,
177
182
  FilterApi,
178
183
  FunctionType,
179
184
  FunctionReference,
@@ -26,6 +26,14 @@ export type TransactionMetrics = {
26
26
  documentsWritten: TransactionMetric;
27
27
  functionsScheduled: TransactionMetric;
28
28
  scheduledFunctionArgsBytes: TransactionMetric;
29
+ /** @internal */
30
+ filesWritten: TransactionMetric;
31
+ /** @internal */
32
+ fileWriteBytes: TransactionMetric;
33
+ /** @internal */
34
+ filesRead: TransactionMetric;
35
+ /** @internal */
36
+ fileReadBytes: TransactionMetric;
29
37
  };
30
38
 
31
39
  /**
@@ -43,6 +51,14 @@ export interface TransactionLimits {
43
51
  documentsWritten?: number;
44
52
  functionsScheduled?: number;
45
53
  scheduledFunctionArgsBytes?: number;
54
+ /** @internal */
55
+ filesWritten?: number;
56
+ /** @internal */
57
+ fileWriteBytes?: number;
58
+ /** @internal */
59
+ filesRead?: number;
60
+ /** @internal */
61
+ fileReadBytes?: number;
46
62
  }
47
63
 
48
64
  /**
@@ -130,9 +146,48 @@ export type RequestMetadata = {
130
146
  * @public
131
147
  */
132
148
  export interface QueryMeta {
149
+ /**
150
+ * Metadata about the currently executing Convex function.
151
+ */
133
152
  getFunctionMetadata(): Promise<FunctionMetadata>;
153
+ /**
154
+ * The remaining headroom for a transaction before hitting limits.
155
+ *
156
+ * See https://docs.convex.dev/production/state/limits
157
+ */
134
158
  getTransactionMetrics(): Promise<TransactionMetrics>;
159
+ /**
160
+ * Metadata about the deployment this function is running on.
161
+ */
135
162
  getDeploymentMetadata(): Promise<DeploymentMetadata>;
163
+ /**
164
+ * Returns the timestamp of the database snapshot this transaction reads
165
+ * from, in nanoseconds.
166
+ *
167
+ * All commits at or before this timestamp are observable within the
168
+ * transaction, and no later commits are. The value is fixed for the
169
+ * lifetime of the transaction and shared with all nested `runMutation` and
170
+ * non-stale `runQuery` calls. If a nested query is called with
171
+ * `useStaleSnapshot: true`, then the nested query may in a future backend
172
+ * version choose an older snapshotTs.
173
+ *
174
+ * It is on the same clock as `db.vars.commitTs`: documents observable in
175
+ * this transaction have `commitTs` values at or before this timestamp, and
176
+ * no new documents will be written with a `commitTs` at or below this,
177
+ * including from the current transaction. When reading documents with an
178
+ * index in commitTs order, you can use this as an upper bound to prevent
179
+ * conflicting with racing inserts.
180
+ *
181
+ * Since the timestamp differs on every execution, calling this in a query
182
+ * limits caching of the query's result the same way `Date.now()` does.
183
+ *
184
+ * Note: this should not be compared to `_creationTime` or `Date.now()`, as
185
+ * those are based on wall-clock time rather than the database clock, and
186
+ * aren't guaranteed to follow commit order.
187
+ *
188
+ * Docs: https://docs.convex.dev/database/advanced/commit-timestamp
189
+ */
190
+ getSnapshotTs(): bigint;
136
191
  }
137
192
 
138
193
  /**
@@ -141,6 +196,15 @@ export interface QueryMeta {
141
196
  * @public
142
197
  */
143
198
  export interface MutationMeta extends QueryMeta {
199
+ /**
200
+ * Metadata about the HTTP request that triggered the current function execution.
201
+ *
202
+ * `ip` and `userAgent` are `null` when the function was not triggered by an
203
+ * HTTP request (e.g. scheduled jobs or cron jobs).
204
+ *
205
+ * Functions called from within a function (i.e. using `runMutation`) will have
206
+ * the same request metadata as the parent function.
207
+ */
144
208
  getRequestMetadata(): Promise<RequestMetadata>;
145
209
  }
146
210
 
@@ -150,7 +214,22 @@ export interface MutationMeta extends QueryMeta {
150
214
  * @public
151
215
  */
152
216
  export interface ActionMeta {
217
+ /**
218
+ * Metadata about the currently executing Convex function.
219
+ */
153
220
  getFunctionMetadata(): Promise<FunctionMetadata>;
221
+ /**
222
+ * Metadata about the deployment this function is running on.
223
+ */
154
224
  getDeploymentMetadata(): Promise<DeploymentMetadata>;
225
+ /**
226
+ * Metadata about the HTTP request that triggered the current function execution.
227
+ *
228
+ * `ip` and `userAgent` are `null` when the function was not triggered by an
229
+ * HTTP request (e.g. scheduled jobs or cron jobs).
230
+ *
231
+ * Functions called from within a function (i.e. using `runMutation` or
232
+ * `runAction`) will have the same request metadata as the parent function.
233
+ */
155
234
  getRequestMetadata(): Promise<RequestMetadata>;
156
235
  }
@@ -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>>;
@@ -1213,6 +1234,11 @@ export type HttpActionBuilder = (
1213
1234
  ) => PublicHttpAction;
1214
1235
 
1215
1236
  export interface AdvancedRunQueryOptions {
1237
+ /**
1238
+ * Custom limits for a nested transaction. Each field specifies the absolute
1239
+ * maximum allowed for the nested function call. Values are capped at the
1240
+ * global transaction limits, so they can only lower limits, never raise them.
1241
+ */
1216
1242
  transactionLimits?: TransactionLimits;
1217
1243
  /**
1218
1244
  * Run a query on a recent snapshot of the database that is not guaranteed
@@ -1223,6 +1249,11 @@ export interface AdvancedRunQueryOptions {
1223
1249
  * database read conflicts are expected, e.g. reading from an append-only
1224
1250
  * table with immutable records where the only read conflicts are from
1225
1251
  * concurrent appends.
1252
+ *
1253
+ * To determine the snapshot of the nested query, you can call
1254
+ * `ctx.meta.getSnapshotTs()` from within the stale snapshot query. To
1255
+ * compare to the parent mutation's snapshot timestamp, you can return that
1256
+ * value from the query and call `ctx.meta.getSnapshotTs()` from the parent.
1226
1257
  */
1227
1258
  useStaleSnapshot?: boolean;
1228
1259
  }
@@ -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,67 @@ export class TableDefinition<
557
560
  return this;
558
561
  }
559
562
 
563
+ /**
564
+ * Stage changes to this table's document validator.
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 writes. Once
569
+ * the background validation succeeds, apply the staged changes
570
+ * and remove `.staged()`.
571
+ *
572
+ * For an object validator, pass only the fields to add or replace. Fields
573
+ * omitted from the changes keep their enforced validators.
574
+ * Set a field to `undefined` to remove it from the staged validator.
575
+ * For nested objects, you must specify the full object validator.
576
+ *
577
+ * ```ts
578
+ * defineTable({
579
+ * apple: v.string(),
580
+ * banana: v.number(),
581
+ * legacy: v.optional(v.string()),
582
+ * }).staged({
583
+ * banana: v.union(v.string(), v.number()),
584
+ * legacy: undefined,
585
+ * })
586
+ * ```
587
+ *
588
+ * See [Staged validators](https://docs.convex.dev/database/schemas#staged-validators).
589
+ *
590
+ * @param documentSchema - Field changes for a table defined as an object or
591
+ * `v.any()`, or a full schema validator specifying the proposed next document
592
+ * type. Use a full schema validator for a table defined as a union.
593
+ * @returns A {@link TableDefinition} with the staged validator attached.
594
+ */
595
+ staged(
596
+ documentSchema:
597
+ | Validator<Record<string, any>, "required", any>
598
+ | Record<string, GenericValidator | undefined>,
599
+ ): TableDefinition<DocumentType, Indexes, SearchIndexes, VectorIndexes> {
600
+ if (this.stagedValidator !== undefined) {
601
+ throw new Error("Table cannot have more than one staged validator.");
602
+ }
603
+ if (isValidator(documentSchema)) {
604
+ this.stagedValidator = documentSchema;
605
+ } else {
606
+ if (this.validator.kind !== "object" && this.validator.kind !== "any") {
607
+ throw new Error(
608
+ "Specifying top-level field changes is only supported for simple table definitions. For a table defined with a union or record validator, you must stage a fully defined object or union validator.",
609
+ );
610
+ }
611
+ const enforcedFields =
612
+ this.validator.kind === "object" ? this.validator.fields : {};
613
+ const fields: Record<string, GenericValidator> = Object.fromEntries(
614
+ Object.entries({ ...enforcedFields, ...documentSchema }).filter(
615
+ (entry): entry is [string, GenericValidator] =>
616
+ entry[1] !== undefined,
617
+ ),
618
+ );
619
+ this.stagedValidator = v.object(fields);
620
+ }
621
+ return this.self();
622
+ }
623
+
560
624
  /**
561
625
  * Work around for https://github.com/microsoft/TypeScript/issues/57035
562
626
  */
@@ -582,6 +646,16 @@ export class TableDefinition<
582
646
  );
583
647
  }
584
648
 
649
+ let stagedDocumentType = undefined;
650
+ if (this.stagedValidator !== undefined) {
651
+ stagedDocumentType = this.stagedValidator.json;
652
+ if (typeof stagedDocumentType !== "object") {
653
+ throw new Error(
654
+ "Invalid staged validator: please make sure that the parameter of `.staged()` is valid (see https://docs.convex.dev/database/schemas)",
655
+ );
656
+ }
657
+ }
658
+
585
659
  return {
586
660
  indexes: this.indexes,
587
661
  stagedDbIndexes: this.stagedDbIndexes,
@@ -590,6 +664,7 @@ export class TableDefinition<
590
664
  vectorIndexes: this.vectorIndexes,
591
665
  stagedVectorIndexes: this.stagedVectorIndexes,
592
666
  documentType,
667
+ stagedDocumentType,
593
668
  };
594
669
  }
595
670
  }
@@ -884,6 +959,7 @@ export class SchemaDefinition<
884
959
  vectorIndexes,
885
960
  stagedVectorIndexes,
886
961
  documentType,
962
+ stagedDocumentType,
887
963
  } = definition.export();
888
964
  return {
889
965
  tableName,
@@ -894,6 +970,7 @@ export class SchemaDefinition<
894
970
  vectorIndexes,
895
971
  stagedVectorIndexes,
896
972
  documentType,
973
+ stagedDocumentType,
897
974
  };
898
975
  }),
899
976
  schemaValidation: this.schemaValidation,
@@ -194,6 +194,23 @@ export interface StorageWriter extends StorageReader {
194
194
  delete<T extends StorageId>(
195
195
  storageId: T extends { __tableName: any } ? never : T,
196
196
  ): Promise<void>;
197
+
198
+ /**
199
+ * @internal
200
+ */
201
+ // TODO: move `store` from StorageActionWriter to StorageWriter when mutation
202
+ // file storage access is ready for release
203
+ store(
204
+ blob: Blob,
205
+ options?: { sha256?: string },
206
+ ): Promise<GenericId<"_storage">>;
207
+
208
+ /**
209
+ * @internal
210
+ */
211
+ // TODO: move `get` from StorageActionWriter to StorageWriter when mutation
212
+ // file storage access is ready for release
213
+ get(storageId: GenericId<"_storage">): Promise<Blob | null>;
197
214
  }
198
215
 
199
216
  /**
@@ -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
  /**