convex 1.45.0 → 1.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (319) hide show
  1. package/CHANGELOG.md +48 -6
  2. package/dist/browser.bundle.js +1 -1
  3. package/dist/browser.bundle.js.map +2 -2
  4. package/dist/cjs/browser/http_client.js.map +2 -2
  5. package/dist/cjs/browser/query_options.js.map +2 -2
  6. package/dist/cjs/browser/simple_client.js.map +2 -2
  7. package/dist/cjs/browser/sync/optimistic_updates.js.map +1 -1
  8. package/dist/cjs/browser/sync/optimistic_updates_impl.js.map +2 -2
  9. package/dist/cjs/cli/codegen.js +2 -0
  10. package/dist/cjs/cli/codegen.js.map +2 -2
  11. package/dist/cjs/cli/deploy.js +1 -0
  12. package/dist/cjs/cli/deploy.js.map +2 -2
  13. package/dist/cjs/cli/docs.js +3 -36
  14. package/dist/cjs/cli/docs.js.map +2 -2
  15. package/dist/cjs/cli/lib/checkForLargeIndexDeletion.js +101 -60
  16. package/dist/cjs/cli/lib/checkForLargeIndexDeletion.js.map +2 -2
  17. package/dist/cjs/cli/lib/checkForSlowSchemaValidation.js +107 -0
  18. package/dist/cjs/cli/lib/checkForSlowSchemaValidation.js.map +7 -0
  19. package/dist/cjs/cli/lib/codegen.js.map +2 -2
  20. package/dist/cjs/cli/lib/components.js +12 -0
  21. package/dist/cjs/cli/lib/components.js.map +2 -2
  22. package/dist/cjs/cli/lib/deploy2.js +29 -2
  23. package/dist/cjs/cli/lib/deploy2.js.map +2 -2
  24. package/dist/cjs/cli/lib/deployApi/evaluateSchema.js +73 -0
  25. package/dist/cjs/cli/lib/deployApi/evaluateSchema.js.map +7 -0
  26. package/dist/cjs/cli/lib/deployApi/finishPush.js +1 -0
  27. package/dist/cjs/cli/lib/deployApi/finishPush.js.map +2 -2
  28. package/dist/cjs/cli/lib/deployApi/startPush.js +1 -1
  29. package/dist/cjs/cli/lib/deployApi/startPush.js.map +2 -2
  30. package/dist/cjs/cli/lib/dev.js +1 -0
  31. package/dist/cjs/cli/lib/dev.js.map +2 -2
  32. package/dist/cjs/cli/lib/generatedFunctionLogsApi.js.map +1 -1
  33. package/dist/cjs/cli/lib/localDeployment/run.js +30 -1
  34. package/dist/cjs/cli/lib/localDeployment/run.js.map +2 -2
  35. package/dist/cjs/cli/lib/localDeployment/upgrade.js +6 -5
  36. package/dist/cjs/cli/lib/localDeployment/upgrade.js.map +2 -2
  37. package/dist/cjs/cli/lib/localDeployment/utils.js +5 -1
  38. package/dist/cjs/cli/lib/localDeployment/utils.js.map +2 -2
  39. package/dist/cjs/cli/lib/run.js +1 -0
  40. package/dist/cjs/cli/lib/run.js.map +2 -2
  41. package/dist/cjs/cli/lib/utils/utils.js +36 -29
  42. package/dist/cjs/cli/lib/utils/utils.js.map +2 -2
  43. package/dist/cjs/index.js +1 -1
  44. package/dist/cjs/index.js.map +1 -1
  45. package/dist/cjs/nextjs/index.js.map +2 -2
  46. package/dist/cjs/react/client.js.map +2 -2
  47. package/dist/cjs/react/hydration.js.map +2 -2
  48. package/dist/cjs/react/queries_observer.js.map +2 -2
  49. package/dist/cjs/react/use_paginated_query2.js.map +2 -2
  50. package/dist/cjs/react/use_queries.js.map +2 -2
  51. package/dist/cjs/server/api.js.map +2 -2
  52. package/dist/cjs/server/components/index.js.map +2 -2
  53. package/dist/cjs/server/cron.js +10 -10
  54. package/dist/cjs/server/cron.js.map +2 -2
  55. package/dist/cjs/server/impl/actions_impl.js.map +2 -2
  56. package/dist/cjs/server/impl/meta_impl.js +8 -2
  57. package/dist/cjs/server/impl/meta_impl.js.map +2 -2
  58. package/dist/cjs/server/impl/scheduler_impl.js.map +2 -2
  59. package/dist/cjs/server/index.js.map +2 -2
  60. package/dist/cjs/server/meta.js.map +1 -1
  61. package/dist/cjs/server/registration.js.map +1 -1
  62. package/dist/cjs/server/scheduler.js.map +1 -1
  63. package/dist/cjs/server/schema.js +50 -3
  64. package/dist/cjs/server/schema.js.map +2 -2
  65. package/dist/cjs/values/validator.js +1 -1
  66. package/dist/cjs/values/validator.js.map +2 -2
  67. package/dist/cjs/values/validators.js +81 -25
  68. package/dist/cjs/values/validators.js.map +2 -2
  69. package/dist/cjs-types/browser/http_client.d.ts +5 -5
  70. package/dist/cjs-types/browser/http_client.d.ts.map +1 -1
  71. package/dist/cjs-types/browser/query_options.d.ts +2 -2
  72. package/dist/cjs-types/browser/query_options.d.ts.map +1 -1
  73. package/dist/cjs-types/browser/simple_client.d.ts +6 -6
  74. package/dist/cjs-types/browser/simple_client.d.ts.map +1 -1
  75. package/dist/cjs-types/browser/sync/optimistic_updates.d.ts +4 -4
  76. package/dist/cjs-types/browser/sync/optimistic_updates.d.ts.map +1 -1
  77. package/dist/cjs-types/browser/sync/optimistic_updates_impl.d.ts.map +1 -1
  78. package/dist/cjs-types/cli/codegen.d.ts.map +1 -1
  79. package/dist/cjs-types/cli/docs.d.ts.map +1 -1
  80. package/dist/cjs-types/cli/lib/checkForLargeIndexDeletion.d.ts +26 -5
  81. package/dist/cjs-types/cli/lib/checkForLargeIndexDeletion.d.ts.map +1 -1
  82. package/dist/cjs-types/cli/lib/checkForSlowSchemaValidation.d.ts +14 -0
  83. package/dist/cjs-types/cli/lib/checkForSlowSchemaValidation.d.ts.map +1 -0
  84. package/dist/cjs-types/cli/lib/codegen.d.ts +1 -0
  85. package/dist/cjs-types/cli/lib/codegen.d.ts.map +1 -1
  86. package/dist/cjs-types/cli/lib/components.d.ts +1 -0
  87. package/dist/cjs-types/cli/lib/components.d.ts.map +1 -1
  88. package/dist/cjs-types/cli/lib/deploy2.d.ts +6 -0
  89. package/dist/cjs-types/cli/lib/deploy2.d.ts.map +1 -1
  90. package/dist/cjs-types/cli/lib/deployApi/evaluateSchema.d.ts +453 -0
  91. package/dist/cjs-types/cli/lib/deployApi/evaluateSchema.d.ts.map +1 -0
  92. package/dist/cjs-types/cli/lib/deployApi/finishPush.d.ts +1 -2
  93. package/dist/cjs-types/cli/lib/deployApi/finishPush.d.ts.map +1 -1
  94. package/dist/cjs-types/cli/lib/dev.d.ts.map +1 -1
  95. package/dist/cjs-types/cli/lib/generatedFunctionLogsApi.d.ts +2 -0
  96. package/dist/cjs-types/cli/lib/generatedFunctionLogsApi.d.ts.map +1 -1
  97. package/dist/cjs-types/cli/lib/localDeployment/run.d.ts +2 -0
  98. package/dist/cjs-types/cli/lib/localDeployment/run.d.ts.map +1 -1
  99. package/dist/cjs-types/cli/lib/localDeployment/upgrade.d.ts.map +1 -1
  100. package/dist/cjs-types/cli/lib/localDeployment/utils.d.ts +1 -0
  101. package/dist/cjs-types/cli/lib/localDeployment/utils.d.ts.map +1 -1
  102. package/dist/cjs-types/cli/lib/run.d.ts.map +1 -1
  103. package/dist/cjs-types/cli/lib/utils/utils.d.ts +5 -5
  104. package/dist/cjs-types/cli/lib/utils/utils.d.ts.map +1 -1
  105. package/dist/cjs-types/index.d.ts +1 -1
  106. package/dist/cjs-types/nextjs/index.d.ts +6 -6
  107. package/dist/cjs-types/nextjs/index.d.ts.map +1 -1
  108. package/dist/cjs-types/react/client.d.ts +15 -15
  109. package/dist/cjs-types/react/client.d.ts.map +1 -1
  110. package/dist/cjs-types/react/hydration.d.ts +3 -3
  111. package/dist/cjs-types/react/hydration.d.ts.map +1 -1
  112. package/dist/cjs-types/react/queries_observer.d.ts +9 -9
  113. package/dist/cjs-types/react/queries_observer.d.ts.map +1 -1
  114. package/dist/cjs-types/react/use_paginated_query2.d.ts.map +1 -1
  115. package/dist/cjs-types/react/use_queries.d.ts +14 -6
  116. package/dist/cjs-types/react/use_queries.d.ts.map +1 -1
  117. package/dist/cjs-types/server/api.d.ts +157 -7
  118. package/dist/cjs-types/server/api.d.ts.map +1 -1
  119. package/dist/cjs-types/server/components/index.d.ts +2 -2
  120. package/dist/cjs-types/server/components/index.d.ts.map +1 -1
  121. package/dist/cjs-types/server/cron.d.ts +21 -20
  122. package/dist/cjs-types/server/cron.d.ts.map +1 -1
  123. package/dist/cjs-types/server/impl/actions_impl.d.ts +4 -4
  124. package/dist/cjs-types/server/impl/actions_impl.d.ts.map +1 -1
  125. package/dist/cjs-types/server/impl/meta_impl.d.ts.map +1 -1
  126. package/dist/cjs-types/server/impl/scheduler_impl.d.ts.map +1 -1
  127. package/dist/cjs-types/server/index.d.ts +1 -1
  128. package/dist/cjs-types/server/index.d.ts.map +1 -1
  129. package/dist/cjs-types/server/meta.d.ts.map +1 -1
  130. package/dist/cjs-types/server/registration.d.ts +7 -7
  131. package/dist/cjs-types/server/registration.d.ts.map +1 -1
  132. package/dist/cjs-types/server/scheduler.d.ts +9 -7
  133. package/dist/cjs-types/server/scheduler.d.ts.map +1 -1
  134. package/dist/cjs-types/server/schema.d.ts +1 -0
  135. package/dist/cjs-types/server/schema.d.ts.map +1 -1
  136. package/dist/cjs-types/values/validator.d.ts.map +1 -1
  137. package/dist/cjs-types/values/validators.d.ts +30 -0
  138. package/dist/cjs-types/values/validators.d.ts.map +1 -1
  139. package/dist/cli.bundle.cjs +347 -133
  140. package/dist/cli.bundle.cjs.map +4 -4
  141. package/dist/esm/browser/http_client.js.map +2 -2
  142. package/dist/esm/browser/query_options.js.map +2 -2
  143. package/dist/esm/browser/simple_client.js.map +2 -2
  144. package/dist/esm/browser/sync/optimistic_updates_impl.js.map +2 -2
  145. package/dist/esm/cli/codegen.js +2 -0
  146. package/dist/esm/cli/codegen.js.map +2 -2
  147. package/dist/esm/cli/deploy.js +1 -0
  148. package/dist/esm/cli/deploy.js.map +2 -2
  149. package/dist/esm/cli/docs.js +3 -43
  150. package/dist/esm/cli/docs.js.map +2 -2
  151. package/dist/esm/cli/lib/checkForLargeIndexDeletion.js +100 -60
  152. package/dist/esm/cli/lib/checkForLargeIndexDeletion.js.map +2 -2
  153. package/dist/esm/cli/lib/checkForSlowSchemaValidation.js +85 -0
  154. package/dist/esm/cli/lib/checkForSlowSchemaValidation.js.map +7 -0
  155. package/dist/esm/cli/lib/codegen.js.map +2 -2
  156. package/dist/esm/cli/lib/components.js +12 -0
  157. package/dist/esm/cli/lib/components.js.map +2 -2
  158. package/dist/esm/cli/lib/deploy2.js +30 -2
  159. package/dist/esm/cli/lib/deploy2.js.map +2 -2
  160. package/dist/esm/cli/lib/deployApi/evaluateSchema.js +46 -0
  161. package/dist/esm/cli/lib/deployApi/evaluateSchema.js.map +7 -0
  162. package/dist/esm/cli/lib/deployApi/finishPush.js +1 -1
  163. package/dist/esm/cli/lib/deployApi/finishPush.js.map +2 -2
  164. package/dist/esm/cli/lib/deployApi/startPush.js +1 -1
  165. package/dist/esm/cli/lib/deployApi/startPush.js.map +2 -2
  166. package/dist/esm/cli/lib/dev.js +1 -0
  167. package/dist/esm/cli/lib/dev.js.map +2 -2
  168. package/dist/esm/cli/lib/localDeployment/run.js +30 -2
  169. package/dist/esm/cli/lib/localDeployment/run.js.map +2 -2
  170. package/dist/esm/cli/lib/localDeployment/upgrade.js +4 -3
  171. package/dist/esm/cli/lib/localDeployment/upgrade.js.map +2 -2
  172. package/dist/esm/cli/lib/localDeployment/utils.js +3 -0
  173. package/dist/esm/cli/lib/localDeployment/utils.js.map +2 -2
  174. package/dist/esm/cli/lib/run.js +1 -0
  175. package/dist/esm/cli/lib/run.js.map +2 -2
  176. package/dist/esm/cli/lib/utils/utils.js +36 -30
  177. package/dist/esm/cli/lib/utils/utils.js.map +2 -2
  178. package/dist/esm/index.js +1 -1
  179. package/dist/esm/index.js.map +1 -1
  180. package/dist/esm/nextjs/index.js.map +2 -2
  181. package/dist/esm/react/client.js.map +2 -2
  182. package/dist/esm/react/hydration.js +3 -1
  183. package/dist/esm/react/hydration.js.map +2 -2
  184. package/dist/esm/react/queries_observer.js +3 -1
  185. package/dist/esm/react/queries_observer.js.map +2 -2
  186. package/dist/esm/react/use_paginated_query2.js +3 -1
  187. package/dist/esm/react/use_paginated_query2.js.map +2 -2
  188. package/dist/esm/react/use_queries.js.map +2 -2
  189. package/dist/esm/server/api.js.map +2 -2
  190. package/dist/esm/server/components/index.js.map +2 -2
  191. package/dist/esm/server/cron.js +13 -11
  192. package/dist/esm/server/cron.js.map +2 -2
  193. package/dist/esm/server/impl/actions_impl.js.map +2 -2
  194. package/dist/esm/server/impl/meta_impl.js +9 -3
  195. package/dist/esm/server/impl/meta_impl.js.map +2 -2
  196. package/dist/esm/server/impl/scheduler_impl.js.map +2 -2
  197. package/dist/esm/server/index.js.map +2 -2
  198. package/dist/esm/server/schema.js +50 -3
  199. package/dist/esm/server/schema.js.map +2 -2
  200. package/dist/esm/values/validator.js +1 -1
  201. package/dist/esm/values/validator.js.map +2 -2
  202. package/dist/esm/values/validators.js +81 -25
  203. package/dist/esm/values/validators.js.map +2 -2
  204. package/dist/esm-types/browser/http_client.d.ts +5 -5
  205. package/dist/esm-types/browser/http_client.d.ts.map +1 -1
  206. package/dist/esm-types/browser/query_options.d.ts +2 -2
  207. package/dist/esm-types/browser/query_options.d.ts.map +1 -1
  208. package/dist/esm-types/browser/simple_client.d.ts +6 -6
  209. package/dist/esm-types/browser/simple_client.d.ts.map +1 -1
  210. package/dist/esm-types/browser/sync/optimistic_updates.d.ts +4 -4
  211. package/dist/esm-types/browser/sync/optimistic_updates.d.ts.map +1 -1
  212. package/dist/esm-types/browser/sync/optimistic_updates_impl.d.ts.map +1 -1
  213. package/dist/esm-types/cli/codegen.d.ts.map +1 -1
  214. package/dist/esm-types/cli/docs.d.ts.map +1 -1
  215. package/dist/esm-types/cli/lib/checkForLargeIndexDeletion.d.ts +26 -5
  216. package/dist/esm-types/cli/lib/checkForLargeIndexDeletion.d.ts.map +1 -1
  217. package/dist/esm-types/cli/lib/checkForSlowSchemaValidation.d.ts +14 -0
  218. package/dist/esm-types/cli/lib/checkForSlowSchemaValidation.d.ts.map +1 -0
  219. package/dist/esm-types/cli/lib/codegen.d.ts +1 -0
  220. package/dist/esm-types/cli/lib/codegen.d.ts.map +1 -1
  221. package/dist/esm-types/cli/lib/components.d.ts +1 -0
  222. package/dist/esm-types/cli/lib/components.d.ts.map +1 -1
  223. package/dist/esm-types/cli/lib/deploy2.d.ts +6 -0
  224. package/dist/esm-types/cli/lib/deploy2.d.ts.map +1 -1
  225. package/dist/esm-types/cli/lib/deployApi/evaluateSchema.d.ts +453 -0
  226. package/dist/esm-types/cli/lib/deployApi/evaluateSchema.d.ts.map +1 -0
  227. package/dist/esm-types/cli/lib/deployApi/finishPush.d.ts +1 -2
  228. package/dist/esm-types/cli/lib/deployApi/finishPush.d.ts.map +1 -1
  229. package/dist/esm-types/cli/lib/dev.d.ts.map +1 -1
  230. package/dist/esm-types/cli/lib/generatedFunctionLogsApi.d.ts +2 -0
  231. package/dist/esm-types/cli/lib/generatedFunctionLogsApi.d.ts.map +1 -1
  232. package/dist/esm-types/cli/lib/localDeployment/run.d.ts +2 -0
  233. package/dist/esm-types/cli/lib/localDeployment/run.d.ts.map +1 -1
  234. package/dist/esm-types/cli/lib/localDeployment/upgrade.d.ts.map +1 -1
  235. package/dist/esm-types/cli/lib/localDeployment/utils.d.ts +1 -0
  236. package/dist/esm-types/cli/lib/localDeployment/utils.d.ts.map +1 -1
  237. package/dist/esm-types/cli/lib/run.d.ts.map +1 -1
  238. package/dist/esm-types/cli/lib/utils/utils.d.ts +5 -5
  239. package/dist/esm-types/cli/lib/utils/utils.d.ts.map +1 -1
  240. package/dist/esm-types/index.d.ts +1 -1
  241. package/dist/esm-types/nextjs/index.d.ts +6 -6
  242. package/dist/esm-types/nextjs/index.d.ts.map +1 -1
  243. package/dist/esm-types/react/client.d.ts +15 -15
  244. package/dist/esm-types/react/client.d.ts.map +1 -1
  245. package/dist/esm-types/react/hydration.d.ts +3 -3
  246. package/dist/esm-types/react/hydration.d.ts.map +1 -1
  247. package/dist/esm-types/react/queries_observer.d.ts +9 -9
  248. package/dist/esm-types/react/queries_observer.d.ts.map +1 -1
  249. package/dist/esm-types/react/use_paginated_query2.d.ts.map +1 -1
  250. package/dist/esm-types/react/use_queries.d.ts +14 -6
  251. package/dist/esm-types/react/use_queries.d.ts.map +1 -1
  252. package/dist/esm-types/server/api.d.ts +157 -7
  253. package/dist/esm-types/server/api.d.ts.map +1 -1
  254. package/dist/esm-types/server/components/index.d.ts +2 -2
  255. package/dist/esm-types/server/components/index.d.ts.map +1 -1
  256. package/dist/esm-types/server/cron.d.ts +21 -20
  257. package/dist/esm-types/server/cron.d.ts.map +1 -1
  258. package/dist/esm-types/server/impl/actions_impl.d.ts +4 -4
  259. package/dist/esm-types/server/impl/actions_impl.d.ts.map +1 -1
  260. package/dist/esm-types/server/impl/meta_impl.d.ts.map +1 -1
  261. package/dist/esm-types/server/impl/scheduler_impl.d.ts.map +1 -1
  262. package/dist/esm-types/server/index.d.ts +1 -1
  263. package/dist/esm-types/server/index.d.ts.map +1 -1
  264. package/dist/esm-types/server/meta.d.ts.map +1 -1
  265. package/dist/esm-types/server/registration.d.ts +7 -7
  266. package/dist/esm-types/server/registration.d.ts.map +1 -1
  267. package/dist/esm-types/server/scheduler.d.ts +9 -7
  268. package/dist/esm-types/server/scheduler.d.ts.map +1 -1
  269. package/dist/esm-types/server/schema.d.ts +1 -0
  270. package/dist/esm-types/server/schema.d.ts.map +1 -1
  271. package/dist/esm-types/values/validator.d.ts.map +1 -1
  272. package/dist/esm-types/values/validators.d.ts +30 -0
  273. package/dist/esm-types/values/validators.d.ts.map +1 -1
  274. package/dist/react.bundle.js +1 -1
  275. package/dist/react.bundle.js.map +2 -2
  276. package/package.json +5 -5
  277. package/src/browser/http_client.ts +43 -10
  278. package/src/browser/query_options.ts +11 -5
  279. package/src/browser/simple_client.ts +35 -14
  280. package/src/browser/sync/optimistic_updates.ts +17 -4
  281. package/src/browser/sync/optimistic_updates_impl.ts +17 -4
  282. package/src/cli/codegen.ts +1 -0
  283. package/src/cli/deploy.ts +1 -0
  284. package/src/cli/docs.ts +3 -44
  285. package/src/cli/lib/checkForLargeIndexDeletion.ts +154 -82
  286. package/src/cli/lib/checkForSlowSchemaValidation.ts +130 -0
  287. package/src/cli/lib/codegen.ts +1 -0
  288. package/src/cli/lib/components.ts +17 -0
  289. package/src/cli/lib/deploy2.ts +56 -1
  290. package/src/cli/lib/deployApi/evaluateSchema.ts +62 -0
  291. package/src/cli/lib/deployApi/finishPush.ts +1 -1
  292. package/src/cli/lib/deployApi/startPush.ts +1 -1
  293. package/src/cli/lib/dev.ts +1 -0
  294. package/src/cli/lib/generatedFunctionLogsApi.ts +2 -0
  295. package/src/cli/lib/localDeployment/run.ts +44 -2
  296. package/src/cli/lib/localDeployment/upgrade.ts +4 -6
  297. package/src/cli/lib/localDeployment/utils.ts +6 -0
  298. package/src/cli/lib/run.ts +1 -0
  299. package/src/cli/lib/utils/utils.ts +63 -35
  300. package/src/index.ts +1 -1
  301. package/src/nextjs/index.ts +19 -8
  302. package/src/react/client.ts +73 -30
  303. package/src/react/hydration.tsx +14 -6
  304. package/src/react/queries_observer.ts +19 -16
  305. package/src/react/use_paginated_query2.ts +10 -6
  306. package/src/react/use_queries.ts +23 -7
  307. package/src/server/api.ts +220 -14
  308. package/src/server/components/index.ts +4 -6
  309. package/src/server/cron.ts +34 -24
  310. package/src/server/impl/actions_impl.ts +13 -4
  311. package/src/server/impl/meta_impl.ts +8 -1
  312. package/src/server/impl/scheduler_impl.ts +13 -6
  313. package/src/server/index.ts +1 -0
  314. package/src/server/meta.ts +25 -0
  315. package/src/server/registration.ts +28 -7
  316. package/src/server/scheduler.ts +22 -7
  317. package/src/server/schema.ts +55 -0
  318. package/src/values/validator.ts +3 -1
  319. package/src/values/validators.ts +84 -26
@@ -1,15 +1,27 @@
1
1
  import { convexToJson, Value } from "../values/index.js";
2
2
  import { PaginatedWatch, Watch } from "./client.js";
3
3
  import { QueryJournal } from "../browser/sync/protocol.js";
4
- import { FunctionReference, getFunctionName } from "../server/api.js";
5
- import { RequestForQueries } from "./use_queries.js";
4
+ import {
5
+ getFunctionName,
6
+ FunctionReference,
7
+ FunctionReference_future,
8
+ } from "../server/api.js";
6
9
  import { PaginatedQueryResult } from "../browser/sync/pagination.js";
7
10
  import { SubscribeToPaginatedQueryOptions } from "../browser/sync/paginated_query_client.js";
8
11
 
9
12
  type Identifier = string;
10
13
 
14
+ type RequestForQueriesCompat = Record<
15
+ Identifier,
16
+ {
17
+ query: FunctionReference<"query"> | FunctionReference_future<"query">;
18
+ args: Record<string, Value>;
19
+ paginationOptions?: SubscribeToPaginatedQueryOptions;
20
+ }
21
+ >;
22
+
11
23
  type QueryInfo = {
12
- query: FunctionReference<"query">;
24
+ query: FunctionReference<"query"> | FunctionReference_future<"query">;
13
25
  args: Record<string, Value>;
14
26
  watch: Watch<Value> | PaginatedWatch<Value>;
15
27
  unsubscribe: () => void;
@@ -18,7 +30,7 @@ type QueryInfo = {
18
30
 
19
31
  export interface CreateWatch {
20
32
  (
21
- query: FunctionReference<"query">,
33
+ query: FunctionReference<"query"> | FunctionReference_future<"query">,
22
34
  args: Record<string, Value>,
23
35
  options: {
24
36
  journal?: QueryJournal;
@@ -44,16 +56,7 @@ export class QueriesObserver {
44
56
  this.listeners = new Set();
45
57
  }
46
58
 
47
- setQueries(
48
- newQueries: Record<
49
- Identifier,
50
- {
51
- query: FunctionReference<"query">;
52
- args: Record<string, Value>;
53
- paginationOptions?: SubscribeToPaginatedQueryOptions;
54
- }
55
- >,
56
- ) {
59
+ setQueries(newQueries: RequestForQueriesCompat) {
57
60
  // Add the new queries before unsubscribing from the old ones so that
58
61
  // the deduping in the `ConvexReactClient` can help if there are duplicates.
59
62
  for (const identifier of Object.keys(newQueries)) {
@@ -107,7 +110,7 @@ export class QueriesObserver {
107
110
  }
108
111
 
109
112
  getLocalResults(
110
- queries: RequestForQueries,
113
+ queries: RequestForQueriesCompat,
111
114
  ): Record<
112
115
  Identifier,
113
116
  Value | undefined | Error | PaginatedQueryResult<Value>
@@ -173,7 +176,7 @@ export class QueriesObserver {
173
176
 
174
177
  private addQuery(
175
178
  identifier: Identifier,
176
- query: FunctionReference<"query">,
179
+ query: FunctionReference<"query"> | FunctionReference_future<"query">,
177
180
  args: Record<string, Value>,
178
181
  {
179
182
  paginationOptions,
@@ -1,6 +1,10 @@
1
1
  import { useState } from "react";
2
2
 
3
- import { FunctionReference, getFunctionName } from "../server/api.js";
3
+ import {
4
+ FunctionReference,
5
+ FunctionReturnType,
6
+ getFunctionName,
7
+ } from "../server/api.js";
4
8
  import {
5
9
  PaginatedQueryReference,
6
10
  PaginatedQueryArgs,
@@ -255,7 +259,7 @@ export function usePaginatedQuery_experimental<
255
259
  throw new Error("Why is it missing?");
256
260
  }
257
261
  const internalResult = {
258
- results: [] as Query["_returnType"]["page"],
262
+ results: [] as FunctionReturnType<Query>["page"],
259
263
  status: "LoadingFirstPage" as const,
260
264
  isLoading: true as const,
261
265
  loadMore: function skipNOP(_numItems: number) {
@@ -270,7 +274,7 @@ export function usePaginatedQuery_experimental<
270
274
  return internalResult as unknown as UsePaginatedQueryReturnType<Query>;
271
275
  }
272
276
  const result = resultsObject.paginatedQuery as
273
- | PaginatedQueryResult<Query["_returnType"]["page"][number]>
277
+ | PaginatedQueryResult<FunctionReturnType<Query>["page"][number]>
274
278
  | Error;
275
279
 
276
280
  // TODO this is a weird mix of responsibilities:
@@ -279,7 +283,7 @@ export function usePaginatedQuery_experimental<
279
283
  // It comes back to why we'd ever get undefined when asking about a query; have we not yet called subscribe for it?
280
284
  if (result === undefined) {
281
285
  const internalResult = {
282
- results: [] as Query["_returnType"]["page"],
286
+ results: [] as FunctionReturnType<Query>["page"],
283
287
  loadMore: () => false,
284
288
  isLoading: true as const,
285
289
  status: "LoadingFirstPage" as const,
@@ -313,7 +317,7 @@ export function usePaginatedQuery_experimental<
313
317
  );
314
318
  setState(createInitialState);
315
319
  const internalResult = {
316
- results: [] as Query["_returnType"]["page"],
320
+ results: [] as FunctionReturnType<Query>["page"],
317
321
  loadMore: () => false,
318
322
  isLoading: true as const,
319
323
  status: "LoadingFirstPage" as const,
@@ -329,7 +333,7 @@ export function usePaginatedQuery_experimental<
329
333
  throw result;
330
334
  }
331
335
  const internalResult = {
332
- results: [] as Query["_returnType"]["page"],
336
+ results: [] as FunctionReturnType<Query>["page"],
333
337
  loadMore: () => false,
334
338
  isLoading: false as const,
335
339
  status: "Error" as const,
@@ -4,7 +4,7 @@ import { useConvex } from "./client.js";
4
4
  import { CreateWatch, QueriesObserver } from "./queries_observer.js";
5
5
  import { useSubscription } from "./use_subscription.js";
6
6
  import { QueryJournal } from "../browser/index.js";
7
- import { FunctionReference } from "../server/api.js";
7
+ import { FunctionReference, FunctionReference_future } from "../server/api.js";
8
8
  import { SubscribeToPaginatedQueryOptions } from "../browser/sync/paginated_query_client.js";
9
9
 
10
10
  /**
@@ -15,9 +15,10 @@ import { SubscribeToPaginatedQueryOptions } from "../browser/sync/paginated_quer
15
15
  * of queries without violating the rules of React hooks.
16
16
  *
17
17
  * This hook accepts an object whose keys are identifiers for each query and the
18
- * values are objects of `{ query: FunctionReference, args: Record<string, Value> }`. The
19
- * `query` is a FunctionReference for the Convex query function to load, and the `args` are
20
- * the arguments to that function.
18
+ * values are objects of
19
+ * `{ query: FunctionReference | FunctionReference_future, args: Record<string, Value> }`.
20
+ * The `query` is a reference to the Convex query function to load, and the
21
+ * `args` are the arguments to that function.
21
22
  *
22
23
  * The hook returns an object that maps each identifier to the result of the query,
23
24
  * `undefined` if the query is still loading, or an instance of `Error` if the query
@@ -59,7 +60,7 @@ import { SubscribeToPaginatedQueryOptions } from "../browser/sync/paginated_quer
59
60
  * @public
60
61
  */
61
62
  export function useQueries(
62
- queries: RequestForQueries,
63
+ queries: RequestForQueriesCompat,
63
64
  ): Record<string, any | undefined | Error> {
64
65
  const convex = useConvex();
65
66
  if (convex === undefined) {
@@ -73,7 +74,7 @@ export function useQueries(
73
74
  }
74
75
  const createWatch = useMemo(() => {
75
76
  return (
76
- query: FunctionReference<"query">,
77
+ query: FunctionReference<"query"> | FunctionReference_future<"query">,
77
78
  args: Record<string, Value>,
78
79
  {
79
80
  journal,
@@ -97,7 +98,7 @@ export function useQueries(
97
98
  * Internal version of `useQueries` that is exported for testing.
98
99
  */
99
100
  export function useQueriesHelper(
100
- queries: RequestForQueries,
101
+ queries: RequestForQueriesCompat,
101
102
  createWatch: CreateWatch,
102
103
  ): Record<string, any | undefined | Error> {
103
104
  const [observer] = useState(() => new QueriesObserver(createWatch));
@@ -143,3 +144,18 @@ export type RequestForQueries = Record<
143
144
  paginationOptions?: SubscribeToPaginatedQueryOptions;
144
145
  }
145
146
  >;
147
+
148
+ // The `queries` parameter of `useQueries`: `RequestForQueries` with `query`
149
+ // also accepting a `FunctionReference_future`. The exported type stays a plain
150
+ // reference so that code reading a `query` out of one gets a
151
+ // `FunctionReference` it can forward anywhere. Module-local so that a
152
+ // consumer's declaration file inlines it rather than importing it from a path
153
+ // outside the package's public entry points.
154
+ type RequestForQueriesCompat = Record<
155
+ string,
156
+ {
157
+ query: FunctionReference<"query"> | FunctionReference_future<"query">;
158
+ args: Record<string, Value>;
159
+ paginationOptions?: SubscribeToPaginatedQueryOptions;
160
+ }
161
+ >;
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,