@@ -181,10 +181,11 @@ async function contractsOf(
181181/**
182182 * Discover `server/database/routes/*.ts`, write the lazy `routes.gen.ts` entry
183183 * that lists every module, and write the browser contract of each published
184- * operation. Any malformed or duplicate declaration fails generation and
184+ * operation. A schema-only app gets an empty registry so development can
185+ * discover its first operation without restarting manually. Any malformed or duplicate declaration fails generation and
185186 * neutralizes the contracts; a declaration without authorization is skipped
186187 * with a warning, or fails in strict mode. Both files are created only while
187- * the routes directory exists, and emptied once it is gone.
188+ * a schema or routes directory exists, and emptied once routes are gone.
188189 */
189190export async function generateDatabaseOperations (
190191 options : GenerateDatabaseOperationsOptions ,
@@ -197,11 +198,14 @@ export async function generateDatabaseOperations(
197198 } )
198199 ?. isDirectory ( ) ?? false ;
199200 const files = routesPresent ? discoverRouteModules ( options . appRoot ) : [ ] ;
200- if ( routesPresent || fsSync . existsSync ( routesFile ) ) {
201+ const schemaPresent = fsSync . existsSync (
202+ fromRoot ( options . appRoot , SCHEMA_FILE ) ,
203+ ) ;
204+ if ( schemaPresent || routesPresent || fsSync . existsSync ( routesFile ) ) {
201205 await writeIfChanged ( routesFile , renderDatabaseRoutes ( files ) ) ;
202206 }
203207 if ( ! routesPresent ) {
204- if ( fsSync . existsSync ( options . outFile ) ) {
208+ if ( schemaPresent || fsSync . existsSync ( options . outFile ) ) {
205209 await writeIfChanged ( options . outFile , NEUTRAL_DATABASE_OPERATION_TYPES ) ;
206210 }
207211 return ;
0 commit comments