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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/server/index.ts"],
4
- "sourcesContent": ["/**\n * Utilities for implementing server-side Convex query and mutation functions.\n *\n * ## Usage\n *\n * ### Code Generation\n *\n * This module is typically used alongside generated server code.\n *\n * To generate the server code, run `npx convex dev` in your Convex project.\n * This will create a `convex/_generated/server.js` file with the following\n * functions, typed for your schema:\n * - [query](https://docs.convex.dev/generated-api/server#query)\n * - [mutation](https://docs.convex.dev/generated-api/server#mutation)\n *\n * If you aren't using TypeScript and code generation, you can use these untyped\n * functions instead:\n * - {@link queryGeneric}\n * - {@link mutationGeneric}\n *\n * ### Example\n *\n * Convex functions are defined by using either the `query` or\n * `mutation` wrappers.\n *\n * Queries receive a `db` that implements the {@link GenericDatabaseReader} interface.\n *\n * ```js\n * import { query } from \"./_generated/server\";\n *\n * export default query({\n * handler: async ({ db }, { arg1, arg2 }) => {\n * // Your (read-only) code here!\n * },\n * });\n * ```\n *\n * If your function needs to write to the database, such as inserting, updating,\n * or deleting documents, use `mutation` instead which provides a `db` that\n * implements the {@link GenericDatabaseWriter} interface.\n *\n * ```js\n * import { mutation } from \"./_generated/server\";\n *\n * export default mutation({\n * handler: async ({ db }, { arg1, arg2 }) => {\n * // Your mutation code here!\n * },\n * });\n * ```\n * @module\n */\n\nexport type {\n Auth,\n AuthConfig,\n AuthProvider,\n UserIdentity,\n UserIdentityAttributes,\n} from \"./authentication.js\";\nexport * from \"./database.js\";\nexport type {\n GenericDocument,\n GenericFieldPaths,\n GenericIndexFields,\n GenericTableIndexes,\n GenericSearchIndexConfig,\n GenericTableSearchIndexes,\n GenericVectorIndexConfig,\n GenericTableVectorIndexes,\n FieldTypeFromFieldPath,\n FieldTypeFromFieldPathInner,\n GenericTableInfo,\n DocumentByInfo,\n FieldPaths,\n Indexes,\n IndexNames,\n NamedIndex,\n SearchIndexes,\n SearchIndexNames,\n NamedSearchIndex,\n VectorIndexes,\n VectorIndexNames,\n NamedVectorIndex,\n GenericDataModel,\n AnyDataModel,\n TableNamesInDataModel,\n NamedTableInfo,\n DocumentByName,\n} from \"./data_model.js\";\n\nexport type {\n Expression,\n ExpressionOrValue,\n FilterBuilder,\n} from \"./filter_builder.js\";\nexport {\n actionGeneric,\n httpActionGeneric,\n mutationGeneric,\n queryGeneric,\n internalActionGeneric,\n internalMutationGeneric,\n internalQueryGeneric,\n} from \"./impl/registration_impl.js\";\nexport { getServiceToken } from \"./impl/actions_impl.js\";\nexport type {\n TransactionMetric,\n TransactionMetrics,\n TransactionLimits,\n FunctionMetadata,\n DeploymentMetadata,\n RequestMetadata,\n QueryMeta,\n MutationMeta,\n ActionMeta,\n} from \"./meta.js\";\nexport type { IndexRange, IndexRangeBuilder } from \"./index_range_builder.js\";\nexport * from \"./pagination.js\";\nexport type { OrderedQuery, Query, QueryInitializer } from \"./query.js\";\nexport type {\n AdvancedRunQueryOptions,\n ArgsArray,\n DefaultFunctionArgs,\n FunctionVisibility,\n ActionBuilder,\n MutationBuilder,\n MutationBuilderWithTable,\n QueryBuilder,\n QueryBuilderWithTable,\n HttpActionBuilder,\n GenericActionCtx,\n GenericMutationCtx,\n GenericMutationCtxWithTable,\n GenericQueryCtx,\n GenericQueryCtxWithTable,\n RegisteredAction,\n RegisteredMutation,\n RegisteredQuery,\n PublicHttpAction,\n UnvalidatedFunction,\n ValidatedFunction,\n ReturnValueForOptionalValidator,\n ArgsArrayForOptionalValidator,\n ArgsArrayToObject,\n DefaultArgsForOptionalValidator,\n} from \"./registration.js\";\nexport * from \"./search_filter_builder.js\";\nexport * from \"./storage.js\";\nexport type { Scheduler, SchedulableFunctionReference } from \"./scheduler.js\";\nexport { cronJobs } from \"./cron.js\";\nexport type { CronJob, Crons } from \"./cron.js\";\nexport type {\n SystemFields,\n IdField,\n WithoutSystemFields,\n WithOptionalSystemFields,\n SystemIndexes,\n IndexTiebreakerField,\n} from \"./system_fields.js\";\nexport { httpRouter, HttpRouter, ROUTABLE_HTTP_METHODS } from \"./router.js\";\nexport type {\n RoutableMethod,\n RouteSpec,\n RouteSpecWithPath,\n RouteSpecWithPathPrefix,\n} from \"./router.js\";\nexport {\n anyApi,\n getFunctionName,\n makeFunctionReference,\n filterApi,\n} from \"./api.js\";\nexport type {\n ApiFromModules,\n AnyApi,\n FilterApi,\n FunctionType,\n FunctionReference,\n FunctionArgs,\n OptionalRestArgs,\n PartialApi,\n ArgsAndOptions,\n FunctionReturnType,\n ValidatorTypeToReturnType,\n} from \"./api.js\";\nexport {\n defineApp,\n defineComponent,\n componentsGeneric,\n createFunctionHandle,\n type AnyChildComponents,\n type EnvDefinition,\n type EnvFromDefinition,\n type EnvFromAppDefinition,\n type AppDefinition,\n} from \"./components/index.js\";\n/**\n * @internal\n */\nexport { currentSystemUdfInComponent } from \"./components/index.js\";\nexport { getFunctionAddress } from \"./components/index.js\";\nexport type {\n ComponentDefinition,\n AnyComponents,\n FunctionHandle,\n} from \"./components/index.js\";\n\n/**\n * @internal\n */\nexport type { Index, SearchIndex, VectorIndex } from \"./schema.js\";\n\nexport { log } from \"./log.js\";\nexport type { AuditLogBody, AuditLogValue } from \"./audit_logging.js\";\n\nexport type {\n SearchIndexConfig,\n VectorIndexConfig,\n TableDefinition,\n SchemaDefinition,\n DefineSchemaOptions,\n GenericSchema,\n DataModelFromSchemaDefinition,\n SystemDataModel,\n SystemTableNames,\n DocValidator,\n SystemFieldValidators,\n} from \"./schema.js\";\nexport { defineTable, defineSchema, docValidator } from \"./schema.js\";\n\nexport type {\n VectorSearch,\n VectorSearchQuery,\n VectorFilterBuilder,\n FilterExpression,\n} from \"./vector_search.js\";\n\n/**\n * @public\n */\nexport type { BetterOmit, Expand } from \"../type_utils.js\";\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA4DA,2BAAc,0BA5Dd;AAgGA,+BAQO;AACP,0BAAgC;AAahC,2BAAc,4BAtHd;AAmJA,2BAAc,uCAnJd;AAoJA,2BAAc,yBApJd;AAsJA,kBAAyB;AAUzB,oBAA8D;AAO9D,iBAKO;AAcP,wBAUO;AAIP,IAAAA,qBAA4C;AAC5C,IAAAA,qBAAmC;AAYnC,iBAAoB;AAgBpB,oBAAwD;",
4
+ "sourcesContent": ["/**\n * Utilities for implementing server-side Convex query and mutation functions.\n *\n * ## Usage\n *\n * ### Code Generation\n *\n * This module is typically used alongside generated server code.\n *\n * To generate the server code, run `npx convex dev` in your Convex project.\n * This will create a `convex/_generated/server.js` file with the following\n * functions, typed for your schema:\n * - [query](https://docs.convex.dev/generated-api/server#query)\n * - [mutation](https://docs.convex.dev/generated-api/server#mutation)\n *\n * If you aren't using TypeScript and code generation, you can use these untyped\n * functions instead:\n * - {@link queryGeneric}\n * - {@link mutationGeneric}\n *\n * ### Example\n *\n * Convex functions are defined by using either the `query` or\n * `mutation` wrappers.\n *\n * Queries receive a `db` that implements the {@link GenericDatabaseReader} interface.\n *\n * ```js\n * import { query } from \"./_generated/server\";\n *\n * export default query({\n * handler: async ({ db }, { arg1, arg2 }) => {\n * // Your (read-only) code here!\n * },\n * });\n * ```\n *\n * If your function needs to write to the database, such as inserting, updating,\n * or deleting documents, use `mutation` instead which provides a `db` that\n * implements the {@link GenericDatabaseWriter} interface.\n *\n * ```js\n * import { mutation } from \"./_generated/server\";\n *\n * export default mutation({\n * handler: async ({ db }, { arg1, arg2 }) => {\n * // Your mutation code here!\n * },\n * });\n * ```\n * @module\n */\n\nexport type {\n Auth,\n AuthConfig,\n AuthProvider,\n UserIdentity,\n UserIdentityAttributes,\n} from \"./authentication.js\";\nexport * from \"./database.js\";\nexport type {\n GenericDocument,\n GenericFieldPaths,\n GenericIndexFields,\n GenericTableIndexes,\n GenericSearchIndexConfig,\n GenericTableSearchIndexes,\n GenericVectorIndexConfig,\n GenericTableVectorIndexes,\n FieldTypeFromFieldPath,\n FieldTypeFromFieldPathInner,\n GenericTableInfo,\n DocumentByInfo,\n FieldPaths,\n Indexes,\n IndexNames,\n NamedIndex,\n SearchIndexes,\n SearchIndexNames,\n NamedSearchIndex,\n VectorIndexes,\n VectorIndexNames,\n NamedVectorIndex,\n GenericDataModel,\n AnyDataModel,\n TableNamesInDataModel,\n NamedTableInfo,\n DocumentByName,\n} from \"./data_model.js\";\n\nexport type {\n Expression,\n ExpressionOrValue,\n FilterBuilder,\n} from \"./filter_builder.js\";\nexport {\n actionGeneric,\n httpActionGeneric,\n mutationGeneric,\n queryGeneric,\n internalActionGeneric,\n internalMutationGeneric,\n internalQueryGeneric,\n} from \"./impl/registration_impl.js\";\nexport {\n getServiceToken,\n getServiceUrl,\n type ServiceName,\n} from \"./impl/actions_impl.js\";\nexport type {\n TransactionMetric,\n TransactionMetrics,\n TransactionLimits,\n FunctionMetadata,\n DeploymentMetadata,\n RequestMetadata,\n QueryMeta,\n MutationMeta,\n ActionMeta,\n} from \"./meta.js\";\nexport type { IndexRange, IndexRangeBuilder } from \"./index_range_builder.js\";\nexport * from \"./pagination.js\";\nexport type { OrderedQuery, Query, QueryInitializer } from \"./query.js\";\nexport type {\n AdvancedRunQueryOptions,\n ArgsArray,\n DefaultFunctionArgs,\n FunctionVisibility,\n ActionBuilder,\n MutationBuilder,\n MutationBuilderWithTable,\n QueryBuilder,\n QueryBuilderWithTable,\n HttpActionBuilder,\n GenericActionCtx,\n GenericMutationCtx,\n GenericMutationCtxWithTable,\n GenericQueryCtx,\n GenericQueryCtxWithTable,\n RegisteredAction,\n RegisteredMutation,\n RegisteredQuery,\n PublicHttpAction,\n UnvalidatedFunction,\n ValidatedFunction,\n ReturnValueForOptionalValidator,\n ArgsArrayForOptionalValidator,\n ArgsArrayToObject,\n DefaultArgsForOptionalValidator,\n} from \"./registration.js\";\nexport * from \"./search_filter_builder.js\";\nexport * from \"./storage.js\";\nexport type { Scheduler, SchedulableFunctionReference } from \"./scheduler.js\";\nexport { cronJobs } from \"./cron.js\";\nexport type { CronJob, Crons } from \"./cron.js\";\nexport type {\n SystemFields,\n IdField,\n WithoutSystemFields,\n WithOptionalSystemFields,\n SystemIndexes,\n IndexTiebreakerField,\n} from \"./system_fields.js\";\nexport { httpRouter, HttpRouter, ROUTABLE_HTTP_METHODS } from \"./router.js\";\nexport type {\n RoutableMethod,\n RouteSpec,\n RouteSpecWithPath,\n RouteSpecWithPathPrefix,\n} from \"./router.js\";\nexport {\n anyApi,\n getFunctionName,\n makeFunctionReference,\n filterApi,\n} from \"./api.js\";\nexport type {\n ApiFromModules,\n AnyApi,\n FunctionReference_future,\n FilterApi,\n FunctionType,\n FunctionReference,\n FunctionArgs,\n OptionalRestArgs,\n PartialApi,\n ArgsAndOptions,\n FunctionReturnType,\n ValidatorTypeToReturnType,\n} from \"./api.js\";\nexport {\n defineApp,\n defineComponent,\n componentsGeneric,\n createFunctionHandle,\n type AnyChildComponents,\n type EnvDefinition,\n type EnvFromDefinition,\n type EnvFromAppDefinition,\n type AppDefinition,\n} from \"./components/index.js\";\n/**\n * @internal\n */\nexport { currentSystemUdfInComponent } from \"./components/index.js\";\nexport { getFunctionAddress } from \"./components/index.js\";\nexport type {\n ComponentDefinition,\n AnyComponents,\n FunctionHandle,\n} from \"./components/index.js\";\n\n/**\n * @internal\n */\nexport type { Index, SearchIndex, VectorIndex } from \"./schema.js\";\n\nexport { log } from \"./log.js\";\nexport type { AuditLogBody, AuditLogValue } from \"./audit_logging.js\";\n\nexport type {\n SearchIndexConfig,\n VectorIndexConfig,\n TableDefinition,\n SchemaDefinition,\n DefineSchemaOptions,\n GenericSchema,\n DataModelFromSchemaDefinition,\n SystemDataModel,\n SystemTableNames,\n DocValidator,\n SystemFieldValidators,\n} from \"./schema.js\";\nexport { defineTable, defineSchema, docValidator } from \"./schema.js\";\n\nexport type {\n VectorSearch,\n VectorSearchQuery,\n VectorFilterBuilder,\n FilterExpression,\n} from \"./vector_search.js\";\n\n/**\n * @public\n */\nexport type { BetterOmit, Expand } from \"../type_utils.js\";\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA4DA,2BAAc,0BA5Dd;AAgGA,+BAQO;AACP,0BAIO;AAaP,2BAAc,4BA1Hd;AAuJA,2BAAc,uCAvJd;AAwJA,2BAAc,yBAxJd;AA0JA,kBAAyB;AAUzB,oBAA8D;AAO9D,iBAKO;AAeP,wBAUO;AAIP,IAAAA,qBAA4C;AAC5C,IAAAA,qBAAmC;AAYnC,iBAAoB;AAgBpB,oBAAwD;",
6
6
  "names": ["import_components"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/server/meta.ts"],
4
- "sourcesContent": ["import { FunctionType } from \"./api.js\";\nimport { FunctionVisibility } from \"./registration.js\";\n\n/**\n * Used and remaining amounts for a single transaction limit.\n *\n * @public\n */\nexport type TransactionMetric = {\n used: number;\n remaining: number;\n};\n\n/**\n * The remaining headroom for a transaction before hitting limits.\n *\n * See https://docs.convex.dev/production/state/limits\n *\n * @public\n */\nexport type TransactionMetrics = {\n bytesRead: TransactionMetric;\n bytesWritten: TransactionMetric;\n databaseQueries: TransactionMetric;\n documentsRead: TransactionMetric;\n documentsWritten: TransactionMetric;\n functionsScheduled: TransactionMetric;\n scheduledFunctionArgsBytes: TransactionMetric;\n};\n\n/**\n * Custom limits for a nested transaction. Each field specifies the absolute\n * maximum allowed for the nested function call. Values are capped at the\n * global transaction limits, so they can only lower limits, never raise them.\n *\n * @public\n */\nexport interface TransactionLimits {\n bytesRead?: number;\n bytesWritten?: number;\n databaseQueries?: number;\n documentsRead?: number;\n documentsWritten?: number;\n functionsScheduled?: number;\n scheduledFunctionArgsBytes?: number;\n}\n\n/**\n * Metadata about the currently executing Convex function.\n *\n * @public\n */\nexport type FunctionMetadata = {\n /**\n * The name of the function, in the format `\"path/to/module:functionName\"`\n */\n name: string;\n /**\n * The path of the component this function belongs to.\n * This is an empty string `\"\"` for the app.\n */\n componentPath: string;\n /** Whether it's a query, mutation, or action. */\n type: FunctionType;\n /** Whether the function is public or internal. */\n visibility: FunctionVisibility;\n};\n\n/**\n * Metadata about the deployment this function is running on.\n *\n * @public\n */\nexport type DeploymentMetadata = {\n /**\n * The deployment name, e.g. `\"tall-tiger-123\"` for cloud deployments,\n * `\"local-my_team-my_project\"` for local deployments, or\n * `\"anonymous-*\"` for anonymous deployments.\n */\n name: string;\n /**\n * The deployment region, e.g. `\"aws-us-east-1\"`.\n * `null` for local and self-hosted deployments.\n */\n region: string | null;\n /**\n * The deployment class, e.g. `\"s16\"`, `\"s256\"`, `\"d1024\"`, or `\"d2048\"`.\n */\n class: \"s16\" | \"s256\" | \"d1024\" | \"d2048\";\n};\n\n/**\n * Metadata about the HTTP request that triggered the current function execution.\n *\n * `ip` and `userAgent` are `null` when the function was not triggered by an\n * HTTP request (e.g. scheduled jobs or cron jobs).\n *\n * Functions called from within a function (i.e. using `runMutation` or\n * `runAction`) will have the same request metadata as the parent function.\n *\n * @public\n */\nexport type RequestMetadata = {\n ip: string | null;\n userAgent: string | null;\n requestId: string;\n /**\n * The ID of the scheduled function document (in `_scheduled_functions`) that\n * this execution belongs to, or `null` otherwise.\n *\n * This is set for the scheduled function itself and for any functions it\n * calls (e.g. a mutation invoked via `runMutation` by a scheduled action),\n * propagating the top-level scheduled function's ID down the call tree. It is\n * `null` when the function was not scheduled.\n */\n scheduledFunctionId: string | null;\n /**\n * The raw auth token (a JWT) the request was authenticated with, or `null`\n * when the request was unauthenticated or authenticated with an admin key.\n *\n * This is the same token that `ctx.auth.getUserIdentity()` derives its\n * attributes from.\n */\n authToken: string | null;\n};\n\n/**\n * Extra context available in Convex query functions.\n *\n * @public\n */\nexport interface QueryMeta {\n getFunctionMetadata(): Promise<FunctionMetadata>;\n getTransactionMetrics(): Promise<TransactionMetrics>;\n getDeploymentMetadata(): Promise<DeploymentMetadata>;\n}\n\n/**\n * Extra context available in Convex mutation functions.\n *\n * @public\n */\nexport interface MutationMeta extends QueryMeta {\n getRequestMetadata(): Promise<RequestMetadata>;\n}\n\n/**\n * Extra context available in Convex action functions.\n *\n * @public\n */\nexport interface ActionMeta {\n getFunctionMetadata(): Promise<FunctionMetadata>;\n getDeploymentMetadata(): Promise<DeploymentMetadata>;\n getRequestMetadata(): Promise<RequestMetadata>;\n}\n"],
4
+ "sourcesContent": ["import { FunctionType } from \"./api.js\";\nimport { FunctionVisibility } from \"./registration.js\";\n\n/**\n * Used and remaining amounts for a single transaction limit.\n *\n * @public\n */\nexport type TransactionMetric = {\n used: number;\n remaining: number;\n};\n\n/**\n * The remaining headroom for a transaction before hitting limits.\n *\n * See https://docs.convex.dev/production/state/limits\n *\n * @public\n */\nexport type TransactionMetrics = {\n bytesRead: TransactionMetric;\n bytesWritten: TransactionMetric;\n databaseQueries: TransactionMetric;\n documentsRead: TransactionMetric;\n documentsWritten: TransactionMetric;\n functionsScheduled: TransactionMetric;\n scheduledFunctionArgsBytes: TransactionMetric;\n /** @internal */\n filesWritten: TransactionMetric;\n /** @internal */\n fileWriteBytes: TransactionMetric;\n /** @internal */\n filesRead: TransactionMetric;\n /** @internal */\n fileReadBytes: TransactionMetric;\n};\n\n/**\n * Custom limits for a nested transaction. Each field specifies the absolute\n * maximum allowed for the nested function call. Values are capped at the\n * global transaction limits, so they can only lower limits, never raise them.\n *\n * @public\n */\nexport interface TransactionLimits {\n bytesRead?: number;\n bytesWritten?: number;\n databaseQueries?: number;\n documentsRead?: number;\n documentsWritten?: number;\n functionsScheduled?: number;\n scheduledFunctionArgsBytes?: number;\n /** @internal */\n filesWritten?: number;\n /** @internal */\n fileWriteBytes?: number;\n /** @internal */\n filesRead?: number;\n /** @internal */\n fileReadBytes?: number;\n}\n\n/**\n * Metadata about the currently executing Convex function.\n *\n * @public\n */\nexport type FunctionMetadata = {\n /**\n * The name of the function, in the format `\"path/to/module:functionName\"`\n */\n name: string;\n /**\n * The path of the component this function belongs to.\n * This is an empty string `\"\"` for the app.\n */\n componentPath: string;\n /** Whether it's a query, mutation, or action. */\n type: FunctionType;\n /** Whether the function is public or internal. */\n visibility: FunctionVisibility;\n};\n\n/**\n * Metadata about the deployment this function is running on.\n *\n * @public\n */\nexport type DeploymentMetadata = {\n /**\n * The deployment name, e.g. `\"tall-tiger-123\"` for cloud deployments,\n * `\"local-my_team-my_project\"` for local deployments, or\n * `\"anonymous-*\"` for anonymous deployments.\n */\n name: string;\n /**\n * The deployment region, e.g. `\"aws-us-east-1\"`.\n * `null` for local and self-hosted deployments.\n */\n region: string | null;\n /**\n * The deployment class, e.g. `\"s16\"`, `\"s256\"`, `\"d1024\"`, or `\"d2048\"`.\n */\n class: \"s16\" | \"s256\" | \"d1024\" | \"d2048\";\n};\n\n/**\n * Metadata about the HTTP request that triggered the current function execution.\n *\n * `ip` and `userAgent` are `null` when the function was not triggered by an\n * HTTP request (e.g. scheduled jobs or cron jobs).\n *\n * Functions called from within a function (i.e. using `runMutation` or\n * `runAction`) will have the same request metadata as the parent function.\n *\n * @public\n */\nexport type RequestMetadata = {\n ip: string | null;\n userAgent: string | null;\n requestId: string;\n /**\n * The ID of the scheduled function document (in `_scheduled_functions`) that\n * this execution belongs to, or `null` otherwise.\n *\n * This is set for the scheduled function itself and for any functions it\n * calls (e.g. a mutation invoked via `runMutation` by a scheduled action),\n * propagating the top-level scheduled function's ID down the call tree. It is\n * `null` when the function was not scheduled.\n */\n scheduledFunctionId: string | null;\n /**\n * The raw auth token (a JWT) the request was authenticated with, or `null`\n * when the request was unauthenticated or authenticated with an admin key.\n *\n * This is the same token that `ctx.auth.getUserIdentity()` derives its\n * attributes from.\n */\n authToken: string | null;\n};\n\n/**\n * Extra context available in Convex query functions.\n *\n * @public\n */\nexport interface QueryMeta {\n /**\n * Metadata about the currently executing Convex function.\n */\n getFunctionMetadata(): Promise<FunctionMetadata>;\n /**\n * The remaining headroom for a transaction before hitting limits.\n *\n * See https://docs.convex.dev/production/state/limits\n */\n getTransactionMetrics(): Promise<TransactionMetrics>;\n /**\n * Metadata about the deployment this function is running on.\n */\n getDeploymentMetadata(): Promise<DeploymentMetadata>;\n /**\n * Returns the timestamp of the database snapshot this transaction reads\n * from, in nanoseconds.\n *\n * All commits at or before this timestamp are observable within the\n * transaction, and no later commits are. The value is fixed for the\n * lifetime of the transaction and shared with all nested `runMutation` and\n * non-stale `runQuery` calls. If a nested query is called with\n * `useStaleSnapshot: true`, then the nested query may in a future backend\n * version choose an older snapshotTs.\n *\n * It is on the same clock as `db.vars.commitTs`: documents observable in\n * this transaction have `commitTs` values at or before this timestamp, and\n * no new documents will be written with a `commitTs` at or below this,\n * including from the current transaction. When reading documents with an\n * index in commitTs order, you can use this as an upper bound to prevent\n * conflicting with racing inserts.\n *\n * Since the timestamp differs on every execution, calling this in a query\n * limits caching of the query's result the same way `Date.now()` does.\n *\n * Note: this should not be compared to `_creationTime` or `Date.now()`, as\n * those are based on wall-clock time rather than the database clock, and\n * aren't guaranteed to follow commit order.\n *\n * Docs: https://docs.convex.dev/database/advanced/commit-timestamp\n */\n getSnapshotTs(): bigint;\n}\n\n/**\n * Extra context available in Convex mutation functions.\n *\n * @public\n */\nexport interface MutationMeta extends QueryMeta {\n /**\n * Metadata about the HTTP request that triggered the current function execution.\n *\n * `ip` and `userAgent` are `null` when the function was not triggered by an\n * HTTP request (e.g. scheduled jobs or cron jobs).\n *\n * Functions called from within a function (i.e. using `runMutation`) will have\n * the same request metadata as the parent function.\n */\n getRequestMetadata(): Promise<RequestMetadata>;\n}\n\n/**\n * Extra context available in Convex action functions.\n *\n * @public\n */\nexport interface ActionMeta {\n /**\n * Metadata about the currently executing Convex function.\n */\n getFunctionMetadata(): Promise<FunctionMetadata>;\n /**\n * Metadata about the deployment this function is running on.\n */\n getDeploymentMetadata(): Promise<DeploymentMetadata>;\n /**\n * Metadata about the HTTP request that triggered the current function execution.\n *\n * `ip` and `userAgent` are `null` when the function was not triggered by an\n * HTTP request (e.g. scheduled jobs or cron jobs).\n *\n * Functions called from within a function (i.e. using `runMutation` or\n * `runAction`) will have the same request metadata as the parent function.\n */\n getRequestMetadata(): Promise<RequestMetadata>;\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/server/registration.ts"],
4
- "sourcesContent": ["import {\n Auth,\n GenericDatabaseReader,\n GenericDatabaseReaderWithTable,\n GenericDatabaseWriter,\n GenericDatabaseWriterWithTable,\n StorageActionWriter,\n StorageReader,\n StorageWriter,\n} from \"./index.js\";\nimport {\n ActionMeta,\n MutationMeta,\n QueryMeta,\n TransactionLimits,\n} from \"./meta.js\";\nimport {\n ArgsAndOptions,\n FunctionReference,\n FunctionReturnType,\n OptionalRestArgs,\n ValidatorTypeToReturnType,\n} from \"../server/api.js\";\nimport {\n GenericValidator,\n Infer,\n ObjectType,\n PropertyValidators,\n} from \"../values/validator.js\";\nimport { Id } from \"../values/value.js\";\nimport {\n GenericDataModel,\n NamedTableInfo,\n TableNamesInDataModel,\n VectorIndexNames,\n} from \"./data_model.js\";\nimport { Scheduler } from \"./scheduler.js\";\nimport { VectorSearchQuery } from \"./vector_search.js\";\nimport { Expand } from \"../type_utils.js\";\nimport { Validator } from \"../values/validators.js\";\n\n/**\n * A set of services for use within Convex mutation functions.\n *\n * The mutation context is passed as the first argument to any Convex mutation\n * function run on the server. Mutations run **transactionally**, all reads\n * and writes within a single mutation are atomic and isolated.\n *\n * You should generally use the `MutationCtx` type from\n * `\"./_generated/server\"`.\n *\n * @example\n * ```typescript\n * import { mutation } from \"./_generated/server\";\n * import { internal } from \"./_generated/api\";\n * import { v } from \"convex/values\";\n *\n * export const createTask = mutation({\n * args: { text: v.string() },\n * returns: v.id(\"tasks\"),\n * handler: async (ctx, args) => {\n * // ctx.db: read and write documents\n * const taskId = await ctx.db.insert(\"tasks\", { text: args.text, completed: false });\n *\n * // ctx.auth: check the authenticated user\n * const identity = await ctx.auth.getUserIdentity();\n *\n * // ctx.scheduler: schedule functions for later\n * await ctx.scheduler.runAfter(0, internal.notifications.send, { taskId });\n *\n * return taskId;\n * },\n * });\n * ```\n *\n * @public\n */\nexport interface GenericMutationCtx<DataModel extends GenericDataModel> {\n /**\n * A utility for reading and writing data in the database.\n *\n * Use `ctx.db.insert()`, `ctx.db.patch()`, `ctx.db.replace()`, and\n * `ctx.db.delete()` to write data. Use `ctx.db.get()` and `ctx.db.query()`\n * to read data. All operations within a mutation are atomic.\n */\n db: GenericDatabaseWriter<DataModel>;\n\n /**\n * Information about the currently authenticated user.\n *\n * Call `await ctx.auth.getUserIdentity()` to get the current user's identity,\n * or `null` if the user is not authenticated.\n */\n auth: Auth;\n\n /**\n * A utility for reading and writing files in storage.\n *\n * Use `ctx.storage.generateUploadUrl()` to create an upload URL for clients,\n * `ctx.storage.getUrl(storageId)` to get a URL for a stored file,\n * or `ctx.storage.delete(storageId)` to remove one.\n */\n storage: StorageWriter;\n\n /**\n * A utility for scheduling Convex functions to run in the future.\n *\n * @example\n * ```typescript\n * // Schedule an action to run immediately after this mutation commits:\n * await ctx.scheduler.runAfter(0, internal.emails.sendWelcome, { userId });\n *\n * // Schedule a cleanup to run in 24 hours:\n * await ctx.scheduler.runAfter(24 * 60 * 60 * 1000, internal.tasks.cleanup, {});\n * ```\n */\n scheduler: Scheduler;\n\n /**\n * Call a query function within the same transaction.\n *\n * The query runs within the same transaction as the calling mutation,\n * seeing a consistent snapshot of the database. Requires a\n * {@link FunctionReference} (e.g., `api.myModule.myQuery` or\n * `internal.myModule.myQuery`).\n *\n * NOTE: Often you can extract shared logic into a helper function instead.\n * `runQuery` incurs overhead of running argument and return value validation,\n * and creating a new isolated JS context.\n *\n * @example\n * ```typescript\n * const user = await ctx.runQuery(internal.users.getUser, { userId });\n * ```\n */\n runQuery: <Query extends FunctionReference<\"query\", \"public\" | \"internal\">>(\n query: Query,\n ...args: ArgsAndOptions<Query, AdvancedRunQueryOptions>\n ) => Promise<FunctionReturnType<Query>>;\n\n /**\n * Call a mutation function within the same transaction.\n *\n * The mutation runs in a sub-transaction, so if it throws an error, all of\n * its writes will be rolled back. Requires a {@link FunctionReference}.\n *\n * NOTE: Often you can extract shared logic into a helper function instead.\n * `runMutation` incurs overhead of running argument and return value\n * validation, and creating a new isolated JS context.\n */\n runMutation: <\n Mutation extends FunctionReference<\"mutation\", \"public\" | \"internal\">,\n >(\n mutation: Mutation,\n ...args: ArgsAndOptions<Mutation, { transactionLimits?: TransactionLimits }>\n ) => Promise<FunctionReturnType<Mutation>>;\n\n meta: MutationMeta;\n}\n\n/**\n * A set of services for use within Convex mutation functions.\n *\n * The mutation context is passed as the first argument to any Convex mutation\n * function run on the server.\n *\n * You should generally use the `MutationCtx` type from\n * `\"./_generated/server\"`.\n *\n * @public\n */\nexport type GenericMutationCtxWithTable<DataModel extends GenericDataModel> =\n Omit<GenericMutationCtx<DataModel>, \"db\"> & {\n db: GenericDatabaseWriterWithTable<DataModel>;\n };\n\n/**\n * A set of services for use within Convex query functions.\n *\n * The query context is passed as the first argument to any Convex query\n * function run on the server. Queries are **read-only**, they can read from\n * the database but cannot write. They are also **reactive**, when used with\n * `useQuery` on the client, the result automatically updates when data changes.\n *\n * You should generally use the `QueryCtx` type from\n * `\"./_generated/server\"`.\n *\n * @example\n * ```typescript\n * import { query } from \"./_generated/server\";\n * import { v } from \"convex/values\";\n *\n * export const listTasks = query({\n * args: {},\n * returns: v.array(v.object({\n * _id: v.id(\"tasks\"),\n * _creationTime: v.number(),\n * text: v.string(),\n * completed: v.boolean(),\n * })),\n * handler: async (ctx, args) => {\n * // ctx.db: read-only database access\n * return await ctx.db.query(\"tasks\").order(\"desc\").take(100);\n * },\n * });\n * ```\n *\n * @public\n */\nexport interface GenericQueryCtx<DataModel extends GenericDataModel> {\n /**\n * A utility for reading data in the database.\n *\n * Use `ctx.db.get(table, id)` to fetch a single document by ID, or\n * `ctx.db.query(\"tableName\")` to query multiple documents with filtering\n * and ordering. Queries are read-only, no write methods are available.\n */\n db: GenericDatabaseReader<DataModel>;\n\n /**\n * Information about the currently authenticated user.\n *\n * Call `await ctx.auth.getUserIdentity()` to get the current user's identity,\n * or `null` if the user is not authenticated.\n */\n auth: Auth;\n\n /**\n * A utility for reading files in storage.\n *\n * Use `ctx.storage.getUrl(storageId)` to get a URL for a stored file.\n */\n storage: StorageReader;\n\n /**\n * Call a query function within the same transaction.\n *\n * The query runs within the same read snapshot. Requires a\n * {@link FunctionReference} (e.g., `api.myModule.myQuery` or\n * `internal.myModule.myQuery`).\n *\n * NOTE: Often you can extract shared logic into a helper function instead.\n * `runQuery` incurs overhead of running argument and return value validation,\n * and creating a new isolated JS context.\n */\n runQuery: <Query extends FunctionReference<\"query\", \"public\" | \"internal\">>(\n query: Query,\n ...args: ArgsAndOptions<Query, { transactionLimits?: TransactionLimits }>\n ) => Promise<FunctionReturnType<Query>>;\n\n meta: QueryMeta;\n}\n\n/**\n * A set of services for use within Convex query functions.\n *\n * The query context is passed as the first argument to any Convex query\n * function run on the server.\n *\n * This differs from the {@link MutationCtx} because all of the services are\n * read-only.\n *\n *\n * @public\n */\nexport type GenericQueryCtxWithTable<DataModel extends GenericDataModel> = Omit<\n GenericQueryCtx<DataModel>,\n \"db\"\n> & {\n db: GenericDatabaseReaderWithTable<DataModel>;\n};\n\n/**\n * A set of services for use within Convex action functions.\n *\n * The action context is passed as the first argument to any Convex action\n * run on the server. Actions can call external APIs and use Node.js libraries,\n * but do **not** have direct database access (`ctx.db` is not available).\n * Use `ctx.runQuery` and `ctx.runMutation` to interact with the database.\n *\n * You should generally use the `ActionCtx` type from\n * `\"./_generated/server\"`.\n *\n * @example\n * ```typescript\n * import { action } from \"./_generated/server\";\n * import { internal } from \"./_generated/api\";\n * import { v } from \"convex/values\";\n *\n * export const processPayment = action({\n * args: { orderId: v.id(\"orders\"), amount: v.number() },\n * returns: v.null(),\n * handler: async (ctx, args) => {\n * // Read data via ctx.runQuery:\n * const order = await ctx.runQuery(internal.orders.get, { id: args.orderId });\n *\n * // Call external API:\n * const result = await fetch(\"https://api.stripe.com/v1/charges\", { ... });\n *\n * // Write results back via ctx.runMutation:\n * await ctx.runMutation(internal.orders.markPaid, { id: args.orderId });\n *\n * return null;\n * },\n * });\n * ```\n *\n * **Common mistake:** `ctx.db` is not available in actions. Do not try to\n * access it, use `ctx.runQuery` and `ctx.runMutation` instead.\n *\n * @public\n */\nexport interface GenericActionCtx<DataModel extends GenericDataModel> {\n /**\n * Run the Convex query with the given name and arguments.\n *\n * Each `runQuery` call is a separate read transaction. Consider using an\n * {@link internalQuery} to prevent users from calling the query directly.\n *\n * @example\n * ```typescript\n * const user = await ctx.runQuery(internal.users.get, { userId });\n * ```\n *\n * @param query - A {@link FunctionReference} for the query to run.\n * @param args - The arguments to the query function.\n * @returns A promise of the query's result.\n */\n runQuery<Query extends FunctionReference<\"query\", \"public\" | \"internal\">>(\n query: Query,\n ...args: OptionalRestArgs<Query>\n ): Promise<FunctionReturnType<Query>>;\n\n /**\n * Run the Convex mutation with the given name and arguments.\n *\n * Each `runMutation` call is a separate write transaction. Consider using\n * an {@link internalMutation} to prevent users from calling it directly.\n *\n * @example\n * ```typescript\n * await ctx.runMutation(internal.orders.markPaid, { id: orderId });\n * ```\n *\n * @param mutation - A {@link FunctionReference} for the mutation to run.\n * @param args - The arguments to the mutation function.\n * @returns A promise of the mutation's result.\n */\n runMutation<\n Mutation extends FunctionReference<\"mutation\", \"public\" | \"internal\">,\n >(\n mutation: Mutation,\n ...args: OptionalRestArgs<Mutation>\n ): Promise<FunctionReturnType<Mutation>>;\n\n /**\n * Run the Convex action with the given name and arguments.\n *\n * **Important:** Only use `runAction` when you need to cross runtimes\n * (e.g., calling a `\"use node\"` action from the default Convex runtime).\n * For code in the same runtime, extract shared logic into a plain\n * TypeScript helper function instead, `runAction` has significant\n * overhead (separate function call, separate resource allocation).\n *\n * Consider using an {@link internalAction} to prevent users from calling the\n * action directly.\n *\n * @param action - A {@link FunctionReference} for the action to run.\n * @param args - The arguments to the action function.\n * @returns A promise of the action's result.\n */\n runAction<Action extends FunctionReference<\"action\", \"public\" | \"internal\">>(\n action: Action,\n ...args: OptionalRestArgs<Action>\n ): Promise<FunctionReturnType<Action>>;\n\n /**\n * A utility for scheduling Convex functions to run in the future.\n */\n scheduler: Scheduler;\n\n /**\n * Information about the currently authenticated user.\n */\n auth: Auth;\n\n /**\n * A utility for reading and writing files in storage.\n */\n storage: StorageActionWriter;\n\n /**\n * Run a vector search on the given table and index.\n *\n * @param tableName - The name of the table to query.\n * @param indexName - The name of the vector index on the table to query.\n * @param query - A {@link VectorSearchQuery} containing the vector to query,\n * the number of results to return, and any filters.\n * @returns A promise of IDs and scores for the documents with the nearest\n * vectors\n */\n vectorSearch<\n TableName extends TableNamesInDataModel<DataModel>,\n IndexName extends VectorIndexNames<NamedTableInfo<DataModel, TableName>>,\n >(\n tableName: TableName,\n indexName: IndexName,\n query: Expand<\n VectorSearchQuery<NamedTableInfo<DataModel, TableName>, IndexName>\n >,\n ): Promise<Array<{ _id: Id<TableName>; _score: number }>>;\n\n meta: ActionMeta;\n}\n\n/**\n * The default arguments type for a Convex query, mutation, or action function.\n *\n * Convex functions always take an arguments object that maps the argument\n * names to their values.\n *\n * @public\n */\nexport type DefaultFunctionArgs = Record<string, unknown>;\n\n/**\n * The arguments array for a function that takes arguments.\n *\n * This is an array of a single {@link DefaultFunctionArgs} element.\n */\ntype OneArgArray<ArgsObject extends DefaultFunctionArgs = DefaultFunctionArgs> =\n [ArgsObject];\n\n/**\n * The arguments to a function that takes no arguments (just an empty array).\n */\ntype NoArgsArray = [];\n\n/**\n * An array of arguments to a Convex function.\n *\n * Convex functions can take either a single {@link DefaultFunctionArgs} object or no\n * args at all.\n *\n * @public\n */\nexport type ArgsArray = OneArgArray | NoArgsArray;\n\n/**\n * A type for the empty object `{}`.\n *\n * Note that we don't use `type EmptyObject = {}` because that matches every object.\n */\nexport type EmptyObject = Record<string, never>;\n\n/**\n * Convert an {@link ArgsArray} into a single object type.\n *\n * Empty arguments arrays are converted to {@link EmptyObject}.\n * @public\n */\nexport type ArgsArrayToObject<Args extends ArgsArray> =\n Args extends OneArgArray<infer ArgsObject> ? ArgsObject : EmptyObject;\n\n/**\n * A type representing the visibility of a Convex function.\n *\n * @public\n */\nexport type FunctionVisibility = \"public\" | \"internal\";\n\n/**\n * Given a {@link FunctionVisibility}, should this function have `isPublic: true`\n * or `isInternal: true`?\n */\ntype VisibilityProperties<Visiblity extends FunctionVisibility> = {\n /** Phantom type marker; not present at runtime. */\n _visibility: Visiblity;\n} & (Visiblity extends \"public\"\n ? {\n isPublic: true;\n }\n : {\n isInternal: true;\n });\n\n/**\n * A mutation function that is part of this app.\n *\n * You can create a mutation by wrapping your function in\n * {@link mutationGeneric} or {@link internalMutationGeneric} and exporting it.\n *\n * @public\n */\nexport type RegisteredMutation<\n Visibility extends FunctionVisibility,\n Args extends DefaultFunctionArgs,\n Returns,\n> = {\n isConvexFunction: true;\n isMutation: true;\n\n /** @internal */\n invokeMutation(argsStr: string): Promise<string>;\n\n /** @internal */\n exportArgs(): string;\n\n /** @internal */\n exportReturns(): string;\n\n /** @internal */\n _handler: (ctx: GenericMutationCtx<any>, args: Args) => Returns;\n} & VisibilityProperties<Visibility>;\n\n/**\n * A query function that is part of this app.\n *\n * You can create a query by wrapping your function in\n * {@link queryGeneric} or {@link internalQueryGeneric} and exporting it.\n *\n * @public\n */\nexport type RegisteredQuery<\n Visibility extends FunctionVisibility,\n Args extends DefaultFunctionArgs,\n Returns,\n> = {\n isConvexFunction: true;\n isQuery: true;\n\n /** @internal */\n invokeQuery(argsStr: string): Promise<string>;\n\n /** @internal */\n exportArgs(): string;\n\n /** @internal */\n exportReturns(): string;\n\n /** @internal */\n _handler: (ctx: GenericQueryCtx<any>, args: Args) => Returns;\n} & VisibilityProperties<Visibility>;\n\n/**\n * An action that is part of this app.\n *\n * You can create an action by wrapping your function in\n * {@link actionGeneric} or {@link internalActionGeneric} and exporting it.\n *\n * @public\n */\nexport type RegisteredAction<\n Visibility extends FunctionVisibility,\n Args extends DefaultFunctionArgs,\n Returns,\n> = {\n isConvexFunction: true;\n isAction: true;\n\n /** @internal */\n invokeAction(requestId: string, argsStr: string): Promise<string>;\n\n /** @internal */\n exportArgs(): string;\n\n /** @internal */\n exportReturns(): string;\n\n /** @internal */\n _handler: (ctx: GenericActionCtx<any>, args: Args) => Returns;\n} & VisibilityProperties<Visibility>;\n\n/**\n * An HTTP action that is part of this app's public API.\n *\n * You can create public HTTP actions by wrapping your function in\n * {@link httpActionGeneric} and exporting it.\n *\n * @public\n */\nexport type PublicHttpAction = {\n isHttp: true;\n\n /** @internal */\n invokeHttpAction(request: Request): Promise<Response>;\n /** @internal */\n _handler: (ctx: GenericActionCtx<any>, request: Request) => Promise<Response>;\n};\n\n/**\n * @deprecated -- See the type definition for `MutationBuilder` or similar for\n * the types used for defining Convex functions.\n *\n * The definition of a Convex query, mutation, or action function without\n * argument validation.\n *\n * Convex functions always take a context object as their first argument\n * and an (optional) args object as their second argument.\n *\n * This can be written as a function like:\n * ```js\n * import { query } from \"./_generated/server\";\n *\n * export const func = query(({ db }, { arg }) => {...});\n * ```\n * or as an object like:\n *\n * ```js\n * import { query } from \"./_generated/server\";\n *\n * export const func = query({\n * handler: ({ db }, { arg }) => {...},\n * });\n * ```\n * See {@link ValidatedFunction} to add argument validation.\n *\n * @public\n */\nexport type UnvalidatedFunction<Ctx, Args extends ArgsArray, Returns> =\n | ((ctx: Ctx, ...args: Args) => Returns)\n | {\n handler: (ctx: Ctx, ...args: Args) => Returns;\n };\n\n/**\n * @deprecated -- See the type definition for `MutationBuilder` or similar for\n * the types used for defining Convex functions.\n *\n * The definition of a Convex query, mutation, or action function with argument\n * validation.\n *\n * Argument validation allows you to assert that the arguments to this function\n * are the expected type.\n *\n * Example:\n *\n * ```js\n * import { query } from \"./_generated/server\";\n * import { v } from \"convex/values\";\n *\n * export const func = query({\n * args: {\n * arg: v.string()\n * },\n * handler: ({ db }, { arg }) => {...},\n * });\n * ```\n *\n * **For security, argument validation should be added to all public functions in\n * production apps.**\n *\n * See {@link UnvalidatedFunction} for functions without argument validation.\n * @public\n */\nexport interface ValidatedFunction<\n Ctx,\n ArgsValidator extends PropertyValidators,\n Returns,\n> {\n /**\n * A validator for the arguments of this function.\n *\n * This is an object mapping argument names to validators constructed with\n * {@link values.v}.\n *\n * ```js\n * import { v } from \"convex/values\";\n *\n * const args = {\n * stringArg: v.string(),\n * optionalNumberArg: v.optional(v.number()),\n * }\n * ```\n */\n args: ArgsValidator;\n\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator.\n * @returns\n */\n handler: (ctx: Ctx, args: ObjectType<ArgsValidator>) => Returns;\n}\n\n/**\n * There are multiple syntaxes for defining a Convex function:\n * ```\n * - query(async (ctx, args) => {...})\n * - query({ handler: async (ctx, args) => {...} })\n * - query({ args: { a: v.string }, handler: async (ctx, args) => {...} } })\n * - query({ args: { a: v.string }, returns: v.string(), handler: async (ctx, args) => {...} } })\n *```\n *\n * In each of these, we want to correctly infer the type for the arguments and\n * return value, preferring the type derived from a validator if it's provided.\n *\n * To avoid having a separate overload for each, which would show up in error messages,\n * we use the type params -- ArgsValidator, ReturnsValidator, ReturnValue, OneOrZeroArgs.\n *\n * The type for ReturnValue and OneOrZeroArgs are constrained by the type or ArgsValidator and\n * ReturnsValidator if they're present, and inferred from any explicit type annotations to the\n * arguments or return value of the function.\n *\n * Below are a few utility types to get the appropriate type constraints based on\n * an optional validator.\n *\n * Additional tricks:\n * - We use Validator | void instead of Validator | undefined because the latter does\n * not work with `strictNullChecks` since it's equivalent to just `Validator`.\n * - We use a tuple type of length 1 to avoid distribution over the union\n * https://github.com/microsoft/TypeScript/issues/29368#issuecomment-453529532\n */\n\nexport type ReturnValueForOptionalValidator<\n ReturnsValidator extends Validator<any, any, any> | PropertyValidators | void,\n> = [ReturnsValidator] extends [Validator<any, any, any>]\n ? ValidatorTypeToReturnType<Infer<ReturnsValidator>>\n : [ReturnsValidator] extends [PropertyValidators]\n ? ValidatorTypeToReturnType<ObjectType<ReturnsValidator>>\n : any;\n\nexport type ArgsArrayForOptionalValidator<\n ArgsValidator extends GenericValidator | PropertyValidators | void,\n> = [ArgsValidator] extends [Validator<any, any, any>]\n ? OneArgArray<Infer<ArgsValidator>>\n : [ArgsValidator] extends [PropertyValidators]\n ? OneArgArray<ObjectType<ArgsValidator>>\n : ArgsArray;\n\nexport type DefaultArgsForOptionalValidator<\n ArgsValidator extends GenericValidator | PropertyValidators | void,\n> = [ArgsValidator] extends [Validator<any, any, any>]\n ? [Infer<ArgsValidator>]\n : [ArgsValidator] extends [PropertyValidators]\n ? [ObjectType<ArgsValidator>]\n : OneArgArray;\n\n/**\n * Internal type helper used by Convex code generation.\n *\n * Used to give {@link mutationGeneric} a type specific to your data model.\n * @public\n */\nexport type MutationBuilder<\n DataModel extends GenericDataModel,\n Visibility extends FunctionVisibility,\n> = {\n <\n ArgsValidator extends\n | PropertyValidators\n | Validator<any, \"required\", any>\n | void,\n ReturnsValidator extends\n | PropertyValidators\n | Validator<any, \"required\", any>\n | void,\n ReturnValue extends ReturnValueForOptionalValidator<ReturnsValidator> = any,\n OneOrZeroArgs extends ArgsArrayForOptionalValidator<ArgsValidator> =\n DefaultArgsForOptionalValidator<ArgsValidator>,\n >(\n mutation:\n | {\n /**\n * Argument validation.\n *\n * Examples:\n *\n * ```\n * args: {}\n * args: { input: v.optional(v.number()) }\n * args: { message: v.string(), author: v.id(\"authors\") }\n * args: { messages: v.array(v.string()) }\n * ```\n */\n args?: ArgsValidator;\n /**\n * The return value validator.\n *\n * Examples:\n *\n * ```\n * returns: v.null()\n * returns: v.string()\n * returns: { message: v.string(), author: v.id(\"authors\") }\n * returns: v.array(v.string())\n * ```\n */\n returns?: ReturnsValidator;\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator if provided.\n * @returns\n */\n handler: (\n ctx: GenericMutationCtx<DataModel>,\n ...args: OneOrZeroArgs\n ) => ReturnValue;\n }\n | {\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator if provided.\n * @returns\n */\n (\n ctx: GenericMutationCtx<DataModel>,\n ...args: OneOrZeroArgs\n ): ReturnValue;\n },\n ): RegisteredMutation<\n Visibility,\n ArgsArrayToObject<OneOrZeroArgs>,\n ReturnValue\n >;\n};\n\n/**\n * Internal type helper used by Convex code generation.\n *\n * Used to give {@link mutationGeneric} a type specific to your data model.\n * @public\n */\nexport type MutationBuilderWithTable<\n DataModel extends GenericDataModel,\n Visibility extends FunctionVisibility,\n> = {\n <\n ArgsValidator extends\n | PropertyValidators\n | Validator<any, \"required\", any>\n | void,\n ReturnsValidator extends\n | PropertyValidators\n | Validator<any, \"required\", any>\n | void,\n ReturnValue extends ReturnValueForOptionalValidator<ReturnsValidator> = any,\n OneOrZeroArgs extends ArgsArrayForOptionalValidator<ArgsValidator> =\n DefaultArgsForOptionalValidator<ArgsValidator>,\n >(\n mutation:\n | {\n /**\n * Argument validation.\n *\n * Examples:\n *\n * ```\n * args: {}\n * args: { input: v.optional(v.number()) }\n * args: { message: v.string(), author: v.id(\"authors\") }\n * args: { messages: v.array(v.string()) }\n * ```\n */\n args?: ArgsValidator;\n /**\n * The return value validator.\n *\n * Examples:\n *\n * ```\n * returns: v.null()\n * returns: v.string()\n * returns: { message: v.string(), author: v.id(\"authors\") }\n * returns: v.array(v.string())\n * ```\n */\n returns?: ReturnsValidator;\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator if provided.\n * @returns\n */\n handler: (\n ctx: GenericMutationCtxWithTable<DataModel>,\n ...args: OneOrZeroArgs\n ) => ReturnValue;\n }\n | {\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator if provided.\n * @returns\n */\n (\n ctx: GenericMutationCtxWithTable<DataModel>,\n ...args: OneOrZeroArgs\n ): ReturnValue;\n },\n ): RegisteredMutation<\n Visibility,\n ArgsArrayToObject<OneOrZeroArgs>,\n ReturnValue\n >;\n};\n\n/**\n * Internal type helper used by Convex code generation.\n *\n * Used to give {@link queryGeneric} a type specific to your data model.\n * @public\n */\nexport type QueryBuilder<\n DataModel extends GenericDataModel,\n Visibility extends FunctionVisibility,\n> = {\n <\n ArgsValidator extends\n | PropertyValidators\n | Validator<any, \"required\", any>\n | void,\n ReturnsValidator extends\n | PropertyValidators\n | Validator<any, \"required\", any>\n | void,\n ReturnValue extends ReturnValueForOptionalValidator<ReturnsValidator> = any,\n OneOrZeroArgs extends ArgsArrayForOptionalValidator<ArgsValidator> =\n DefaultArgsForOptionalValidator<ArgsValidator>,\n >(\n query:\n | {\n /**\n * Argument validation.\n *\n * Examples:\n *\n * ```\n * args: {}\n * args: { input: v.optional(v.number()) }\n * args: { message: v.string(), author: v.id(\"authors\") }\n * args: { messages: v.array(v.string()) }\n * ```\n */\n args?: ArgsValidator;\n /**\n * The return value validator.\n *\n * Examples:\n *\n * ```\n * returns: v.null()\n * returns: v.string()\n * returns: { message: v.string(), author: v.id(\"authors\") }\n * returns: v.array(v.string())\n * ```\n */\n returns?: ReturnsValidator;\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator if provided.\n * @returns\n */\n handler: (\n ctx: GenericQueryCtx<DataModel>,\n ...args: OneOrZeroArgs\n ) => ReturnValue;\n }\n | {\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator if provided.\n * @returns\n */\n (\n ctx: GenericQueryCtx<DataModel>,\n ...args: OneOrZeroArgs\n ): ReturnValue;\n },\n ): RegisteredQuery<Visibility, ArgsArrayToObject<OneOrZeroArgs>, ReturnValue>;\n};\n\n/**\n * Internal type helper used by Convex code generation.\n *\n * Used to give {@link queryGeneric} a type specific to your data model.\n * @public\n */\nexport type QueryBuilderWithTable<\n DataModel extends GenericDataModel,\n Visibility extends FunctionVisibility,\n> = {\n <\n ArgsValidator extends\n | PropertyValidators\n | Validator<any, \"required\", any>\n | void,\n ReturnsValidator extends\n | PropertyValidators\n | Validator<any, \"required\", any>\n | void,\n ReturnValue extends ReturnValueForOptionalValidator<ReturnsValidator> = any,\n OneOrZeroArgs extends ArgsArrayForOptionalValidator<ArgsValidator> =\n DefaultArgsForOptionalValidator<ArgsValidator>,\n >(\n query:\n | {\n /**\n * Argument validation.\n *\n * Examples:\n *\n * ```\n * args: {}\n * args: { input: v.optional(v.number()) }\n * args: { message: v.string(), author: v.id(\"authors\") }\n * args: { messages: v.array(v.string()) }\n * ```\n */\n args?: ArgsValidator;\n /**\n * The return value validator.\n *\n * Examples:\n *\n * ```\n * returns: v.null()\n * returns: v.string()\n * returns: { message: v.string(), author: v.id(\"authors\") }\n * returns: v.array(v.string())\n * ```\n */\n returns?: ReturnsValidator;\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator if provided.\n * @returns\n */\n handler: (\n ctx: GenericQueryCtxWithTable<DataModel>,\n ...args: OneOrZeroArgs\n ) => ReturnValue;\n }\n | {\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator if provided.\n * @returns\n */\n (\n ctx: GenericQueryCtxWithTable<DataModel>,\n ...args: OneOrZeroArgs\n ): ReturnValue;\n },\n ): RegisteredQuery<Visibility, ArgsArrayToObject<OneOrZeroArgs>, ReturnValue>;\n};\n\n/**\n * Internal type helper used by Convex code generation.\n *\n * Used to give {@link actionGeneric} a type specific to your data model.\n * @public\n */\nexport type ActionBuilder<\n DataModel extends GenericDataModel,\n Visibility extends FunctionVisibility,\n> = {\n <\n ArgsValidator extends\n | PropertyValidators\n | Validator<any, \"required\", any>\n | void,\n ReturnsValidator extends\n | PropertyValidators\n | Validator<any, \"required\", any>\n | void,\n ReturnValue extends ReturnValueForOptionalValidator<ReturnsValidator> = any,\n OneOrZeroArgs extends ArgsArrayForOptionalValidator<ArgsValidator> =\n DefaultArgsForOptionalValidator<ArgsValidator>,\n >(\n func:\n | {\n /**\n * Argument validation.\n *\n * Examples:\n *\n * ```\n * args: {}\n * args: { input: v.optional(v.number()) }\n * args: { message: v.string(), author: v.id(\"authors\") }\n * args: { messages: v.array(v.string()) }\n * ```\n *\n */\n args?: ArgsValidator;\n /**\n * The return value validator.\n *\n * Examples:\n *\n * ```\n * returns: v.null()\n * returns: v.string()\n * returns: { message: v.string(), author: v.id(\"authors\") }\n * returns: v.array(v.string())\n * ```\n */\n returns?: ReturnsValidator;\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator if provided.\n * @returns\n */\n handler: (\n ctx: GenericActionCtx<DataModel>,\n ...args: OneOrZeroArgs\n ) => ReturnValue;\n }\n | {\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator if provided.\n * @returns\n */\n (\n ctx: GenericActionCtx<DataModel>,\n ...args: OneOrZeroArgs\n ): ReturnValue;\n },\n ): RegisteredAction<\n Visibility,\n ArgsArrayToObject<OneOrZeroArgs>,\n ReturnValue\n >;\n};\n\n/**\n * Internal type helper used by Convex code generation.\n *\n * Used to give {@link httpActionGeneric} a type specific to your data model\n * and functions.\n * @public\n */\nexport type HttpActionBuilder = (\n func: (ctx: GenericActionCtx<any>, request: Request) => Promise<Response>,\n) => PublicHttpAction;\n\nexport interface AdvancedRunQueryOptions {\n transactionLimits?: TransactionLimits;\n /**\n * Run a query on a recent snapshot of the database that is not guaranteed\n * to be up-to-date when this transaction commits.\n *\n * This is an advanced feature which can introduce subtle race conditions,\n * so its use is generally discouraged except for specific use-cases where\n * database read conflicts are expected, e.g. reading from an append-only\n * table with immutable records where the only read conflicts are from\n * concurrent appends.\n */\n useStaleSnapshot?: boolean;\n}\n"],
4
+ "sourcesContent": ["import {\n Auth,\n GenericDatabaseReader,\n GenericDatabaseReaderWithTable,\n GenericDatabaseWriter,\n GenericDatabaseWriterWithTable,\n StorageActionWriter,\n StorageReader,\n StorageWriter,\n} from \"./index.js\";\nimport {\n ActionMeta,\n MutationMeta,\n QueryMeta,\n TransactionLimits,\n} from \"./meta.js\";\nimport {\n ArgsAndOptions,\n FunctionReturnType,\n OptionalRestArgs,\n ValidatorTypeToReturnType,\n FunctionReference,\n FunctionReference_future,\n} from \"../server/api.js\";\nimport {\n GenericValidator,\n Infer,\n ObjectType,\n PropertyValidators,\n} from \"../values/validator.js\";\nimport { Id } from \"../values/value.js\";\nimport {\n GenericDataModel,\n NamedTableInfo,\n TableNamesInDataModel,\n VectorIndexNames,\n} from \"./data_model.js\";\nimport { Scheduler } from \"./scheduler.js\";\nimport { VectorSearchQuery } from \"./vector_search.js\";\nimport { Expand } from \"../type_utils.js\";\nimport { Validator } from \"../values/validators.js\";\n\n/**\n * A set of services for use within Convex mutation functions.\n *\n * The mutation context is passed as the first argument to any Convex mutation\n * function run on the server. Mutations run **transactionally**, all reads\n * and writes within a single mutation are atomic and isolated.\n *\n * You should generally use the `MutationCtx` type from\n * `\"./_generated/server\"`.\n *\n * @example\n * ```typescript\n * import { mutation } from \"./_generated/server\";\n * import { internal } from \"./_generated/api\";\n * import { v } from \"convex/values\";\n *\n * export const createTask = mutation({\n * args: { text: v.string() },\n * returns: v.id(\"tasks\"),\n * handler: async (ctx, args) => {\n * // ctx.db: read and write documents\n * const taskId = await ctx.db.insert(\"tasks\", { text: args.text, completed: false });\n *\n * // ctx.auth: check the authenticated user\n * const identity = await ctx.auth.getUserIdentity();\n *\n * // ctx.scheduler: schedule functions for later\n * await ctx.scheduler.runAfter(0, internal.notifications.send, { taskId });\n *\n * return taskId;\n * },\n * });\n * ```\n *\n * @public\n */\nexport interface GenericMutationCtx<DataModel extends GenericDataModel> {\n /**\n * A utility for reading and writing data in the database.\n *\n * Use `ctx.db.insert()`, `ctx.db.patch()`, `ctx.db.replace()`, and\n * `ctx.db.delete()` to write data. Use `ctx.db.get()` and `ctx.db.query()`\n * to read data. All operations within a mutation are atomic.\n */\n db: GenericDatabaseWriter<DataModel>;\n\n /**\n * Information about the currently authenticated user.\n *\n * Call `await ctx.auth.getUserIdentity()` to get the current user's identity,\n * or `null` if the user is not authenticated.\n */\n auth: Auth;\n\n /**\n * A utility for reading and writing files in storage.\n *\n * Use `ctx.storage.generateUploadUrl()` to create an upload URL for clients,\n * `ctx.storage.getUrl(storageId)` to get a URL for a stored file,\n * or `ctx.storage.delete(storageId)` to remove one.\n */\n storage: StorageWriter;\n\n /**\n * A utility for scheduling Convex functions to run in the future.\n *\n * @example\n * ```typescript\n * // Schedule an action to run immediately after this mutation commits:\n * await ctx.scheduler.runAfter(0, internal.emails.sendWelcome, { userId });\n *\n * // Schedule a cleanup to run in 24 hours:\n * await ctx.scheduler.runAfter(24 * 60 * 60 * 1000, internal.tasks.cleanup, {});\n * ```\n */\n scheduler: Scheduler;\n\n /**\n * Call a query function within the same transaction.\n *\n * The query runs within the same transaction as the calling mutation,\n * seeing a consistent snapshot of the database. Requires a\n * {@link FunctionReference} (e.g., `api.myModule.myQuery` or\n * `internal.myModule.myQuery`).\n *\n * NOTE: Often you can extract shared logic into a helper function instead.\n * `runQuery` incurs overhead of running argument and return value validation,\n * and creating a new isolated JS context.\n *\n * @example\n * ```typescript\n * const user = await ctx.runQuery(internal.users.getUser, { userId });\n * ```\n */\n runQuery: <\n Query extends\n | FunctionReference<\"query\", \"public\" | \"internal\">\n | FunctionReference_future<\"query\", \"public\" | \"internal\">,\n >(\n query: Query,\n ...args: ArgsAndOptions<Query, AdvancedRunQueryOptions>\n ) => Promise<FunctionReturnType<Query>>;\n\n /**\n * Call a mutation function within the same transaction.\n *\n * The mutation runs in a sub-transaction, so if it throws an error, all of\n * its writes will be rolled back. Requires a {@link FunctionReference}.\n *\n * NOTE: Often you can extract shared logic into a helper function instead.\n * `runMutation` incurs overhead of running argument and return value\n * validation, and creating a new isolated JS context.\n */\n runMutation: <\n Mutation extends\n | FunctionReference<\"mutation\", \"public\" | \"internal\">\n | FunctionReference_future<\"mutation\", \"public\" | \"internal\">,\n >(\n mutation: Mutation,\n ...args: ArgsAndOptions<Mutation, { transactionLimits?: TransactionLimits }>\n ) => Promise<FunctionReturnType<Mutation>>;\n\n meta: MutationMeta;\n}\n\n/**\n * A set of services for use within Convex mutation functions.\n *\n * The mutation context is passed as the first argument to any Convex mutation\n * function run on the server.\n *\n * You should generally use the `MutationCtx` type from\n * `\"./_generated/server\"`.\n *\n * @public\n */\nexport type GenericMutationCtxWithTable<DataModel extends GenericDataModel> =\n Omit<GenericMutationCtx<DataModel>, \"db\"> & {\n db: GenericDatabaseWriterWithTable<DataModel>;\n };\n\n/**\n * A set of services for use within Convex query functions.\n *\n * The query context is passed as the first argument to any Convex query\n * function run on the server. Queries are **read-only**, they can read from\n * the database but cannot write. They are also **reactive**, when used with\n * `useQuery` on the client, the result automatically updates when data changes.\n *\n * You should generally use the `QueryCtx` type from\n * `\"./_generated/server\"`.\n *\n * @example\n * ```typescript\n * import { query } from \"./_generated/server\";\n * import { v } from \"convex/values\";\n *\n * export const listTasks = query({\n * args: {},\n * returns: v.array(v.object({\n * _id: v.id(\"tasks\"),\n * _creationTime: v.number(),\n * text: v.string(),\n * completed: v.boolean(),\n * })),\n * handler: async (ctx, args) => {\n * // ctx.db: read-only database access\n * return await ctx.db.query(\"tasks\").order(\"desc\").take(100);\n * },\n * });\n * ```\n *\n * @public\n */\nexport interface GenericQueryCtx<DataModel extends GenericDataModel> {\n /**\n * A utility for reading data in the database.\n *\n * Use `ctx.db.get(table, id)` to fetch a single document by ID, or\n * `ctx.db.query(\"tableName\")` to query multiple documents with filtering\n * and ordering. Queries are read-only, no write methods are available.\n */\n db: GenericDatabaseReader<DataModel>;\n\n /**\n * Information about the currently authenticated user.\n *\n * Call `await ctx.auth.getUserIdentity()` to get the current user's identity,\n * or `null` if the user is not authenticated.\n */\n auth: Auth;\n\n /**\n * A utility for reading files in storage.\n *\n * Use `ctx.storage.getUrl(storageId)` to get a URL for a stored file.\n */\n storage: StorageReader;\n\n /**\n * Call a query function within the same transaction.\n *\n * The query runs within the same read snapshot. Requires a\n * {@link FunctionReference} (e.g., `api.myModule.myQuery` or\n * `internal.myModule.myQuery`).\n *\n * NOTE: Often you can extract shared logic into a helper function instead.\n * `runQuery` incurs overhead of running argument and return value validation,\n * and creating a new isolated JS context.\n */\n runQuery: <\n Query extends\n | FunctionReference<\"query\", \"public\" | \"internal\">\n | FunctionReference_future<\"query\", \"public\" | \"internal\">,\n >(\n query: Query,\n ...args: ArgsAndOptions<Query, { transactionLimits?: TransactionLimits }>\n ) => Promise<FunctionReturnType<Query>>;\n\n meta: QueryMeta;\n}\n\n/**\n * A set of services for use within Convex query functions.\n *\n * The query context is passed as the first argument to any Convex query\n * function run on the server.\n *\n * This differs from the {@link MutationCtx} because all of the services are\n * read-only.\n *\n *\n * @public\n */\nexport type GenericQueryCtxWithTable<DataModel extends GenericDataModel> = Omit<\n GenericQueryCtx<DataModel>,\n \"db\"\n> & {\n db: GenericDatabaseReaderWithTable<DataModel>;\n};\n\n/**\n * A set of services for use within Convex action functions.\n *\n * The action context is passed as the first argument to any Convex action\n * run on the server. Actions can call external APIs and use Node.js libraries,\n * but do **not** have direct database access (`ctx.db` is not available).\n * Use `ctx.runQuery` and `ctx.runMutation` to interact with the database.\n *\n * You should generally use the `ActionCtx` type from\n * `\"./_generated/server\"`.\n *\n * @example\n * ```typescript\n * import { action } from \"./_generated/server\";\n * import { internal } from \"./_generated/api\";\n * import { v } from \"convex/values\";\n *\n * export const processPayment = action({\n * args: { orderId: v.id(\"orders\"), amount: v.number() },\n * returns: v.null(),\n * handler: async (ctx, args) => {\n * // Read data via ctx.runQuery:\n * const order = await ctx.runQuery(internal.orders.get, { id: args.orderId });\n *\n * // Call external API:\n * const result = await fetch(\"https://api.stripe.com/v1/charges\", { ... });\n *\n * // Write results back via ctx.runMutation:\n * await ctx.runMutation(internal.orders.markPaid, { id: args.orderId });\n *\n * return null;\n * },\n * });\n * ```\n *\n * **Common mistake:** `ctx.db` is not available in actions. Do not try to\n * access it, use `ctx.runQuery` and `ctx.runMutation` instead.\n *\n * @public\n */\nexport interface GenericActionCtx<DataModel extends GenericDataModel> {\n /**\n * Run the Convex query with the given name and arguments.\n *\n * Each `runQuery` call is a separate read transaction. Consider using an\n * {@link internalQuery} to prevent users from calling the query directly.\n *\n * @example\n * ```typescript\n * const user = await ctx.runQuery(internal.users.get, { userId });\n * ```\n *\n * @param query - A {@link FunctionReference} for the query to run.\n * @param args - The arguments to the query function.\n * @returns A promise of the query's result.\n */\n runQuery<\n Query extends\n | FunctionReference<\"query\", \"public\" | \"internal\">\n | FunctionReference_future<\"query\", \"public\" | \"internal\">,\n >(\n query: Query,\n ...args: OptionalRestArgs<Query>\n ): Promise<FunctionReturnType<Query>>;\n\n /**\n * Run the Convex mutation with the given name and arguments.\n *\n * Each `runMutation` call is a separate write transaction. Consider using\n * an {@link internalMutation} to prevent users from calling it directly.\n *\n * @example\n * ```typescript\n * await ctx.runMutation(internal.orders.markPaid, { id: orderId });\n * ```\n *\n * @param mutation - A {@link FunctionReference} for the mutation to run.\n * @param args - The arguments to the mutation function.\n * @returns A promise of the mutation's result.\n */\n runMutation<\n Mutation extends\n | FunctionReference<\"mutation\", \"public\" | \"internal\">\n | FunctionReference_future<\"mutation\", \"public\" | \"internal\">,\n >(\n mutation: Mutation,\n ...args: OptionalRestArgs<Mutation>\n ): Promise<FunctionReturnType<Mutation>>;\n\n /**\n * Run the Convex action with the given name and arguments.\n *\n * **Important:** Only use `runAction` when you need to cross runtimes\n * (e.g., calling a `\"use node\"` action from the default Convex runtime).\n * For code in the same runtime, extract shared logic into a plain\n * TypeScript helper function instead, `runAction` has significant\n * overhead (separate function call, separate resource allocation).\n *\n * Consider using an {@link internalAction} to prevent users from calling the\n * action directly.\n *\n * @param action - A {@link FunctionReference} for the action to run.\n * @param args - The arguments to the action function.\n * @returns A promise of the action's result.\n */\n runAction<\n Action extends\n | FunctionReference<\"action\", \"public\" | \"internal\">\n | FunctionReference_future<\"action\", \"public\" | \"internal\">,\n >(\n action: Action,\n ...args: OptionalRestArgs<Action>\n ): Promise<FunctionReturnType<Action>>;\n\n /**\n * A utility for scheduling Convex functions to run in the future.\n */\n scheduler: Scheduler;\n\n /**\n * Information about the currently authenticated user.\n */\n auth: Auth;\n\n /**\n * A utility for reading and writing files in storage.\n */\n storage: StorageActionWriter;\n\n /**\n * Run a vector search on the given table and index.\n *\n * @param tableName - The name of the table to query.\n * @param indexName - The name of the vector index on the table to query.\n * @param query - A {@link VectorSearchQuery} containing the vector to query,\n * the number of results to return, and any filters.\n * @returns A promise of IDs and scores for the documents with the nearest\n * vectors\n */\n vectorSearch<\n TableName extends TableNamesInDataModel<DataModel>,\n IndexName extends VectorIndexNames<NamedTableInfo<DataModel, TableName>>,\n >(\n tableName: TableName,\n indexName: IndexName,\n query: Expand<\n VectorSearchQuery<NamedTableInfo<DataModel, TableName>, IndexName>\n >,\n ): Promise<Array<{ _id: Id<TableName>; _score: number }>>;\n\n meta: ActionMeta;\n}\n\n/**\n * The default arguments type for a Convex query, mutation, or action function.\n *\n * Convex functions always take an arguments object that maps the argument\n * names to their values.\n *\n * @public\n */\nexport type DefaultFunctionArgs = Record<string, unknown>;\n\n/**\n * The arguments array for a function that takes arguments.\n *\n * This is an array of a single {@link DefaultFunctionArgs} element.\n */\ntype OneArgArray<ArgsObject extends DefaultFunctionArgs = DefaultFunctionArgs> =\n [ArgsObject];\n\n/**\n * The arguments to a function that takes no arguments (just an empty array).\n */\ntype NoArgsArray = [];\n\n/**\n * An array of arguments to a Convex function.\n *\n * Convex functions can take either a single {@link DefaultFunctionArgs} object or no\n * args at all.\n *\n * @public\n */\nexport type ArgsArray = OneArgArray | NoArgsArray;\n\n/**\n * A type for the empty object `{}`.\n *\n * Note that we don't use `type EmptyObject = {}` because that matches every object.\n */\nexport type EmptyObject = Record<string, never>;\n\n/**\n * Convert an {@link ArgsArray} into a single object type.\n *\n * Empty arguments arrays are converted to {@link EmptyObject}.\n * @public\n */\nexport type ArgsArrayToObject<Args extends ArgsArray> =\n Args extends OneArgArray<infer ArgsObject> ? ArgsObject : EmptyObject;\n\n/**\n * A type representing the visibility of a Convex function.\n *\n * @public\n */\nexport type FunctionVisibility = \"public\" | \"internal\";\n\n/**\n * Given a {@link FunctionVisibility}, should this function have `isPublic: true`\n * or `isInternal: true`?\n */\ntype VisibilityProperties<Visiblity extends FunctionVisibility> = {\n /** Phantom type marker; not present at runtime. */\n _visibility: Visiblity;\n} & (Visiblity extends \"public\"\n ? {\n isPublic: true;\n }\n : {\n isInternal: true;\n });\n\n/**\n * A mutation function that is part of this app.\n *\n * You can create a mutation by wrapping your function in\n * {@link mutationGeneric} or {@link internalMutationGeneric} and exporting it.\n *\n * @public\n */\nexport type RegisteredMutation<\n Visibility extends FunctionVisibility,\n Args extends DefaultFunctionArgs,\n Returns,\n> = {\n isConvexFunction: true;\n isMutation: true;\n\n /** @internal */\n invokeMutation(argsStr: string): Promise<string>;\n\n /** @internal */\n exportArgs(): string;\n\n /** @internal */\n exportReturns(): string;\n\n /** @internal */\n _handler: (ctx: GenericMutationCtx<any>, args: Args) => Returns;\n} & VisibilityProperties<Visibility>;\n\n/**\n * A query function that is part of this app.\n *\n * You can create a query by wrapping your function in\n * {@link queryGeneric} or {@link internalQueryGeneric} and exporting it.\n *\n * @public\n */\nexport type RegisteredQuery<\n Visibility extends FunctionVisibility,\n Args extends DefaultFunctionArgs,\n Returns,\n> = {\n isConvexFunction: true;\n isQuery: true;\n\n /** @internal */\n invokeQuery(argsStr: string): Promise<string>;\n\n /** @internal */\n exportArgs(): string;\n\n /** @internal */\n exportReturns(): string;\n\n /** @internal */\n _handler: (ctx: GenericQueryCtx<any>, args: Args) => Returns;\n} & VisibilityProperties<Visibility>;\n\n/**\n * An action that is part of this app.\n *\n * You can create an action by wrapping your function in\n * {@link actionGeneric} or {@link internalActionGeneric} and exporting it.\n *\n * @public\n */\nexport type RegisteredAction<\n Visibility extends FunctionVisibility,\n Args extends DefaultFunctionArgs,\n Returns,\n> = {\n isConvexFunction: true;\n isAction: true;\n\n /** @internal */\n invokeAction(requestId: string, argsStr: string): Promise<string>;\n\n /** @internal */\n exportArgs(): string;\n\n /** @internal */\n exportReturns(): string;\n\n /** @internal */\n _handler: (ctx: GenericActionCtx<any>, args: Args) => Returns;\n} & VisibilityProperties<Visibility>;\n\n/**\n * An HTTP action that is part of this app's public API.\n *\n * You can create public HTTP actions by wrapping your function in\n * {@link httpActionGeneric} and exporting it.\n *\n * @public\n */\nexport type PublicHttpAction = {\n isHttp: true;\n\n /** @internal */\n invokeHttpAction(request: Request): Promise<Response>;\n /** @internal */\n _handler: (ctx: GenericActionCtx<any>, request: Request) => Promise<Response>;\n};\n\n/**\n * @deprecated -- See the type definition for `MutationBuilder` or similar for\n * the types used for defining Convex functions.\n *\n * The definition of a Convex query, mutation, or action function without\n * argument validation.\n *\n * Convex functions always take a context object as their first argument\n * and an (optional) args object as their second argument.\n *\n * This can be written as a function like:\n * ```js\n * import { query } from \"./_generated/server\";\n *\n * export const func = query(({ db }, { arg }) => {...});\n * ```\n * or as an object like:\n *\n * ```js\n * import { query } from \"./_generated/server\";\n *\n * export const func = query({\n * handler: ({ db }, { arg }) => {...},\n * });\n * ```\n * See {@link ValidatedFunction} to add argument validation.\n *\n * @public\n */\nexport type UnvalidatedFunction<Ctx, Args extends ArgsArray, Returns> =\n | ((ctx: Ctx, ...args: Args) => Returns)\n | {\n handler: (ctx: Ctx, ...args: Args) => Returns;\n };\n\n/**\n * @deprecated -- See the type definition for `MutationBuilder` or similar for\n * the types used for defining Convex functions.\n *\n * The definition of a Convex query, mutation, or action function with argument\n * validation.\n *\n * Argument validation allows you to assert that the arguments to this function\n * are the expected type.\n *\n * Example:\n *\n * ```js\n * import { query } from \"./_generated/server\";\n * import { v } from \"convex/values\";\n *\n * export const func = query({\n * args: {\n * arg: v.string()\n * },\n * handler: ({ db }, { arg }) => {...},\n * });\n * ```\n *\n * **For security, argument validation should be added to all public functions in\n * production apps.**\n *\n * See {@link UnvalidatedFunction} for functions without argument validation.\n * @public\n */\nexport interface ValidatedFunction<\n Ctx,\n ArgsValidator extends PropertyValidators,\n Returns,\n> {\n /**\n * A validator for the arguments of this function.\n *\n * This is an object mapping argument names to validators constructed with\n * {@link values.v}.\n *\n * ```js\n * import { v } from \"convex/values\";\n *\n * const args = {\n * stringArg: v.string(),\n * optionalNumberArg: v.optional(v.number()),\n * }\n * ```\n */\n args: ArgsValidator;\n\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator.\n * @returns\n */\n handler: (ctx: Ctx, args: ObjectType<ArgsValidator>) => Returns;\n}\n\n/**\n * There are multiple syntaxes for defining a Convex function:\n * ```\n * - query(async (ctx, args) => {...})\n * - query({ handler: async (ctx, args) => {...} })\n * - query({ args: { a: v.string }, handler: async (ctx, args) => {...} } })\n * - query({ args: { a: v.string }, returns: v.string(), handler: async (ctx, args) => {...} } })\n *```\n *\n * In each of these, we want to correctly infer the type for the arguments and\n * return value, preferring the type derived from a validator if it's provided.\n *\n * To avoid having a separate overload for each, which would show up in error messages,\n * we use the type params -- ArgsValidator, ReturnsValidator, ReturnValue, OneOrZeroArgs.\n *\n * The type for ReturnValue and OneOrZeroArgs are constrained by the type or ArgsValidator and\n * ReturnsValidator if they're present, and inferred from any explicit type annotations to the\n * arguments or return value of the function.\n *\n * Below are a few utility types to get the appropriate type constraints based on\n * an optional validator.\n *\n * Additional tricks:\n * - We use Validator | void instead of Validator | undefined because the latter does\n * not work with `strictNullChecks` since it's equivalent to just `Validator`.\n * - We use a tuple type of length 1 to avoid distribution over the union\n * https://github.com/microsoft/TypeScript/issues/29368#issuecomment-453529532\n */\n\nexport type ReturnValueForOptionalValidator<\n ReturnsValidator extends Validator<any, any, any> | PropertyValidators | void,\n> = [ReturnsValidator] extends [Validator<any, any, any>]\n ? ValidatorTypeToReturnType<Infer<ReturnsValidator>>\n : [ReturnsValidator] extends [PropertyValidators]\n ? ValidatorTypeToReturnType<ObjectType<ReturnsValidator>>\n : any;\n\nexport type ArgsArrayForOptionalValidator<\n ArgsValidator extends GenericValidator | PropertyValidators | void,\n> = [ArgsValidator] extends [Validator<any, any, any>]\n ? OneArgArray<Infer<ArgsValidator>>\n : [ArgsValidator] extends [PropertyValidators]\n ? OneArgArray<ObjectType<ArgsValidator>>\n : ArgsArray;\n\nexport type DefaultArgsForOptionalValidator<\n ArgsValidator extends GenericValidator | PropertyValidators | void,\n> = [ArgsValidator] extends [Validator<any, any, any>]\n ? [Infer<ArgsValidator>]\n : [ArgsValidator] extends [PropertyValidators]\n ? [ObjectType<ArgsValidator>]\n : OneArgArray;\n\n/**\n * Internal type helper used by Convex code generation.\n *\n * Used to give {@link mutationGeneric} a type specific to your data model.\n * @public\n */\nexport type MutationBuilder<\n DataModel extends GenericDataModel,\n Visibility extends FunctionVisibility,\n> = {\n <\n ArgsValidator extends\n | PropertyValidators\n | Validator<any, \"required\", any>\n | void,\n ReturnsValidator extends\n | PropertyValidators\n | Validator<any, \"required\", any>\n | void,\n ReturnValue extends ReturnValueForOptionalValidator<ReturnsValidator> = any,\n OneOrZeroArgs extends ArgsArrayForOptionalValidator<ArgsValidator> =\n DefaultArgsForOptionalValidator<ArgsValidator>,\n >(\n mutation:\n | {\n /**\n * Argument validation.\n *\n * Examples:\n *\n * ```\n * args: {}\n * args: { input: v.optional(v.number()) }\n * args: { message: v.string(), author: v.id(\"authors\") }\n * args: { messages: v.array(v.string()) }\n * ```\n */\n args?: ArgsValidator;\n /**\n * The return value validator.\n *\n * Examples:\n *\n * ```\n * returns: v.null()\n * returns: v.string()\n * returns: { message: v.string(), author: v.id(\"authors\") }\n * returns: v.array(v.string())\n * ```\n */\n returns?: ReturnsValidator;\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator if provided.\n * @returns\n */\n handler: (\n ctx: GenericMutationCtx<DataModel>,\n ...args: OneOrZeroArgs\n ) => ReturnValue;\n }\n | {\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator if provided.\n * @returns\n */\n (\n ctx: GenericMutationCtx<DataModel>,\n ...args: OneOrZeroArgs\n ): ReturnValue;\n },\n ): RegisteredMutation<\n Visibility,\n ArgsArrayToObject<OneOrZeroArgs>,\n ReturnValue\n >;\n};\n\n/**\n * Internal type helper used by Convex code generation.\n *\n * Used to give {@link mutationGeneric} a type specific to your data model.\n * @public\n */\nexport type MutationBuilderWithTable<\n DataModel extends GenericDataModel,\n Visibility extends FunctionVisibility,\n> = {\n <\n ArgsValidator extends\n | PropertyValidators\n | Validator<any, \"required\", any>\n | void,\n ReturnsValidator extends\n | PropertyValidators\n | Validator<any, \"required\", any>\n | void,\n ReturnValue extends ReturnValueForOptionalValidator<ReturnsValidator> = any,\n OneOrZeroArgs extends ArgsArrayForOptionalValidator<ArgsValidator> =\n DefaultArgsForOptionalValidator<ArgsValidator>,\n >(\n mutation:\n | {\n /**\n * Argument validation.\n *\n * Examples:\n *\n * ```\n * args: {}\n * args: { input: v.optional(v.number()) }\n * args: { message: v.string(), author: v.id(\"authors\") }\n * args: { messages: v.array(v.string()) }\n * ```\n */\n args?: ArgsValidator;\n /**\n * The return value validator.\n *\n * Examples:\n *\n * ```\n * returns: v.null()\n * returns: v.string()\n * returns: { message: v.string(), author: v.id(\"authors\") }\n * returns: v.array(v.string())\n * ```\n */\n returns?: ReturnsValidator;\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator if provided.\n * @returns\n */\n handler: (\n ctx: GenericMutationCtxWithTable<DataModel>,\n ...args: OneOrZeroArgs\n ) => ReturnValue;\n }\n | {\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator if provided.\n * @returns\n */\n (\n ctx: GenericMutationCtxWithTable<DataModel>,\n ...args: OneOrZeroArgs\n ): ReturnValue;\n },\n ): RegisteredMutation<\n Visibility,\n ArgsArrayToObject<OneOrZeroArgs>,\n ReturnValue\n >;\n};\n\n/**\n * Internal type helper used by Convex code generation.\n *\n * Used to give {@link queryGeneric} a type specific to your data model.\n * @public\n */\nexport type QueryBuilder<\n DataModel extends GenericDataModel,\n Visibility extends FunctionVisibility,\n> = {\n <\n ArgsValidator extends\n | PropertyValidators\n | Validator<any, \"required\", any>\n | void,\n ReturnsValidator extends\n | PropertyValidators\n | Validator<any, \"required\", any>\n | void,\n ReturnValue extends ReturnValueForOptionalValidator<ReturnsValidator> = any,\n OneOrZeroArgs extends ArgsArrayForOptionalValidator<ArgsValidator> =\n DefaultArgsForOptionalValidator<ArgsValidator>,\n >(\n query:\n | {\n /**\n * Argument validation.\n *\n * Examples:\n *\n * ```\n * args: {}\n * args: { input: v.optional(v.number()) }\n * args: { message: v.string(), author: v.id(\"authors\") }\n * args: { messages: v.array(v.string()) }\n * ```\n */\n args?: ArgsValidator;\n /**\n * The return value validator.\n *\n * Examples:\n *\n * ```\n * returns: v.null()\n * returns: v.string()\n * returns: { message: v.string(), author: v.id(\"authors\") }\n * returns: v.array(v.string())\n * ```\n */\n returns?: ReturnsValidator;\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator if provided.\n * @returns\n */\n handler: (\n ctx: GenericQueryCtx<DataModel>,\n ...args: OneOrZeroArgs\n ) => ReturnValue;\n }\n | {\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator if provided.\n * @returns\n */\n (\n ctx: GenericQueryCtx<DataModel>,\n ...args: OneOrZeroArgs\n ): ReturnValue;\n },\n ): RegisteredQuery<Visibility, ArgsArrayToObject<OneOrZeroArgs>, ReturnValue>;\n};\n\n/**\n * Internal type helper used by Convex code generation.\n *\n * Used to give {@link queryGeneric} a type specific to your data model.\n * @public\n */\nexport type QueryBuilderWithTable<\n DataModel extends GenericDataModel,\n Visibility extends FunctionVisibility,\n> = {\n <\n ArgsValidator extends\n | PropertyValidators\n | Validator<any, \"required\", any>\n | void,\n ReturnsValidator extends\n | PropertyValidators\n | Validator<any, \"required\", any>\n | void,\n ReturnValue extends ReturnValueForOptionalValidator<ReturnsValidator> = any,\n OneOrZeroArgs extends ArgsArrayForOptionalValidator<ArgsValidator> =\n DefaultArgsForOptionalValidator<ArgsValidator>,\n >(\n query:\n | {\n /**\n * Argument validation.\n *\n * Examples:\n *\n * ```\n * args: {}\n * args: { input: v.optional(v.number()) }\n * args: { message: v.string(), author: v.id(\"authors\") }\n * args: { messages: v.array(v.string()) }\n * ```\n */\n args?: ArgsValidator;\n /**\n * The return value validator.\n *\n * Examples:\n *\n * ```\n * returns: v.null()\n * returns: v.string()\n * returns: { message: v.string(), author: v.id(\"authors\") }\n * returns: v.array(v.string())\n * ```\n */\n returns?: ReturnsValidator;\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator if provided.\n * @returns\n */\n handler: (\n ctx: GenericQueryCtxWithTable<DataModel>,\n ...args: OneOrZeroArgs\n ) => ReturnValue;\n }\n | {\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator if provided.\n * @returns\n */\n (\n ctx: GenericQueryCtxWithTable<DataModel>,\n ...args: OneOrZeroArgs\n ): ReturnValue;\n },\n ): RegisteredQuery<Visibility, ArgsArrayToObject<OneOrZeroArgs>, ReturnValue>;\n};\n\n/**\n * Internal type helper used by Convex code generation.\n *\n * Used to give {@link actionGeneric} a type specific to your data model.\n * @public\n */\nexport type ActionBuilder<\n DataModel extends GenericDataModel,\n Visibility extends FunctionVisibility,\n> = {\n <\n ArgsValidator extends\n | PropertyValidators\n | Validator<any, \"required\", any>\n | void,\n ReturnsValidator extends\n | PropertyValidators\n | Validator<any, \"required\", any>\n | void,\n ReturnValue extends ReturnValueForOptionalValidator<ReturnsValidator> = any,\n OneOrZeroArgs extends ArgsArrayForOptionalValidator<ArgsValidator> =\n DefaultArgsForOptionalValidator<ArgsValidator>,\n >(\n func:\n | {\n /**\n * Argument validation.\n *\n * Examples:\n *\n * ```\n * args: {}\n * args: { input: v.optional(v.number()) }\n * args: { message: v.string(), author: v.id(\"authors\") }\n * args: { messages: v.array(v.string()) }\n * ```\n *\n */\n args?: ArgsValidator;\n /**\n * The return value validator.\n *\n * Examples:\n *\n * ```\n * returns: v.null()\n * returns: v.string()\n * returns: { message: v.string(), author: v.id(\"authors\") }\n * returns: v.array(v.string())\n * ```\n */\n returns?: ReturnsValidator;\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator if provided.\n * @returns\n */\n handler: (\n ctx: GenericActionCtx<DataModel>,\n ...args: OneOrZeroArgs\n ) => ReturnValue;\n }\n | {\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator if provided.\n * @returns\n */\n (\n ctx: GenericActionCtx<DataModel>,\n ...args: OneOrZeroArgs\n ): ReturnValue;\n },\n ): RegisteredAction<\n Visibility,\n ArgsArrayToObject<OneOrZeroArgs>,\n ReturnValue\n >;\n};\n\n/**\n * Internal type helper used by Convex code generation.\n *\n * Used to give {@link httpActionGeneric} a type specific to your data model\n * and functions.\n * @public\n */\nexport type HttpActionBuilder = (\n func: (ctx: GenericActionCtx<any>, request: Request) => Promise<Response>,\n) => PublicHttpAction;\n\nexport interface AdvancedRunQueryOptions {\n /**\n * Custom limits for a nested transaction. Each field specifies the absolute\n * maximum allowed for the nested function call. Values are capped at the\n * global transaction limits, so they can only lower limits, never raise them.\n */\n transactionLimits?: TransactionLimits;\n /**\n * Run a query on a recent snapshot of the database that is not guaranteed\n * to be up-to-date when this transaction commits.\n *\n * This is an advanced feature which can introduce subtle race conditions,\n * so its use is generally discouraged except for specific use-cases where\n * database read conflicts are expected, e.g. reading from an append-only\n * table with immutable records where the only read conflicts are from\n * concurrent appends.\n *\n * To determine the snapshot of the nested query, you can call\n * `ctx.meta.getSnapshotTs()` from within the stale snapshot query. To\n * compare to the parent mutation's snapshot timestamp, you can return that\n * value from the query and call `ctx.meta.getSnapshotTs()` from the parent.\n */\n useStaleSnapshot?: boolean;\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/server/scheduler.ts"],
4
- "sourcesContent": ["import { FunctionReference, OptionalRestArgs } from \"../server/api.js\";\nimport { Id } from \"../values/value.js\";\n\n/**\n * A {@link FunctionReference} that can be scheduled to run in the future.\n *\n * Schedulable functions are mutations and actions that are public or internal.\n *\n * @public\n */\nexport type SchedulableFunctionReference = FunctionReference<\n \"mutation\" | \"action\",\n \"public\" | \"internal\"\n>;\n\n/**\n * An interface to schedule Convex functions to run in the future.\n *\n * Available as `ctx.scheduler` in mutations and actions.\n *\n * **Execution guarantees:**\n * - **Scheduled mutations** are guaranteed to execute **exactly once**. They\n * are automatically retried on transient errors.\n * - **Scheduled actions** execute **at most once**. They are not retried and\n * may fail due to transient errors.\n *\n * Consider using an `internalMutation` or `internalAction` to ensure that\n * scheduled functions cannot be called directly from a client.\n *\n * @example\n * ```typescript\n * import { mutation } from \"./_generated/server\";\n * import { internal } from \"./_generated/api\";\n * import { v } from \"convex/values\";\n *\n * export const createOrder = mutation({\n * args: { items: v.array(v.string()) },\n * returns: v.null(),\n * handler: async (ctx, args) => {\n * const orderId = await ctx.db.insert(\"orders\", { items: args.items });\n *\n * // Run immediately after this mutation commits:\n * await ctx.scheduler.runAfter(0, internal.emails.sendConfirmation, {\n * orderId,\n * });\n *\n * // Run cleanup in 7 days:\n * await ctx.scheduler.runAfter(\n * 7 * 24 * 60 * 60 * 1000,\n * internal.orders.archiveOrder,\n * { orderId },\n * );\n *\n * return null;\n * },\n * });\n * ```\n *\n * @see https://docs.convex.dev/scheduling/scheduled-functions\n * @public\n */\nexport interface Scheduler {\n /**\n * Schedule a function to execute after a delay.\n *\n * @example\n * ```typescript\n * // Schedule to run as soon as possible (if this is a mutation it would be after this mutation commits):\n * await ctx.scheduler.runAfter(0, internal.tasks.process, { taskId });\n *\n * // Run after 5 seconds:\n * await ctx.scheduler.runAfter(5000, internal.tasks.process, { taskId });\n *\n * // Run after 1 hour:\n * await ctx.scheduler.runAfter(60 * 60 * 1000, internal.cleanup.run, {});\n * ```\n *\n * @param delayMs - Delay in milliseconds. Must be non-negative. If the delay\n * is zero, the scheduled function will be due to execute immediately after the\n * scheduling one completes.\n * @param functionReference - A {@link FunctionReference} for the function\n * to schedule.\n * @param args - Arguments to call the scheduled functions with.\n * @returns The ID of the scheduled function in the `_scheduled_functions`\n * system table. Use this to cancel it later if needed.\n **/\n runAfter<FuncRef extends SchedulableFunctionReference>(\n delayMs: number,\n functionReference: FuncRef,\n ...args: OptionalRestArgs<FuncRef>\n ): Promise<Id<\"_scheduled_functions\">>;\n\n /**\n * Schedule a function to execute at a specific time.\n *\n * @example\n * ```typescript\n * // Run at a specific Date:\n * await ctx.scheduler.runAt(\n * new Date(\"2030-01-01T00:00:00Z\"),\n * internal.events.triggerNewYear,\n * {},\n * );\n *\n * // Run at a timestamp (milliseconds since epoch):\n * await ctx.scheduler.runAt(Date.now() + 60000, internal.tasks.process, { taskId });\n * ```\n *\n * @param timestamp - A Date or a timestamp (milliseconds since the epoch).\n * If the timestamp is in the past, the scheduled function will be due to\n * execute immediately after the scheduling one completes. The timestamp can't\n * be more than five years in the past or more than five years in the future.\n * @param functionReference - A {@link FunctionReference} for the function\n * to schedule.\n * @param args - Arguments to call the scheduled functions with.\n * @returns The ID of the scheduled function in the `_scheduled_functions`\n * system table.\n **/\n runAt<FuncRef extends SchedulableFunctionReference>(\n timestamp: number | Date,\n functionReference: FuncRef,\n ...args: OptionalRestArgs<FuncRef>\n ): Promise<Id<\"_scheduled_functions\">>;\n\n /**\n * Cancel a previously scheduled function.\n *\n * For scheduled **actions**: if the action has not started, it will\n * not run. If it is already in progress, it will continue running but any\n * new functions it tries to schedule will be canceled.\n * If it had already completed, canceling will throw an error.\n * For scheduled **mutations**: the mutation will either show up as\n * \"pending\", \"completed\", or \"failed\", but never \"inProgress\".\n * Canceling a mutation will atomically cancel it entirely or fail to cancel\n * if it has committed. It is a transaction that will either run to\n * completion and commit or fully roll back.\n *\n * @example\n * ```typescript\n * // Cancel a scheduled function:\n * await ctx.scheduler.cancel(scheduledFunctionId);\n * ```\n *\n * @param id - The ID of the scheduled function to cancel (returned by\n * `runAfter` or `runAt`).\n */\n cancel(id: Id<\"_scheduled_functions\">): Promise<void>;\n}\n"],
4
+ "sourcesContent": ["import {\n FunctionReference,\n FunctionReference_future,\n OptionalRestArgs,\n} from \"../server/api.js\";\nimport { Id } from \"../values/value.js\";\n\n/**\n * A {@link FunctionReference} that can be scheduled to run in the future.\n *\n * Schedulable functions are mutations and actions that are public or internal.\n *\n * @public\n */\nexport type SchedulableFunctionReference = FunctionReference<\n \"mutation\" | \"action\",\n \"public\" | \"internal\"\n>;\n\n// What the scheduling methods accept. This is kept separate from the exported\n// `SchedulableFunctionReference` so that alias keeps describing a plain\n// reference. Existing code depending on it can still forward it to anything\n// typed with `FunctionReference` or read its `_args`. This alias is\n// module-local so that a consumer's declaration file inlines it instead of\n// importing it from a path that is not part of the package's public entry\n// points.\ntype SchedulableFunctionReferenceCompat =\n | SchedulableFunctionReference\n | FunctionReference_future<\"mutation\" | \"action\", \"public\" | \"internal\">;\n\n/**\n * An interface to schedule Convex functions to run in the future.\n *\n * Available as `ctx.scheduler` in mutations and actions.\n *\n * **Execution guarantees:**\n * - **Scheduled mutations** are guaranteed to execute **exactly once**. They\n * are automatically retried on transient errors.\n * - **Scheduled actions** execute **at most once**. They are not retried and\n * may fail due to transient errors.\n *\n * Consider using an `internalMutation` or `internalAction` to ensure that\n * scheduled functions cannot be called directly from a client.\n *\n * @example\n * ```typescript\n * import { mutation } from \"./_generated/server\";\n * import { internal } from \"./_generated/api\";\n * import { v } from \"convex/values\";\n *\n * export const createOrder = mutation({\n * args: { items: v.array(v.string()) },\n * returns: v.null(),\n * handler: async (ctx, args) => {\n * const orderId = await ctx.db.insert(\"orders\", { items: args.items });\n *\n * // Run immediately after this mutation commits:\n * await ctx.scheduler.runAfter(0, internal.emails.sendConfirmation, {\n * orderId,\n * });\n *\n * // Run cleanup in 7 days:\n * await ctx.scheduler.runAfter(\n * 7 * 24 * 60 * 60 * 1000,\n * internal.orders.archiveOrder,\n * { orderId },\n * );\n *\n * return null;\n * },\n * });\n * ```\n *\n * @see https://docs.convex.dev/scheduling/scheduled-functions\n * @public\n */\nexport interface Scheduler {\n /**\n * Schedule a function to execute after a delay.\n *\n * @example\n * ```typescript\n * // Schedule to run as soon as possible (if this is a mutation it would be after this mutation commits):\n * await ctx.scheduler.runAfter(0, internal.tasks.process, { taskId });\n *\n * // Run after 5 seconds:\n * await ctx.scheduler.runAfter(5000, internal.tasks.process, { taskId });\n *\n * // Run after 1 hour:\n * await ctx.scheduler.runAfter(60 * 60 * 1000, internal.cleanup.run, {});\n * ```\n *\n * @param delayMs - Delay in milliseconds. Must be non-negative. If the delay\n * is zero, the scheduled function will be due to execute immediately after the\n * scheduling one completes.\n * @param functionReference - A {@link FunctionReference} or\n * {@link FunctionReference_future} for the function to schedule.\n * @param args - Arguments to call the scheduled functions with.\n * @returns The ID of the scheduled function in the `_scheduled_functions`\n * system table. Use this to cancel it later if needed.\n **/\n runAfter<FuncRef extends SchedulableFunctionReferenceCompat>(\n delayMs: number,\n functionReference: FuncRef,\n ...args: OptionalRestArgs<FuncRef>\n ): Promise<Id<\"_scheduled_functions\">>;\n\n /**\n * Schedule a function to execute at a specific time.\n *\n * @example\n * ```typescript\n * // Run at a specific Date:\n * await ctx.scheduler.runAt(\n * new Date(\"2030-01-01T00:00:00Z\"),\n * internal.events.triggerNewYear,\n * {},\n * );\n *\n * // Run at a timestamp (milliseconds since epoch):\n * await ctx.scheduler.runAt(Date.now() + 60000, internal.tasks.process, { taskId });\n * ```\n *\n * @param timestamp - A Date or a timestamp (milliseconds since the epoch).\n * If the timestamp is in the past, the scheduled function will be due to\n * execute immediately after the scheduling one completes. The timestamp can't\n * be more than five years in the past or more than five years in the future.\n * @param functionReference - A {@link FunctionReference} or\n * {@link FunctionReference_future} for the function to schedule.\n * @param args - Arguments to call the scheduled functions with.\n * @returns The ID of the scheduled function in the `_scheduled_functions`\n * system table.\n **/\n runAt<FuncRef extends SchedulableFunctionReferenceCompat>(\n timestamp: number | Date,\n functionReference: FuncRef,\n ...args: OptionalRestArgs<FuncRef>\n ): Promise<Id<\"_scheduled_functions\">>;\n\n /**\n * Cancel a previously scheduled function.\n *\n * For scheduled **actions**: if the action has not started, it will\n * not run. If it is already in progress, it will continue running but any\n * new functions it tries to schedule will be canceled.\n * If it had already completed, canceling will throw an error.\n * For scheduled **mutations**: the mutation will either show up as\n * \"pending\", \"completed\", or \"failed\", but never \"inProgress\".\n * Canceling a mutation will atomically cancel it entirely or fail to cancel\n * if it has committed. It is a transaction that will either run to\n * completion and commit or fully roll back.\n *\n * @example\n * ```typescript\n * // Cancel a scheduled function:\n * await ctx.scheduler.cancel(scheduledFunctionId);\n * ```\n *\n * @param id - The ID of the scheduled function to cancel (returned by\n * `runAfter` or `runAt`).\n */\n cancel(id: Id<\"_scheduled_functions\">): Promise<void>;\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
6
6
  "names": []
7
7
  }
@@ -41,6 +41,9 @@ class TableDefinition {
41
41
  __publicField(this, "stagedVectorIndexes");
42
42
  // The type of documents stored in this table.
43
43
  __publicField(this, "validator");
44
+ // The proposed next validator for this table, validated against existing
45
+ // documents in the background while `validator` remains enforced.
46
+ __publicField(this, "stagedValidator");
44
47
  this.indexes = [];
45
48
  this.stagedDbIndexes = [];
46
49
  this.searchIndexes = [];
@@ -113,6 +116,60 @@ class TableDefinition {
113
116
  }
114
117
  return this;
115
118
  }
119
+ /**
120
+ * Stage changes to this table's document validator.
121
+ *
122
+ * Convex validates the staged validator against the table's existing
123
+ * documents in the background, while the validator passed to
124
+ * {@link defineTable} remains the one enforced on writes. Once
125
+ * the background validation succeeds, apply the staged changes
126
+ * and remove `.staged()`.
127
+ *
128
+ * For an object validator, pass only the fields to add or replace. Fields
129
+ * omitted from the changes keep their enforced validators.
130
+ * Set a field to `undefined` to remove it from the staged validator.
131
+ * For nested objects, you must specify the full object validator.
132
+ *
133
+ * ```ts
134
+ * defineTable({
135
+ * apple: v.string(),
136
+ * banana: v.number(),
137
+ * legacy: v.optional(v.string()),
138
+ * }).staged({
139
+ * banana: v.union(v.string(), v.number()),
140
+ * legacy: undefined,
141
+ * })
142
+ * ```
143
+ *
144
+ * See [Staged validators](https://docs.convex.dev/database/schemas#staged-validators).
145
+ *
146
+ * @param documentSchema - Field changes for a table defined as an object or
147
+ * `v.any()`, or a full schema validator specifying the proposed next document
148
+ * type. Use a full schema validator for a table defined as a union.
149
+ * @returns A {@link TableDefinition} with the staged validator attached.
150
+ */
151
+ staged(documentSchema) {
152
+ if (this.stagedValidator !== void 0) {
153
+ throw new Error("Table cannot have more than one staged validator.");
154
+ }
155
+ if ((0, import_validator.isValidator)(documentSchema)) {
156
+ this.stagedValidator = documentSchema;
157
+ } else {
158
+ if (this.validator.kind !== "object" && this.validator.kind !== "any") {
159
+ throw new Error(
160
+ "Specifying top-level field changes is only supported for simple table definitions. For a table defined with a union or record validator, you must stage a fully defined object or union validator."
161
+ );
162
+ }
163
+ const enforcedFields = this.validator.kind === "object" ? this.validator.fields : {};
164
+ const fields = Object.fromEntries(
165
+ Object.entries({ ...enforcedFields, ...documentSchema }).filter(
166
+ (entry) => entry[1] !== void 0
167
+ )
168
+ );
169
+ this.stagedValidator = import_validator.v.object(fields);
170
+ }
171
+ return this.self();
172
+ }
116
173
  /**
117
174
  * Work around for https://github.com/microsoft/TypeScript/issues/57035
118
175
  */
@@ -132,6 +189,15 @@ class TableDefinition {
132
189
  "Invalid validator: please make sure that the parameter of `defineTable` is valid (see https://docs.convex.dev/database/schemas)"
133
190
  );
134
191
  }
192
+ let stagedDocumentType = void 0;
193
+ if (this.stagedValidator !== void 0) {
194
+ stagedDocumentType = this.stagedValidator.json;
195
+ if (typeof stagedDocumentType !== "object") {
196
+ throw new Error(
197
+ "Invalid staged validator: please make sure that the parameter of `.staged()` is valid (see https://docs.convex.dev/database/schemas)"
198
+ );
199
+ }
200
+ }
135
201
  return {
136
202
  indexes: this.indexes,
137
203
  stagedDbIndexes: this.stagedDbIndexes,
@@ -139,7 +205,8 @@ class TableDefinition {
139
205
  stagedSearchIndexes: this.stagedSearchIndexes,
140
206
  vectorIndexes: this.vectorIndexes,
141
207
  stagedVectorIndexes: this.stagedVectorIndexes,
142
- documentType
208
+ documentType,
209
+ stagedDocumentType
143
210
  };
144
211
  }
145
212
  }
@@ -244,7 +311,8 @@ class SchemaDefinition {
244
311
  stagedSearchIndexes,
245
312
  vectorIndexes,
246
313
  stagedVectorIndexes,
247
- documentType
314
+ documentType,
315
+ stagedDocumentType
248
316
  } = definition.export();
249
317
  return {
250
318
  tableName,
@@ -254,7 +322,8 @@ class SchemaDefinition {
254
322
  stagedSearchIndexes,
255
323
  vectorIndexes,
256
324
  stagedVectorIndexes,
257
- documentType
325
+ documentType,
326
+ stagedDocumentType
258
327
  };
259
328
  }),
260
329
  schemaValidation: this.schemaValidation