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
@@ -0,0 +1,35 @@
1
+ import { chalkStderr } from "chalk";
2
+ import { DiscardedStagedValidator } from "./deployApi/evaluateSchema.js";
3
+
4
+ export function formatValidationProgress({
5
+ numDocsValidated,
6
+ totalDocs,
7
+ }: {
8
+ numDocsValidated: number;
9
+ totalDocs?: number | null | undefined;
10
+ }): string {
11
+ const checked = numDocsValidated.toLocaleString();
12
+ return totalDocs === null || totalDocs === undefined
13
+ ? `${checked} documents checked`
14
+ : `${checked} of approximately ${totalDocs.toLocaleString()} documents checked`;
15
+ }
16
+
17
+ /** "validated; the push removes the staged validator" */
18
+ export function formatDiscardedStagedValidator(
19
+ validator: DiscardedStagedValidator,
20
+ ): string {
21
+ let status;
22
+ switch (validator.state.state) {
23
+ case "pending": {
24
+ status = `validating in the background (${formatValidationProgress(validator.state)})`;
25
+ break;
26
+ }
27
+ case "valid":
28
+ status = chalkStderr.green("validated");
29
+ break;
30
+ }
31
+ const action = validator.replaced
32
+ ? "the push stages a different validator"
33
+ : "the push removes the staged validator";
34
+ return `${status}; ${action}`;
35
+ }
@@ -103,6 +103,8 @@ export interface components {
103
103
  /** Format: int64 */
104
104
  databaseWriteDocuments: number;
105
105
  /** Format: int64 */
106
+ databaseWriteIndexRows: number;
107
+ /** Format: int64 */
106
108
  storageReadBytes: number;
107
109
  /** Format: int64 */
108
110
  storageWriteBytes: number;
@@ -27,7 +27,7 @@ export type LargeIndexDeletionCheck =
27
27
  | "no verification"
28
28
  // If large indexes are being deleted, ask for confirmation (and fail in non-interactive envs)
29
29
  | "ask for confirmation"
30
- // If large indexes are being deleted, confirm (the user has used --allow-deleting-large-indexes)
30
+ // If large indexes are being deleted, confirm (the user has used --skip-large-indexes-check)
31
31
  | "has confirmation";
32
32
 
33
33
  export function addProgressLinkIfSlow(
@@ -13,10 +13,28 @@ import detect from "detect-port";
13
13
  import { LOCAL_BACKEND_SENTRY_DSN } from "../utils/sentry.js";
14
14
  import { createHash } from "crypto";
15
15
  import { LocalDeploymentError } from "./errors.js";
16
- import { LOCAL_BACKEND_INSTANCE_SECRET } from "./utils.js";
16
+ import { LOCAL_BACKEND_INSTANCE_SECRET, releaseDate } from "./utils.js";
17
17
  import { DeploymentType, DetailedDeploymentCredentials } from "../api.js";
18
+ import { productionProvisionHost, provisionHost } from "../config.js";
18
19
 
19
20
  const DEFAULT_STARTUP_TIMEOUT_SECS = 30;
21
+ const FIRST_CONTROL_PLANE_AUTH_BACKEND_VERSION =
22
+ "precompiled-2026-09-15-4e9b83a";
23
+
24
+ export function _backendSupportsControlPlaneAuth(version: string): boolean {
25
+ if (version === FIRST_CONTROL_PLANE_AUTH_BACKEND_VERSION) {
26
+ return true;
27
+ }
28
+ const backendDate = releaseDate(version);
29
+ const firstSupportedDate = releaseDate(
30
+ FIRST_CONTROL_PLANE_AUTH_BACKEND_VERSION,
31
+ );
32
+ return (
33
+ backendDate !== null &&
34
+ firstSupportedDate !== null &&
35
+ backendDate > firstSupportedDate
36
+ );
37
+ }
20
38
 
21
39
  async function parseStartupTimeoutSecs(ctx: Context): Promise<number> {
22
40
  const raw = process.env.CONVEX_LOCAL_BACKEND_STARTUP_TIMEOUT_SECS;
@@ -44,6 +62,7 @@ export async function runLocalBackend(
44
62
  deploymentKind: LocalDeploymentKind;
45
63
  deploymentName: string;
46
64
  binaryPath: string;
65
+ backendVersion: string;
47
66
  instanceSecret: string;
48
67
  isLatestVersion: boolean;
49
68
  },
@@ -128,7 +147,29 @@ export async function runLocalBackend(
128
147
  errForSentry: new LocalDeploymentError(message),
129
148
  });
130
149
  }
131
- const commandStr = `${args.binaryPath} ${commandArgs.join(" ")}`;
150
+ const supportsControlPlane = _backendSupportsControlPlaneAuth(
151
+ args.backendVersion,
152
+ );
153
+ if (supportsControlPlane && provisionHost !== productionProvisionHost) {
154
+ commandArgs.push("--control-plane-url", provisionHost);
155
+ }
156
+ const auth = ctx.bigBrainAuth();
157
+ if (
158
+ supportsControlPlane &&
159
+ args.deploymentKind === "local" &&
160
+ auth?.kind === "accessToken"
161
+ ) {
162
+ commandArgs.push("--control-plane-access-token", auth.accessToken);
163
+ }
164
+ const displayArgs = commandArgs.map((arg, index) =>
165
+ index > 0 &&
166
+ ["--instance-secret", "--control-plane-access-token"].includes(
167
+ commandArgs[index - 1],
168
+ )
169
+ ? "[REDACTED]"
170
+ : arg,
171
+ );
172
+ const commandStr = `${args.binaryPath} ${displayArgs.join(" ")}`;
132
173
  logVerbose(`Starting local backend: \`${commandStr}\``);
133
174
  const p = child_process
134
175
  .spawn(args.binaryPath, commandArgs, {
@@ -428,6 +469,7 @@ async function startEphemeralLocalBackend(
428
469
 
429
470
  const { cleanupHandle } = await runLocalBackend(ctx, {
430
471
  binaryPath,
472
+ backendVersion: config.backendVersion,
431
473
  ports: config.ports,
432
474
  deploymentKind,
433
475
  deploymentName: args.deploymentName,
@@ -10,6 +10,7 @@ import {
10
10
  saveDeploymentConfig,
11
11
  } from "./filePaths.js";
12
12
  import { runLocalBackend } from "./run.js";
13
+ import { releaseDate } from "./utils.js";
13
14
  import { promptYesNo } from "../utils/prompts.js";
14
15
  import { ensureBackendBinaryDownloaded } from "./download.js";
15
16
  import {
@@ -66,6 +67,7 @@ export async function handlePotentialUpgradeAndStart(
66
67
  );
67
68
  const { cleanupHandle } = await runLocalBackend(ctx, {
68
69
  binaryPath: args.newBinaryPath,
70
+ backendVersion: args.newVersion,
69
71
  deploymentKind: args.deploymentKind,
70
72
  deploymentName: args.deploymentName,
71
73
  ports: args.ports,
@@ -99,6 +101,7 @@ export async function handlePotentialUpgradeAndStart(
99
101
  });
100
102
  const { cleanupHandle } = await runLocalBackend(ctx, {
101
103
  binaryPath: oldBinaryPath,
104
+ backendVersion: args.oldVersion,
102
105
  ports: args.ports,
103
106
  deploymentKind: args.deploymentKind,
104
107
  deploymentName: args.deploymentName,
@@ -155,6 +158,7 @@ async function handleUpgrade(
155
158
  logVerbose(`Running backend on new version ${args.newVersion}`);
156
159
  const { cleanupHandle } = await runLocalBackend(ctx, {
157
160
  binaryPath: args.newBinaryPath,
161
+ backendVersion: args.newVersion,
158
162
  ports: args.ports,
159
163
  deploymentKind: args.deploymentKind,
160
164
  deploymentName: args.deploymentName,
@@ -182,9 +186,3 @@ export function _isDowngrade(oldVersion: string, newVersion: string): boolean {
182
186
  const newDate = releaseDate(newVersion);
183
187
  return oldDate !== null && newDate !== null && newDate < oldDate;
184
188
  }
185
-
186
- // Backend releases are tagged `precompiled-YYYY-MM-DD-<commit>`, so the dates
187
- // sort lexicographically.
188
- function releaseDate(version: string): string | null {
189
- return /^precompiled-(\d{4}-\d{2}-\d{2})-/.exec(version)?.[1] ?? null;
190
- }
@@ -92,3 +92,9 @@ export function printLocalDeploymentWelcomeMessage() {
92
92
 
93
93
  export const LOCAL_BACKEND_INSTANCE_SECRET =
94
94
  "4361726e697461732c206c69746572616c6c79206d65616e696e6720226c6974";
95
+
96
+ // Backend releases are tagged `precompiled-YYYY-MM-DD-<commit>`, so the dates
97
+ // sort lexicographically.
98
+ export function releaseDate(version: string): string | null {
99
+ return /^precompiled-(\d{4}-\d{2}-\d{2})-/.exec(version)?.[1] ?? null;
100
+ }
@@ -12,13 +12,22 @@ const envListInputSchema = z.object({
12
12
  .describe(
13
13
  "Deployment selector (from the status tool) to list environment variables from.",
14
14
  ),
15
+ includeValues: z
16
+ .boolean()
17
+ .optional()
18
+ .describe(
19
+ "Also return each variable's value. Values are often secrets like API keys, so leave this off unless you need every value, and use envGet to read a single variable instead.",
20
+ ),
15
21
  });
16
22
 
17
23
  const envListOutputSchema = z.object({
18
24
  variables: z.array(
19
25
  z.object({
20
26
  name: z.string(),
21
- value: z.string(),
27
+ value: z
28
+ .string()
29
+ .optional()
30
+ .describe("Only present when includeValues is true."),
22
31
  }),
23
32
  ),
24
33
  });
@@ -28,7 +37,8 @@ export const EnvListTool: ConvexTool<
28
37
  typeof envListOutputSchema
29
38
  > = {
30
39
  name: "envList",
31
- description: "List all environment variables in your Convex deployment.",
40
+ description:
41
+ "List the names of all environment variables in your Convex deployment. Values are left out unless includeValues is true.",
32
42
  inputSchema: envListInputSchema,
33
43
  outputSchema: envListOutputSchema,
34
44
  handler: async (ctx, args) => {
@@ -51,7 +61,11 @@ export const EnvListTool: ConvexTool<
51
61
  componentPath: undefined,
52
62
  args: {},
53
63
  })) as EnvVar[];
54
- return { variables };
64
+ return {
65
+ variables: variables.map(({ name, value }) =>
66
+ args.includeValues ? { name, value } : { name },
67
+ ),
68
+ };
55
69
  },
56
70
  };
57
71
 
@@ -535,6 +535,9 @@ export async function pushToDeployment(
535
535
  liveComponentSources: args.liveComponentSources,
536
536
  pushAllModules: false,
537
537
  largeIndexDeletionCheck: "no verification", // `convex run` can’t push to prod
538
+ largeIndexBackfillCheck: "no verification", // ditto
539
+ stagedValidatorDeletionCheck: "no verification", // ditto
540
+ warnOnSlowSchemaValidation: true,
538
541
  message: null,
539
542
  },
540
543
  {
@@ -0,0 +1,88 @@
1
+ import { Context } from "../../bundler/context.js";
2
+ import { logVerbose } from "../../bundler/log.js";
3
+ import { EvaluateSchemaResponse } from "./deployApi/evaluateSchema.js";
4
+ import { StartPushRequest } from "./deployApi/startPush.js";
5
+ import { evaluateSchema } from "./deploy2.js";
6
+ import { Span } from "./tracing.js";
7
+
8
+ type EvaluateOptions = {
9
+ url: string;
10
+ deploymentName: string | null;
11
+ adminKey: string;
12
+ };
13
+
14
+ /**
15
+ * A schema evaluation shared by the pre-push checks. Resolves to `null` when
16
+ * the deployment doesn't support `evaluate_schema` or the request failed, in
17
+ * which case each check skips itself.
18
+ */
19
+ export type SchemaEvaluation = (
20
+ span: Span,
21
+ ) => Promise<EvaluateSchemaResponse | null>;
22
+
23
+ /**
24
+ * Evaluate the schema at most once per push however many checks consume it:
25
+ * the first check to call sends the request under its own span, and the rest
26
+ * await the same promise. Each request makes the backend evaluate the schema
27
+ * module in an isolate and predict against a fresh snapshot, so repeating it
28
+ * per check would add that work and a round trip to the deploy's critical
29
+ * path for every check.
30
+ */
31
+ /**
32
+ * Whether a schema module in the push calls `.staged(`. Bundles aren't
33
+ * minified, so the call survives bundling. A false positive from a comment or
34
+ * string costs one evaluation, while a push without staged validators skips
35
+ * the evaluation round trip on its critical path.
36
+ */
37
+ export function pushStagesValidators(request: StartPushRequest): boolean {
38
+ return [
39
+ request.appDefinition.schema,
40
+ ...request.componentDefinitions.map((definition) => definition.schema),
41
+ ].some((schema) => schema?.source.includes(".staged(") ?? false);
42
+ }
43
+
44
+ export function sharedSchemaEvaluation(
45
+ ctx: Context,
46
+ request: StartPushRequest,
47
+ options: EvaluateOptions,
48
+ ): SchemaEvaluation {
49
+ let evaluation: Promise<EvaluateSchemaResponse | null> | undefined;
50
+ return (span) => {
51
+ evaluation ??= evaluateSchemaBestEffort({ ctx, span, request, options });
52
+ return evaluation;
53
+ };
54
+ }
55
+
56
+ // The checks are advisory: if evaluation fails, fall back to skipping them
57
+ // rather than aborting the push over a check that isn't required for
58
+ // correctness. Plausibly transient failures — network errors and 5xx
59
+ // responses (e.g. table summaries still bootstrapping) — are retried with
60
+ // backoff by the shared fetch wrapper (see `pushCode`); anything else is
61
+ // deterministic, including a 2xx whose shape the CLI doesn't recognize, so
62
+ // it skips the checks immediately.
63
+ async function evaluateSchemaBestEffort({
64
+ ctx,
65
+ span,
66
+ request,
67
+ options,
68
+ }: {
69
+ ctx: Context;
70
+ span: Span;
71
+ request: StartPushRequest;
72
+ options: EvaluateOptions;
73
+ }): Promise<EvaluateSchemaResponse | null> {
74
+ try {
75
+ return await evaluateSchema(
76
+ ctx,
77
+ span,
78
+ request,
79
+ options,
80
+ /* bestEffort */ true,
81
+ );
82
+ } catch (error: unknown) {
83
+ logVerbose(
84
+ `Skipping schema evaluation checks: ${error instanceof Error ? error.message : String(error)}`,
85
+ );
86
+ return null;
87
+ }
88
+ }
@@ -21,6 +21,7 @@ export const USAGE_LIMIT_METRICS = [
21
21
  "databaseIoGb",
22
22
  "searchQueryGb",
23
23
  "dataEgressGb",
24
+ "aiGatewayCostDollars",
24
25
  ] as const satisfies readonly UsageLimitMetric[];
25
26
 
26
27
  // Fails to compile if the backend's `UsageLimitMetric` gains a metric not listed
@@ -47,6 +48,7 @@ export const METRIC_LABELS: Record<UsageLimitMetric, string> = {
47
48
  databaseIoGb: "Database I/O",
48
49
  searchQueryGb: "Search queries",
49
50
  dataEgressGb: "Data egress",
51
+ aiGatewayCostDollars: "AI Gateway",
50
52
  };
51
53
 
52
54
  export function metricLabel(metric: string): string {
@@ -1,32 +1,14 @@
1
1
  export class Mutex {
2
- currentlyRunning: Promise<void> | null = null;
3
- waiting: Array<() => Promise<void>> = [];
2
+ private tail: Promise<void> = Promise.resolve();
4
3
 
5
4
  async runExclusive<T>(fn: () => Promise<T>): Promise<T> {
6
- const outerPromise = new Promise<T>((resolve, reject) => {
7
- const wrappedCallback: () => Promise<void> = () => {
8
- return fn()
9
- .then((v: T) => resolve(v))
10
- .catch((e: any) => reject(e));
11
- };
12
- this.enqueueCallbackForMutex(wrappedCallback);
13
- });
14
- return outerPromise;
15
- }
16
-
17
- private enqueueCallbackForMutex(callback: () => Promise<void>) {
18
- if (this.currentlyRunning === null) {
19
- this.currentlyRunning = callback().finally(() => {
20
- const nextCb = this.waiting.shift();
21
- if (nextCb === undefined) {
22
- this.currentlyRunning = null;
23
- } else {
24
- this.enqueueCallbackForMutex(nextCb);
25
- }
26
- });
27
- this.waiting.length = 0;
28
- } else {
29
- this.waiting.push(callback);
30
- }
5
+ const result = this.tail.then(fn);
6
+ // Reserve the next position before running fn, and allow the queue to
7
+ // continue even if fn rejects or throws synchronously.
8
+ this.tail = result.then(
9
+ () => {},
10
+ () => {},
11
+ );
12
+ return result;
31
13
  }
32
14
  }
@@ -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,
@@ -972,40 +994,49 @@ export function waitUntilCalled(): [Promise<unknown>, () => void] {
972
994
  return [waitPromise, () => onCalled(null)];
973
995
  }
974
996
 
975
- const BYTE_UNITS: [number, string][] = [
976
- [1 << 30, "GiB"],
977
- [1_000_000_000, "GB"],
978
- [1 << 20, "MiB"],
979
- [1_000_000, "MB"],
980
- [1 << 10, "KiB"],
981
- [1_000, "KB"],
982
- ];
997
+ const BYTE_UNITS = ["bytes", "KiB", "MiB", "GiB", "TiB", "PiB"];
983
998
 
984
999
  /**
985
- * Format a byte count into a human-friendly string.
986
- *
987
- * Picks the unit (binary or decimal) that divides most cleanly.
988
- * Shows one decimal place only when it divides exactly (e.g. "4.1 MiB").
989
- * Falls back to raw bytes when no unit divides cleanly.
1000
+ * Format a byte count into a human-friendly string, rounded to one decimal
1001
+ * place (dropped when it would be ".0"), e.g. "4.1 MiB" or "128 MiB".
990
1002
  */
991
1003
  export function formatSize(n: number): string {
992
- if (n === 0) {
993
- return "0 bytes";
1004
+ let value = n;
1005
+ let unitIndex = 0;
1006
+ while (value >= 1024 && unitIndex < BYTE_UNITS.length - 1) {
1007
+ value /= 1024;
1008
+ unitIndex++;
994
1009
  }
995
- for (const [unitSize, unitName] of BYTE_UNITS) {
996
- if (n < unitSize) {
997
- continue;
998
- }
999
- if (n % unitSize === 0) {
1000
- return `${n / unitSize} ${unitName}`;
1001
- }
1002
- if ((n * 10) % unitSize === 0) {
1003
- const whole = Math.floor(n / unitSize);
1004
- const frac = Math.floor((n * 10) / unitSize) % 10;
1005
- return `${whole}.${frac} ${unitName}`;
1006
- }
1010
+ // Rounding to one decimal place can itself reach the next unit's
1011
+ // boundary (e.g. 1023.999 KiB -> "1024.0 KiB" instead of "1.0 MiB").
1012
+ const roundedValue = Number(value.toFixed(1));
1013
+ if (roundedValue >= 1024 && unitIndex < BYTE_UNITS.length - 1) {
1014
+ value /= 1024;
1015
+ unitIndex++;
1016
+ }
1017
+ const formatted = value.toFixed(1).replace(/\.0$/, "");
1018
+ return `${formatted} ${BYTE_UNITS[unitIndex]}`;
1019
+ }
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;
1007
1038
  }
1008
- return `${n} bytes`;
1039
+ return Number(envValue);
1009
1040
  }
1010
1041
 
1011
1042
  export function formatDuration(ms: number): string {
@@ -1195,12 +1226,12 @@ export function spawnAsync(
1195
1226
 
1196
1227
  const IDEMPOTENT_METHODS = ["GET", "HEAD", "PUT", "DELETE", "OPTIONS", "TRACE"];
1197
1228
 
1198
- function retryDelay(
1229
+ // immediate, 1s delay, 2s delay, 4s delay, etc.
1230
+ export function retryDelay(
1199
1231
  attempt: number,
1200
1232
  _error: Error | null,
1201
1233
  _response: Response | null,
1202
1234
  ): number {
1203
- // immediate, 1s delay, 2s delay, 4s delay, etc.
1204
1235
  const delay = attempt === 0 ? 1 : 2 ** (attempt - 1) * 1000;
1205
1236
  const randomSum = delay * 0.2 * Math.random();
1206
1237
  return delay + randomSum;
@@ -1209,8 +1240,13 @@ function retryDelay(
1209
1240
  function deploymentFetchRetryOn(
1210
1241
  onError?: (err: any, attempt: number) => void,
1211
1242
  method?: string,
1243
+ maxRetries: number = MAX_RETRIES,
1244
+ shouldRetryOverride?: (
1245
+ error: Error | null,
1246
+ response: Response | null,
1247
+ ) => boolean,
1212
1248
  ) {
1213
- const shouldRetry = function (
1249
+ const defaultShouldRetry = function (
1214
1250
  _attempt: number,
1215
1251
  error: Error | null,
1216
1252
  response: Response | null,
@@ -1266,6 +1302,21 @@ function deploymentFetchRetryOn(
1266
1302
  return { kind: "stop" };
1267
1303
  };
1268
1304
 
1305
+ const shouldRetry = shouldRetryOverride
1306
+ ? function (
1307
+ _attempt: number,
1308
+ error: Error | null,
1309
+ response: Response | null,
1310
+ ): { kind: "retry"; error: any } | { kind: "stop" } {
1311
+ return shouldRetryOverride(error, response)
1312
+ ? {
1313
+ kind: "retry",
1314
+ error:
1315
+ error ?? `Received response with status ${response?.status}`,
1316
+ }
1317
+ : { kind: "stop" };
1318
+ }
1319
+ : defaultShouldRetry;
1269
1320
  return function (
1270
1321
  attempt: number,
1271
1322
  error: Error | null,
@@ -1275,7 +1326,7 @@ function deploymentFetchRetryOn(
1275
1326
  if (result.kind === "retry") {
1276
1327
  onError?.(result.error, attempt);
1277
1328
  }
1278
- if (attempt >= MAX_RETRIES) {
1329
+ if (attempt >= maxRetries) {
1279
1330
  // Stop retrying if we've exhausted all retries, but do this after we've
1280
1331
  // called `onError` so that the caller can still log the error.
1281
1332
  return false;
@@ -1334,15 +1385,30 @@ export function deploymentFetch(
1334
1385
  deploymentUrl: string;
1335
1386
  adminKey: string;
1336
1387
  onError?: (err: any) => void;
1388
+ // Defaults to MAX_RETRIES. Lower this for best-effort requests (e.g.
1389
+ // advisory checks) where a slow retry loop against an unsupported or
1390
+ // unhealthy endpoint shouldn't hold up the surrounding command.
1391
+ maxRetries?: number | undefined;
1392
+ // Replaces the default retry policy (which is tuned for pushes: network
1393
+ // errors, 404s on fresh deployments, retries of idempotent methods).
1394
+ // Return true to retry the request. Backoff and retry logging are
1395
+ // shared either way.
1396
+ shouldRetry?: (error: Error | null, response: Response | null) => boolean;
1337
1397
  },
1338
1398
  ): typeof fetch {
1339
- const { deploymentUrl, adminKey, onError } = options;
1399
+ const {
1400
+ deploymentUrl,
1401
+ adminKey,
1402
+ onError,
1403
+ maxRetries = MAX_RETRIES,
1404
+ shouldRetry,
1405
+ } = options;
1340
1406
  const onErrorWithAttempt = (err: any, attempt: number) => {
1341
1407
  onError?.(err);
1342
1408
  if (attempt >= RETRY_LOG_THRESHOLD) {
1343
1409
  logMessage(
1344
1410
  chalkStderr.gray(
1345
- `Retrying request (attempt ${attempt}/${MAX_RETRIES})...`,
1411
+ `Retrying request (attempt ${attempt}/${maxRetries})...`,
1346
1412
  ),
1347
1413
  );
1348
1414
  }
@@ -1367,7 +1433,12 @@ export function deploymentFetch(
1367
1433
  }
1368
1434
  const func = throwingFetch(url, {
1369
1435
  retryDelay,
1370
- retryOn: deploymentFetchRetryOn(onErrorWithAttempt, options?.method),
1436
+ retryOn: deploymentFetchRetryOn(
1437
+ onErrorWithAttempt,
1438
+ options?.method,
1439
+ maxRetries,
1440
+ shouldRetry,
1441
+ ),
1371
1442
  ...options,
1372
1443
  headers,
1373
1444
  });