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
package/src/server/api.ts CHANGED
@@ -42,6 +42,9 @@ export type FunctionType = "query" | "mutation" | "action";
42
42
  * const result = useQuery(api.myModule.myFunction);
43
43
  * ```
44
44
  *
45
+ * If you want to accept a `FunctionReference` as a callback argument, prefer
46
+ * typing the callback parameter as {@link FunctionReference_future}.
47
+ *
45
48
  * @typeParam Type - The type of the function ("query", "mutation", or "action").
46
49
  * @typeParam Visibility - The visibility of the function ("public" or "internal").
47
50
  * @typeParam Args - The arguments to this function. This is an object mapping
@@ -58,9 +61,179 @@ export type FunctionReference<
58
61
  > = {
59
62
  _type: Type;
60
63
  _visibility: Visibility;
64
+ /**
65
+ * To read the arguments for a `FunctionReference`, prefer
66
+ * {@link FunctionArgs}.
67
+ *
68
+ * This slot will be removed in a future version.
69
+ *
70
+ * @deprecated
71
+ */
61
72
  _args: Args;
73
+ /**
74
+ * To read the return type of a `FunctionReference`, prefer
75
+ * {@link FunctionReturnType}.
76
+ *
77
+ * This slot will be removed in a future version.
78
+ *
79
+ * @deprecated
80
+ */
62
81
  _returnType: ReturnType;
63
82
  _componentPath: ComponentPath;
83
+ /**
84
+ * To read the arguments or return type of a `FunctionReference`, prefer
85
+ * {@link FunctionArgs} and {@link FunctionReturnType}.
86
+ */
87
+ // This phantom slot exists so that a `FunctionReference` can be checked
88
+ // against a `FunctionReference_future`. It changes nothing about how two
89
+ // `FunctionReference`s compare with each other.
90
+ //
91
+ // The slot models the function itself: it puts `Args` in a contravariant
92
+ // position and `ReturnType` in a covariant one, so the slot alone is enough
93
+ // to compare a reference the way TypeScript compares two functions.
94
+ //
95
+ // In that comparison the `keys` parameter has an important role. It carries
96
+ // the keys of `Args`, so that checking a `FunctionReference` against a
97
+ // `FunctionReference_future` also checks that every key the consumer passes
98
+ // is a key the function declares. TypeScript treats a surplus property as
99
+ // harmless, but a Convex argument validator rejects it, so this is what
100
+ // makes the comparison match the runtime. See `FunctionReferenceArgKeys`.
101
+ _fn?(args: Args, keys: FunctionReferenceArgKeys<Args>): ReturnType;
102
+ };
103
+
104
+ /**
105
+ * The keys of a reference's arguments.
106
+ *
107
+ * `0 extends 1 & Args` holds only when `Args` is `any`. That maps to `any`
108
+ * rather than `keyof any` so that an untyped reference neither imposes nor
109
+ * fails the key check in either direction. Arguments with an index signature,
110
+ * such as `EmptyObject` and `DefaultFunctionArgs`, map to `string`, which
111
+ * accepts every key and leaves the decision to the first parameter.
112
+ */
113
+ type ArgKeys<Args> = 0 extends 1 & Args ? any : keyof Args;
114
+
115
+ /**
116
+ * The second parameter of `FunctionReference._fn`.
117
+ *
118
+ * Wrapping the keys in a function of a function puts them two parameters deep,
119
+ * so comparing this parameter contravariantly checks that every key the
120
+ * consumer passes is one the function declares. That is the check a Convex
121
+ * argument validator performs and an ordinary function-type comparison skips.
122
+ *
123
+ * The union with {@link UncheckedArgKeys} is what keeps two
124
+ * `FunctionReference`s comparing as they did before this slot existed. Every
125
+ * `FunctionReferenceArgKeys` is assignable to `UncheckedArgKeys`, so between
126
+ * two `FunctionReference`s the keys always relate and only `_args` decides.
127
+ * {@link FunctionReference_futureArgKeys} is not assignable to it, so a
128
+ * `FunctionReference` compared against a `FunctionReference_future` has to
129
+ * satisfy the real check.
130
+ */
131
+ type FunctionReferenceArgKeys<Args> = 0 extends 1 & Args
132
+ ? any
133
+ : ((keys: (key: ArgKeys<Args>) => void) => void) | UncheckedArgKeys;
134
+
135
+ /**
136
+ * A keys parameter that every {@link FunctionReferenceArgKeys} is assignable
137
+ * to, and that no {@link FunctionReference_futureArgKeys} is: `unknown` for
138
+ * the second parameter accepts the former's missing parameter and rejects the
139
+ * latter's `never`.
140
+ */
141
+ type UncheckedArgKeys = (keys: never, unchecked?: unknown) => void;
142
+
143
+ /**
144
+ * The second parameter of `FunctionReference_future._fn`. The same shape as
145
+ * {@link FunctionReferenceArgKeys} plus a `guard` parameter that keeps it out
146
+ * of {@link UncheckedArgKeys}.
147
+ */
148
+ type FunctionReference_futureArgKeys<Args> = 0 extends 1 & Args
149
+ ? any
150
+ : (keys: (key: ArgKeys<Args>) => void, guard?: never) => void;
151
+
152
+ /**
153
+ * A reference to a Convex function whose arguments are checked closer to the
154
+ * way Convex checks them at runtime.
155
+ *
156
+ * Use this instead of {@link FunctionReference} when you accept someone else's
157
+ * Convex function as a callback and know which arguments you will pass it.
158
+ *
159
+ * A plain `FunctionReference` gets a couple things backwards: it accepts a
160
+ * function requiring arguments you never pass, and rejects a function
161
+ * accepting broader values than you pass. An ordinary TypeScript function type
162
+ * doesn't map perfectly either: it treats a surplus argument as harmless,
163
+ * where a Convex validator rejects it.
164
+ *
165
+ * This type melds regular TypeScript function reference behavior with top
166
+ * level checking of arguments to prevent surplus arguments from hitting
167
+ * runtime validation errors. The caveat: a surplus key inside a nested object,
168
+ * an array element, or one arm of a union passes the type check and fails the
169
+ * validator at runtime.
170
+ *
171
+ * ```ts
172
+ * import { FunctionReference_future } from "convex/server";
173
+ *
174
+ * declare function onComplete(
175
+ * fn: FunctionReference_future<
176
+ * "mutation",
177
+ * "internal",
178
+ * { taskId: string; force: boolean },
179
+ * null
180
+ * >,
181
+ * ): void;
182
+ *
183
+ * // Takes exactly `{ taskId: string; force: boolean }`.
184
+ * onComplete(internal.tasks.finish);
185
+ * // Takes `{ taskId: string | number; force?: boolean }`: calling it is safe.
186
+ * onComplete(internal.tasks.finishLoosely);
187
+ * // Requires a `reason` argument that `onComplete` never passes.
188
+ * onComplete(internal.tasks.finishWithReason);
189
+ * // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ rejected
190
+ * // Takes only `{ taskId: string }`: its validator would reject `force`.
191
+ * onComplete(internal.tasks.finishById);
192
+ * // ~~~~~~~~~~~~~~~~~~~~~~~~ rejected
193
+ * ```
194
+ *
195
+ * A value of this type is usable with `ctx.runMutation`,
196
+ * `ctx.scheduler.runAfter`, `createFunctionHandle`, and everything else in
197
+ * this package that takes a reference, all of which accept either kind.
198
+ *
199
+ * It is *not* assignable to a plain `FunctionReference`. Code that wants to
200
+ * accept both kinds should take
201
+ * `FunctionReference<...> | FunctionReference_future<...>` and read arguments
202
+ * and return types through {@link FunctionArgs} and {@link FunctionReturnType}.
203
+ *
204
+ * Argument checking here relies on `strictFunctionTypes` (implied by `strict`)
205
+ * and is skipped for projects that disable it. Everything else about the
206
+ * reference is compared exactly as `FunctionReference` compares it.
207
+ *
208
+ * @typeParam Type - The type of the function ("query", "mutation", or "action").
209
+ * @typeParam Visibility - The visibility of the function ("public" or "internal").
210
+ * @typeParam Args - The arguments the consumer of the reference will pass.
211
+ * @typeParam ReturnType - The return type of this function.
212
+ * @public
213
+ */
214
+ export type FunctionReference_future<
215
+ Type extends FunctionType,
216
+ Visibility extends FunctionVisibility = "public",
217
+ Args extends DefaultFunctionArgs = any,
218
+ ReturnType = any,
219
+ ComponentPath = string | undefined,
220
+ > = {
221
+ _type: Type;
222
+ _visibility: Visibility;
223
+ _componentPath: ComponentPath;
224
+ // Declared as a *property* rather than a method: TypeScript compares method
225
+ // parameters bivariantly and would not check anything. The explicit
226
+ // `| undefined` is needed because an optional method on the source side
227
+ // (`FunctionReference._fn`) carries a real `undefined` in its type, which
228
+ // `exactOptionalPropertyTypes` would otherwise reject.
229
+ //
230
+ // Both parameters are compared contravariantly: the first checks that the
231
+ // consumer's arguments satisfy the function's, the second that the consumer
232
+ // passes no key the function does not declare. See
233
+ // `FunctionReference_futureArgKeys`.
234
+ _fn?:
235
+ | ((args: Args, keys: FunctionReference_futureArgKeys<Args>) => ReturnType)
236
+ | undefined;
64
237
  };
65
238
 
66
239
  /**
@@ -76,7 +249,9 @@ export type FunctionReference<
76
249
  * @public
77
250
  */
78
251
  export function getFunctionName(
79
- functionReference: AnyFunctionReference,
252
+ functionReference:
253
+ | FunctionReference<any, any>
254
+ | FunctionReference_future<any, any>,
80
255
  ): string {
81
256
  const address = getFunctionAddress(functionReference);
82
257
 
@@ -431,13 +606,33 @@ export type PartialApi<API> = {
431
606
  export const anyApi: AnyApi = createApi() as any;
432
607
 
433
608
  /**
434
- * Given a {@link FunctionReference}, get the return type of the function.
609
+ * Given a {@link FunctionReference} or {@link FunctionReference_future}, get
610
+ * the arguments of the function.
435
611
  *
436
612
  * This is represented as an object mapping argument names to values.
613
+ *
437
614
  * @public
438
615
  */
439
- export type FunctionArgs<FuncRef extends AnyFunctionReference> =
440
- FuncRef["_args"];
616
+ export type FunctionArgs<
617
+ FuncRef extends
618
+ | FunctionReference<any, any>
619
+ | FunctionReference_future<any, any>,
620
+ > = ExtractSignature<FuncRef>["args"];
621
+
622
+ // The arguments and return type a reference declares. A `FunctionReference`
623
+ // declares them in `_args` and `_returnType`, a `FunctionReference_future`
624
+ // only in its `_fn` slot. Reading the named slots first also covers a
625
+ // reference typed by an older copy of this package, which has no `_fn`.
626
+ type ExtractSignature<FuncRef> = FuncRef extends {
627
+ _args: infer Args;
628
+ _returnType: infer R;
629
+ }
630
+ ? { args: Args; returnType: R }
631
+ : FuncRef extends {
632
+ _fn?: ((args: infer Args, keys: never) => infer R) | undefined;
633
+ }
634
+ ? { args: Args; returnType: R }
635
+ : { args: any; returnType: any };
441
636
 
442
637
  /**
443
638
  * A tuple type of the (maybe optional) arguments to `FuncRef`.
@@ -447,10 +642,14 @@ export type FunctionArgs<FuncRef extends AnyFunctionReference> =
447
642
  *
448
643
  * @public
449
644
  */
450
- export type OptionalRestArgs<FuncRef extends AnyFunctionReference> =
451
- FuncRef["_args"] extends EmptyObject
645
+ export type OptionalRestArgs<
646
+ FuncRef extends
647
+ | FunctionReference<any, any>
648
+ | FunctionReference_future<any, any>,
649
+ > =
650
+ FunctionArgs<FuncRef> extends EmptyObject
452
651
  ? [args?: EmptyObject]
453
- : [args: FuncRef["_args"]];
652
+ : [args: FunctionArgs<FuncRef>];
454
653
 
455
654
  /**
456
655
  * A tuple type of the (maybe optional) arguments to `FuncRef`, followed by an options
@@ -462,19 +661,26 @@ export type OptionalRestArgs<FuncRef extends AnyFunctionReference> =
462
661
  * @public
463
662
  */
464
663
  export type ArgsAndOptions<
465
- FuncRef extends AnyFunctionReference,
664
+ FuncRef extends
665
+ | FunctionReference<any, any>
666
+ | FunctionReference_future<any, any>,
466
667
  Options,
467
- > = FuncRef["_args"] extends EmptyObject
468
- ? [args?: EmptyObject, options?: Options]
469
- : [args: FuncRef["_args"], options?: Options];
668
+ > =
669
+ FunctionArgs<FuncRef> extends EmptyObject
670
+ ? [args?: EmptyObject, options?: Options]
671
+ : [args: FunctionArgs<FuncRef>, options?: Options];
470
672
 
471
673
  /**
472
- * Given a {@link FunctionReference}, get the return type of the function.
674
+ * Given a {@link FunctionReference} or {@link FunctionReference_future}, get
675
+ * the return type of the function.
473
676
  *
474
677
  * @public
475
678
  */
476
- export type FunctionReturnType<FuncRef extends AnyFunctionReference> =
477
- FuncRef["_returnType"];
679
+ export type FunctionReturnType<
680
+ FuncRef extends
681
+ | FunctionReference<any, any>
682
+ | FunctionReference_future<any, any>,
683
+ > = ExtractSignature<FuncRef>["returnType"];
478
684
 
479
685
  type UndefinedToNull<T> = T extends void ? null : T;
480
686
 
@@ -3,6 +3,7 @@ import { version } from "../../index.js";
3
3
  import {
4
4
  AnyFunctionReference,
5
5
  FunctionReference,
6
+ FunctionReference_future,
6
7
  FunctionType,
7
8
  } from "../api.js";
8
9
  import { performAsyncSyscall } from "../impl/syscall.js";
@@ -66,12 +67,9 @@ export async function createFunctionHandle<
66
67
  Args extends DefaultFunctionArgs,
67
68
  ReturnType,
68
69
  >(
69
- functionReference: FunctionReference<
70
- Type,
71
- "public" | "internal",
72
- Args,
73
- ReturnType
74
- >,
70
+ functionReference:
71
+ | FunctionReference<Type, "public" | "internal", Args, ReturnType>
72
+ | FunctionReference_future<Type, "public" | "internal", Args, ReturnType>,
75
73
  ): Promise<FunctionHandle<Type, Args, ReturnType>> {
76
74
  const address = getFunctionAddress(functionReference);
77
75
  return await performAsyncSyscall("1.0/createFunctionHandle", {
@@ -1,9 +1,19 @@
1
- import { getFunctionName, OptionalRestArgs } from "../server/api.js";
1
+ import {
2
+ FunctionReference_future,
3
+ getFunctionName,
4
+ OptionalRestArgs,
5
+ } from "../server/api.js";
2
6
  import { parseArgs } from "../common/index.js";
3
7
  import { convexToJson, JSONValue, Value } from "../values/index.js";
4
8
  import { getFunctionAddress } from "./components/paths.js";
5
9
  import { SchedulableFunctionReference } from "./scheduler.js";
6
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
+
7
17
  type CronSchedule = {
8
18
  type: "cron";
9
19
  cron: string;
@@ -238,8 +248,8 @@ function validatedOptionalMinuteOfHour(n: number | undefined) {
238
248
  // call shapes apart by whether the second argument resolves to a function
239
249
  // reference (the way the scheduler syscalls do) rather than a schedule object.
240
250
  function isSchedulableFunctionReference(
241
- arg: Hourly | SchedulableFunctionReference,
242
- ): arg is SchedulableFunctionReference {
251
+ arg: Hourly | SchedulableFunctionReferenceCompat,
252
+ ): arg is SchedulableFunctionReferenceCompat {
243
253
  try {
244
254
  getFunctionAddress(arg);
245
255
  return true;
@@ -280,7 +290,7 @@ export class Crons {
280
290
  schedule(
281
291
  cronIdentifier: string,
282
292
  schedule: Schedule,
283
- functionReference: SchedulableFunctionReference,
293
+ functionReference: SchedulableFunctionReferenceCompat,
284
294
  args?: Record<string, Value>,
285
295
  ) {
286
296
  const cronArgs = parseArgs(args);
@@ -304,11 +314,11 @@ export class Crons {
304
314
  *
305
315
  * @param identifier - A unique name for this scheduled job.
306
316
  * @param schedule - The time between runs for this scheduled job.
307
- * @param functionReference - A {@link FunctionReference} for the function
308
- * to schedule.
317
+ * @param functionReference - A {@link FunctionReference} or
318
+ * {@link FunctionReference_future} for the function to schedule.
309
319
  * @param args - The arguments to the function.
310
320
  */
311
- interval<FuncRef extends SchedulableFunctionReference>(
321
+ interval<FuncRef extends SchedulableFunctionReferenceCompat>(
312
322
  cronIdentifier: string,
313
323
  schedule: Interval,
314
324
  functionReference: FuncRef,
@@ -353,22 +363,22 @@ export class Crons {
353
363
  * @param cronIdentifier - A unique name for this scheduled job.
354
364
  * @param schedule - What minute (UTC) of each hour to run this function. May
355
365
  * be omitted to let Convex pick a minute and spread runs across the hour.
356
- * @param functionReference - A {@link FunctionReference} for the function
357
- * to schedule.
366
+ * @param functionReference - A {@link FunctionReference} or
367
+ * {@link FunctionReference_future} for the function to schedule.
358
368
  * @param args - The arguments to the function.
359
369
  */
360
- hourly<FuncRef extends SchedulableFunctionReference>(
370
+ hourly<FuncRef extends SchedulableFunctionReferenceCompat>(
361
371
  cronIdentifier: string,
362
372
  functionReference: FuncRef,
363
373
  ...args: OptionalRestArgs<FuncRef>
364
374
  ): void;
365
- hourly<FuncRef extends SchedulableFunctionReference>(
375
+ hourly<FuncRef extends SchedulableFunctionReferenceCompat>(
366
376
  cronIdentifier: string,
367
377
  schedule: Hourly,
368
378
  functionReference: FuncRef,
369
379
  ...args: OptionalRestArgs<FuncRef>
370
380
  ): void;
371
- hourly<FuncRef extends SchedulableFunctionReference>(
381
+ hourly<FuncRef extends SchedulableFunctionReferenceCompat>(
372
382
  cronIdentifier: string,
373
383
  scheduleOrFunctionReference: Hourly | FuncRef,
374
384
  functionReferenceOrArg?: FuncRef | Record<string, Value>,
@@ -414,11 +424,11 @@ export class Crons {
414
424
  *
415
425
  * @param cronIdentifier - A unique name for this scheduled job.
416
426
  * @param schedule - What time (UTC) each day to run this function.
417
- * @param functionReference - A {@link FunctionReference} for the function
418
- * to schedule.
427
+ * @param functionReference - A {@link FunctionReference} or
428
+ * {@link FunctionReference_future} for the function to schedule.
419
429
  * @param args - The arguments to the function.
420
430
  */
421
- daily<FuncRef extends SchedulableFunctionReference>(
431
+ daily<FuncRef extends SchedulableFunctionReferenceCompat>(
422
432
  cronIdentifier: string,
423
433
  schedule: Daily,
424
434
  functionReference: FuncRef,
@@ -453,10 +463,10 @@ export class Crons {
453
463
  *
454
464
  * @param cronIdentifier - A unique name for this scheduled job.
455
465
  * @param schedule - What day and time (UTC) each week to run this function.
456
- * @param functionReference - A {@link FunctionReference} for the function
457
- * to schedule.
466
+ * @param functionReference - A {@link FunctionReference} or
467
+ * {@link FunctionReference_future} for the function to schedule.
458
468
  */
459
- weekly<FuncRef extends SchedulableFunctionReference>(
469
+ weekly<FuncRef extends SchedulableFunctionReferenceCompat>(
460
470
  cronIdentifier: string,
461
471
  schedule: Weekly,
462
472
  functionReference: FuncRef,
@@ -495,11 +505,11 @@ export class Crons {
495
505
  *
496
506
  * @param cronIdentifier - A unique name for this scheduled job.
497
507
  * @param schedule - What day and time (UTC) each month to run this function.
498
- * @param functionReference - A {@link FunctionReference} for the function
499
- * to schedule.
508
+ * @param functionReference - A {@link FunctionReference} or
509
+ * {@link FunctionReference_future} for the function to schedule.
500
510
  * @param args - The arguments to the function.
501
511
  */
502
- monthly<FuncRef extends SchedulableFunctionReference>(
512
+ monthly<FuncRef extends SchedulableFunctionReferenceCompat>(
503
513
  cronIdentifier: string,
504
514
  schedule: Monthly,
505
515
  functionReference: FuncRef,
@@ -534,11 +544,11 @@ export class Crons {
534
544
  *
535
545
  * @param cronIdentifier - A unique name for this scheduled job.
536
546
  * @param cron - Cron string like `"15 7 * * *"` (Every day at 7:15 UTC)
537
- * @param functionReference - A {@link FunctionReference} for the function
538
- * to schedule.
547
+ * @param functionReference - A {@link FunctionReference} or
548
+ * {@link FunctionReference_future} for the function to schedule.
539
549
  * @param args - The arguments to the function.
540
550
  */
541
- cron<FuncRef extends SchedulableFunctionReference>(
551
+ cron<FuncRef extends SchedulableFunctionReferenceCompat>(
542
552
  cronIdentifier: string,
543
553
  cron: CronString,
544
554
  functionReference: FuncRef,
@@ -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(
@@ -55,26 +64,46 @@ export function setupActionCalls(requestId: string) {
55
64
  };
56
65
  }
57
66
 
67
+ /**
68
+ * A Convex-managed service. The backend decides which names it accepts; this
69
+ * type lists the ones the current release knows about.
70
+ */
71
+ export type ServiceName = "ai-gateway";
72
+
58
73
  /**
59
74
  * Get a short-lived credential for calling a Convex-managed service.
60
75
  *
61
76
  * This function can only be called while an action is running. The credential
62
77
  * is scoped to the current deployment and should be sent as a bearer token.
63
- * Repeated calls in the same action reuse one token; a failed mint is not
64
- * cached, so a later call retries.
78
+ * The action runtime caches and refreshes credentials as needed, so call
79
+ * this function whenever making a service request.
65
80
  *
66
81
  * @param service - The service the credential may access.
67
82
  * @returns A JWT to send as `Authorization: Bearer <token>`. Keep it inside
68
83
  * the action: don't return it to clients or store it in environment
69
84
  * variables.
70
85
  */
71
- export async function getServiceToken(service: "ai-gateway"): Promise<string> {
86
+ export async function getServiceToken(service: ServiceName): Promise<string> {
72
87
  validateArg(service, 1, "getServiceToken", "service");
73
- if (service !== "ai-gateway") {
74
- throw new Error(`Unsupported service "${String(service)}"`);
75
- }
76
88
  return await performAsyncSyscall("1.0/createServiceToken", {
77
89
  service,
78
90
  version,
79
91
  });
80
92
  }
93
+
94
+ /**
95
+ * Get the base URL of a Convex-managed service.
96
+ *
97
+ * This function can only be called while an action is running. Pair it with
98
+ * {@link getServiceToken} to reach the service.
99
+ *
100
+ * @param service - The service to address.
101
+ * @returns The service's origin, without a trailing slash.
102
+ */
103
+ export async function getServiceUrl(service: ServiceName): Promise<string> {
104
+ validateArg(service, 1, "getServiceUrl", "service");
105
+ return await performAsyncSyscall("1.0/getServiceUrl", {
106
+ service,
107
+ version,
108
+ });
109
+ }
@@ -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;