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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/cli/lib/components/definition/bundle.ts"],
4
- "sourcesContent": ["import path from \"path\";\nimport {\n ComponentDirectory,\n ComponentDefinitionPath,\n buildComponentDirectory,\n isComponentDirectory,\n qualifiedDefinitionPath,\n toComponentDefinitionPath,\n} from \"./directoryStructure.js\";\nimport { Context } from \"../../../../bundler/context.js\";\nimport {\n logMessage,\n logWarning,\n showSpinner,\n} from \"../../../../bundler/log.js\";\nimport esbuild, { BuildOptions, Metafile, OutputFile, Plugin } from \"esbuild\";\nimport { chalkStderr } from \"chalk\";\nimport {\n AppDefinitionSpecWithoutImpls,\n ComponentDefinitionSpecWithoutImpls,\n} from \"../../config.js\";\nimport {\n Bundle,\n bundle,\n bundleAuthConfig,\n bundleSchema,\n entryPointsByEnvironment,\n} from \"../../../../bundler/index.js\";\nimport { NodeDependency } from \"../../deployApi/modules.js\";\n\nconst VIRTUAL_CONFIG_NAMESPACE = \"convex-virtual-config\";\nconst VIRTUAL_CONFIG_CONTENTS = `import { defineApp } from \"convex/server\";\\nconst app = defineApp();\\nexport default app;`;\n\n/**\n * An esbuild plugin to insert a virtual `convex.config.js` file into the bundle\n * when Convex project doesn't have one explicitly defined.\n *\n * This allows us to use the components push path even when the Convex project doesn't\n * have a config file defined.\n *\n * When importComponentPath is provided, the virtual config will import and use the\n * component found at that path.\n */\nfunction virtualConfig({\n rootComponentDirectory,\n importComponentPath,\n}: {\n rootComponentDirectory: ComponentDirectory;\n importComponentPath?: string;\n}): Plugin {\n // Empty config with no components\n let contents = VIRTUAL_CONFIG_CONTENTS;\n\n if (importComponentPath) {\n // Generate config that imports the specified component\n const relativeImport = path.relative(\n rootComponentDirectory.path,\n importComponentPath,\n );\n let normalizedImport = relativeImport\n .replace(/\\\\/g, \"/\")\n .replace(/\\.ts$/, \".js\");\n\n // We don't generate code for this synthetic root component so the name we\n // use for the component doesn't matter.\n contents = `import { defineApp } from \"convex/server\";\nimport component from \"${normalizedImport}\";\n\nconst app = defineApp();\napp.use(component, { name: \"exampleComponentInstance\" });\nexport default app;`;\n }\n\n return {\n name: `convex-virtual-config`,\n async setup(build) {\n const filter = pathToRegexFilter(rootComponentDirectory);\n build.onResolve({ filter }, async (args) => {\n return { path: args.path, namespace: VIRTUAL_CONFIG_NAMESPACE };\n });\n build.onLoad(\n { filter, namespace: VIRTUAL_CONFIG_NAMESPACE },\n async (_args) => {\n return {\n contents,\n resolveDir: rootComponentDirectory.path,\n };\n },\n );\n },\n };\n}\n\nfunction pathToRegexFilter(root: ComponentDirectory) {\n let path = qualifiedDefinitionPath(root);\n const escaped = path\n .replace(/\\\\/g, \"/\")\n .replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n return new RegExp(`^${escaped}$`);\n}\n\n/**\n * An esbuild plugin to mark component definitions external or return a list of\n * all component definitions.\n *\n * By default this plugin runs in \"bundle\" mode and marks all imported component\n * definition files as external, not traversing further.\n *\n * If \"discover\" mode is specified it traverses the entire tree.\n */\nfunction componentPlugin({\n mode = \"bundle\",\n rootComponentDirectory,\n verbose,\n ctx,\n}: {\n mode: \"discover\" | \"bundle\";\n rootComponentDirectory: ComponentDirectory;\n verbose?: boolean;\n ctx: Context;\n}): Plugin {\n const components = new Map<string, ComponentDirectory>();\n return {\n name: `convex-${mode === \"discover\" ? \"discover-components\" : \"bundle-components\"}`,\n async setup(build) {\n // This regex can't be really precise since developers could import\n // \"convex.config\", \"convex.config.js\", \"convex.config.ts\", etc.\n build.onResolve({ filter: /.*convex.config.*/ }, async (args) => {\n verbose && logMessage(\"esbuild resolving import:\", args);\n if (\n args.namespace !== \"file\" &&\n args.namespace !== VIRTUAL_CONFIG_NAMESPACE\n ) {\n verbose && logMessage(\" Not a file or virtual config.\");\n return;\n }\n if (args.kind === \"entry-point\") {\n verbose && logMessage(\" -> Top-level entry-point.\");\n const componentDirectory = await buildComponentDirectory(\n ctx,\n path.resolve(args.path),\n );\n\n // No attempt to resolve args.path is made for entry points so they\n // must be relative or absolute file paths, not npm packages.\n // Whether we're bundling or discovering, we're done.\n if (components.get(args.path)) {\n // We always invoke esbuild in a try/catch.\n // eslint-disable-next-line no-restricted-syntax\n throw new Error(\n `Entry point component \"${args.path}\" already registered.`,\n );\n }\n components.set(args.path, componentDirectory);\n return;\n }\n\n const candidates = [args.path];\n const ext = path.extname(args.path);\n if (ext === \".js\") {\n candidates.push(args.path.slice(0, -\".js\".length) + \".ts\");\n }\n if (ext !== \".js\" && ext !== \".ts\") {\n candidates.push(args.path + \".js\");\n candidates.push(args.path + \".ts\");\n }\n let resolvedPath = undefined;\n for (const candidate of candidates) {\n const result = await build.resolve(candidate, {\n // We expect this to be \"import-statement\" but pass 'kind' through\n // to say honest to normal esbuild behavior.\n kind: args.kind,\n resolveDir: args.resolveDir,\n });\n if (result.path) {\n resolvedPath = result.path;\n break;\n }\n }\n if (resolvedPath === undefined) {\n verbose && logMessage(` -> ${args.path} not found.`);\n return;\n }\n\n const parentDir = path.dirname(resolvedPath);\n let imported = components.get(resolvedPath);\n if (!imported) {\n const isComponent = isComponentDirectory(ctx, parentDir, false);\n if (isComponent.kind !== \"ok\") {\n verbose && logMessage(\" -> Not a component:\", isComponent);\n return;\n }\n imported = isComponent.component;\n components.set(resolvedPath, imported);\n }\n\n verbose &&\n logMessage(\n \" -> Component import! Recording it.\",\n args.path,\n resolvedPath,\n );\n\n if (mode === \"discover\") {\n return {\n path: resolvedPath,\n };\n } else {\n // In bundle mode, transform external imports to use componentPaths:\n // import rateLimiter from \"convex_ratelimiter\";\n // => import rateLimiter from `_componentDeps/${base64('../node_modules/convex_ratelimiter')}`;\n\n // A componentPath is path from the root component to the directory\n // of the this component's definition file.\n const componentPath = toComponentDefinitionPath(\n rootComponentDirectory,\n imported,\n );\n const importPath = definitionImportPath(componentPath);\n return {\n path: importPath,\n external: true,\n };\n }\n });\n },\n };\n}\n\n/** The path on the deployment that identifier a component definition. */\nfunction definitionImportPath(componentPath: ComponentDefinitionPath): string {\n return `./_componentDeps/${Buffer.from(componentPath).toString(\"base64url\")}`;\n}\n\n// Share configuration between the component definition discovery and bundling passes.\nfunction sharedEsbuildOptions({\n liveComponentSources = false,\n}: {\n liveComponentSources?: boolean;\n}) {\n const options = {\n bundle: true,\n platform: \"browser\",\n format: \"esm\",\n target: \"esnext\",\n\n conditions: [\"convex\", \"module\"] as string[],\n\n // `false` is the default for splitting. It's simpler to evaluate these on\n // the server as a single file.\n // Splitting could be enabled for speed once the server supports it.\n splitting: false,\n\n // place output files in memory at their source locations\n write: false,\n outdir: path.parse(process.cwd()).root,\n outbase: path.parse(process.cwd()).root,\n\n minify: true, // Note that this implies NODE_ENV=\"production\".\n keepNames: true,\n\n metafile: true,\n } as const satisfies BuildOptions;\n\n // Link directly to component sources (usually .ts) in order to\n // skip the build step. This also causes codegen to run for components\n // loaded from npm packages.\n if (liveComponentSources) {\n options.conditions.push(\"@convex-dev/component-source\");\n }\n return options;\n}\n\n// Use the esbuild metafile to discover the dependency graph in which component\n// definitions are nodes.\nexport async function componentGraph(\n ctx: Context,\n absWorkingDir: string,\n rootComponentDirectory: ComponentDirectory,\n liveComponentSources: boolean,\n verbose: boolean = true,\n): Promise<{\n components: Map<string, ComponentDirectory>;\n dependencyGraph: [ComponentDirectory, ComponentDirectory][];\n}> {\n if (\n rootComponentDirectory.isRootWithoutConfig &&\n !rootComponentDirectory.syntheticComponentImport\n ) {\n return {\n components: new Map([\n [rootComponentDirectory.path, rootComponentDirectory],\n ]),\n dependencyGraph: [],\n };\n }\n let result;\n try {\n result = await esbuild.build({\n absWorkingDir, // This is mostly useful for formatting error messages.\n entryPoints: [qualifiedDefinitionPath(rootComponentDirectory)],\n plugins: [\n componentPlugin({\n ctx,\n mode: \"discover\",\n verbose,\n rootComponentDirectory,\n }),\n ...(rootComponentDirectory.syntheticComponentImport\n ? [\n virtualConfig({\n rootComponentDirectory,\n importComponentPath:\n rootComponentDirectory.syntheticComponentImport,\n }),\n ]\n : []),\n ],\n sourcemap: \"external\",\n sourcesContent: false,\n\n ...sharedEsbuildOptions({ liveComponentSources }),\n });\n await registerEsbuildReads(ctx, absWorkingDir, result.metafile);\n } catch (err: any) {\n return await ctx.crash({\n exitCode: 1,\n errorType: \"invalid filesystem data\",\n printedMessage: `esbuild failed: ${err}`,\n });\n }\n\n if (result.errors.length) {\n const message = result.errors.map((error) => error.text).join(\"\\n\");\n return await ctx.crash({\n exitCode: 1,\n errorType: \"invalid filesystem data\",\n printedMessage: message,\n });\n }\n for (const warning of result.warnings) {\n logWarning(chalkStderr.yellow(`esbuild warning: ${warning.text}`));\n }\n\n if (rootComponentDirectory.syntheticComponentImport) {\n // Virtual configs appear in the metafile with a namespace prefix\n // and can't have ComponentDirectory objects built by reading the filesystem\n // so swap in this rootComponentDirectory.\n return await findComponentDependencies(ctx, result.metafile, {\n [`${VIRTUAL_CONFIG_NAMESPACE}:${qualifiedDefinitionPath(rootComponentDirectory)}`]:\n rootComponentDirectory,\n });\n }\n\n return await findComponentDependencies(ctx, result.metafile);\n}\n\n/**\n * Get dependencies of a ComponenDirectory as ComponentPaths.\n *\n * Component paths are paths relative to the root component.\n */\nexport function getDeps(\n rootComponent: ComponentDirectory,\n dependencyGraph: [ComponentDirectory, ComponentDirectory][],\n definitionPath: string,\n): ComponentDefinitionPath[] {\n return dependencyGraph\n .filter(\n ([importer, _imported]) => importer.definitionPath === definitionPath,\n )\n .map(([_importer, imported]) =>\n toComponentDefinitionPath(rootComponent, imported),\n );\n}\n\n/**\n * The returned dependency graph is an array of tuples of [importer, imported]\n *\n * This doesn't work on just any esbuild metafile because it assumes input\n * imports have not been transformed. We run it on the metafile produced by\n * the esbuild invocation that uses the component plugin in \"discover\" mode.\n *\n * @param inputOverrides - ComponentDirectory objects to be used for metafile.inputs\n * keys, in case they don't exist (namely virtual configs via esbuild plugin namespaces).\n */\nasync function findComponentDependencies(\n ctx: Context,\n metafile: Metafile,\n inputOverrides: Record<string, ComponentDirectory> = {},\n): Promise<{\n components: Map<string, ComponentDirectory>;\n dependencyGraph: [ComponentDirectory, ComponentDirectory][];\n}> {\n const { inputs } = metafile;\n\n const componentsByKey = new Map<string, ComponentDirectory>();\n for (const inputPath of Object.keys(inputs)) {\n if (!inputPath.includes(\".config.\")) continue;\n\n const override: ComponentDirectory | undefined = inputOverrides[inputPath];\n if (override) {\n componentsByKey.set(inputPath, override);\n } else {\n // Normal component - build from filesystem\n const component = await buildComponentDirectory(ctx, inputPath);\n componentsByKey.set(path.resolve(inputPath), component);\n }\n }\n\n const dependencyGraph: [ComponentDirectory, ComponentDirectory][] = [];\n\n for (const inputPath of Object.keys(inputs)) {\n if (!inputPath.includes(\".config.\")) continue;\n\n // For overridden inputs, use the original key; for normal components, use resolved path\n const importerKey =\n inputPath in inputOverrides ? inputPath : path.resolve(inputPath);\n\n const importer = componentsByKey.get(importerKey);\n if (!importer) continue;\n\n const { imports } = inputs[inputPath];\n const componentImports = imports.filter((imp) =>\n imp.path.includes(\".config.\"),\n );\n\n for (const imp of componentImports) {\n const imported = componentsByKey.get(path.resolve(imp.path));\n if (!imported) {\n return await ctx.crash({\n exitCode: 1,\n errorType: \"invalid filesystem data\",\n printedMessage: `Didn't find ${path.resolve(imp.path)} in ${[...componentsByKey.keys()].toString()}`,\n });\n }\n\n // Grab the import specifier from the metafile (e.g. `@convex-dev/workpool/convex.config`) so\n // we can use it to import component APIs\n if (imp.original) {\n const importSpecifier = imp.original;\n const relativeSpecifier = importSpecifier.replace(\n /\\/convex\\.config.*$/,\n \"\",\n );\n\n imported.importSpecifier = relativeSpecifier;\n }\n\n dependencyGraph.push([importer, imported]);\n }\n }\n\n const components = new Map<string, ComponentDirectory>();\n for (const directory of componentsByKey.values()) {\n components.set(directory.path, directory);\n }\n\n return { components, dependencyGraph };\n}\n\n// NB: If a directory linked to is not a member of the passed\n// componentDirectories array then there will be external links\n// with no corresponding definition bundle.\n// That could be made to throw an error but maybe those are already available\n// on the Convex definition filesystem somehow, e.g. builtin components.\n/** Bundle the component definitions listed. */\nexport async function bundleDefinitions(\n ctx: Context,\n absWorkingDir: string,\n dependencyGraph: [ComponentDirectory, ComponentDirectory][],\n rootComponentDirectory: ComponentDirectory,\n componentDirectories: ComponentDirectory[],\n liveComponentSources: boolean,\n verbose: boolean = false,\n): Promise<{\n appDefinitionSpecWithoutImpls: AppDefinitionSpecWithoutImpls;\n componentDefinitionSpecsWithoutImpls: ComponentDefinitionSpecWithoutImpls[];\n}> {\n let result;\n try {\n let plugins = [\n componentPlugin({\n ctx,\n mode: \"bundle\",\n verbose,\n rootComponentDirectory,\n }),\n ];\n if (\n rootComponentDirectory.syntheticComponentImport ||\n rootComponentDirectory.isRootWithoutConfig\n ) {\n // Use virtual config (either with a component import or empty)\n plugins.push(\n virtualConfig(\n rootComponentDirectory.syntheticComponentImport\n ? {\n rootComponentDirectory,\n importComponentPath:\n rootComponentDirectory.syntheticComponentImport,\n }\n : { rootComponentDirectory },\n ),\n );\n }\n result = await esbuild.build({\n absWorkingDir,\n entryPoints: componentDirectories.map((dir) =>\n qualifiedDefinitionPath(dir),\n ),\n plugins,\n sourcemap: true,\n ...sharedEsbuildOptions({ liveComponentSources }),\n });\n await registerEsbuildReads(ctx, absWorkingDir, result.metafile);\n } catch (err: any) {\n return await ctx.crash({\n exitCode: 1,\n errorType: \"invalid filesystem data\",\n printedMessage: `esbuild failed: ${err}`,\n });\n }\n\n if (result.errors.length) {\n const message = result.errors.map((error) => error.text).join(\"\\n\");\n return await ctx.crash({\n exitCode: 1,\n errorType: \"invalid filesystem data\",\n printedMessage: message,\n });\n }\n for (const warning of result.warnings) {\n logWarning(chalkStderr.yellow(`esbuild warning: ${warning.text}`));\n }\n\n const outputs: {\n outputJs: OutputFile;\n outputJsMap?: OutputFile;\n directory: ComponentDirectory;\n }[] = [];\n for (const directory of componentDirectories) {\n const absInput = path.resolve(absWorkingDir, directory.definitionPath);\n const expectedOutputJs =\n absInput.slice(0, absInput.lastIndexOf(\".\")) + \".js\";\n const expectedOutputMap =\n absInput.slice(0, absInput.lastIndexOf(\".\")) + \".js.map\";\n const outputJs = result.outputFiles.filter(\n (outputFile) => outputFile.path === expectedOutputJs,\n )[0];\n if (!outputJs) {\n return await ctx.crash({\n exitCode: 1,\n errorType: \"fatal\",\n printedMessage: `no JS found matching ${expectedOutputJs} in ${result.outputFiles.map((x) => x.path).toString()}`,\n });\n }\n const outputJsMap = result.outputFiles.filter(\n (outputFile) => outputFile.path === expectedOutputMap,\n )[0];\n outputs.push({\n outputJs,\n outputJsMap,\n directory,\n });\n }\n\n const appBundles = outputs.filter(\n (out) => out.directory.path === rootComponentDirectory.path,\n );\n if (appBundles.length !== 1) {\n return await ctx.crash({\n exitCode: 1,\n errorType: \"fatal\",\n printedMessage: \"found wrong number of app bundles\",\n });\n }\n const appBundle = appBundles[0];\n const componentBundles = outputs.filter(\n (out) => out.directory.path !== rootComponentDirectory.path,\n );\n\n const componentDefinitionSpecsWithoutImpls: ComponentDefinitionSpecWithoutImpls[] =\n componentBundles.map(({ directory, outputJs, outputJsMap }) => ({\n definitionPath: toComponentDefinitionPath(\n rootComponentDirectory,\n directory,\n ),\n definition: {\n path: path.relative(directory.path, outputJs.path),\n source: outputJs.text,\n sourceMap: outputJsMap?.text,\n environment: \"isolate\" as const,\n },\n dependencies: getDeps(\n rootComponentDirectory,\n dependencyGraph,\n directory.definitionPath,\n ),\n }));\n const appDeps = getDeps(\n rootComponentDirectory,\n dependencyGraph,\n appBundle.directory.definitionPath,\n );\n const appDefinitionSpecWithoutImpls: AppDefinitionSpecWithoutImpls = {\n definition: {\n path: path.relative(rootComponentDirectory.path, appBundle.outputJs.path),\n source: appBundle.outputJs.text,\n sourceMap: appBundle.outputJsMap?.text,\n environment: \"isolate\" as const,\n },\n dependencies: appDeps,\n };\n return {\n appDefinitionSpecWithoutImpls,\n componentDefinitionSpecsWithoutImpls,\n };\n}\n\nexport async function bundleImplementations({\n ctx,\n rootComponentDirectory,\n componentDirectories,\n nodeExternalPackages,\n extraConditions,\n verbose = false,\n includeSourcesContent = false,\n}: {\n ctx: Context;\n rootComponentDirectory: ComponentDirectory;\n componentDirectories: ComponentDirectory[];\n nodeExternalPackages: string[];\n extraConditions: string[];\n verbose: boolean;\n includeSourcesContent?: boolean;\n}): Promise<{\n appImplementation: {\n schema: Bundle | null;\n functions: Bundle[];\n externalNodeDependencies: NodeDependency[];\n };\n componentImplementations: {\n schema: Bundle | null;\n functions: Bundle[];\n definitionPath: ComponentDefinitionPath;\n }[];\n}> {\n let appImplementation;\n const componentImplementations = [];\n\n // For --component-dir flag, skip bundling root implementations (no real code to bundle)\n const directoriesToBundle = rootComponentDirectory.syntheticComponentImport\n ? componentDirectories\n : [rootComponentDirectory, ...componentDirectories];\n\n for (const directory of directoriesToBundle) {\n const isRoot = directory.path === rootComponentDirectory.path;\n const resolvedPath = path.resolve(\n rootComponentDirectory.path,\n directory.path,\n );\n let schema;\n if (ctx.fs.exists(path.resolve(resolvedPath, \"schema.ts\"))) {\n schema =\n (await bundleSchema(ctx, resolvedPath, extraConditions))[0] || null;\n } else if (ctx.fs.exists(path.resolve(resolvedPath, \"schema.js\"))) {\n schema =\n (await bundleSchema(ctx, resolvedPath, extraConditions))[0] || null;\n } else {\n schema = null;\n }\n\n const entryPoints = await entryPointsByEnvironment(ctx, resolvedPath);\n const convexResult: {\n modules: Bundle[];\n externalDependencies: Map<string, string>;\n bundledModuleNames: Set<string>;\n } = await bundle({\n ctx,\n dir: resolvedPath,\n entryPoints: entryPoints.isolate,\n generateSourceMaps: true,\n platform: \"browser\",\n extraConditions,\n includeSourcesContent,\n });\n\n if (convexResult.externalDependencies.size !== 0) {\n return await ctx.crash({\n exitCode: 1,\n errorType: \"fatal\",\n printedMessage: \"external dependencies not supported\",\n });\n }\n const functions = convexResult.modules;\n if (isRoot) {\n if (verbose) {\n showSpinner(\"Bundling modules for Node.js runtime...\");\n }\n const nodeResult: {\n modules: Bundle[];\n externalDependencies: Map<string, string>;\n bundledModuleNames: Set<string>;\n } = await bundle({\n ctx,\n dir: resolvedPath,\n entryPoints: entryPoints.node,\n generateSourceMaps: true,\n platform: \"node\",\n chunksFolder: path.join(\"_deps\", \"node\"),\n externalPackagesAllowList: nodeExternalPackages,\n extraConditions,\n includeSourcesContent,\n });\n\n const externalNodeDependencies: NodeDependency[] = [];\n for (const [\n moduleName,\n moduleVersion,\n ] of nodeResult.externalDependencies) {\n externalNodeDependencies.push({\n name: moduleName,\n version: moduleVersion,\n });\n }\n const authBundle = await bundleAuthConfig(ctx, resolvedPath);\n appImplementation = {\n schema,\n functions: functions.concat(nodeResult.modules).concat(authBundle),\n externalNodeDependencies,\n };\n } else {\n // Reject push if components have node bundles in non-root directories.\n if (directory.path !== rootComponentDirectory.path) {\n const nodeResult: {\n modules: Bundle[];\n externalDependencies: Map<string, string>;\n bundledModuleNames: Set<string>;\n } = await bundle({\n ctx,\n dir: resolvedPath,\n entryPoints: entryPoints.node,\n generateSourceMaps: true,\n platform: \"node\",\n chunksFolder: path.join(\"_deps\", \"node\"),\n externalPackagesAllowList: nodeExternalPackages,\n extraConditions,\n includeSourcesContent,\n });\n if (nodeResult.modules.length > 0) {\n // TODO(ENG-7116) Remove error and bundle the component node actions when we are ready to support them.\n await ctx.crash({\n exitCode: 1,\n errorType: \"invalid filesystem data\",\n printedMessage: `\"use node\" directive is not supported in components. Remove it from the component at: ${resolvedPath}.`,\n });\n }\n }\n // definitionPath is the canonical form\n const definitionPath = toComponentDefinitionPath(\n rootComponentDirectory,\n directory,\n );\n componentImplementations.push({ definitionPath, schema, functions });\n }\n }\n\n if (!appImplementation) {\n // For --component-dir flag, we don't bundle root implementations so provide an empty one\n if (rootComponentDirectory.syntheticComponentImport) {\n appImplementation = {\n schema: null,\n functions: [],\n externalNodeDependencies: [],\n };\n } else {\n return await ctx.crash({\n exitCode: 1,\n errorType: \"fatal\",\n printedMessage: \"No app implementation found\",\n });\n }\n }\n\n return { appImplementation, componentImplementations };\n}\n\nasync function registerEsbuildReads(\n ctx: Context,\n absWorkingDir: string,\n metafile: Metafile,\n) {\n for (const [relPath, input] of Object.entries(metafile.inputs)) {\n if (\n // We rewrite these files so this integrity check isn't useful.\n path.basename(relPath).includes(\"convex.config\") ||\n // TODO: esbuild outputs paths prefixed with \"(disabled)\" when bundling our internal\n // udf-system package. The files do actually exist locally, though.\n relPath.indexOf(\"(disabled):\") !== -1 ||\n relPath.startsWith(\"wasm-binary:\") ||\n relPath.startsWith(\"wasm-stub:\")\n ) {\n continue;\n }\n const absPath = path.resolve(absWorkingDir, relPath);\n const st = ctx.fs.stat(absPath);\n if (st.size !== input.bytes) {\n // Consider this a transient error so we'll try again and hopefully\n // no files change right after esbuild next time.\n logWarning(\n `Bundled file ${absPath} changed right after esbuild invocation`,\n );\n return await ctx.crash({\n exitCode: 1,\n errorType: \"transient\",\n printedMessage: null,\n });\n }\n ctx.fs.registerPath(absPath, st);\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,gCAOO;AAEP,iBAIO;AACP,qBAAoE;AACpE,mBAA4B;AAK5B,qBAMO;AAGP,MAAM,2BAA2B;AACjC,MAAM,0BAA0B;AAAA;AAAA;AAYhC,SAAS,cAAc;AAAA,EACrB;AAAA,EACA;AACF,GAGW;AAET,MAAI,WAAW;AAEf,MAAI,qBAAqB;AAEvB,UAAM,iBAAiB,YAAAA,QAAK;AAAA,MAC1B,uBAAuB;AAAA,MACvB;AAAA,IACF;AACA,QAAI,mBAAmB,eACpB,QAAQ,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jC,QAAQ,WAAW,YAAY;AAAA,MAC/B;AACA;AAAA,IACF;AACA,UAAM,UAAU,YAAAA,QAAK,QAAQ,eAAe,OAAO;AACnD,UAAM,KAAK,IAAI,GAAG,KAAK,OAAO;AAC9B,QAAI,GAAG,SAAS,MAAM,OAAO;AAG3B;AAAA,QACE,gBAAgB,OAAO;AAAA,MACzB;AACA,aAAO,MAAM,IAAI,MAAM;AAAA,QACrB,UAAU;AAAA,QACV,WAAW;AAAA,QACX,gBAAgB;AAAA,MAClB,CAAC;AAAA,IACH;AACA,QAAI,GAAG,aAAa,SAAS,EAAE;AAAA,EACjC;AACF;",
4
+ "sourcesContent": ["import path from \"path\";\nimport {\n ComponentDirectory,\n ComponentDefinitionPath,\n buildComponentDirectory,\n isComponentDirectory,\n qualifiedDefinitionPath,\n toComponentDefinitionPath,\n} from \"./directoryStructure.js\";\nimport { Context } from \"../../../../bundler/context.js\";\nimport {\n logMessage,\n logWarning,\n showSpinner,\n} from \"../../../../bundler/log.js\";\nimport esbuild, { BuildOptions, Metafile, OutputFile, Plugin } from \"esbuild\";\nimport { chalkStderr } from \"chalk\";\nimport {\n AppDefinitionSpecWithoutImpls,\n ComponentDefinitionSpecWithoutImpls,\n} from \"../../config.js\";\nimport {\n Bundle,\n bundle,\n bundleAuthConfig,\n bundleSchema,\n entryPointsByEnvironment,\n} from \"../../../../bundler/index.js\";\nimport { NodeDependency } from \"../../deployApi/modules.js\";\n\nconst VIRTUAL_CONFIG_NAMESPACE = \"convex-virtual-config\";\nconst VIRTUAL_CONFIG_CONTENTS = `import { defineApp } from \"convex/server\";\\nconst app = defineApp();\\nexport default app;`;\n\n/**\n * An esbuild plugin to insert a virtual `convex.config.js` file into the bundle\n * when Convex project doesn't have one explicitly defined.\n *\n * This allows us to use the components push path even when the Convex project doesn't\n * have a config file defined.\n *\n * When importComponentPath is provided, the virtual config will import and use the\n * component found at that path.\n */\nfunction virtualConfig({\n rootComponentDirectory,\n importComponentPath,\n}: {\n rootComponentDirectory: ComponentDirectory;\n importComponentPath?: string;\n}): Plugin {\n // Empty config with no components\n let contents = VIRTUAL_CONFIG_CONTENTS;\n\n if (importComponentPath) {\n // Generate config that imports the specified component\n const relativeImport = path.relative(\n rootComponentDirectory.path,\n importComponentPath,\n );\n let normalizedImport = relativeImport\n .replace(/\\\\/g, \"/\")\n .replace(/\\.ts$/, \".js\");\n\n // We don't generate code for this synthetic root component so the name we\n // use for the component doesn't matter.\n contents = `import { defineApp } from \"convex/server\";\nimport component from \"${normalizedImport}\";\n\nconst app = defineApp();\napp.use(component, { name: \"exampleComponentInstance\" });\nexport default app;`;\n }\n\n return {\n name: `convex-virtual-config`,\n async setup(build) {\n const filter = pathToRegexFilter(rootComponentDirectory);\n build.onResolve({ filter }, async (args) => {\n return { path: args.path, namespace: VIRTUAL_CONFIG_NAMESPACE };\n });\n build.onLoad(\n { filter, namespace: VIRTUAL_CONFIG_NAMESPACE },\n async (_args) => {\n return {\n contents,\n resolveDir: rootComponentDirectory.path,\n };\n },\n );\n },\n };\n}\n\nfunction pathToRegexFilter(root: ComponentDirectory) {\n let path = qualifiedDefinitionPath(root);\n const escaped = path\n .replace(/\\\\/g, \"/\")\n .replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n return new RegExp(`^${escaped}$`);\n}\n\n/**\n * An esbuild plugin to mark component definitions external or return a list of\n * all component definitions.\n *\n * By default this plugin runs in \"bundle\" mode and marks all imported component\n * definition files as external, not traversing further.\n *\n * If \"discover\" mode is specified it traverses the entire tree.\n */\nfunction componentPlugin({\n mode = \"bundle\",\n rootComponentDirectory,\n verbose,\n ctx,\n}: {\n mode: \"discover\" | \"bundle\";\n rootComponentDirectory: ComponentDirectory;\n verbose?: boolean;\n ctx: Context;\n}): Plugin {\n const components = new Map<string, ComponentDirectory>();\n return {\n name: `convex-${mode === \"discover\" ? \"discover-components\" : \"bundle-components\"}`,\n async setup(build) {\n // This regex can't be really precise since developers could import\n // \"convex.config\", \"convex.config.js\", \"convex.config.ts\", etc.\n build.onResolve({ filter: /.*convex.config.*/ }, async (args) => {\n verbose && logMessage(\"esbuild resolving import:\", args);\n if (\n args.namespace !== \"file\" &&\n args.namespace !== VIRTUAL_CONFIG_NAMESPACE\n ) {\n verbose && logMessage(\" Not a file or virtual config.\");\n return;\n }\n if (args.kind === \"entry-point\") {\n verbose && logMessage(\" -> Top-level entry-point.\");\n const componentDirectory = await buildComponentDirectory(\n ctx,\n path.resolve(args.path),\n );\n\n // No attempt to resolve args.path is made for entry points so they\n // must be relative or absolute file paths, not npm packages.\n // Whether we're bundling or discovering, we're done.\n if (components.get(args.path)) {\n // We always invoke esbuild in a try/catch.\n // eslint-disable-next-line no-restricted-syntax\n throw new Error(\n `Entry point component \"${args.path}\" already registered.`,\n );\n }\n components.set(args.path, componentDirectory);\n return;\n }\n\n const candidates = [args.path];\n const ext = path.extname(args.path);\n if (ext === \".js\") {\n candidates.push(args.path.slice(0, -\".js\".length) + \".ts\");\n }\n if (ext !== \".js\" && ext !== \".ts\") {\n candidates.push(args.path + \".js\");\n candidates.push(args.path + \".ts\");\n }\n let resolvedPath = undefined;\n for (const candidate of candidates) {\n const result = await build.resolve(candidate, {\n // We expect this to be \"import-statement\" but pass 'kind' through\n // to say honest to normal esbuild behavior.\n kind: args.kind,\n resolveDir: args.resolveDir,\n });\n if (result.path) {\n resolvedPath = result.path;\n break;\n }\n }\n if (resolvedPath === undefined) {\n verbose && logMessage(` -> ${args.path} not found.`);\n return;\n }\n\n const parentDir = path.dirname(resolvedPath);\n let imported = components.get(resolvedPath);\n if (!imported) {\n const isComponent = isComponentDirectory(ctx, parentDir, false);\n if (isComponent.kind !== \"ok\") {\n verbose && logMessage(\" -> Not a component:\", isComponent);\n return;\n }\n imported = isComponent.component;\n components.set(resolvedPath, imported);\n }\n\n verbose &&\n logMessage(\n \" -> Component import! Recording it.\",\n args.path,\n resolvedPath,\n );\n\n if (mode === \"discover\") {\n return {\n path: resolvedPath,\n };\n } else {\n // In bundle mode, transform external imports to use componentPaths:\n // import rateLimiter from \"convex_ratelimiter\";\n // => import rateLimiter from `_componentDeps/${base64('../node_modules/convex_ratelimiter')}`;\n\n // A componentPath is path from the root component to the directory\n // of the this component's definition file.\n const componentPath = toComponentDefinitionPath(\n rootComponentDirectory,\n imported,\n );\n const importPath = definitionImportPath(componentPath);\n return {\n path: importPath,\n external: true,\n };\n }\n });\n },\n };\n}\n\n/** The path on the deployment that identifier a component definition. */\nfunction definitionImportPath(componentPath: ComponentDefinitionPath): string {\n return `./_componentDeps/${Buffer.from(componentPath).toString(\"base64url\")}`;\n}\n\n// Share configuration between the component definition discovery and bundling passes.\nfunction sharedEsbuildOptions({\n liveComponentSources = false,\n}: {\n liveComponentSources?: boolean;\n}) {\n const options = {\n bundle: true,\n platform: \"browser\",\n format: \"esm\",\n target: \"esnext\",\n\n conditions: [\"convex\", \"module\"] as string[],\n\n // `false` is the default for splitting. It's simpler to evaluate these on\n // the server as a single file.\n // Splitting could be enabled for speed once the server supports it.\n splitting: false,\n\n // place output files in memory at their source locations\n write: false,\n outdir: path.parse(process.cwd()).root,\n outbase: path.parse(process.cwd()).root,\n\n minify: true, // Note that this implies NODE_ENV=\"production\".\n keepNames: true,\n\n metafile: true,\n } as const satisfies BuildOptions;\n\n // Link directly to component sources (usually .ts) in order to\n // skip the build step. This also causes codegen to run for components\n // loaded from npm packages.\n if (liveComponentSources) {\n options.conditions.push(\"@convex-dev/component-source\");\n }\n return options;\n}\n\n// Use the esbuild metafile to discover the dependency graph in which component\n// definitions are nodes.\nexport async function componentGraph(\n ctx: Context,\n absWorkingDir: string,\n rootComponentDirectory: ComponentDirectory,\n liveComponentSources: boolean,\n verbose: boolean = true,\n): Promise<{\n components: Map<string, ComponentDirectory>;\n dependencyGraph: [ComponentDirectory, ComponentDirectory][];\n}> {\n if (\n rootComponentDirectory.isRootWithoutConfig &&\n !rootComponentDirectory.syntheticComponentImport\n ) {\n return {\n components: new Map([\n [rootComponentDirectory.path, rootComponentDirectory],\n ]),\n dependencyGraph: [],\n };\n }\n let result;\n try {\n result = await esbuild.build({\n absWorkingDir, // This is mostly useful for formatting error messages.\n entryPoints: [qualifiedDefinitionPath(rootComponentDirectory)],\n plugins: [\n componentPlugin({\n ctx,\n mode: \"discover\",\n verbose,\n rootComponentDirectory,\n }),\n ...(rootComponentDirectory.syntheticComponentImport\n ? [\n virtualConfig({\n rootComponentDirectory,\n importComponentPath:\n rootComponentDirectory.syntheticComponentImport,\n }),\n ]\n : []),\n ],\n sourcemap: \"external\",\n sourcesContent: false,\n\n ...sharedEsbuildOptions({ liveComponentSources }),\n });\n await registerEsbuildReads(ctx, absWorkingDir, result.metafile);\n } catch (err: any) {\n return await ctx.crash({\n exitCode: 1,\n errorType: \"invalid filesystem data\",\n printedMessage: `esbuild failed: ${err}`,\n });\n }\n\n if (result.errors.length) {\n const message = result.errors.map((error) => error.text).join(\"\\n\");\n return await ctx.crash({\n exitCode: 1,\n errorType: \"invalid filesystem data\",\n printedMessage: message,\n });\n }\n for (const warning of result.warnings) {\n logWarning(chalkStderr.yellow(`esbuild warning: ${warning.text}`));\n }\n\n if (rootComponentDirectory.syntheticComponentImport) {\n // Virtual configs appear in the metafile with a namespace prefix\n // and can't have ComponentDirectory objects built by reading the filesystem\n // so swap in this rootComponentDirectory.\n return await findComponentDependencies(ctx, result.metafile, {\n [`${VIRTUAL_CONFIG_NAMESPACE}:${qualifiedDefinitionPath(rootComponentDirectory)}`]:\n rootComponentDirectory,\n });\n }\n\n return await findComponentDependencies(ctx, result.metafile);\n}\n\n/**\n * Get dependencies of a ComponenDirectory as ComponentPaths.\n *\n * Component paths are paths relative to the root component.\n */\nexport function getDeps(\n rootComponent: ComponentDirectory,\n dependencyGraph: [ComponentDirectory, ComponentDirectory][],\n definitionPath: string,\n): ComponentDefinitionPath[] {\n return dependencyGraph\n .filter(\n ([importer, _imported]) => importer.definitionPath === definitionPath,\n )\n .map(([_importer, imported]) =>\n toComponentDefinitionPath(rootComponent, imported),\n );\n}\n\n/**\n * The returned dependency graph is an array of tuples of [importer, imported]\n *\n * This doesn't work on just any esbuild metafile because it assumes input\n * imports have not been transformed. We run it on the metafile produced by\n * the esbuild invocation that uses the component plugin in \"discover\" mode.\n *\n * @param inputOverrides - ComponentDirectory objects to be used for metafile.inputs\n * keys, in case they don't exist (namely virtual configs via esbuild plugin namespaces).\n */\nasync function findComponentDependencies(\n ctx: Context,\n metafile: Metafile,\n inputOverrides: Record<string, ComponentDirectory> = {},\n): Promise<{\n components: Map<string, ComponentDirectory>;\n dependencyGraph: [ComponentDirectory, ComponentDirectory][];\n}> {\n const { inputs } = metafile;\n\n const componentsByKey = new Map<string, ComponentDirectory>();\n for (const inputPath of Object.keys(inputs)) {\n if (!inputPath.includes(\".config.\")) continue;\n\n const override: ComponentDirectory | undefined = inputOverrides[inputPath];\n if (override) {\n componentsByKey.set(inputPath, override);\n } else {\n // Normal component - build from filesystem\n const component = await buildComponentDirectory(ctx, inputPath);\n componentsByKey.set(path.resolve(inputPath), component);\n }\n }\n\n const dependencyGraph: [ComponentDirectory, ComponentDirectory][] = [];\n\n for (const inputPath of Object.keys(inputs)) {\n if (!inputPath.includes(\".config.\")) continue;\n\n // For overridden inputs, use the original key; for normal components, use resolved path\n const importerKey =\n inputPath in inputOverrides ? inputPath : path.resolve(inputPath);\n\n const importer = componentsByKey.get(importerKey);\n if (!importer) continue;\n\n const { imports } = inputs[inputPath];\n const componentImports = imports.filter((imp) =>\n imp.path.includes(\".config.\"),\n );\n\n for (const imp of componentImports) {\n const imported = componentsByKey.get(path.resolve(imp.path));\n if (!imported) {\n return await ctx.crash({\n exitCode: 1,\n errorType: \"invalid filesystem data\",\n printedMessage: `Didn't find ${path.resolve(imp.path)} in ${[...componentsByKey.keys()].toString()}`,\n });\n }\n\n // Grab the import specifier from the metafile (e.g. `@convex-dev/workpool/convex.config`) so\n // we can use it to import component APIs\n if (imp.original) {\n const importSpecifier = imp.original;\n const relativeSpecifier = importSpecifier.replace(\n /\\/convex\\.config.*$/,\n \"\",\n );\n\n imported.importSpecifier = relativeSpecifier;\n }\n\n dependencyGraph.push([importer, imported]);\n }\n }\n\n const components = new Map<string, ComponentDirectory>();\n for (const directory of componentsByKey.values()) {\n components.set(directory.path, directory);\n }\n\n return { components, dependencyGraph };\n}\n\n// NB: If a directory linked to is not a member of the passed\n// componentDirectories array then there will be external links\n// with no corresponding definition bundle.\n// That could be made to throw an error but maybe those are already available\n// on the Convex definition filesystem somehow, e.g. builtin components.\n/** Bundle the component definitions listed. */\nexport async function bundleDefinitions(\n ctx: Context,\n absWorkingDir: string,\n dependencyGraph: [ComponentDirectory, ComponentDirectory][],\n rootComponentDirectory: ComponentDirectory,\n componentDirectories: ComponentDirectory[],\n liveComponentSources: boolean,\n verbose: boolean = false,\n): Promise<{\n appDefinitionSpecWithoutImpls: AppDefinitionSpecWithoutImpls;\n componentDefinitionSpecsWithoutImpls: ComponentDefinitionSpecWithoutImpls[];\n}> {\n let result;\n try {\n let plugins = [\n componentPlugin({\n ctx,\n mode: \"bundle\",\n verbose,\n rootComponentDirectory,\n }),\n ];\n if (\n rootComponentDirectory.syntheticComponentImport ||\n rootComponentDirectory.isRootWithoutConfig\n ) {\n // Use virtual config (either with a component import or empty)\n plugins.push(\n virtualConfig(\n rootComponentDirectory.syntheticComponentImport\n ? {\n rootComponentDirectory,\n importComponentPath:\n rootComponentDirectory.syntheticComponentImport,\n }\n : { rootComponentDirectory },\n ),\n );\n }\n result = await esbuild.build({\n absWorkingDir,\n entryPoints: componentDirectories.map((dir) =>\n qualifiedDefinitionPath(dir),\n ),\n plugins,\n sourcemap: true,\n ...sharedEsbuildOptions({ liveComponentSources }),\n });\n await registerEsbuildReads(ctx, absWorkingDir, result.metafile);\n } catch (err: any) {\n return await ctx.crash({\n exitCode: 1,\n errorType: \"invalid filesystem data\",\n printedMessage: `esbuild failed: ${err}`,\n });\n }\n\n if (result.errors.length) {\n const message = result.errors.map((error) => error.text).join(\"\\n\");\n return await ctx.crash({\n exitCode: 1,\n errorType: \"invalid filesystem data\",\n printedMessage: message,\n });\n }\n for (const warning of result.warnings) {\n logWarning(chalkStderr.yellow(`esbuild warning: ${warning.text}`));\n }\n\n const outputs: {\n outputJs: OutputFile;\n outputJsMap?: OutputFile;\n directory: ComponentDirectory;\n }[] = [];\n for (const directory of componentDirectories) {\n const absInput = path.resolve(absWorkingDir, directory.definitionPath);\n const expectedOutputJs =\n absInput.slice(0, absInput.lastIndexOf(\".\")) + \".js\";\n const expectedOutputMap =\n absInput.slice(0, absInput.lastIndexOf(\".\")) + \".js.map\";\n const outputJs = result.outputFiles.filter(\n (outputFile) => outputFile.path === expectedOutputJs,\n )[0];\n if (!outputJs) {\n return await ctx.crash({\n exitCode: 1,\n errorType: \"fatal\",\n printedMessage: `no JS found matching ${expectedOutputJs} in ${result.outputFiles.map((x) => x.path).toString()}`,\n });\n }\n const outputJsMap = result.outputFiles.filter(\n (outputFile) => outputFile.path === expectedOutputMap,\n )[0];\n outputs.push({\n outputJs,\n outputJsMap,\n directory,\n });\n }\n\n const appBundles = outputs.filter(\n (out) => out.directory.path === rootComponentDirectory.path,\n );\n if (appBundles.length !== 1) {\n return await ctx.crash({\n exitCode: 1,\n errorType: \"fatal\",\n printedMessage: \"found wrong number of app bundles\",\n });\n }\n const appBundle = appBundles[0];\n const componentBundles = outputs.filter(\n (out) => out.directory.path !== rootComponentDirectory.path,\n );\n\n const componentDefinitionSpecsWithoutImpls: ComponentDefinitionSpecWithoutImpls[] =\n componentBundles.map(({ directory, outputJs, outputJsMap }) => ({\n definitionPath: toComponentDefinitionPath(\n rootComponentDirectory,\n directory,\n ),\n definition: {\n path: path.relative(directory.path, outputJs.path),\n source: outputJs.text,\n sourceMap: outputJsMap?.text,\n environment: \"isolate\" as const,\n },\n dependencies: getDeps(\n rootComponentDirectory,\n dependencyGraph,\n directory.definitionPath,\n ),\n }));\n const appDeps = getDeps(\n rootComponentDirectory,\n dependencyGraph,\n appBundle.directory.definitionPath,\n );\n const appDefinitionSpecWithoutImpls: AppDefinitionSpecWithoutImpls = {\n definition: {\n path: path.relative(rootComponentDirectory.path, appBundle.outputJs.path),\n source: appBundle.outputJs.text,\n sourceMap: appBundle.outputJsMap?.text,\n environment: \"isolate\" as const,\n },\n dependencies: appDeps,\n };\n return {\n appDefinitionSpecWithoutImpls,\n componentDefinitionSpecsWithoutImpls,\n };\n}\n\nexport async function bundleImplementations({\n ctx,\n rootComponentDirectory,\n componentDirectories,\n nodeExternalPackages,\n extraConditions,\n verbose = false,\n includeSourcesContent = false,\n}: {\n ctx: Context;\n rootComponentDirectory: ComponentDirectory;\n componentDirectories: ComponentDirectory[];\n nodeExternalPackages: string[];\n extraConditions: string[];\n verbose: boolean;\n includeSourcesContent?: boolean;\n}): Promise<{\n appImplementation: {\n schema: Bundle | null;\n functions: Bundle[];\n externalNodeDependencies: NodeDependency[];\n };\n componentImplementations: {\n schema: Bundle | null;\n functions: Bundle[];\n definitionPath: ComponentDefinitionPath;\n }[];\n buildDebugInfos: BuildDebugInfo[];\n}> {\n let appImplementation;\n const componentImplementations = [];\n const buildDebugInfos: BuildDebugInfo[] = [];\n\n // For --component-dir flag, skip bundling root implementations (no real code to bundle)\n const directoriesToBundle = rootComponentDirectory.syntheticComponentImport\n ? componentDirectories\n : [rootComponentDirectory, ...componentDirectories];\n\n for (const directory of directoriesToBundle) {\n const isRoot = directory.path === rootComponentDirectory.path;\n const resolvedPath = path.resolve(\n rootComponentDirectory.path,\n directory.path,\n );\n // definitionPath is the canonical form\n const definitionPath = toComponentDefinitionPath(\n rootComponentDirectory,\n directory,\n );\n let schema;\n if (\n ctx.fs.exists(path.resolve(resolvedPath, \"schema.ts\")) ||\n ctx.fs.exists(path.resolve(resolvedPath, \"schema.js\"))\n ) {\n const schemaResult = await bundleSchema(\n ctx,\n resolvedPath,\n extraConditions,\n );\n buildDebugInfos.push(\n buildDebugInfo(directory, definitionPath, \"schema\", schemaResult),\n );\n schema = schemaResult.modules[0] || null;\n } else {\n schema = null;\n }\n\n const entryPoints = await entryPointsByEnvironment(ctx, resolvedPath);\n const convexResult: {\n modules: Bundle[];\n externalDependencies: Map<string, string>;\n bundledModuleNames: Set<string>;\n metafile: Metafile | null;\n } = await bundle({\n ctx,\n dir: resolvedPath,\n entryPoints: entryPoints.isolate,\n generateSourceMaps: true,\n platform: \"browser\",\n extraConditions,\n includeSourcesContent,\n });\n\n if (convexResult.externalDependencies.size !== 0) {\n return await ctx.crash({\n exitCode: 1,\n errorType: \"fatal\",\n printedMessage: \"external dependencies not supported\",\n });\n }\n buildDebugInfos.push(\n buildDebugInfo(directory, definitionPath, \"convex\", convexResult),\n );\n const functions = convexResult.modules;\n if (isRoot) {\n if (verbose) {\n showSpinner(\"Bundling modules for Node.js runtime...\");\n }\n const nodeResult: {\n modules: Bundle[];\n externalDependencies: Map<string, string>;\n bundledModuleNames: Set<string>;\n metafile: Metafile | null;\n } = await bundle({\n ctx,\n dir: resolvedPath,\n entryPoints: entryPoints.node,\n generateSourceMaps: true,\n platform: \"node\",\n chunksFolder: path.join(\"_deps\", \"node\"),\n externalPackagesAllowList: nodeExternalPackages,\n extraConditions,\n includeSourcesContent,\n });\n buildDebugInfos.push(\n buildDebugInfo(directory, definitionPath, \"node\", nodeResult),\n );\n\n const externalNodeDependencies: NodeDependency[] = [];\n for (const [\n moduleName,\n moduleVersion,\n ] of nodeResult.externalDependencies) {\n externalNodeDependencies.push({\n name: moduleName,\n version: moduleVersion,\n });\n }\n const authResult = await bundleAuthConfig(ctx, resolvedPath);\n buildDebugInfos.push(\n buildDebugInfo(directory, definitionPath, \"auth\", authResult),\n );\n appImplementation = {\n schema,\n functions: functions\n .concat(nodeResult.modules)\n .concat(authResult.modules),\n externalNodeDependencies,\n };\n } else {\n // Reject push if components have node bundles in non-root directories.\n if (directory.path !== rootComponentDirectory.path) {\n const nodeResult: {\n modules: Bundle[];\n externalDependencies: Map<string, string>;\n bundledModuleNames: Set<string>;\n } = await bundle({\n ctx,\n dir: resolvedPath,\n entryPoints: entryPoints.node,\n generateSourceMaps: true,\n platform: \"node\",\n chunksFolder: path.join(\"_deps\", \"node\"),\n externalPackagesAllowList: nodeExternalPackages,\n extraConditions,\n includeSourcesContent,\n });\n if (nodeResult.modules.length > 0) {\n // TODO(ENG-7116) Remove error and bundle the component node actions when we are ready to support them.\n await ctx.crash({\n exitCode: 1,\n errorType: \"invalid filesystem data\",\n printedMessage: `\"use node\" directive is not supported in components. Remove it from the component at: ${resolvedPath}.`,\n });\n }\n }\n componentImplementations.push({ definitionPath, schema, functions });\n }\n }\n\n if (!appImplementation) {\n // For --component-dir flag, we don't bundle root implementations so provide an empty one\n if (rootComponentDirectory.syntheticComponentImport) {\n appImplementation = {\n schema: null,\n functions: [],\n externalNodeDependencies: [],\n };\n } else {\n return await ctx.crash({\n exitCode: 1,\n errorType: \"fatal\",\n printedMessage: \"No app implementation found\",\n });\n }\n }\n\n return { appImplementation, componentImplementations, buildDebugInfos };\n}\n\n/**\n * Debug information for a build in a push.\n */\nexport type BuildDebugInfo = {\n directory: ComponentDirectory;\n definitionPath: ComponentDefinitionPath;\n kind: \"convex\" | \"node\" | \"schema\" | \"auth\";\n metafile: Metafile | null;\n modules: Bundle[];\n externalDependencies: Map<string, string>;\n};\n\nfunction buildDebugInfo(\n directory: ComponentDirectory,\n definitionPath: ComponentDefinitionPath,\n kind: BuildDebugInfo[\"kind\"],\n result: {\n modules: Bundle[];\n metafile: Metafile | null;\n externalDependencies?: Map<string, string>;\n },\n): BuildDebugInfo {\n return {\n directory,\n definitionPath,\n kind,\n metafile: result.metafile,\n modules: result.modules,\n externalDependencies: result.externalDependencies ?? new Map(),\n };\n}\n\nasync function registerEsbuildReads(\n ctx: Context,\n absWorkingDir: string,\n metafile: Metafile,\n) {\n for (const [relPath, input] of Object.entries(metafile.inputs)) {\n if (\n // We rewrite these files so this integrity check isn't useful.\n path.basename(relPath).includes(\"convex.config\") ||\n // TODO: esbuild outputs paths prefixed with \"(disabled)\" when bundling our internal\n // udf-system package. The files do actually exist locally, though.\n relPath.indexOf(\"(disabled):\") !== -1 ||\n relPath.startsWith(\"wasm-binary:\") ||\n relPath.startsWith(\"wasm-stub:\")\n ) {\n continue;\n }\n const absPath = path.resolve(absWorkingDir, relPath);\n const st = ctx.fs.stat(absPath);\n if (st.size !== input.bytes) {\n // Consider this a transient error so we'll try again and hopefully\n // no files change right after esbuild next time.\n logWarning(\n `Bundled file ${absPath} changed right after esbuild invocation`,\n );\n return await ctx.crash({\n exitCode: 1,\n errorType: \"transient\",\n printedMessage: null,\n });\n }\n ctx.fs.registerPath(absPath, st);\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,gCAOO;AAEP,iBAIO;AACP,qBAAoE;AACpE,mBAA4B;AAK5B,qBAMO;AAGP,MAAM,2BAA2B;AACjC,MAAM,0BAA0B;AAAA;AAAA;AAYhC,SAAS,cAAc;AAAA,EACrB;AAAA,EACA;AACF,GAGW;AAET,MAAI,WAAW;AAEf,MAAI,qBAAqB;AAEvB,UAAM,iBAAiB,YAAAA,QAAK;AAAA,MAC1B,uBAAuB;AAAA,MACvB;AAAA,IACF;AACA,QAAI,mBAAmB,eACpB,QAAQ,OAAO,GAAG,EAClB,QAAQ,SAAS,KAAK;AAIzB,eAAW;AAAA,yBACU,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA,EAKvC;AAEA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM,MAAM,OAAO;AACjB,YAAM,SAAS,kBAAkB,sBAAsB;AACvD,YAAM,UAAU,EAAE,OAAO,GAAG,OAAO,SAAS;AAC1C,eAAO,EAAE,MAAM,KAAK,MAAM,WAAW,yBAAyB;AAAA,MAChE,CAAC;AACD,YAAM;AAAA,QACJ,EAAE,QAAQ,WAAW,yBAAyB;AAAA,QAC9C,OAAO,UAAU;AACf,iBAAO;AAAA,YACL;AAAA,YACA,YAAY,u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Q,aAAa,MAAM,MACnC,QAAQ,WAAW,cAAc,KACjC,QAAQ,WAAW,YAAY;AAAA,MAC/B;AACA;AAAA,IACF;AACA,UAAM,UAAU,YAAAA,QAAK,QAAQ,eAAe,OAAO;AACnD,UAAM,KAAK,IAAI,GAAG,KAAK,OAAO;AAC9B,QAAI,GAAG,SAAS,MAAM,OAAO;AAG3B;AAAA,QACE,gBAAgB,OAAO;AAAA,MACzB;AACA,aAAO,MAAM,IAAI,MAAM;AAAA,QACrB,UAAU;AAAA,QACV,WAAW;AAAA,QACX,gBAAgB;AAAA,MAClB,CAAC;AAAA,IACH;AACA,QAAI,GAAG,aAAa,SAAS,EAAE;AAAA,EACjC;AACF;",
6
6
  "names": ["path", "esbuild"]
7
7
  }
@@ -54,6 +54,9 @@ var import_dashboard = require("./dashboard.js");
54
54
  var import_indexes = require("./indexes.js");
55
55
  var import_checkForLargeIndexDeletion = require("./checkForLargeIndexDeletion.js");
56
56
  var import_checkForSlowSchemaValidation = require("./checkForSlowSchemaValidation.js");
57
+ var import_checkForLargeIndexBackfill = require("./checkForLargeIndexBackfill.js");
58
+ var import_schemaEvaluation = require("./schemaEvaluation.js");
59
+ var import_checkForStagedValidatorDeletion = require("./checkForStagedValidatorDeletion.js");
57
60
  var import_crypto = require("crypto");
58
61
  async function runCodegen(ctx, credentials, options) {
59
62
  await (0, import_utils.ensureHasConvexDependency)(ctx, "codegen");
@@ -85,7 +88,12 @@ async function runCodegen(ctx, credentials, options) {
85
88
  codegen: true,
86
89
  liveComponentSources: options.liveComponentSources,
87
90
  typecheckComponents: false,
88
- debugNodeApis: options.debugNodeApis
91
+ debugNodeApis: options.debugNodeApis,
92
+ // Code generation uses the source schema independently of deployment data.
93
+ largeIndexDeletionCheck: "no verification",
94
+ largeIndexBackfillCheck: "no verification",
95
+ stagedValidatorDeletionCheck: "no verification",
96
+ warnOnSlowSchemaValidation: false
89
97
  }
90
98
  );
91
99
  } else {
@@ -314,6 +322,11 @@ async function startComponentsPushAndCodegen(ctx, parentSpan, projectConfig, con
314
322
  return null;
315
323
  }
316
324
  logStartPushSizes(parentSpan, startPushRequest);
325
+ const schemaEvaluation = (0, import_schemaEvaluation.sharedSchemaEvaluation)(
326
+ ctx,
327
+ startPushRequest,
328
+ options
329
+ );
317
330
  if (options.largeIndexDeletionCheck !== "no verification") {
318
331
  await parentSpan.enterAsync(
319
332
  "checkForLargeIndexDeletion",
@@ -322,18 +335,48 @@ async function startComponentsPushAndCodegen(ctx, parentSpan, projectConfig, con
322
335
  span,
323
336
  request: startPushRequest,
324
337
  options,
338
+ schemaEvaluation,
325
339
  askForConfirmation: options.largeIndexDeletionCheck === "ask for confirmation"
326
340
  })
327
341
  );
328
342
  }
329
- if (options.dryRun && options.warnOnSlowSchemaValidation) {
343
+ const largeIndexBackfillCheck = options.largeIndexBackfillCheck;
344
+ if (largeIndexBackfillCheck !== "no verification") {
345
+ await parentSpan.enterAsync(
346
+ "checkForLargeIndexBackfill",
347
+ (span) => (0, import_checkForLargeIndexBackfill.checkForLargeIndexBackfill)({
348
+ ctx,
349
+ span,
350
+ schemaEvaluation,
351
+ options,
352
+ // A dry run never blocks on a backfill, so it only reports.
353
+ mode: options.dryRun ? "warn" : largeIndexBackfillCheck
354
+ })
355
+ );
356
+ }
357
+ const stagedValidatorDeletionCheck = options.stagedValidatorDeletionCheck;
358
+ if (stagedValidatorDeletionCheck !== "no verification") {
359
+ await parentSpan.enterAsync(
360
+ "checkForStagedValidatorDeletion",
361
+ async (span) => {
362
+ const response = await schemaEvaluation(span);
363
+ await (0, import_checkForStagedValidatorDeletion.checkForStagedValidatorDeletion)({
364
+ ctx,
365
+ response,
366
+ askForConfirmation: stagedValidatorDeletionCheck === "ask for confirmation",
367
+ // A dry run previews the confirmation required by a real push.
368
+ dryRun: options.dryRun
369
+ });
370
+ }
371
+ );
372
+ }
373
+ if (options.warnOnSlowSchemaValidation && (options.dryRun || stagedValidatorDeletionCheck !== "no verification" || (0, import_schemaEvaluation.pushStagesValidators)(startPushRequest))) {
330
374
  await parentSpan.enterAsync(
331
375
  "checkForSlowSchemaValidation",
332
376
  (span) => (0, import_checkForSlowSchemaValidation.checkForSlowSchemaValidation)({
333
- ctx,
334
377
  span,
335
- request: startPushRequest,
336
- options
378
+ schemaEvaluation,
379
+ dryRun: options.dryRun
337
380
  })
338
381
  );
339
382
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/cli/lib/components.ts"],
4
- "sourcesContent": ["import path from \"path\";\nimport { Context } from \"../../bundler/context.js\";\nimport {\n changeSpinner,\n logFinishedStep,\n logMessage,\n} from \"../../bundler/log.js\";\nimport {\n ProjectConfig,\n configFromProjectConfig,\n debugIsolateEndpointBundles,\n getFunctionsDirectoryPath,\n readProjectConfig,\n pullConfig,\n diffConfig,\n} from \"./config.js\";\nimport {\n finishPush,\n reportPushCompleted,\n startPush,\n waitForSchema,\n} from \"./deploy2.js\";\nimport { version } from \"../version.js\";\nimport { ensureHasConvexDependency, functionsDir } from \"./utils/utils.js\";\nimport {\n bundleDefinitions,\n bundleImplementations,\n componentGraph,\n} from \"./components/definition/bundle.js\";\nimport { isComponentDirectory } from \"./components/definition/directoryStructure.js\";\nimport {\n doFinalComponentCodegen,\n doInitialComponentCodegen,\n CodegenOptions,\n doInitConvexFolder,\n doCodegen,\n} from \"./codegen.js\";\nimport {\n AppDefinitionConfig,\n ComponentDefinitionConfig,\n} from \"./deployApi/definitionConfig.js\";\nimport { typeCheckFunctionsInMode, TypeCheckMode } from \"./typecheck.js\";\nimport { withTmpDir } from \"../../bundler/fs.js\";\nimport { handleDebugBundlePath } from \"./debugBundlePath.js\";\nimport { chalkStderr } from \"chalk\";\nimport { StartPushRequest, StartPushResponse } from \"./deployApi/startPush.js\";\nimport { DetailedDeploymentCredentials } from \"./api.js\";\nimport { FinishPushDiff } from \"./deployApi/finishPush.js\";\nimport { Reporter, Span } from \"./tracing.js\";\nimport { DEFINITION_FILENAME_TS } from \"./components/constants.js\";\nimport { DeploymentType } from \"./api.js\";\nimport { deploymentDashboardUrlPage } from \"./dashboard.js\";\nimport { formatIndex, LargeIndexDeletionCheck } from \"./indexes.js\";\nimport { checkForLargeIndexDeletion } from \"./checkForLargeIndexDeletion.js\";\nimport { checkForSlowSchemaValidation } from \"./checkForSlowSchemaValidation.js\";\nimport { LogManager } from \"./logs.js\";\nimport { createHash } from \"crypto\";\nimport { Bundle, BundleHash } from \"../../bundler/index.js\";\nimport { ModuleHashConfig } from \"./deployApi/modules.js\";\n\nexport type PushOptions = {\n adminKey: string;\n verbose: boolean;\n dryRun: boolean;\n typecheck: \"enable\" | \"try\" | \"disable\";\n typecheckComponents: boolean;\n debug: boolean;\n debugBundlePath?: string | undefined;\n debugNodeApis: boolean;\n codegen: boolean;\n url: string;\n deploymentName: string | null;\n deploymentType?: DeploymentType;\n writePushRequest?: string | undefined;\n liveComponentSources: boolean;\n pushAllModules: boolean;\n logManager?: LogManager | undefined;\n largeIndexDeletionCheck: LargeIndexDeletionCheck;\n // Whether a dry run should warn when the schema change would block the\n // deploy on a slow table walk. On for deploys; off for commands whose dry\n // runs never deploy (e.g. codegen).\n warnOnSlowSchemaValidation: boolean;\n message: string | null;\n};\n\nexport async function runCodegen(\n ctx: Context,\n credentials: DetailedDeploymentCredentials | null,\n options: CodegenOptions,\n) {\n // This also ensures the current directory is the project root.\n await ensureHasConvexDependency(ctx, \"codegen\");\n\n const { configPath, projectConfig } = await readProjectConfig(ctx);\n const functionsDirectoryPath = functionsDir(configPath, projectConfig);\n\n if (options.init) {\n await doInitConvexFolder(ctx, functionsDirectoryPath, {\n dryRun: options.dryRun,\n debug: options.debug,\n });\n }\n\n if (!options.systemUdfs) {\n if (credentials === null) {\n return;\n }\n\n await startComponentsPushAndCodegen(\n ctx,\n Span.noop(),\n projectConfig,\n configPath,\n {\n ...options,\n deploymentName: credentials.deploymentFields?.deploymentName ?? null,\n ...(credentials.deploymentFields?.deploymentType !== undefined\n ? { deploymentType: credentials.deploymentFields.deploymentType }\n : {}),\n url: credentials.url,\n adminKey: credentials.adminKey,\n generateCommonJSApi: options.commonjs,\n verbose: !!process.env.CONVEX_VERBOSE,\n codegen: true,\n liveComponentSources: options.liveComponentSources,\n typecheckComponents: false,\n debugNodeApis: options.debugNodeApis,\n },\n );\n } else {\n if (options.typecheck !== \"disable\") {\n logMessage(chalkStderr.gray(\"Running TypeScript typecheck\u2026\"));\n }\n\n await doCodegen(ctx, functionsDirectoryPath, options.typecheck, {\n dryRun: options.dryRun,\n debug: options.debug,\n generateCommonJSApi: options.commonjs,\n });\n }\n}\n\nexport async function runPush(ctx: Context, options: PushOptions) {\n const { configPath, projectConfig } = await readProjectConfig(ctx);\n await runComponentsPush(ctx, options, configPath, projectConfig);\n}\n\nexport function hash(bundle: Bundle) {\n return createHash(\"sha256\")\n .update(bundle.source)\n .update(bundle.sourceMap || \"\")\n .digest(\"hex\");\n}\n\nfunction isModuleTheSame(newBundle: Bundle, oldBundleHash: BundleHash) {\n return (\n newBundle.environment === oldBundleHash.environment &&\n hash(newBundle) === oldBundleHash.hash\n );\n}\n\nexport function partitionModulesByChanges(\n functions: Bundle[],\n remoteHashesByPath: Map<string, BundleHash>,\n): {\n unchangedModuleHashes: ModuleHashConfig[];\n changedModules: Bundle[];\n} {\n // Partition modules based on whether they match the existing modules\n const unchangedModuleHashes = functions\n .filter((newBundle) => {\n const oldBundleHash = remoteHashesByPath.get(newBundle.path);\n return oldBundleHash && isModuleTheSame(newBundle, oldBundleHash);\n })\n .map((func) => ({\n path: func.path,\n environment: func.environment,\n sha256: hash(func),\n }));\n const changedModules = functions.filter((newBundle) => {\n const oldBundleHash = remoteHashesByPath.get(newBundle.path);\n return !oldBundleHash || !isModuleTheSame(newBundle, oldBundleHash);\n });\n return { unchangedModuleHashes, changedModules };\n}\n\nasync function getUnchangedModuleHashesFromServer(\n ctx: Context,\n appImplementation: { functions: Bundle[] },\n options: { url: string; adminKey: string },\n): Promise<{\n unchangedModuleHashes: ModuleHashConfig[];\n changedModules: Bundle[];\n}> {\n const remoteConfigWithModuleHashes = await pullConfig(\n ctx,\n undefined,\n undefined,\n options.url,\n options.adminKey,\n );\n const remoteHashesByPath = new Map(\n remoteConfigWithModuleHashes.moduleHashes.map((moduleHash) => [\n moduleHash.path,\n moduleHash,\n ]),\n );\n return partitionModulesByChanges(\n appImplementation.functions,\n remoteHashesByPath,\n );\n}\n\nasync function startComponentsPushAndCodegen(\n ctx: Context,\n parentSpan: Span,\n projectConfig: ProjectConfig,\n configPath: string,\n options: {\n typecheck: TypeCheckMode;\n typecheckComponents: boolean;\n adminKey: string;\n url: string;\n deploymentName: string | null;\n deploymentType?: DeploymentType;\n verbose: boolean;\n debugBundlePath?: string | undefined;\n dryRun: boolean;\n generateCommonJSApi?: boolean;\n debug: boolean;\n writePushRequest?: string | undefined;\n codegen: boolean;\n liveComponentSources?: boolean;\n pushAllModules?: boolean;\n debugNodeApis: boolean;\n largeIndexDeletionCheck: LargeIndexDeletionCheck;\n warnOnSlowSchemaValidation: boolean;\n codegenOnlyThisComponent?: string | undefined;\n },\n): Promise<StartPushResponse | null> {\n const convexDir = await getFunctionsDirectoryPath(ctx);\n\n // '.' means use the process current working directory, it's the default behavior.\n // Spelling it out here to be explicit for a future where this code can run\n // from other directories.\n // In esbuild the working directory is used to print error messages and resolving\n // relatives paths passed to it. It generally doesn't matter for resolving imports,\n // imports are resolved from the file where they are written.\n const absWorkingDir = path.resolve(\".\");\n const isComponent = isComponentDirectory(ctx, convexDir, true);\n if (isComponent.kind === \"err\") {\n return await ctx.crash({\n exitCode: 1,\n errorType: \"invalid filesystem data\",\n printedMessage: `Invalid component root directory (${isComponent.why}): ${convexDir}`,\n });\n }\n\n let rootComponent = isComponent.component;\n if (options.codegenOnlyThisComponent) {\n const absolutePath = path.resolve(options.codegenOnlyThisComponent);\n let componentConfigPath: string;\n\n // Must be a directory containing a convex.config.ts\n componentConfigPath = path.join(absolutePath, DEFINITION_FILENAME_TS);\n if (!ctx.fs.exists(componentConfigPath)) {\n return await ctx.crash({\n exitCode: 1,\n errorType: \"invalid filesystem data\",\n printedMessage: `Only directories with convex.config.ts files are supported, this directory does not: ${absolutePath}`,\n });\n }\n\n const syntheticConfigPath = path.join(\n rootComponent.path,\n DEFINITION_FILENAME_TS,\n );\n rootComponent = {\n isRoot: true,\n path: rootComponent.path,\n definitionPath: syntheticConfigPath,\n isRootWithoutConfig: false,\n syntheticComponentImport: componentConfigPath,\n };\n }\n\n changeSpinner(\"Finding component definitions...\");\n // Create a list of relevant component directories. These are just for knowing\n // while directories to bundle in bundleDefinitions and bundleImplementations.\n // This produces a bundle in memory as a side effect but it's thrown away.\n const { components, dependencyGraph } = await parentSpan.enterAsync(\n \"componentGraph\",\n () =>\n componentGraph(\n ctx,\n absWorkingDir,\n rootComponent,\n !!options.liveComponentSources,\n options.verbose,\n ),\n );\n\n // Initial codegen is everything we need to get code runnable:\n // root components and other components need a basic _generated/api.ts etc.\n // just to make the code bundleable and runnable so we can analyze.\n if (options.codegen) {\n changeSpinner(\"Generating server code...\");\n await parentSpan.enterAsync(\"doInitialComponentCodegen\", () =>\n withTmpDir(async (tmpDir) => {\n // Skip the root in component cases\n if (!rootComponent.syntheticComponentImport) {\n // Do root first so if a component fails, we'll at least have a working root.\n await doInitialComponentCodegen(ctx, tmpDir, rootComponent, options);\n }\n for (const directory of components.values()) {\n if (directory.isRoot) {\n continue;\n }\n // When --component-dir is used, only generate code for the target component\n if (\n rootComponent.syntheticComponentImport &&\n directory.definitionPath !== rootComponent.syntheticComponentImport\n ) {\n continue;\n }\n await doInitialComponentCodegen(ctx, tmpDir, directory, options);\n }\n }),\n );\n }\n\n changeSpinner(\"Bundling component definitions...\");\n // This bundles everything but the actual function definitions\n const {\n appDefinitionSpecWithoutImpls,\n componentDefinitionSpecsWithoutImpls,\n } = await parentSpan.enterAsync(\"bundleDefinitions\", () =>\n bundleDefinitions(\n ctx,\n absWorkingDir,\n dependencyGraph,\n rootComponent,\n // Note that this *includes* the root component.\n [...components.values()],\n !!options.liveComponentSources,\n options.verbose,\n ),\n );\n\n if (options.debugNodeApis) {\n await debugIsolateEndpointBundles(ctx, projectConfig, configPath);\n logFinishedStep(\n \"All non-'use node' entry points successfully bundled. Skipping rest of push.\",\n );\n return null;\n }\n\n changeSpinner(\"Bundling component schemas and implementations...\");\n const { appImplementation, componentImplementations } =\n await parentSpan.enterAsync(\"bundleImplementations\", () =>\n bundleImplementations({\n ctx,\n rootComponentDirectory: rootComponent,\n // When running codegen for a specific component, don't bundle the root.\n componentDirectories: [...components.values()].filter(\n (dir) => !dir.isRoot && !dir.syntheticComponentImport,\n ),\n nodeExternalPackages: projectConfig.node.externalPackages,\n extraConditions: options.liveComponentSources\n ? [\"@convex-dev/component-source\"]\n : [],\n verbose: options.verbose,\n includeSourcesContent:\n projectConfig.bundler?.includeSourcesContent ?? false,\n }),\n );\n if (options.debugBundlePath) {\n const { config: localConfig } = await configFromProjectConfig(\n ctx,\n projectConfig,\n configPath,\n options.verbose,\n );\n // TODO(ENG-6972): Actually write the bundles for components.\n await handleDebugBundlePath(ctx, options.debugBundlePath, localConfig);\n logMessage(\n `Wrote bundle and metadata for modules in the root to ${options.debugBundlePath}. Skipping rest of push.`,\n );\n return null;\n }\n\n // We're just using the version this CLI is running with for now.\n // This could be different than the version of `convex` the app runs with\n // if the CLI is installed globally.\n // TODO: This should be the version of the `convex` package used by each\n // component, and may be different for each component.\n const udfServerVersion = version;\n\n const { unchangedModuleHashes, changedModules } = options.pushAllModules\n ? {\n unchangedModuleHashes: [],\n changedModules: appImplementation.functions,\n }\n : await parentSpan.enterAsync(\"getUnchangedModuleHashesFromServer\", () =>\n getUnchangedModuleHashesFromServer(ctx, appImplementation, options),\n );\n\n const appDefinition: AppDefinitionConfig = {\n ...appDefinitionSpecWithoutImpls,\n schema: appImplementation.schema,\n changedModules,\n unchangedModuleHashes,\n udfServerVersion,\n };\n\n const componentDefinitions: ComponentDefinitionConfig[] = [];\n for (const componentDefinition of componentDefinitionSpecsWithoutImpls) {\n const impl = componentImplementations.filter(\n (impl) => impl.definitionPath === componentDefinition.definitionPath,\n )[0];\n if (!impl) {\n return await ctx.crash({\n exitCode: 1,\n errorType: \"fatal\",\n printedMessage: `missing! couldn't find ${componentDefinition.definitionPath} in ${componentImplementations.map((impl) => impl.definitionPath).toString()}`,\n });\n }\n componentDefinitions.push({\n ...componentDefinition,\n ...impl,\n udfServerVersion,\n });\n }\n const startPushRequest = {\n adminKey: options.adminKey,\n dryRun: options.dryRun,\n functions: projectConfig.functions,\n appDefinition,\n componentDefinitions,\n nodeDependencies: appImplementation.externalNodeDependencies,\n nodeVersion: projectConfig.node.nodeVersion,\n forCodegen: !!options.codegenOnlyThisComponent,\n };\n if (options.writePushRequest) {\n const pushRequestPath = path.resolve(options.writePushRequest);\n ctx.fs.writeUtf8File(\n `${pushRequestPath}.json`,\n JSON.stringify(startPushRequest),\n );\n return null;\n }\n logStartPushSizes(parentSpan, startPushRequest);\n\n if (options.largeIndexDeletionCheck !== \"no verification\") {\n await parentSpan.enterAsync(\"checkForLargeIndexDeletion\", (span) =>\n checkForLargeIndexDeletion({\n ctx,\n span,\n request: startPushRequest,\n options,\n askForConfirmation:\n options.largeIndexDeletionCheck === \"ask for confirmation\",\n }),\n );\n }\n\n if (options.dryRun && options.warnOnSlowSchemaValidation) {\n await parentSpan.enterAsync(\"checkForSlowSchemaValidation\", (span) =>\n checkForSlowSchemaValidation({\n ctx,\n span,\n request: startPushRequest,\n options,\n }),\n );\n }\n\n changeSpinner(\"Uploading functions to Convex...\");\n const startPushResponse = await parentSpan.enterAsync(\"startPush\", (span) =>\n startPush(ctx, span, startPushRequest, options),\n );\n\n if (options.verbose) {\n logMessage(\"startPush: \" + JSON.stringify(startPushResponse, null, 2));\n }\n\n if (options.codegen) {\n changeSpinner(\"Generating TypeScript bindings...\");\n await parentSpan.enterAsync(\"doFinalComponentCodegen\", () =>\n withTmpDir(async (tmpDir) => {\n // TODO generating code for the root component last might be better DX\n // When running codegen for a specific component, don't generate types for the root\n if (!rootComponent.syntheticComponentImport) {\n // Do the root first\n await doFinalComponentCodegen(\n ctx,\n tmpDir,\n rootComponent,\n rootComponent,\n startPushResponse,\n components,\n options,\n );\n }\n for (const directory of components.values()) {\n if (directory.isRoot) {\n continue;\n }\n // When --component-dir is used, only generate code for the target component\n if (\n rootComponent.syntheticComponentImport &&\n directory.definitionPath !== rootComponent.syntheticComponentImport\n ) {\n continue;\n }\n await doFinalComponentCodegen(\n ctx,\n tmpDir,\n rootComponent,\n directory,\n startPushResponse,\n components,\n options,\n );\n }\n }),\n );\n }\n\n changeSpinner(\"Running TypeScript...\");\n await parentSpan.enterAsync(\"typeCheckFunctionsInMode\", async () => {\n // When running codegen for a specific component, don't typecheck the root\n if (!rootComponent.syntheticComponentImport) {\n await typeCheckFunctionsInMode(\n ctx,\n options.typecheck,\n rootComponent.path,\n );\n }\n if (options.typecheckComponents) {\n for (const directory of components.values()) {\n if (!directory.isRoot) {\n await typeCheckFunctionsInMode(\n ctx,\n options.typecheck,\n directory.path,\n );\n }\n }\n } else if (rootComponent.syntheticComponentImport) {\n // When running codegen for a specific component, only typecheck that component.\n for (const directory of components.values()) {\n if (\n directory.isRoot ||\n directory.definitionPath !== rootComponent.syntheticComponentImport\n ) {\n continue;\n }\n await typeCheckFunctionsInMode(ctx, options.typecheck, directory.path);\n }\n }\n });\n\n return startPushResponse;\n}\n\nfunction logStartPushSizes(span: Span, startPushRequest: StartPushRequest) {\n let v8Size = 0;\n let v8Count = 0;\n let nodeSize = 0;\n let nodeCount = 0;\n\n for (const componentDefinition of startPushRequest.componentDefinitions) {\n for (const module of componentDefinition.functions) {\n if (module.environment === \"isolate\") {\n v8Size += module.source.length + (module.sourceMap ?? \"\").length;\n v8Count += 1;\n } else if (module.environment === \"node\") {\n nodeSize += module.source.length + (module.sourceMap ?? \"\").length;\n nodeCount += 1;\n }\n }\n }\n span.setProperty(\"v8_size\", v8Size.toString());\n span.setProperty(\"v8_count\", v8Count.toString());\n span.setProperty(\"node_size\", nodeSize.toString());\n span.setProperty(\"node_count\", nodeCount.toString());\n}\n\nexport async function runComponentsPush(\n ctx: Context,\n options: PushOptions,\n configPath: string,\n projectConfig: ProjectConfig,\n) {\n const reporter = new Reporter();\n const pushSpan = Span.root(reporter, \"runComponentsPush\");\n pushSpan.setProperty(\"cli_version\", version);\n const verbose = options.verbose || options.dryRun;\n\n await ensureHasConvexDependency(ctx, \"push\");\n\n const startPushResponse = await pushSpan.enterAsync(\n \"startComponentsPushAndCodegen\",\n (span) =>\n startComponentsPushAndCodegen(\n ctx,\n span,\n projectConfig,\n configPath,\n options,\n ),\n );\n if (!startPushResponse) {\n return;\n }\n\n await pushSpan.enterAsync(\"waitForSchema\", (span) =>\n waitForSchema(ctx, span, startPushResponse, options),\n );\n\n if (verbose) {\n const remoteConfigWithModuleHashes = await pullConfig(\n ctx,\n undefined,\n undefined,\n options.url,\n options.adminKey,\n );\n\n const { config: localConfig } = await configFromProjectConfig(\n ctx,\n projectConfig,\n configPath,\n options.verbose,\n );\n\n changeSpinner(\"Diffing local code and deployment state...\");\n const { diffString } = diffConfig(\n remoteConfigWithModuleHashes,\n localConfig,\n );\n\n logFinishedStep(\n `Remote config ${\n options.dryRun ? \"would\" : \"will\"\n } be overwritten with the following changes:\\n ` +\n diffString.replace(/\\n/g, \"\\n \"),\n );\n }\n\n const finishPushResponse = await pushSpan.enterAsync(\"finishPush\", (span) =>\n finishPush(ctx, span, startPushResponse, options),\n );\n printDiff(startPushResponse, finishPushResponse, options);\n pushSpan.end();\n\n // Asynchronously report that the push completed.\n if (!options.dryRun) {\n void reportPushCompleted(ctx, options.adminKey, options.url, reporter);\n }\n}\n\nfunction printDiff(\n startPushResponse: StartPushResponse,\n finishPushResponse: FinishPushDiff,\n opts: { verbose: boolean; dryRun: boolean; deploymentName: string | null },\n) {\n if (opts.verbose) {\n const diffString = JSON.stringify(finishPushResponse, null, 2);\n logMessage(diffString);\n return;\n }\n const indexDiffs = startPushResponse.schemaChange.indexDiffs;\n const { componentDiffs } = finishPushResponse;\n\n // Print out index diffs for the root component.\n let rootDiff = indexDiffs?.[\"\"] || componentDiffs[\"\"]?.indexDiff;\n if (rootDiff) {\n if (rootDiff.removed_indexes.length > 0) {\n let msg = `${opts.dryRun ? \"Would delete\" : \"Deleted\"} table indexes:\\n`;\n for (const index of rootDiff.removed_indexes) {\n msg += ` [-] ${formatIndex(index)}\\n`;\n }\n msg = msg.slice(0, -1); // strip last new line\n logFinishedStep(msg);\n }\n\n const addedEnabled = rootDiff.added_indexes.filter((i) => !i.staged);\n if (addedEnabled.length > 0) {\n let msg = `${opts.dryRun ? \"Would add\" : \"Added\"} table indexes:\\n`;\n for (const index of addedEnabled) {\n msg += ` [+] ${formatIndex(index)}\\n`;\n }\n msg = msg.slice(0, -1); // strip last new line\n logFinishedStep(msg);\n }\n\n const addedStaged = rootDiff.added_indexes.filter((i) => i.staged);\n if (addedStaged.length > 0) {\n let msg = `${opts.dryRun ? \"Would add\" : \"Added\"} staged table indexes:\\n`;\n for (const index of addedStaged) {\n const table = index.name.split(\".\")[0];\n const progressLink = deploymentDashboardUrlPage(\n opts.deploymentName,\n `/data?table=${table}&showIndexes=true`,\n );\n msg += ` [+] ${formatIndex(index)}\\n`;\n msg += ` See progress: ${progressLink}\\n`;\n }\n msg = msg.slice(0, -1); // strip last new line\n logFinishedStep(msg);\n }\n\n if (rootDiff.enabled_indexes && rootDiff.enabled_indexes.length > 0) {\n let msg = opts.dryRun\n ? `These indexes would be enabled:\\n`\n : `These indexes are now enabled:\\n`;\n for (const index of rootDiff.enabled_indexes) {\n msg += ` [*] ${formatIndex(index)}\\n`;\n }\n msg = msg.slice(0, -1); // strip last new line\n logFinishedStep(msg);\n }\n\n if (rootDiff.disabled_indexes && rootDiff.disabled_indexes.length > 0) {\n let msg = opts.dryRun\n ? `These indexes would be staged:\\n`\n : `These indexes are now staged:\\n`;\n for (const index of rootDiff.disabled_indexes) {\n msg += ` [*] ${formatIndex(index)}\\n`;\n }\n msg = msg.slice(0, -1); // strip last new line\n logFinishedStep(msg);\n }\n }\n\n // Only show component level diffs for other components.\n for (const [componentPath, componentDiff] of Object.entries(componentDiffs)) {\n if (componentPath === \"\") {\n continue;\n }\n if (componentDiff.diffType.type === \"create\") {\n logFinishedStep(`Installed component ${componentPath}.`);\n }\n if (componentDiff.diffType.type === \"unmount\") {\n logFinishedStep(`Unmounted component ${componentPath}.`);\n }\n if (componentDiff.diffType.type === \"remount\") {\n logFinishedStep(`Remounted component ${componentPath}.`);\n }\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,iBAIO;AACP,oBAQO;AACP,qBAKO;AACP,qBAAwB;AACxB,mBAAwD;AACxD,oBAIO;AACP,gCAAqC;AACrC,qBAMO;AAKP,uBAAwD;AACxD,gBAA2B;AAC3B,6BAAsC;AACtC,mBAA4B;AAI5B,qBAA+B;AAC/B,uBAAuC;AAEvC,uBAA2C;AAC3C,qBAAqD;AACrD,wCAA2C;AAC3C,0CAA6C;AAE7C,oBAA2B;AA6B3B,eAAsB,WACpB,KACA,aACA,SACA;AAEA,YAAM,wCAA0B,KAAK,SAAS;AAE9C,QAAM,EAAE,YAAY,cAAc,IAAI,UAAM,iCAAkB,GAAG;AACjE,QAAM,6BAAyB,2BAAa,YAAY,aAAa;AAErE,MAAI,QAAQ,MAAM;AAChB,cAAM,mCAAmB,KAAK,wBAAwB;AAAA,MACpD,QAAQ,QAAQ;AAAA,MAChB,OAAO,QAAQ;AAAA,IACjB,CAAC;AAAA,EACH;AAEA,MAAI,CAAC,QAAQ,YAAY;AACvB,QAAI,gBAAgB,MAAM;AACxB;AAAA,IACF;AAEA,UAAM;AAAA,MACJ;AAAA,MACA,oBAAK,KAAK;AAAA,MACV;AAAA,MACA;AAAA,MACA;AAAA,QACE,GAAG;AAAA,QACH,gBAAgB,YAA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AAC;AAAA;AAAA,MACpC;AACA,YAAM,IAAI,MAAM,GAAG,EAAE;AACrB,sCAAgB,GAAG;AAAA,IACrB;AAAA,EACF;AAGA,aAAW,CAAC,eAAe,aAAa,KAAK,OAAO,QAAQ,cAAc,GAAG;AAC3E,QAAI,kBAAkB,IAAI;AACxB;AAAA,IACF;AACA,QAAI,cAAc,SAAS,SAAS,UAAU;AAC5C,sCAAgB,uBAAuB,aAAa,GAAG;AAAA,IACzD;AACA,QAAI,cAAc,SAAS,SAAS,WAAW;AAC7C,sCAAgB,uBAAuB,aAAa,GAAG;AAAA,IACzD;AACA,QAAI,cAAc,SAAS,SAAS,WAAW;AAC7C,sCAAgB,uBAAuB,aAAa,GAAG;AAAA,IACzD;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import path from \"path\";\nimport { Context } from \"../../bundler/context.js\";\nimport {\n changeSpinner,\n logFinishedStep,\n logMessage,\n} from \"../../bundler/log.js\";\nimport {\n ProjectConfig,\n configFromProjectConfig,\n debugIsolateEndpointBundles,\n getFunctionsDirectoryPath,\n readProjectConfig,\n pullConfig,\n diffConfig,\n} from \"./config.js\";\nimport {\n finishPush,\n reportPushCompleted,\n startPush,\n waitForSchema,\n} from \"./deploy2.js\";\nimport { version } from \"../version.js\";\nimport { ensureHasConvexDependency, functionsDir } from \"./utils/utils.js\";\nimport {\n bundleDefinitions,\n bundleImplementations,\n componentGraph,\n} from \"./components/definition/bundle.js\";\nimport { isComponentDirectory } from \"./components/definition/directoryStructure.js\";\nimport {\n doFinalComponentCodegen,\n doInitialComponentCodegen,\n CodegenOptions,\n doInitConvexFolder,\n doCodegen,\n} from \"./codegen.js\";\nimport {\n AppDefinitionConfig,\n ComponentDefinitionConfig,\n} from \"./deployApi/definitionConfig.js\";\nimport { typeCheckFunctionsInMode, TypeCheckMode } from \"./typecheck.js\";\nimport { withTmpDir } from \"../../bundler/fs.js\";\nimport { handleDebugBundlePath } from \"./debugBundlePath.js\";\nimport { chalkStderr } from \"chalk\";\nimport { StartPushRequest, StartPushResponse } from \"./deployApi/startPush.js\";\nimport { DetailedDeploymentCredentials } from \"./api.js\";\nimport { FinishPushDiff } from \"./deployApi/finishPush.js\";\nimport { Reporter, Span } from \"./tracing.js\";\nimport { DEFINITION_FILENAME_TS } from \"./components/constants.js\";\nimport { DeploymentType } from \"./api.js\";\nimport { deploymentDashboardUrlPage } from \"./dashboard.js\";\nimport { formatIndex, LargeIndexDeletionCheck } from \"./indexes.js\";\nimport { checkForLargeIndexDeletion } from \"./checkForLargeIndexDeletion.js\";\nimport { checkForSlowSchemaValidation } from \"./checkForSlowSchemaValidation.js\";\nimport {\n checkForLargeIndexBackfill,\n LargeIndexBackfillCheck,\n} from \"./checkForLargeIndexBackfill.js\";\nimport {\n pushStagesValidators,\n sharedSchemaEvaluation,\n} from \"./schemaEvaluation.js\";\nimport {\n checkForStagedValidatorDeletion,\n StagedValidatorDeletionCheck,\n} from \"./checkForStagedValidatorDeletion.js\";\nimport { LogManager } from \"./logs.js\";\nimport { createHash } from \"crypto\";\nimport { Bundle, BundleHash } from \"../../bundler/index.js\";\nimport { ModuleHashConfig } from \"./deployApi/modules.js\";\n\nexport type PushOptions = {\n adminKey: string;\n verbose: boolean;\n dryRun: boolean;\n typecheck: \"enable\" | \"try\" | \"disable\";\n typecheckComponents: boolean;\n debug: boolean;\n debugBundlePath?: string | undefined;\n debugNodeApis: boolean;\n codegen: boolean;\n url: string;\n deploymentName: string | null;\n deploymentType?: DeploymentType;\n writePushRequest?: string | undefined;\n liveComponentSources: boolean;\n pushAllModules: boolean;\n logManager?: LogManager | undefined;\n largeIndexDeletionCheck: LargeIndexDeletionCheck;\n largeIndexBackfillCheck: LargeIndexBackfillCheck;\n stagedValidatorDeletionCheck: StagedValidatorDeletionCheck;\n // Whether a dry run should warn when the schema change would block the\n // deploy on a slow table walk. On for deploys; off for commands whose dry\n // runs never deploy (e.g. codegen).\n warnOnSlowSchemaValidation: boolean;\n message: string | null;\n};\n\nexport async function runCodegen(\n ctx: Context,\n credentials: DetailedDeploymentCredentials | null,\n options: CodegenOptions,\n) {\n // This also ensures the current directory is the project root.\n await ensureHasConvexDependency(ctx, \"codegen\");\n\n const { configPath, projectConfig } = await readProjectConfig(ctx);\n const functionsDirectoryPath = functionsDir(configPath, projectConfig);\n\n if (options.init) {\n await doInitConvexFolder(ctx, functionsDirectoryPath, {\n dryRun: options.dryRun,\n debug: options.debug,\n });\n }\n\n if (!options.systemUdfs) {\n if (credentials === null) {\n return;\n }\n\n await startComponentsPushAndCodegen(\n ctx,\n Span.noop(),\n projectConfig,\n configPath,\n {\n ...options,\n deploymentName: credentials.deploymentFields?.deploymentName ?? null,\n ...(credentials.deploymentFields?.deploymentType !== undefined\n ? { deploymentType: credentials.deploymentFields.deploymentType }\n : {}),\n url: credentials.url,\n adminKey: credentials.adminKey,\n generateCommonJSApi: options.commonjs,\n verbose: !!process.env.CONVEX_VERBOSE,\n codegen: true,\n liveComponentSources: options.liveComponentSources,\n typecheckComponents: false,\n debugNodeApis: options.debugNodeApis,\n // Code generation uses the source schema independently of deployment data.\n largeIndexDeletionCheck: \"no verification\",\n largeIndexBackfillCheck: \"no verification\",\n stagedValidatorDeletionCheck: \"no verification\",\n warnOnSlowSchemaValidation: false,\n },\n );\n } else {\n if (options.typecheck !== \"disable\") {\n logMessage(chalkStderr.gray(\"Running TypeScript typecheck\u2026\"));\n }\n\n await doCodegen(ctx, functionsDirectoryPath, options.typecheck, {\n dryRun: options.dryRun,\n debug: options.debug,\n generateCommonJSApi: options.commonjs,\n });\n }\n}\n\nexport async function runPush(ctx: Context, options: PushOptions) {\n const { configPath, projectConfig } = await readProjectConfig(ctx);\n await runComponentsPush(ctx, options, configPath, projectConfig);\n}\n\nexport function hash(bundle: Bundle) {\n return createHash(\"sha256\")\n .update(bundle.source)\n .update(bundle.sourceMap || \"\")\n .digest(\"hex\");\n}\n\nfunction isModuleTheSame(newBundle: Bundle, oldBundleHash: BundleHash) {\n return (\n newBundle.environment === oldBundleHash.environment &&\n hash(newBundle) === oldBundleHash.hash\n );\n}\n\nexport function partitionModulesByChanges(\n functions: Bundle[],\n remoteHashesByPath: Map<string, BundleHash>,\n): {\n unchangedModuleHashes: ModuleHashConfig[];\n changedModules: Bundle[];\n} {\n // Partition modules based on whether they match the existing modules\n const unchangedModuleHashes = functions\n .filter((newBundle) => {\n const oldBundleHash = remoteHashesByPath.get(newBundle.path);\n return oldBundleHash && isModuleTheSame(newBundle, oldBundleHash);\n })\n .map((func) => ({\n path: func.path,\n environment: func.environment,\n sha256: hash(func),\n }));\n const changedModules = functions.filter((newBundle) => {\n const oldBundleHash = remoteHashesByPath.get(newBundle.path);\n return !oldBundleHash || !isModuleTheSame(newBundle, oldBundleHash);\n });\n return { unchangedModuleHashes, changedModules };\n}\n\nasync function getUnchangedModuleHashesFromServer(\n ctx: Context,\n appImplementation: { functions: Bundle[] },\n options: { url: string; adminKey: string },\n): Promise<{\n unchangedModuleHashes: ModuleHashConfig[];\n changedModules: Bundle[];\n}> {\n const remoteConfigWithModuleHashes = await pullConfig(\n ctx,\n undefined,\n undefined,\n options.url,\n options.adminKey,\n );\n const remoteHashesByPath = new Map(\n remoteConfigWithModuleHashes.moduleHashes.map((moduleHash) => [\n moduleHash.path,\n moduleHash,\n ]),\n );\n return partitionModulesByChanges(\n appImplementation.functions,\n remoteHashesByPath,\n );\n}\n\nasync function startComponentsPushAndCodegen(\n ctx: Context,\n parentSpan: Span,\n projectConfig: ProjectConfig,\n configPath: string,\n options: {\n typecheck: TypeCheckMode;\n typecheckComponents: boolean;\n adminKey: string;\n url: string;\n deploymentName: string | null;\n deploymentType?: DeploymentType;\n verbose: boolean;\n debugBundlePath?: string | undefined;\n dryRun: boolean;\n generateCommonJSApi?: boolean;\n debug: boolean;\n writePushRequest?: string | undefined;\n codegen: boolean;\n liveComponentSources?: boolean;\n pushAllModules?: boolean;\n debugNodeApis: boolean;\n largeIndexDeletionCheck: LargeIndexDeletionCheck;\n largeIndexBackfillCheck: LargeIndexBackfillCheck;\n stagedValidatorDeletionCheck: StagedValidatorDeletionCheck;\n warnOnSlowSchemaValidation: boolean;\n codegenOnlyThisComponent?: string | undefined;\n },\n): Promise<StartPushResponse | null> {\n const convexDir = await getFunctionsDirectoryPath(ctx);\n\n // '.' means use the process current working directory, it's the default behavior.\n // Spelling it out here to be explicit for a future where this code can run\n // from other directories.\n // In esbuild the working directory is used to print error messages and resolving\n // relatives paths passed to it. It generally doesn't matter for resolving imports,\n // imports are resolved from the file where they are written.\n const absWorkingDir = path.resolve(\".\");\n const isComponent = isComponentDirectory(ctx, convexDir, true);\n if (isComponent.kind === \"err\") {\n return await ctx.crash({\n exitCode: 1,\n errorType: \"invalid filesystem data\",\n printedMessage: `Invalid component root directory (${isComponent.why}): ${convexDir}`,\n });\n }\n\n let rootComponent = isComponent.component;\n if (options.codegenOnlyThisComponent) {\n const absolutePath = path.resolve(options.codegenOnlyThisComponent);\n let componentConfigPath: string;\n\n // Must be a directory containing a convex.config.ts\n componentConfigPath = path.join(absolutePath, DEFINITION_FILENAME_TS);\n if (!ctx.fs.exists(componentConfigPath)) {\n return await ctx.crash({\n exitCode: 1,\n errorType: \"invalid filesystem data\",\n printedMessage: `Only directories with convex.config.ts files are supported, this directory does not: ${absolutePath}`,\n });\n }\n\n const syntheticConfigPath = path.join(\n rootComponent.path,\n DEFINITION_FILENAME_TS,\n );\n rootComponent = {\n isRoot: true,\n path: rootComponent.path,\n definitionPath: syntheticConfigPath,\n isRootWithoutConfig: false,\n syntheticComponentImport: componentConfigPath,\n };\n }\n\n changeSpinner(\"Finding component definitions...\");\n // Create a list of relevant component directories. These are just for knowing\n // while directories to bundle in bundleDefinitions and bundleImplementations.\n // This produces a bundle in memory as a side effect but it's thrown away.\n const { components, dependencyGraph } = await parentSpan.enterAsync(\n \"componentGraph\",\n () =>\n componentGraph(\n ctx,\n absWorkingDir,\n rootComponent,\n !!options.liveComponentSources,\n options.verbose,\n ),\n );\n\n // Initial codegen is everything we need to get code runnable:\n // root components and other components need a basic _generated/api.ts etc.\n // just to make the code bundleable and runnable so we can analyze.\n if (options.codegen) {\n changeSpinner(\"Generating server code...\");\n await parentSpan.enterAsync(\"doInitialComponentCodegen\", () =>\n withTmpDir(async (tmpDir) => {\n // Skip the root in component cases\n if (!rootComponent.syntheticComponentImport) {\n // Do root first so if a component fails, we'll at least have a working root.\n await doInitialComponentCodegen(ctx, tmpDir, rootComponent, options);\n }\n for (const directory of components.values()) {\n if (directory.isRoot) {\n continue;\n }\n // When --component-dir is used, only generate code for the target component\n if (\n rootComponent.syntheticComponentImport &&\n directory.definitionPath !== rootComponent.syntheticComponentImport\n ) {\n continue;\n }\n await doInitialComponentCodegen(ctx, tmpDir, directory, options);\n }\n }),\n );\n }\n\n changeSpinner(\"Bundling component definitions...\");\n // This bundles everything but the actual function definitions\n const {\n appDefinitionSpecWithoutImpls,\n componentDefinitionSpecsWithoutImpls,\n } = await parentSpan.enterAsync(\"bundleDefinitions\", () =>\n bundleDefinitions(\n ctx,\n absWorkingDir,\n dependencyGraph,\n rootComponent,\n // Note that this *includes* the root component.\n [...components.values()],\n !!options.liveComponentSources,\n options.verbose,\n ),\n );\n\n if (options.debugNodeApis) {\n await debugIsolateEndpointBundles(ctx, projectConfig, configPath);\n logFinishedStep(\n \"All non-'use node' entry points successfully bundled. Skipping rest of push.\",\n );\n return null;\n }\n\n changeSpinner(\"Bundling component schemas and implementations...\");\n const { appImplementation, componentImplementations } =\n await parentSpan.enterAsync(\"bundleImplementations\", () =>\n bundleImplementations({\n ctx,\n rootComponentDirectory: rootComponent,\n // When running codegen for a specific component, don't bundle the root.\n componentDirectories: [...components.values()].filter(\n (dir) => !dir.isRoot && !dir.syntheticComponentImport,\n ),\n nodeExternalPackages: projectConfig.node.externalPackages,\n extraConditions: options.liveComponentSources\n ? [\"@convex-dev/component-source\"]\n : [],\n verbose: options.verbose,\n includeSourcesContent:\n projectConfig.bundler?.includeSourcesContent ?? false,\n }),\n );\n if (options.debugBundlePath) {\n const { config: localConfig } = await configFromProjectConfig(\n ctx,\n projectConfig,\n configPath,\n options.verbose,\n );\n // TODO(ENG-6972): Actually write the bundles for components.\n await handleDebugBundlePath(ctx, options.debugBundlePath, localConfig);\n logMessage(\n `Wrote bundle and metadata for modules in the root to ${options.debugBundlePath}. Skipping rest of push.`,\n );\n return null;\n }\n\n // We're just using the version this CLI is running with for now.\n // This could be different than the version of `convex` the app runs with\n // if the CLI is installed globally.\n // TODO: This should be the version of the `convex` package used by each\n // component, and may be different for each component.\n const udfServerVersion = version;\n\n const { unchangedModuleHashes, changedModules } = options.pushAllModules\n ? {\n unchangedModuleHashes: [],\n changedModules: appImplementation.functions,\n }\n : await parentSpan.enterAsync(\"getUnchangedModuleHashesFromServer\", () =>\n getUnchangedModuleHashesFromServer(ctx, appImplementation, options),\n );\n\n const appDefinition: AppDefinitionConfig = {\n ...appDefinitionSpecWithoutImpls,\n schema: appImplementation.schema,\n changedModules,\n unchangedModuleHashes,\n udfServerVersion,\n };\n\n const componentDefinitions: ComponentDefinitionConfig[] = [];\n for (const componentDefinition of componentDefinitionSpecsWithoutImpls) {\n const impl = componentImplementations.filter(\n (impl) => impl.definitionPath === componentDefinition.definitionPath,\n )[0];\n if (!impl) {\n return await ctx.crash({\n exitCode: 1,\n errorType: \"fatal\",\n printedMessage: `missing! couldn't find ${componentDefinition.definitionPath} in ${componentImplementations.map((impl) => impl.definitionPath).toString()}`,\n });\n }\n componentDefinitions.push({\n ...componentDefinition,\n ...impl,\n udfServerVersion,\n });\n }\n const startPushRequest = {\n adminKey: options.adminKey,\n dryRun: options.dryRun,\n functions: projectConfig.functions,\n appDefinition,\n componentDefinitions,\n nodeDependencies: appImplementation.externalNodeDependencies,\n nodeVersion: projectConfig.node.nodeVersion,\n forCodegen: !!options.codegenOnlyThisComponent,\n };\n if (options.writePushRequest) {\n const pushRequestPath = path.resolve(options.writePushRequest);\n ctx.fs.writeUtf8File(\n `${pushRequestPath}.json`,\n JSON.stringify(startPushRequest),\n );\n return null;\n }\n logStartPushSizes(parentSpan, startPushRequest);\n\n const schemaEvaluation = sharedSchemaEvaluation(\n ctx,\n startPushRequest,\n options,\n );\n if (options.largeIndexDeletionCheck !== \"no verification\") {\n await parentSpan.enterAsync(\"checkForLargeIndexDeletion\", (span) =>\n checkForLargeIndexDeletion({\n ctx,\n span,\n request: startPushRequest,\n options,\n schemaEvaluation,\n askForConfirmation:\n options.largeIndexDeletionCheck === \"ask for confirmation\",\n }),\n );\n }\n\n const largeIndexBackfillCheck = options.largeIndexBackfillCheck;\n if (largeIndexBackfillCheck !== \"no verification\") {\n await parentSpan.enterAsync(\"checkForLargeIndexBackfill\", (span) =>\n checkForLargeIndexBackfill({\n ctx,\n span,\n schemaEvaluation,\n options,\n // A dry run never blocks on a backfill, so it only reports.\n mode: options.dryRun ? \"warn\" : largeIndexBackfillCheck,\n }),\n );\n }\n\n const stagedValidatorDeletionCheck = options.stagedValidatorDeletionCheck;\n if (stagedValidatorDeletionCheck !== \"no verification\") {\n await parentSpan.enterAsync(\n \"checkForStagedValidatorDeletion\",\n async (span) => {\n const response = await schemaEvaluation(span);\n await checkForStagedValidatorDeletion({\n ctx,\n response,\n askForConfirmation:\n stagedValidatorDeletionCheck === \"ask for confirmation\",\n // A dry run previews the confirmation required by a real push.\n dryRun: options.dryRun,\n });\n },\n );\n }\n\n // A real push evaluates the schema only when the evaluation is already\n // paid for by the unstaging check or the pushed schema stages a validator,\n // so `dev` pushes of ordinary schemas skip the isolate evaluation and round\n // trip that the status report would otherwise add on every save.\n if (\n options.warnOnSlowSchemaValidation &&\n (options.dryRun ||\n stagedValidatorDeletionCheck !== \"no verification\" ||\n pushStagesValidators(startPushRequest))\n ) {\n await parentSpan.enterAsync(\"checkForSlowSchemaValidation\", (span) =>\n checkForSlowSchemaValidation({\n span,\n schemaEvaluation,\n dryRun: options.dryRun,\n }),\n );\n }\n\n changeSpinner(\"Uploading functions to Convex...\");\n const startPushResponse = await parentSpan.enterAsync(\"startPush\", (span) =>\n startPush(ctx, span, startPushRequest, options),\n );\n\n if (options.verbose) {\n logMessage(\"startPush: \" + JSON.stringify(startPushResponse, null, 2));\n }\n\n if (options.codegen) {\n changeSpinner(\"Generating TypeScript bindings...\");\n await parentSpan.enterAsync(\"doFinalComponentCodegen\", () =>\n withTmpDir(async (tmpDir) => {\n // TODO generating code for the root component last might be better DX\n // When running codegen for a specific component, don't generate types for the root\n if (!rootComponent.syntheticComponentImport) {\n // Do the root first\n await doFinalComponentCodegen(\n ctx,\n tmpDir,\n rootComponent,\n rootComponent,\n startPushResponse,\n components,\n options,\n );\n }\n for (const directory of components.values()) {\n if (directory.isRoot) {\n continue;\n }\n // When --component-dir is used, only generate code for the target component\n if (\n rootComponent.syntheticComponentImport &&\n directory.definitionPath !== rootComponent.syntheticComponentImport\n ) {\n continue;\n }\n await doFinalComponentCodegen(\n ctx,\n tmpDir,\n rootComponent,\n directory,\n startPushResponse,\n components,\n options,\n );\n }\n }),\n );\n }\n\n changeSpinner(\"Running TypeScript...\");\n await parentSpan.enterAsync(\"typeCheckFunctionsInMode\", async () => {\n // When running codegen for a specific component, don't typecheck the root\n if (!rootComponent.syntheticComponentImport) {\n await typeCheckFunctionsInMode(\n ctx,\n options.typecheck,\n rootComponent.path,\n );\n }\n if (options.typecheckComponents) {\n for (const directory of components.values()) {\n if (!directory.isRoot) {\n await typeCheckFunctionsInMode(\n ctx,\n options.typecheck,\n directory.path,\n );\n }\n }\n } else if (rootComponent.syntheticComponentImport) {\n // When running codegen for a specific component, only typecheck that component.\n for (const directory of components.values()) {\n if (\n directory.isRoot ||\n directory.definitionPath !== rootComponent.syntheticComponentImport\n ) {\n continue;\n }\n await typeCheckFunctionsInMode(ctx, options.typecheck, directory.path);\n }\n }\n });\n\n return startPushResponse;\n}\n\nfunction logStartPushSizes(span: Span, startPushRequest: StartPushRequest) {\n let v8Size = 0;\n let v8Count = 0;\n let nodeSize = 0;\n let nodeCount = 0;\n\n for (const componentDefinition of startPushRequest.componentDefinitions) {\n for (const module of componentDefinition.functions) {\n if (module.environment === \"isolate\") {\n v8Size += module.source.length + (module.sourceMap ?? \"\").length;\n v8Count += 1;\n } else if (module.environment === \"node\") {\n nodeSize += module.source.length + (module.sourceMap ?? \"\").length;\n nodeCount += 1;\n }\n }\n }\n span.setProperty(\"v8_size\", v8Size.toString());\n span.setProperty(\"v8_count\", v8Count.toString());\n span.setProperty(\"node_size\", nodeSize.toString());\n span.setProperty(\"node_count\", nodeCount.toString());\n}\n\nexport async function runComponentsPush(\n ctx: Context,\n options: PushOptions,\n configPath: string,\n projectConfig: ProjectConfig,\n) {\n const reporter = new Reporter();\n const pushSpan = Span.root(reporter, \"runComponentsPush\");\n pushSpan.setProperty(\"cli_version\", version);\n const verbose = options.verbose || options.dryRun;\n\n await ensureHasConvexDependency(ctx, \"push\");\n\n const startPushResponse = await pushSpan.enterAsync(\n \"startComponentsPushAndCodegen\",\n (span) =>\n startComponentsPushAndCodegen(\n ctx,\n span,\n projectConfig,\n configPath,\n options,\n ),\n );\n if (!startPushResponse) {\n return;\n }\n\n await pushSpan.enterAsync(\"waitForSchema\", (span) =>\n waitForSchema(ctx, span, startPushResponse, options),\n );\n\n if (verbose) {\n const remoteConfigWithModuleHashes = await pullConfig(\n ctx,\n undefined,\n undefined,\n options.url,\n options.adminKey,\n );\n\n const { config: localConfig } = await configFromProjectConfig(\n ctx,\n projectConfig,\n configPath,\n options.verbose,\n );\n\n changeSpinner(\"Diffing local code and deployment state...\");\n const { diffString } = diffConfig(\n remoteConfigWithModuleHashes,\n localConfig,\n );\n\n logFinishedStep(\n `Remote config ${\n options.dryRun ? \"would\" : \"will\"\n } be overwritten with the following changes:\\n ` +\n diffString.replace(/\\n/g, \"\\n \"),\n );\n }\n\n const finishPushResponse = await pushSpan.enterAsync(\"finishPush\", (span) =>\n finishPush(ctx, span, startPushResponse, options),\n );\n printDiff(startPushResponse, finishPushResponse, options);\n pushSpan.end();\n\n // Asynchronously report that the push completed.\n if (!options.dryRun) {\n void reportPushCompleted(ctx, options.adminKey, options.url, reporter);\n }\n}\n\nfunction printDiff(\n startPushResponse: StartPushResponse,\n finishPushResponse: FinishPushDiff,\n opts: { verbose: boolean; dryRun: boolean; deploymentName: string | null },\n) {\n if (opts.verbose) {\n const diffString = JSON.stringify(finishPushResponse, null, 2);\n logMessage(diffString);\n return;\n }\n const indexDiffs = startPushResponse.schemaChange.indexDiffs;\n const { componentDiffs } = finishPushResponse;\n\n // Print out index diffs for the root component.\n let rootDiff = indexDiffs?.[\"\"] || componentDiffs[\"\"]?.indexDiff;\n if (rootDiff) {\n if (rootDiff.removed_indexes.length > 0) {\n let msg = `${opts.dryRun ? \"Would delete\" : \"Deleted\"} table indexes:\\n`;\n for (const index of rootDiff.removed_indexes) {\n msg += ` [-] ${formatIndex(index)}\\n`;\n }\n msg = msg.slice(0, -1); // strip last new line\n logFinishedStep(msg);\n }\n\n const addedEnabled = rootDiff.added_indexes.filter((i) => !i.staged);\n if (addedEnabled.length > 0) {\n let msg = `${opts.dryRun ? \"Would add\" : \"Added\"} table indexes:\\n`;\n for (const index of addedEnabled) {\n msg += ` [+] ${formatIndex(index)}\\n`;\n }\n msg = msg.slice(0, -1); // strip last new line\n logFinishedStep(msg);\n }\n\n const addedStaged = rootDiff.added_indexes.filter((i) => i.staged);\n if (addedStaged.length > 0) {\n let msg = `${opts.dryRun ? \"Would add\" : \"Added\"} staged table indexes:\\n`;\n for (const index of addedStaged) {\n const table = index.name.split(\".\")[0];\n const progressLink = deploymentDashboardUrlPage(\n opts.deploymentName,\n `/data?table=${table}&showIndexes=true`,\n );\n msg += ` [+] ${formatIndex(index)}\\n`;\n msg += ` See progress: ${progressLink}\\n`;\n }\n msg = msg.slice(0, -1); // strip last new line\n logFinishedStep(msg);\n }\n\n if (rootDiff.enabled_indexes && rootDiff.enabled_indexes.length > 0) {\n let msg = opts.dryRun\n ? `These indexes would be enabled:\\n`\n : `These indexes are now enabled:\\n`;\n for (const index of rootDiff.enabled_indexes) {\n msg += ` [*] ${formatIndex(index)}\\n`;\n }\n msg = msg.slice(0, -1); // strip last new line\n logFinishedStep(msg);\n }\n\n if (rootDiff.disabled_indexes && rootDiff.disabled_indexes.length > 0) {\n let msg = opts.dryRun\n ? `These indexes would be staged:\\n`\n : `These indexes are now staged:\\n`;\n for (const index of rootDiff.disabled_indexes) {\n msg += ` [*] ${formatIndex(index)}\\n`;\n }\n msg = msg.slice(0, -1); // strip last new line\n logFinishedStep(msg);\n }\n }\n\n // Only show component level diffs for other components.\n for (const [componentPath, componentDiff] of Object.entries(componentDiffs)) {\n if (componentPath === \"\") {\n continue;\n }\n if (componentDiff.diffType.type === \"create\") {\n logFinishedStep(`Installed component ${componentPath}.`);\n }\n if (componentDiff.diffType.type === \"unmount\") {\n logFinishedStep(`Unmounted component ${componentPath}.`);\n }\n if (componentDiff.diffType.type === \"remount\") {\n logFinishedStep(`Remounted component ${componentPath}.`);\n }\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,iBAIO;AACP,oBAQO;AACP,qBAKO;AACP,qBAAwB;AACxB,mBAAwD;AACxD,oBAIO;AACP,gCAAqC;AACrC,qBAMO;AAKP,uBAAwD;AACxD,gBAA2B;AAC3B,6BAAsC;AACtC,mBAA4B;AAI5B,qBAA+B;AAC/B,uBAAuC;AAEvC,uBAA2C;AAC3C,qBAAqD;AACrD,wCAA2C;AAC3C,0CAA6C;AAC7C,wCAGO;AACP,8BAGO;AACP,6CAGO;AAEP,oBAA2B;AA+B3B,eAAsB,WACpB,KACA,aACA,SACA;AAEA,YAAM,wCAA0B,KAAK,SAAS;AAE9C,QAAM,EAAE,YAAY,cAAc,IAAI,UAAM,iCAAkB,GAAG;AACjE,QAAM,6BAAyB,2BAAa,YAAY,aAAa;AAErE,MAAI,QAAQ,MAAM;AAChB,cAAM,mCAAmB,KAAK,wBAAwB;AAAA,MACpD,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c,SAAS,SAAS,UAAU;AAC5C,sCAAgB,uBAAuB,aAAa,GAAG;AAAA,IACzD;AACA,QAAI,cAAc,SAAS,SAAS,WAAW;AAC7C,sCAAgB,uBAAuB,aAAa,GAAG;AAAA,IACzD;AACA,QAAI,cAAc,SAAS,SAAS,WAAW;AAC7C,sCAAgB,uBAAuB,aAAa,GAAG;AAAA,IACzD;AAAA,EACF;AACF;",
6
6
  "names": ["path", "impl", "module"]
7
7
  }
@@ -46,6 +46,7 @@ __export(config_exports, {
46
46
  readProjectConfig: () => readProjectConfig,
47
47
  removedExistingConfig: () => removedExistingConfig,
48
48
  resetUnknownKeyWarnings: () => resetUnknownKeyWarnings,
49
+ setEnvVarsInstructions: () => setEnvVarsInstructions,
49
50
  usesComponentApiImports: () => usesComponentApiImports,
50
51
  usesTypeScriptCodegen: () => usesTypeScriptCodegen,
51
52
  writeAiFilesConfig: () => writeAiFilesConfig
@@ -63,6 +64,7 @@ var import_utils = require("./utils/utils.js");
63
64
  var import_fsUtils = require("./fsUtils.js");
64
65
  var import_errors = require("./localDeployment/errors.js");
65
66
  var import_debugBundle = require("../../bundler/debugBundle.js");
67
+ var import_deployment = require("./deployment.js");
66
68
  var import_utils2 = require("./utils/utils.js");
67
69
  const DEFAULT_FUNCTIONS_PATH = "convex/";
68
70
  function usesTypeScriptCodegen(projectConfig) {
@@ -437,7 +439,7 @@ async function configFromProjectConfig(ctx, projectConfig, configPath, verbose)
437
439
  }
438
440
  const modules = convexResult.modules;
439
441
  modules.push(...nodeResult.modules);
440
- modules.push(...await (0, import_bundler.bundleAuthConfig)(ctx, baseDir));
442
+ modules.push(...(await (0, import_bundler.bundleAuthConfig)(ctx, baseDir)).modules);
441
443
  const nodeDependencies = [];
442
444
  for (const [moduleName, moduleVersion] of nodeResult.externalDependencies) {
443
445
  nodeDependencies.push({ name: moduleName, version: moduleVersion });
@@ -584,7 +586,37 @@ function diffConfig(oldConfig, newConfig) {
584
586
  }
585
587
  return { diffString: diff };
586
588
  }
587
- async function handlePushConfigError(ctx, error, defaultMessage, deploymentName, deployment, _deploymentType) {
589
+ function setEnvVarsInstructions(names, deploymentName, deploymentType, deploymentUrl) {
590
+ let deploymentFlag = "";
591
+ if (deploymentName !== null && deploymentType !== "local" && deploymentType !== "anonymous") {
592
+ deploymentFlag = ` --deployment ${deploymentName}`;
593
+ } else if (deploymentType === "prod") {
594
+ deploymentFlag = " --prod";
595
+ } else if (deploymentName === null && deploymentUrl !== void 0) {
596
+ deploymentFlag = ` --url ${deploymentUrl} --admin-key <admin key>`;
597
+ }
598
+ const commands = (names.length > 0 ? names : ["<NAME>"]).map(
599
+ (name) => ` ${import_chalk.chalkStderr.bold(`npx convex env set${deploymentFlag} ${name} <value>`)}`
600
+ );
601
+ let instructions = `Set ${names.length > 1 ? "them" : "it"} with:
602
+
603
+ ${commands.join("\n")}
604
+ `;
605
+ if (deploymentName !== null && !(0, import_deployment.isAnonymousDeployment)(deploymentName)) {
606
+ const variableQuery = names.length === 1 ? `?var=${names[0]}` : "";
607
+ const dashboardUrl = (0, import_dashboard.deploymentDashboardUrlPage)(
608
+ deploymentName,
609
+ `/settings/environment-variables${variableQuery}`
610
+ );
611
+ instructions += `
612
+ or in the dashboard:
613
+
614
+ ${import_chalk.chalkStderr.bold(dashboardUrl)}
615
+ `;
616
+ }
617
+ return instructions;
618
+ }
619
+ async function handlePushConfigError(ctx, error, defaultMessage, deploymentName, deployment, deploymentType) {
588
620
  const data = error instanceof import_utils.ThrowingFetchError ? error.serverErrorData : void 0;
589
621
  if (data?.code === "AuthConfigMissingEnvironmentVariable") {
590
622
  const errorMessage = data.message || "(no error message given)";
@@ -601,26 +633,33 @@ async function handlePushConfigError(ctx, error, defaultMessage, deploymentName,
601
633
  const envVarMessage = `Environment variable ${import_chalk.chalkStderr.bold(
602
634
  variableName
603
635
  )} is used in auth config file but its value was not set.`;
604
- let setEnvVarInstructions = "Go set it in the dashboard or using `npx convex env set`";
605
- if (deploymentName !== null) {
606
- const variableQuery = variableName !== void 0 ? `?var=${variableName}` : "";
607
- const dashboardUrl = (0, import_dashboard.deploymentDashboardUrlPage)(
636
+ await ctx.crash({
637
+ exitCode: 1,
638
+ errorType: "invalid filesystem or env vars",
639
+ errForSentry: error,
640
+ printedMessage: envVarMessage + "\n" + setEnvVarsInstructions(
641
+ variableName !== void 0 ? [variableName] : [],
608
642
  deploymentName,
609
- `/settings/environment-variables${variableQuery}`
610
- );
611
- setEnvVarInstructions = `Go to:
612
-
613
- ${import_chalk.chalkStderr.bold(
614
- dashboardUrl
615
- )}
616
-
617
- to set it up. `;
618
- }
643
+ deploymentType,
644
+ deployment?.deploymentUrl
645
+ )
646
+ });
647
+ }
648
+ if (data?.code === "MissingEnvironmentVariables") {
649
+ const errorMessage = data.message || "(no error message given)";
650
+ const [, namesList] = errorMessage.match(/are not set: ([^.]+)\./) ?? [];
651
+ const names = namesList?.split(", ") ?? [];
652
+ const envVarMessage = names.length === 0 ? errorMessage : names.length === 1 ? `Environment variable ${import_chalk.chalkStderr.bold(names[0])} is declared as required in convex.config.ts but its value was not set.` : `Environment variables ${names.map((name) => import_chalk.chalkStderr.bold(name)).join(", ")} are declared as required in convex.config.ts but their values were not set.`;
619
653
  await ctx.crash({
620
654
  exitCode: 1,
621
655
  errorType: "invalid filesystem or env vars",
622
656
  errForSentry: error,
623
- printedMessage: envVarMessage + "\n" + setEnvVarInstructions
657
+ printedMessage: envVarMessage + "\n" + setEnvVarsInstructions(
658
+ names,
659
+ deploymentName,
660
+ deploymentType,
661
+ deployment?.deploymentUrl
662
+ )
624
663
  });
625
664
  }
626
665
  if (data?.code === "RaceDetected") {