@@ -150,9 +150,63 @@ pub struct PushMetrics {
150150 pub occ_stats : OccRetryStats ,
151151}
152152
153+ struct EvaluatedPushContents {
154+ app : CheckedComponent ,
155+ auth_info : Vec < AuthInfo > ,
156+ component_definition_packages : BTreeMap < ComponentDefinitionPath , SourcePackage > ,
157+ evaluated_components : BTreeMap < ComponentDefinitionPath , EvaluatedComponentDefinition > ,
158+ external_deps_id : Option < ExternalDepsPackageId > ,
159+ user_environment_variables : BTreeMap < EnvVarName , EnvVarValue > ,
160+ }
161+
153162impl < RT : Runtime > Application < RT > {
154163 #[ fastrace:: trace]
155164 pub async fn start_push ( & self , config : & ProjectConfig ) -> anyhow:: Result < StartPushResponse > {
165+ let EvaluatedPushContents {
166+ app,
167+ auth_info,
168+ component_definition_packages,
169+ mut evaluated_components,
170+ external_deps_id,
171+ user_environment_variables,
172+ } = self . evaluate_push_contents ( config) . await ?;
173+
174+ let schema_change = self
175+ . handle_schema_change_in_start_push ( & app, & evaluated_components)
176+ . await ?;
177+ self . database
178+ . load_indexes_into_memory ( btreeset ! { SCHEMAS_TABLE . clone( ) } )
179+ . await ?;
180+
181+ // TODO(ENG-7533): Clean up exports from the start push response when we've
182+ // updated clients to use `functions` directly.
183+ for ( path, definition) in evaluated_components. iter_mut ( ) {
184+ // We don't need to include exports for the root since we don't use codegen
185+ // for the app's `api` object.
186+ if path. is_root ( ) {
187+ continue ;
188+ }
189+ anyhow:: ensure!( definition. definition. exports. is_empty( ) ) ;
190+ definition. definition . exports = file_based_exports ( & definition. functions ) ?;
191+ }
192+
193+ let resp = StartPushResponse {
194+ environment_variables : user_environment_variables,
195+ external_deps_id,
196+ component_definition_packages,
197+ app_auth : auth_info,
198+ analysis : evaluated_components,
199+ app,
200+ schema_change,
201+ } ;
202+ Ok ( resp)
203+ }
204+
205+ #[ fastrace:: trace]
206+ async fn evaluate_push_contents (
207+ & self ,
208+ config : & ProjectConfig ,
209+ ) -> anyhow:: Result < EvaluatedPushContents > {
156210 let unix_timestamp = self . runtime . unix_timestamp ( ) ;
157211 let ( external_deps_id, component_definition_packages) =
158212 self . upload_packages ( config) . await ?;
@@ -206,7 +260,7 @@ impl<RT: Runtime> Application<RT> {
206260 )
207261 . await ?;
208262
209- let mut evaluated_components = self
263+ let evaluated_components = self
210264 . evaluate_components (
211265 config,
212266 & component_definition_packages,
@@ -231,39 +285,18 @@ impl<RT: Runtime> Application<RT> {
231285 let ctx = TypecheckContext :: new ( & evaluated_components, & initializer_evaluator) ;
232286 let app = ctx. instantiate_root ( ) . await ?;
233287
234- let schema_change = self
235- . _handle_schema_change_in_start_push ( & app, & evaluated_components)
236- . await ?;
237- self . database
238- . load_indexes_into_memory ( btreeset ! { SCHEMAS_TABLE . clone( ) } )
239- . await ?;
240-
241- // TODO(ENG-7533): Clean up exports from the start push response when we've
242- // updated clients to use `functions` directly.
243- for ( path, definition) in evaluated_components. iter_mut ( ) {
244- // We don't need to include exports for the root since we don't use codegen
245- // for the app's `api` object.
246- if path. is_root ( ) {
247- continue ;
248- }
249- anyhow:: ensure!( definition. definition. exports. is_empty( ) ) ;
250- definition. definition . exports = file_based_exports ( & definition. functions ) ?;
251- }
252-
253- let resp = StartPushResponse {
254- environment_variables : user_environment_variables,
255- external_deps_id,
256- component_definition_packages,
257- app_auth : auth_info,
258- analysis : evaluated_components,
288+ Ok ( EvaluatedPushContents {
259289 app,
260- schema_change,
261- } ;
262- Ok ( resp)
290+ auth_info,
291+ component_definition_packages,
292+ evaluated_components,
293+ external_deps_id,
294+ user_environment_variables,
295+ } )
263296 }
264297
265298 #[ fastrace:: trace]
266- async fn _handle_schema_change_in_start_push (
299+ async fn handle_schema_change_in_start_push (
267300 & self ,
268301 app : & CheckedComponent ,
269302 evaluated_components : & BTreeMap < ComponentDefinitionPath , EvaluatedComponentDefinition > ,
@@ -289,6 +322,20 @@ impl<RT: Runtime> Application<RT> {
289322 Ok ( schema_change)
290323 }
291324
325+ #[ fastrace:: trace]
326+ async fn handle_schema_change_in_evaluate_push (
327+ & self ,
328+ app : & CheckedComponent ,
329+ evaluated_components : & BTreeMap < ComponentDefinitionPath , EvaluatedComponentDefinition > ,
330+ ) -> anyhow:: Result < SchemaChange > {
331+ let mut tx = self . begin ( Identity :: system ( ) ) . await ?;
332+ let schema_change = ComponentConfigModel :: new ( & mut tx)
333+ . start_component_schema_changes ( app, evaluated_components)
334+ . await ?;
335+ drop ( tx) ;
336+ Ok ( schema_change)
337+ }
338+
292339 #[ fastrace:: trace]
293340 async fn evaluate_components (
294341 & self ,
@@ -451,6 +498,24 @@ impl<RT: Runtime> Application<RT> {
451498 . await
452499 }
453500
501+ #[ fastrace:: trace]
502+ pub async fn evaluate_push (
503+ & self ,
504+ config : & ProjectConfig ,
505+ ) -> anyhow:: Result < EvaluatePushResponse > {
506+ let EvaluatedPushContents {
507+ app,
508+ evaluated_components,
509+ ..
510+ } = self . evaluate_push_contents ( config) . await ?;
511+
512+ let schema_change = self
513+ . handle_schema_change_in_evaluate_push ( & app, & evaluated_components)
514+ . await ?;
515+
516+ Ok ( EvaluatePushResponse { schema_change } )
517+ }
518+
454519 #[ fastrace:: trace]
455520 pub async fn wait_for_schema (
456521 & self ,
@@ -860,6 +925,11 @@ pub struct StartPushResponse {
860925 pub schema_change : SchemaChange ,
861926}
862927
928+ #[ derive( Debug ) ]
929+ pub struct EvaluatePushResponse {
930+ pub schema_change : SchemaChange ,
931+ }
932+
863933impl From < NodeDependencyJson > for NodeDependency {
864934 fn from ( value : NodeDependencyJson ) -> Self {
865935 Self {
0 commit comments