convex 1.46.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 (332) hide show
  1. package/CHANGELOG.md +58 -1
  2. package/dist/browser.bundle.js +7 -1
  3. package/dist/browser.bundle.js.map +2 -2
  4. package/dist/cjs/bundler/index.js +5 -4
  5. package/dist/cjs/bundler/index.js.map +2 -2
  6. package/dist/cjs/cli/codegen.js +0 -4
  7. package/dist/cjs/cli/codegen.js.map +2 -2
  8. package/dist/cjs/cli/configure.js +13 -4
  9. package/dist/cjs/cli/configure.js.map +2 -2
  10. package/dist/cjs/cli/deploy.js +27 -2
  11. package/dist/cjs/cli/deploy.js.map +2 -2
  12. package/dist/cjs/cli/deploymentSelect.js +2 -2
  13. package/dist/cjs/cli/deploymentSelect.js.map +2 -2
  14. package/dist/cjs/cli/dev.js +6 -0
  15. package/dist/cjs/cli/dev.js.map +2 -2
  16. package/dist/cjs/cli/env.js +10 -5
  17. package/dist/cjs/cli/env.js.map +2 -2
  18. package/dist/cjs/cli/envDefault.js +7 -2
  19. package/dist/cjs/cli/envDefault.js.map +2 -2
  20. package/dist/cjs/cli/generatedApi.js.map +1 -1
  21. package/dist/cjs/cli/lib/api.js +2 -0
  22. package/dist/cjs/cli/lib/api.js.map +2 -2
  23. package/dist/cjs/cli/lib/checkForLargeIndexBackfill.js +113 -0
  24. package/dist/cjs/cli/lib/checkForLargeIndexBackfill.js.map +7 -0
  25. package/dist/cjs/cli/lib/checkForLargeIndexDeletion.js +36 -47
  26. package/dist/cjs/cli/lib/checkForLargeIndexDeletion.js.map +2 -2
  27. package/dist/cjs/cli/lib/checkForSlowSchemaValidation.js +58 -39
  28. package/dist/cjs/cli/lib/checkForSlowSchemaValidation.js.map +2 -2
  29. package/dist/cjs/cli/lib/checkForStagedValidatorDeletion.js +90 -0
  30. package/dist/cjs/cli/lib/checkForStagedValidatorDeletion.js.map +7 -0
  31. package/dist/cjs/cli/lib/codegen.js.map +2 -2
  32. package/dist/cjs/cli/lib/command.js +2 -1
  33. package/dist/cjs/cli/lib/command.js.map +2 -2
  34. package/dist/cjs/cli/lib/components/definition/bundle.js +37 -11
  35. package/dist/cjs/cli/lib/components/definition/bundle.js.map +2 -2
  36. package/dist/cjs/cli/lib/components.js +48 -5
  37. package/dist/cjs/cli/lib/components.js.map +2 -2
  38. package/dist/cjs/cli/lib/config.js +56 -17
  39. package/dist/cjs/cli/lib/config.js.map +2 -2
  40. package/dist/cjs/cli/lib/deploy2.js +3 -1
  41. package/dist/cjs/cli/lib/deploy2.js.map +2 -2
  42. package/dist/cjs/cli/lib/deployApi/evaluateSchema.js +30 -2
  43. package/dist/cjs/cli/lib/deployApi/evaluateSchema.js.map +2 -2
  44. package/dist/cjs/cli/lib/dev.js +5 -0
  45. package/dist/cjs/cli/lib/dev.js.map +2 -2
  46. package/dist/cjs/cli/lib/formatValidationProgress.js +47 -0
  47. package/dist/cjs/cli/lib/formatValidationProgress.js.map +7 -0
  48. package/dist/cjs/cli/lib/indexes.js.map +1 -1
  49. package/dist/cjs/cli/lib/mcp/tools/env.js +10 -3
  50. package/dist/cjs/cli/lib/mcp/tools/env.js.map +2 -2
  51. package/dist/cjs/cli/lib/run.js +4 -0
  52. package/dist/cjs/cli/lib/run.js.map +2 -2
  53. package/dist/cjs/cli/lib/schemaEvaluation.js +62 -0
  54. package/dist/cjs/cli/lib/schemaEvaluation.js.map +7 -0
  55. package/dist/cjs/cli/lib/usageLimits.js +4 -2
  56. package/dist/cjs/cli/lib/usageLimits.js.map +2 -2
  57. package/dist/cjs/cli/lib/utils/mutex.js +9 -24
  58. package/dist/cjs/cli/lib/utils/mutex.js.map +2 -2
  59. package/dist/cjs/cli/lib/utils/utils.js +48 -18
  60. package/dist/cjs/cli/lib/utils/utils.js.map +2 -2
  61. package/dist/cjs/cli/projectCreate.js +1 -1
  62. package/dist/cjs/cli/projectCreate.js.map +1 -1
  63. package/dist/cjs/index.js +1 -1
  64. package/dist/cjs/index.js.map +1 -1
  65. package/dist/cjs/server/impl/actions_impl.js +8 -3
  66. package/dist/cjs/server/impl/actions_impl.js.map +2 -2
  67. package/dist/cjs/server/impl/storage_impl.js +29 -0
  68. package/dist/cjs/server/impl/storage_impl.js.map +2 -2
  69. package/dist/cjs/server/index.js +1 -0
  70. package/dist/cjs/server/index.js.map +2 -2
  71. package/dist/cjs/server/meta.js.map +1 -1
  72. package/dist/cjs/server/registration.js.map +1 -1
  73. package/dist/cjs/server/schema.js +34 -12
  74. package/dist/cjs/server/schema.js.map +2 -2
  75. package/dist/cjs/server/storage.js.map +1 -1
  76. package/dist/cjs/values/validators.js +1 -1
  77. package/dist/cjs/values/validators.js.map +2 -2
  78. package/dist/cjs/values/value.js +6 -0
  79. package/dist/cjs/values/value.js.map +2 -2
  80. package/dist/cjs-types/bundler/index.d.ts +9 -2
  81. package/dist/cjs-types/bundler/index.d.ts.map +1 -1
  82. package/dist/cjs-types/cli/codegen.d.ts.map +1 -1
  83. package/dist/cjs-types/cli/configure.d.ts +6 -0
  84. package/dist/cjs-types/cli/configure.d.ts.map +1 -1
  85. package/dist/cjs-types/cli/deploy.d.ts +2 -0
  86. package/dist/cjs-types/cli/deploy.d.ts.map +1 -1
  87. package/dist/cjs-types/cli/deploymentCreate.d.ts +6 -6
  88. package/dist/cjs-types/cli/deploymentSelect.d.ts.map +1 -1
  89. package/dist/cjs-types/cli/dev.d.ts +1 -0
  90. package/dist/cjs-types/cli/dev.d.ts.map +1 -1
  91. package/dist/cjs-types/cli/env.d.ts.map +1 -1
  92. package/dist/cjs-types/cli/envDefault.d.ts.map +1 -1
  93. package/dist/cjs-types/cli/generatedApi.d.ts +1 -1
  94. package/dist/cjs-types/cli/generatedApi.d.ts.map +1 -1
  95. package/dist/cjs-types/cli/lib/api.d.ts.map +1 -1
  96. package/dist/cjs-types/cli/lib/checkForLargeIndexBackfill.d.ts +30 -0
  97. package/dist/cjs-types/cli/lib/checkForLargeIndexBackfill.d.ts.map +1 -0
  98. package/dist/cjs-types/cli/lib/checkForLargeIndexDeletion.d.ts +5 -7
  99. package/dist/cjs-types/cli/lib/checkForLargeIndexDeletion.d.ts.map +1 -1
  100. package/dist/cjs-types/cli/lib/checkForSlowSchemaValidation.d.ts +4 -10
  101. package/dist/cjs-types/cli/lib/checkForSlowSchemaValidation.d.ts.map +1 -1
  102. package/dist/cjs-types/cli/lib/checkForStagedValidatorDeletion.d.ts +17 -0
  103. package/dist/cjs-types/cli/lib/checkForStagedValidatorDeletion.d.ts.map +1 -0
  104. package/dist/cjs-types/cli/lib/codegen.d.ts +0 -3
  105. package/dist/cjs-types/cli/lib/codegen.d.ts.map +1 -1
  106. package/dist/cjs-types/cli/lib/command.d.ts +2 -0
  107. package/dist/cjs-types/cli/lib/command.d.ts.map +1 -1
  108. package/dist/cjs-types/cli/lib/components/definition/bundle.d.ts +13 -0
  109. package/dist/cjs-types/cli/lib/components/definition/bundle.d.ts.map +1 -1
  110. package/dist/cjs-types/cli/lib/components.d.ts +4 -0
  111. package/dist/cjs-types/cli/lib/components.d.ts.map +1 -1
  112. package/dist/cjs-types/cli/lib/config.d.ts +2 -1
  113. package/dist/cjs-types/cli/lib/config.d.ts.map +1 -1
  114. package/dist/cjs-types/cli/lib/deploy2.d.ts +2 -0
  115. package/dist/cjs-types/cli/lib/deploy2.d.ts.map +1 -1
  116. package/dist/cjs-types/cli/lib/deployApi/evaluateSchema.d.ts +460 -16
  117. package/dist/cjs-types/cli/lib/deployApi/evaluateSchema.d.ts.map +1 -1
  118. package/dist/cjs-types/cli/lib/dev.d.ts +1 -0
  119. package/dist/cjs-types/cli/lib/dev.d.ts.map +1 -1
  120. package/dist/cjs-types/cli/lib/formatValidationProgress.d.ts +8 -0
  121. package/dist/cjs-types/cli/lib/formatValidationProgress.d.ts.map +1 -0
  122. package/dist/cjs-types/cli/lib/mcp/tools/env.d.ts +8 -5
  123. package/dist/cjs-types/cli/lib/mcp/tools/env.d.ts.map +1 -1
  124. package/dist/cjs-types/cli/lib/run.d.ts.map +1 -1
  125. package/dist/cjs-types/cli/lib/schemaEvaluation.d.ts +33 -0
  126. package/dist/cjs-types/cli/lib/schemaEvaluation.d.ts.map +1 -0
  127. package/dist/cjs-types/cli/lib/usageLimits.d.ts +1 -1
  128. package/dist/cjs-types/cli/lib/usageLimits.d.ts.map +1 -1
  129. package/dist/cjs-types/cli/lib/utils/mutex.d.ts +1 -3
  130. package/dist/cjs-types/cli/lib/utils/mutex.d.ts.map +1 -1
  131. package/dist/cjs-types/cli/lib/utils/utils.d.ts +10 -2
  132. package/dist/cjs-types/cli/lib/utils/utils.d.ts.map +1 -1
  133. package/dist/cjs-types/index.d.ts +1 -1
  134. package/dist/cjs-types/server/impl/actions_impl.d.ts +18 -3
  135. package/dist/cjs-types/server/impl/actions_impl.d.ts.map +1 -1
  136. package/dist/cjs-types/server/impl/storage_impl.d.ts.map +1 -1
  137. package/dist/cjs-types/server/index.d.ts +1 -1
  138. package/dist/cjs-types/server/index.d.ts.map +1 -1
  139. package/dist/cjs-types/server/meta.d.ts +63 -0
  140. package/dist/cjs-types/server/meta.d.ts.map +1 -1
  141. package/dist/cjs-types/server/registration.d.ts +10 -0
  142. package/dist/cjs-types/server/registration.d.ts.map +1 -1
  143. package/dist/cjs-types/server/schema.d.ts +33 -0
  144. package/dist/cjs-types/server/schema.d.ts.map +1 -1
  145. package/dist/cjs-types/server/storage.d.ts.map +1 -1
  146. package/dist/cjs-types/values/value.d.ts.map +1 -1
  147. package/dist/cli.bundle.cjs +2935 -2048
  148. package/dist/cli.bundle.cjs.map +4 -4
  149. package/dist/esm/bundler/index.js +5 -4
  150. package/dist/esm/bundler/index.js.map +2 -2
  151. package/dist/esm/cli/codegen.js +0 -4
  152. package/dist/esm/cli/codegen.js.map +2 -2
  153. package/dist/esm/cli/configure.js +12 -4
  154. package/dist/esm/cli/configure.js.map +2 -2
  155. package/dist/esm/cli/deploy.js +27 -2
  156. package/dist/esm/cli/deploy.js.map +2 -2
  157. package/dist/esm/cli/deploymentSelect.js +6 -3
  158. package/dist/esm/cli/deploymentSelect.js.map +2 -2
  159. package/dist/esm/cli/dev.js +6 -0
  160. package/dist/esm/cli/dev.js.map +2 -2
  161. package/dist/esm/cli/env.js +11 -6
  162. package/dist/esm/cli/env.js.map +2 -2
  163. package/dist/esm/cli/envDefault.js +7 -2
  164. package/dist/esm/cli/envDefault.js.map +2 -2
  165. package/dist/esm/cli/lib/api.js +2 -0
  166. package/dist/esm/cli/lib/api.js.map +2 -2
  167. package/dist/esm/cli/lib/checkForLargeIndexBackfill.js +95 -0
  168. package/dist/esm/cli/lib/checkForLargeIndexBackfill.js.map +7 -0
  169. package/dist/esm/cli/lib/checkForLargeIndexDeletion.js +37 -48
  170. package/dist/esm/cli/lib/checkForLargeIndexDeletion.js.map +2 -2
  171. package/dist/esm/cli/lib/checkForSlowSchemaValidation.js +63 -41
  172. package/dist/esm/cli/lib/checkForSlowSchemaValidation.js.map +2 -2
  173. package/dist/esm/cli/lib/checkForStagedValidatorDeletion.js +68 -0
  174. package/dist/esm/cli/lib/checkForStagedValidatorDeletion.js.map +7 -0
  175. package/dist/esm/cli/lib/codegen.js.map +2 -2
  176. package/dist/esm/cli/lib/command.js +2 -1
  177. package/dist/esm/cli/lib/command.js.map +2 -2
  178. package/dist/esm/cli/lib/components/definition/bundle.js +37 -11
  179. package/dist/esm/cli/lib/components/definition/bundle.js.map +2 -2
  180. package/dist/esm/cli/lib/components.js +55 -5
  181. package/dist/esm/cli/lib/components.js.map +2 -2
  182. package/dist/esm/cli/lib/config.js +55 -17
  183. package/dist/esm/cli/lib/config.js.map +2 -2
  184. package/dist/esm/cli/lib/deploy2.js +3 -1
  185. package/dist/esm/cli/lib/deploy2.js.map +2 -2
  186. package/dist/esm/cli/lib/deployApi/evaluateSchema.js +28 -2
  187. package/dist/esm/cli/lib/deployApi/evaluateSchema.js.map +2 -2
  188. package/dist/esm/cli/lib/dev.js +5 -0
  189. package/dist/esm/cli/lib/dev.js.map +2 -2
  190. package/dist/esm/cli/lib/formatValidationProgress.js +24 -0
  191. package/dist/esm/cli/lib/formatValidationProgress.js.map +7 -0
  192. package/dist/esm/cli/lib/indexes.js.map +1 -1
  193. package/dist/esm/cli/lib/mcp/tools/env.js +10 -3
  194. package/dist/esm/cli/lib/mcp/tools/env.js.map +2 -2
  195. package/dist/esm/cli/lib/run.js +4 -0
  196. package/dist/esm/cli/lib/run.js.map +2 -2
  197. package/dist/esm/cli/lib/schemaEvaluation.js +39 -0
  198. package/dist/esm/cli/lib/schemaEvaluation.js.map +7 -0
  199. package/dist/esm/cli/lib/usageLimits.js +4 -2
  200. package/dist/esm/cli/lib/usageLimits.js.map +2 -2
  201. package/dist/esm/cli/lib/utils/mutex.js +9 -24
  202. package/dist/esm/cli/lib/utils/mutex.js.map +2 -2
  203. package/dist/esm/cli/lib/utils/utils.js +47 -18
  204. package/dist/esm/cli/lib/utils/utils.js.map +2 -2
  205. package/dist/esm/cli/projectCreate.js +1 -1
  206. package/dist/esm/cli/projectCreate.js.map +1 -1
  207. package/dist/esm/index.js +1 -1
  208. package/dist/esm/index.js.map +1 -1
  209. package/dist/esm/server/impl/actions_impl.js +7 -3
  210. package/dist/esm/server/impl/actions_impl.js.map +2 -2
  211. package/dist/esm/server/impl/storage_impl.js +29 -0
  212. package/dist/esm/server/impl/storage_impl.js.map +2 -2
  213. package/dist/esm/server/index.js +4 -1
  214. package/dist/esm/server/index.js.map +2 -2
  215. package/dist/esm/server/schema.js +34 -12
  216. package/dist/esm/server/schema.js.map +2 -2
  217. package/dist/esm/values/validators.js +1 -1
  218. package/dist/esm/values/validators.js.map +2 -2
  219. package/dist/esm/values/value.js +6 -0
  220. package/dist/esm/values/value.js.map +2 -2
  221. package/dist/esm-types/bundler/index.d.ts +9 -2
  222. package/dist/esm-types/bundler/index.d.ts.map +1 -1
  223. package/dist/esm-types/cli/codegen.d.ts.map +1 -1
  224. package/dist/esm-types/cli/configure.d.ts +6 -0
  225. package/dist/esm-types/cli/configure.d.ts.map +1 -1
  226. package/dist/esm-types/cli/deploy.d.ts +2 -0
  227. package/dist/esm-types/cli/deploy.d.ts.map +1 -1
  228. package/dist/esm-types/cli/deploymentCreate.d.ts +6 -6
  229. package/dist/esm-types/cli/deploymentSelect.d.ts.map +1 -1
  230. package/dist/esm-types/cli/dev.d.ts +1 -0
  231. package/dist/esm-types/cli/dev.d.ts.map +1 -1
  232. package/dist/esm-types/cli/env.d.ts.map +1 -1
  233. package/dist/esm-types/cli/envDefault.d.ts.map +1 -1
  234. package/dist/esm-types/cli/generatedApi.d.ts +1 -1
  235. package/dist/esm-types/cli/generatedApi.d.ts.map +1 -1
  236. package/dist/esm-types/cli/lib/api.d.ts.map +1 -1
  237. package/dist/esm-types/cli/lib/checkForLargeIndexBackfill.d.ts +30 -0
  238. package/dist/esm-types/cli/lib/checkForLargeIndexBackfill.d.ts.map +1 -0
  239. package/dist/esm-types/cli/lib/checkForLargeIndexDeletion.d.ts +5 -7
  240. package/dist/esm-types/cli/lib/checkForLargeIndexDeletion.d.ts.map +1 -1
  241. package/dist/esm-types/cli/lib/checkForSlowSchemaValidation.d.ts +4 -10
  242. package/dist/esm-types/cli/lib/checkForSlowSchemaValidation.d.ts.map +1 -1
  243. package/dist/esm-types/cli/lib/checkForStagedValidatorDeletion.d.ts +17 -0
  244. package/dist/esm-types/cli/lib/checkForStagedValidatorDeletion.d.ts.map +1 -0
  245. package/dist/esm-types/cli/lib/codegen.d.ts +0 -3
  246. package/dist/esm-types/cli/lib/codegen.d.ts.map +1 -1
  247. package/dist/esm-types/cli/lib/command.d.ts +2 -0
  248. package/dist/esm-types/cli/lib/command.d.ts.map +1 -1
  249. package/dist/esm-types/cli/lib/components/definition/bundle.d.ts +13 -0
  250. package/dist/esm-types/cli/lib/components/definition/bundle.d.ts.map +1 -1
  251. package/dist/esm-types/cli/lib/components.d.ts +4 -0
  252. package/dist/esm-types/cli/lib/components.d.ts.map +1 -1
  253. package/dist/esm-types/cli/lib/config.d.ts +2 -1
  254. package/dist/esm-types/cli/lib/config.d.ts.map +1 -1
  255. package/dist/esm-types/cli/lib/deploy2.d.ts +2 -0
  256. package/dist/esm-types/cli/lib/deploy2.d.ts.map +1 -1
  257. package/dist/esm-types/cli/lib/deployApi/evaluateSchema.d.ts +460 -16
  258. package/dist/esm-types/cli/lib/deployApi/evaluateSchema.d.ts.map +1 -1
  259. package/dist/esm-types/cli/lib/dev.d.ts +1 -0
  260. package/dist/esm-types/cli/lib/dev.d.ts.map +1 -1
  261. package/dist/esm-types/cli/lib/formatValidationProgress.d.ts +8 -0
  262. package/dist/esm-types/cli/lib/formatValidationProgress.d.ts.map +1 -0
  263. package/dist/esm-types/cli/lib/mcp/tools/env.d.ts +8 -5
  264. package/dist/esm-types/cli/lib/mcp/tools/env.d.ts.map +1 -1
  265. package/dist/esm-types/cli/lib/run.d.ts.map +1 -1
  266. package/dist/esm-types/cli/lib/schemaEvaluation.d.ts +33 -0
  267. package/dist/esm-types/cli/lib/schemaEvaluation.d.ts.map +1 -0
  268. package/dist/esm-types/cli/lib/usageLimits.d.ts +1 -1
  269. package/dist/esm-types/cli/lib/usageLimits.d.ts.map +1 -1
  270. package/dist/esm-types/cli/lib/utils/mutex.d.ts +1 -3
  271. package/dist/esm-types/cli/lib/utils/mutex.d.ts.map +1 -1
  272. package/dist/esm-types/cli/lib/utils/utils.d.ts +10 -2
  273. package/dist/esm-types/cli/lib/utils/utils.d.ts.map +1 -1
  274. package/dist/esm-types/index.d.ts +1 -1
  275. package/dist/esm-types/server/impl/actions_impl.d.ts +18 -3
  276. package/dist/esm-types/server/impl/actions_impl.d.ts.map +1 -1
  277. package/dist/esm-types/server/impl/storage_impl.d.ts.map +1 -1
  278. package/dist/esm-types/server/index.d.ts +1 -1
  279. package/dist/esm-types/server/index.d.ts.map +1 -1
  280. package/dist/esm-types/server/meta.d.ts +63 -0
  281. package/dist/esm-types/server/meta.d.ts.map +1 -1
  282. package/dist/esm-types/server/registration.d.ts +10 -0
  283. package/dist/esm-types/server/registration.d.ts.map +1 -1
  284. package/dist/esm-types/server/schema.d.ts +33 -0
  285. package/dist/esm-types/server/schema.d.ts.map +1 -1
  286. package/dist/esm-types/server/storage.d.ts.map +1 -1
  287. package/dist/esm-types/values/value.d.ts.map +1 -1
  288. package/dist/react.bundle.js +7 -1
  289. package/dist/react.bundle.js.map +2 -2
  290. package/package.json +5 -5
  291. package/schemas/convex.schema.json +5 -5
  292. package/src/bundler/index.ts +9 -4
  293. package/src/cli/codegen.ts +0 -2
  294. package/src/cli/configure.ts +27 -7
  295. package/src/cli/deploy.ts +36 -5
  296. package/src/cli/deploymentSelect.ts +7 -4
  297. package/src/cli/dev.ts +9 -0
  298. package/src/cli/env.ts +12 -6
  299. package/src/cli/envDefault.ts +8 -2
  300. package/src/cli/generatedApi.ts +1 -1
  301. package/src/cli/lib/api.ts +5 -1
  302. package/src/cli/lib/checkForLargeIndexBackfill.ts +173 -0
  303. package/src/cli/lib/checkForLargeIndexDeletion.ts +45 -58
  304. package/src/cli/lib/checkForSlowSchemaValidation.ts +76 -65
  305. package/src/cli/lib/checkForStagedValidatorDeletion.ts +104 -0
  306. package/src/cli/lib/codegen.ts +0 -3
  307. package/src/cli/lib/command.ts +3 -0
  308. package/src/cli/lib/components/definition/bundle.ts +68 -14
  309. package/src/cli/lib/components.ts +71 -4
  310. package/src/cli/lib/config.ts +85 -18
  311. package/src/cli/lib/deploy2.ts +10 -1
  312. package/src/cli/lib/deployApi/evaluateSchema.ts +35 -0
  313. package/src/cli/lib/dev.ts +14 -0
  314. package/src/cli/lib/formatValidationProgress.ts +35 -0
  315. package/src/cli/lib/indexes.ts +1 -1
  316. package/src/cli/lib/mcp/tools/env.ts +17 -3
  317. package/src/cli/lib/run.ts +2 -0
  318. package/src/cli/lib/schemaEvaluation.ts +88 -0
  319. package/src/cli/lib/usageLimits.ts +2 -0
  320. package/src/cli/lib/utils/mutex.ts +9 -27
  321. package/src/cli/lib/utils/utils.ts +64 -21
  322. package/src/cli/projectCreate.ts +1 -1
  323. package/src/index.ts +1 -1
  324. package/src/server/impl/actions_impl.ts +26 -6
  325. package/src/server/impl/storage_impl.ts +30 -0
  326. package/src/server/index.ts +5 -1
  327. package/src/server/meta.ts +56 -2
  328. package/src/server/registration.ts +10 -0
  329. package/src/server/schema.ts +37 -15
  330. package/src/server/storage.ts +17 -0
  331. package/src/values/validators.ts +1 -1
  332. package/src/values/value.ts +9 -5
@@ -517,6 +517,23 @@ export async function selectRegionOrUseDefault(
517
517
  return selectedRegionName;
518
518
  }
519
519
 
520
+ // Mirrors the order of `REGION_PRESENTATION` in
521
+ // `npm-packages/dashboard/src/lib/regions.ts`, so both region pickers list
522
+ // regions in the same order.
523
+ const REGION_ORDER: string[] = [
524
+ "aws-us-east-1",
525
+ "aws-eu-west-1",
526
+ "aws-ca-central-1",
527
+ "aws-ap-southeast-2",
528
+ ];
529
+
530
+ // Regions missing from `REGION_ORDER` (e.g. newly launched ones) go last, in
531
+ // server order, since `Array.prototype.sort` is stable.
532
+ function regionSortIndex(regionName: string): number {
533
+ const index = REGION_ORDER.indexOf(regionName);
534
+ return index === -1 ? REGION_ORDER.length : index;
535
+ }
536
+
520
537
  export async function selectRegion(
521
538
  ctx: Context,
522
539
  teamId: number,
@@ -538,12 +555,7 @@ export async function selectRegion(
538
555
  name: item.displayName,
539
556
  value: item.name,
540
557
  }))
541
- .sort((a, b) => {
542
- // Show US region first if it exists
543
- if (a.value === "aws-us-east-1") return -1;
544
- if (b.value === "aws-us-east-1") return 1;
545
- return 0;
546
- });
558
+ .sort((a, b) => regionSortIndex(a.value) - regionSortIndex(b.value));
547
559
  return await promptOptions(ctx, {
548
560
  message: `Where should this ${deploymentType} deployment run?`,
549
561
  suffix: `\n${chalkStderr.gray(
@@ -559,16 +571,18 @@ export async function hasProject(
559
571
  projectSlug: string,
560
572
  ) {
561
573
  try {
562
- const projects: Project[] = (
563
- await typedBigBrainClient(ctx).GET("/teams/{team_slug}/projects", {
574
+ await typedPlatformClient(ctx, { throw: true }).GET(
575
+ "/teams/{team_id_or_slug}/projects/{project_slug}",
576
+ {
564
577
  params: {
565
578
  path: {
566
- team_slug: teamSlug,
579
+ team_id_or_slug: teamSlug,
580
+ project_slug: projectSlug,
567
581
  },
568
582
  },
569
- })
570
- ).data!;
571
- return !!projects.find((project) => project.slug === projectSlug);
583
+ },
584
+ );
585
+ return true;
572
586
  } catch {
573
587
  return false;
574
588
  }
@@ -581,19 +595,27 @@ export async function hasProjects(ctx: Context) {
581
595
  export async function validateOrSelectProject(
582
596
  ctx: Context,
583
597
  projectSlug: string | undefined,
584
- teamSlug: string,
598
+ teamId: number,
585
599
  singleProjectPrompt: string,
586
600
  multiProjectPrompt: string,
587
601
  ): Promise<string | null> {
588
- const projects: Project[] = (
589
- await typedBigBrainClient(ctx).GET("/teams/{team_slug}/projects", {
590
- params: {
591
- path: {
592
- team_slug: teamSlug,
602
+ const projects: Project[] = [];
603
+ const client = typedPlatformClient(ctx);
604
+ let cursor: string | undefined;
605
+ do {
606
+ const { items, pagination } = (
607
+ await client.GET("/teams/{team_id}/projects", {
608
+ params: {
609
+ path: { team_id: teamId },
610
+ query: cursor === undefined ? {} : { cursor },
593
611
  },
594
- },
595
- })
596
- ).data!;
612
+ })
613
+ ).data!;
614
+ projects.push(...items);
615
+ cursor = pagination.hasMore
616
+ ? (pagination.nextCursor ?? undefined)
617
+ : undefined;
618
+ } while (cursor !== undefined);
597
619
  if (projects.length === 0) {
598
620
  return await ctx.crash({
599
621
  exitCode: 1,
@@ -996,6 +1018,27 @@ export function formatSize(n: number): string {
996
1018
  return `${formatted} ${BYTE_UNITS[unitIndex]}`;
997
1019
  }
998
1020
 
1021
+ /**
1022
+ * Read an integer override from the environment, falling back to
1023
+ * `defaultValue` when the variable is unset. The whole value must be a
1024
+ * base-10 integer: `parseInt` would read a typo like `100_000` or `100k` as
1025
+ * 100 and silently move the threshold, so anything else is rejected with a
1026
+ * warning instead.
1027
+ */
1028
+ export function integerFromEnv(envVar: string, defaultValue: number): number {
1029
+ const envValue = process.env[envVar];
1030
+ if (envValue === undefined) {
1031
+ return defaultValue;
1032
+ }
1033
+ if (!/^[+-]?\d+$/.test(envValue.trim())) {
1034
+ logWarning(
1035
+ `Ignoring ${envVar}=${JSON.stringify(envValue)}: expected an integer, using ${defaultValue}`,
1036
+ );
1037
+ return defaultValue;
1038
+ }
1039
+ return Number(envValue);
1040
+ }
1041
+
999
1042
  export function formatDuration(ms: number): string {
1000
1043
  const twoDigits = (n: number, unit: string) =>
1001
1044
  `${n.toLocaleString("en-US", { maximumFractionDigits: 2 })}${unit}`;
@@ -64,7 +64,7 @@ async function runProjectCreate(
64
64
  logMessage(
65
65
  chalkStderr.gray(
66
66
  `Next, add a deployment with ` +
67
- `\`npx convex deployment create ${team.slug}:${projectSlug}:dev --type dev\` ` +
67
+ `\`npx convex deployment create ${team.slug}:${projectSlug}:dev/my-feature --type dev --select\` ` +
68
68
  `(pass \`--region us\` to choose a region).`,
69
69
  ),
70
70
  );
package/src/index.ts CHANGED
@@ -1 +1 @@
1
- export const version = "1.46.0";
1
+ export const version = "1.47.0";
@@ -64,26 +64,46 @@ export function setupActionCalls(requestId: string) {
64
64
  };
65
65
  }
66
66
 
67
+ /**
68
+ * A Convex-managed service. The backend decides which names it accepts; this
69
+ * type lists the ones the current release knows about.
70
+ */
71
+ export type ServiceName = "ai-gateway";
72
+
67
73
  /**
68
74
  * Get a short-lived credential for calling a Convex-managed service.
69
75
  *
70
76
  * This function can only be called while an action is running. The credential
71
77
  * is scoped to the current deployment and should be sent as a bearer token.
72
- * Repeated calls in the same action reuse one token; a failed mint is not
73
- * cached, so a later call retries.
78
+ * The action runtime caches and refreshes credentials as needed, so call
79
+ * this function whenever making a service request.
74
80
  *
75
81
  * @param service - The service the credential may access.
76
82
  * @returns A JWT to send as `Authorization: Bearer <token>`. Keep it inside
77
83
  * the action: don't return it to clients or store it in environment
78
84
  * variables.
79
85
  */
80
- export async function getServiceToken(service: "ai-gateway"): Promise<string> {
86
+ export async function getServiceToken(service: ServiceName): Promise<string> {
81
87
  validateArg(service, 1, "getServiceToken", "service");
82
- if (service !== "ai-gateway") {
83
- throw new Error(`Unsupported service "${String(service)}"`);
84
- }
85
88
  return await performAsyncSyscall("1.0/createServiceToken", {
86
89
  service,
87
90
  version,
88
91
  });
89
92
  }
93
+
94
+ /**
95
+ * Get the base URL of a Convex-managed service.
96
+ *
97
+ * This function can only be called while an action is running. Pair it with
98
+ * {@link getServiceToken} to reach the service.
99
+ *
100
+ * @param service - The service to address.
101
+ * @returns The service's origin, without a trailing slash.
102
+ */
103
+ export async function getServiceUrl(service: ServiceName): Promise<string> {
104
+ validateArg(service, 1, "getServiceUrl", "service");
105
+ return await performAsyncSyscall("1.0/getServiceUrl", {
106
+ service,
107
+ version,
108
+ });
109
+ }
@@ -6,6 +6,7 @@ import {
6
6
  StorageWriter,
7
7
  } from "../storage.js";
8
8
  import { version } from "../../index.js";
9
+ import { fromByteArray, toByteArray } from "../../values/base64.js";
9
10
  import { performAsyncSyscall, performJsSyscall } from "./syscall.js";
10
11
  import { validateArg } from "./validate.js";
11
12
 
@@ -45,6 +46,35 @@ export function setupStorageWriter(requestId: string): StorageWriter {
45
46
  storageId,
46
47
  });
47
48
  },
49
+ store: async (blob: Blob, options?: { sha256?: string }) => {
50
+ if (!(blob instanceof Blob)) {
51
+ throw new Error(
52
+ "store() expects a Blob. If you are trying to store a Request, `await request.blob()` will give you the correct input.",
53
+ );
54
+ }
55
+ const bytes = new Uint8Array(await blob.arrayBuffer());
56
+ return await performAsyncSyscall("1.0/storageStore", {
57
+ requestId,
58
+ version,
59
+ blob: fromByteArray(bytes),
60
+ contentType: blob.type,
61
+ sha256: options?.sha256,
62
+ });
63
+ },
64
+ get: async (storageId: FileStorageId) => {
65
+ const result: { blob: string; contentType: string | null } | null =
66
+ await performAsyncSyscall("1.0/storageGet", {
67
+ requestId,
68
+ version,
69
+ storageId,
70
+ });
71
+ if (result === null) {
72
+ return null;
73
+ }
74
+ return new Blob([toByteArray(result.blob)], {
75
+ type: result.contentType ?? "",
76
+ });
77
+ },
48
78
  getUrl: reader.getUrl,
49
79
  getMetadata: reader.getMetadata,
50
80
  };
@@ -103,7 +103,11 @@ export {
103
103
  internalMutationGeneric,
104
104
  internalQueryGeneric,
105
105
  } from "./impl/registration_impl.js";
106
- export { getServiceToken } from "./impl/actions_impl.js";
106
+ export {
107
+ getServiceToken,
108
+ getServiceUrl,
109
+ type ServiceName,
110
+ } from "./impl/actions_impl.js";
107
111
  export type {
108
112
  TransactionMetric,
109
113
  TransactionMetrics,
@@ -26,6 +26,14 @@ export type TransactionMetrics = {
26
26
  documentsWritten: TransactionMetric;
27
27
  functionsScheduled: TransactionMetric;
28
28
  scheduledFunctionArgsBytes: TransactionMetric;
29
+ /** @internal */
30
+ filesWritten: TransactionMetric;
31
+ /** @internal */
32
+ fileWriteBytes: TransactionMetric;
33
+ /** @internal */
34
+ filesRead: TransactionMetric;
35
+ /** @internal */
36
+ fileReadBytes: TransactionMetric;
29
37
  };
30
38
 
31
39
  /**
@@ -43,6 +51,14 @@ export interface TransactionLimits {
43
51
  documentsWritten?: number;
44
52
  functionsScheduled?: number;
45
53
  scheduledFunctionArgsBytes?: number;
54
+ /** @internal */
55
+ filesWritten?: number;
56
+ /** @internal */
57
+ fileWriteBytes?: number;
58
+ /** @internal */
59
+ filesRead?: number;
60
+ /** @internal */
61
+ fileReadBytes?: number;
46
62
  }
47
63
 
48
64
  /**
@@ -130,18 +146,30 @@ export type RequestMetadata = {
130
146
  * @public
131
147
  */
132
148
  export interface QueryMeta {
149
+ /**
150
+ * Metadata about the currently executing Convex function.
151
+ */
133
152
  getFunctionMetadata(): Promise<FunctionMetadata>;
153
+ /**
154
+ * The remaining headroom for a transaction before hitting limits.
155
+ *
156
+ * See https://docs.convex.dev/production/state/limits
157
+ */
134
158
  getTransactionMetrics(): Promise<TransactionMetrics>;
159
+ /**
160
+ * Metadata about the deployment this function is running on.
161
+ */
135
162
  getDeploymentMetadata(): Promise<DeploymentMetadata>;
136
163
  /**
137
- * @internal
138
164
  * Returns the timestamp of the database snapshot this transaction reads
139
165
  * from, in nanoseconds.
140
166
  *
141
167
  * All commits at or before this timestamp are observable within the
142
168
  * transaction, and no later commits are. The value is fixed for the
143
169
  * lifetime of the transaction and shared with all nested `runMutation` and
144
- * `runQuery` calls.
170
+ * non-stale `runQuery` calls. If a nested query is called with
171
+ * `useStaleSnapshot: true`, then the nested query may in a future backend
172
+ * version choose an older snapshotTs.
145
173
  *
146
174
  * It is on the same clock as `db.vars.commitTs`: documents observable in
147
175
  * this transaction have `commitTs` values at or before this timestamp, and
@@ -156,6 +184,8 @@ export interface QueryMeta {
156
184
  * Note: this should not be compared to `_creationTime` or `Date.now()`, as
157
185
  * those are based on wall-clock time rather than the database clock, and
158
186
  * aren't guaranteed to follow commit order.
187
+ *
188
+ * Docs: https://docs.convex.dev/database/advanced/commit-timestamp
159
189
  */
160
190
  getSnapshotTs(): bigint;
161
191
  }
@@ -166,6 +196,15 @@ export interface QueryMeta {
166
196
  * @public
167
197
  */
168
198
  export interface MutationMeta extends QueryMeta {
199
+ /**
200
+ * Metadata about the HTTP request that triggered the current function execution.
201
+ *
202
+ * `ip` and `userAgent` are `null` when the function was not triggered by an
203
+ * HTTP request (e.g. scheduled jobs or cron jobs).
204
+ *
205
+ * Functions called from within a function (i.e. using `runMutation`) will have
206
+ * the same request metadata as the parent function.
207
+ */
169
208
  getRequestMetadata(): Promise<RequestMetadata>;
170
209
  }
171
210
 
@@ -175,7 +214,22 @@ export interface MutationMeta extends QueryMeta {
175
214
  * @public
176
215
  */
177
216
  export interface ActionMeta {
217
+ /**
218
+ * Metadata about the currently executing Convex function.
219
+ */
178
220
  getFunctionMetadata(): Promise<FunctionMetadata>;
221
+ /**
222
+ * Metadata about the deployment this function is running on.
223
+ */
179
224
  getDeploymentMetadata(): Promise<DeploymentMetadata>;
225
+ /**
226
+ * Metadata about the HTTP request that triggered the current function execution.
227
+ *
228
+ * `ip` and `userAgent` are `null` when the function was not triggered by an
229
+ * HTTP request (e.g. scheduled jobs or cron jobs).
230
+ *
231
+ * Functions called from within a function (i.e. using `runMutation` or
232
+ * `runAction`) will have the same request metadata as the parent function.
233
+ */
180
234
  getRequestMetadata(): Promise<RequestMetadata>;
181
235
  }
@@ -1234,6 +1234,11 @@ export type HttpActionBuilder = (
1234
1234
  ) => PublicHttpAction;
1235
1235
 
1236
1236
  export interface AdvancedRunQueryOptions {
1237
+ /**
1238
+ * Custom limits for a nested transaction. Each field specifies the absolute
1239
+ * maximum allowed for the nested function call. Values are capped at the
1240
+ * global transaction limits, so they can only lower limits, never raise them.
1241
+ */
1237
1242
  transactionLimits?: TransactionLimits;
1238
1243
  /**
1239
1244
  * Run a query on a recent snapshot of the database that is not guaranteed
@@ -1244,6 +1249,11 @@ export interface AdvancedRunQueryOptions {
1244
1249
  * database read conflicts are expected, e.g. reading from an append-only
1245
1250
  * table with immutable records where the only read conflicts are from
1246
1251
  * concurrent appends.
1252
+ *
1253
+ * To determine the snapshot of the nested query, you can call
1254
+ * `ctx.meta.getSnapshotTs()` from within the stale snapshot query. To
1255
+ * compare to the parent mutation's snapshot timestamp, you can return that
1256
+ * value from the query and call `ctx.meta.getSnapshotTs()` from the parent.
1247
1257
  */
1248
1258
  useStaleSnapshot?: boolean;
1249
1259
  }
@@ -561,41 +561,63 @@ export class TableDefinition<
561
561
  }
562
562
 
563
563
  /**
564
- * Stage a new document validator for this table.
564
+ * Stage changes to this table's document validator.
565
565
  *
566
566
  * Convex validates the staged validator against the table's existing
567
567
  * documents in the background, while the validator passed to
568
- * {@link defineTable} remains the one enforced on reads and writes. Once
569
- * the background validation succeeds, make the staged validator the
570
- * table's validator and remove `.staged()`.
568
+ * {@link defineTable} remains the one enforced on writes. Once
569
+ * the background validation succeeds, apply the staged changes
570
+ * and remove `.staged()`.
571
+ *
572
+ * For an object validator, pass only the fields to add or replace. Fields
573
+ * omitted from the changes keep their enforced validators.
574
+ * Set a field to `undefined` to remove it from the staged validator.
575
+ * For nested objects, you must specify the full object validator.
571
576
  *
572
577
  * ```ts
573
578
  * defineTable({
574
- * author: v.string(),
579
+ * apple: v.string(),
580
+ * banana: v.number(),
581
+ * legacy: v.optional(v.string()),
575
582
  * }).staged({
576
- * author: v.array(v.string()),
583
+ * banana: v.union(v.string(), v.number()),
584
+ * legacy: undefined,
577
585
  * })
578
586
  * ```
579
587
  *
580
- * TODO: link a worked staged-schema example from the docs once one exists.
588
+ * See [Staged validators](https://docs.convex.dev/database/schemas#staged-validators).
581
589
  *
582
- * @param documentSchema - The proposed next type of documents stored in
583
- * this table, as an object of field validators or a schema validator.
590
+ * @param documentSchema - Field changes for a table defined as an object or
591
+ * `v.any()`, or a full schema validator specifying the proposed next document
592
+ * type. Use a full schema validator for a table defined as a union.
584
593
  * @returns A {@link TableDefinition} with the staged validator attached.
585
- *
586
- * @internal
587
594
  */
588
595
  staged(
589
596
  documentSchema:
590
597
  | Validator<Record<string, any>, "required", any>
591
- | Record<string, GenericValidator>,
598
+ | Record<string, GenericValidator | undefined>,
592
599
  ): TableDefinition<DocumentType, Indexes, SearchIndexes, VectorIndexes> {
593
600
  if (this.stagedValidator !== undefined) {
594
601
  throw new Error("Table cannot have more than one staged validator.");
595
602
  }
596
- this.stagedValidator = isValidator(documentSchema)
597
- ? documentSchema
598
- : v.object(documentSchema);
603
+ if (isValidator(documentSchema)) {
604
+ this.stagedValidator = documentSchema;
605
+ } else {
606
+ if (this.validator.kind !== "object" && this.validator.kind !== "any") {
607
+ throw new Error(
608
+ "Specifying top-level field changes is only supported for simple table definitions. For a table defined with a union or record validator, you must stage a fully defined object or union validator.",
609
+ );
610
+ }
611
+ const enforcedFields =
612
+ this.validator.kind === "object" ? this.validator.fields : {};
613
+ const fields: Record<string, GenericValidator> = Object.fromEntries(
614
+ Object.entries({ ...enforcedFields, ...documentSchema }).filter(
615
+ (entry): entry is [string, GenericValidator] =>
616
+ entry[1] !== undefined,
617
+ ),
618
+ );
619
+ this.stagedValidator = v.object(fields);
620
+ }
599
621
  return this.self();
600
622
  }
601
623
 
@@ -194,6 +194,23 @@ export interface StorageWriter extends StorageReader {
194
194
  delete<T extends StorageId>(
195
195
  storageId: T extends { __tableName: any } ? never : T,
196
196
  ): Promise<void>;
197
+
198
+ /**
199
+ * @internal
200
+ */
201
+ // TODO: move `store` from StorageActionWriter to StorageWriter when mutation
202
+ // file storage access is ready for release
203
+ store(
204
+ blob: Blob,
205
+ options?: { sha256?: string },
206
+ ): Promise<GenericId<"_storage">>;
207
+
208
+ /**
209
+ * @internal
210
+ */
211
+ // TODO: move `get` from StorageActionWriter to StorageWriter when mutation
212
+ // file storage access is ready for release
213
+ get(storageId: GenericId<"_storage">): Promise<Blob | null>;
197
214
  }
198
215
 
199
216
  /**
@@ -641,7 +641,7 @@ export class VRecord<
641
641
  throw new Error("Record validator cannot have optional values");
642
642
  }
643
643
  if (!key.isConvexValidator || !value.isConvexValidator) {
644
- throw new Error("Key and value of v.record() but be validators");
644
+ throw new Error("Key and value of v.record() must be validators");
645
645
  }
646
646
  this.key = key;
647
647
  this.value = value;
@@ -311,13 +311,17 @@ const MAX_VALUE_FOR_ERROR_LEN = 16384;
311
311
  export function stringifyValueForError(value: any) {
312
312
  const str = JSON.stringify(value, (_key, value) => {
313
313
  if (value === undefined) {
314
- // By default `JSON.stringify` converts undefined, functions, symbols,
315
- // Infinity, and NaN to null which produces a confusing error message.
316
- // We deal with `undefined` specifically because it's the most common.
317
- // Ideally we'd use a pretty-printing library that prints `undefined`
318
- // (no quotes), but it might not be worth the bundle size cost.
314
+ // JSON.stringify omits undefined object properties and converts undefined
315
+ // array elements to null. Preserve them in error messages.
319
316
  return "undefined";
320
317
  }
318
+ if (typeof value === "function") {
319
+ // A fixed placeholder also works for functions with custom string coercion.
320
+ return "[Function]";
321
+ }
322
+ if (typeof value === "symbol") {
323
+ return String(value);
324
+ }
321
325
  if (typeof value === "bigint") {
322
326
  // `JSON.stringify` throws on bigints by default.
323
327
  return `${value.toString()}n`;