@@ -32,8 +32,6 @@ import {
3232 currentPackageHomepage ,
3333} from "./utils/utils.js" ;
3434import { createHash } from "crypto" ;
35- import { promisify } from "util" ;
36- import zlib from "zlib" ;
3735import { recursivelyDelete } from "./fsUtils.js" ;
3836import { NodeDependency } from "./deployApi/modules.js" ;
3937import { ComponentDefinitionPath } from "./components/definition/directoryStructure.js" ;
@@ -45,8 +43,6 @@ import { debugIsolateBundlesSerially } from "../../bundler/debugBundle.js";
4543import { ensureWorkosEnvironmentProvisioned } from "./workos/workos.js" ;
4644export { productionProvisionHost , provisionHost } from "./utils/utils.js" ;
4745
48- const brotli = promisify ( zlib . brotliCompress ) ;
49-
5046/** Type representing auth configuration. */
5147export interface AuthInfo {
5248 // Provider-specific application identifier. Corresponds to the `aud` field in an OIDC token.
@@ -801,114 +797,6 @@ export type AppDefinitionSpecWithoutImpls = Omit<
801797 "schema" | "functions" | "auth"
802798> ;
803799
804- export function configJSON (
805- config : Config ,
806- adminKey : string ,
807- schemaId ?: string ,
808- pushMetrics ?: PushMetrics ,
809- bundledModuleInfos ?: BundledModuleInfo [ ] ,
810- ) {
811- // Override origin with the url
812- const projectConfig = {
813- projectSlug : config . projectConfig . project ,
814- teamSlug : config . projectConfig . team ,
815- functions : config . projectConfig . functions ,
816- authInfo : config . projectConfig . authInfo ,
817- } ;
818- return {
819- config : projectConfig ,
820- modules : config . modules ,
821- nodeDependencies : config . nodeDependencies ,
822- udfServerVersion : config . udfServerVersion ,
823- schemaId,
824- adminKey,
825- pushMetrics,
826- bundledModuleInfos,
827- nodeVersion : config . nodeVersion ,
828- } ;
829- }
830-
831- // Time in seconds of various spans of time during a push.
832- export type PushMetrics = {
833- typecheck : number ;
834- bundle : number ;
835- schemaPush : number ;
836- codePull : number ;
837- totalBeforePush : number ;
838- } ;
839-
840- /** Push configuration to the given remote origin. */
841- export async function pushConfig (
842- ctx : Context ,
843- config : Config ,
844- options : {
845- adminKey : string ;
846- url : string ;
847- deploymentName : string | null ;
848- pushMetrics ?: PushMetrics | undefined ;
849- schemaId ?: string | undefined ;
850- bundledModuleInfos ?: BundledModuleInfo [ ] ;
851- } ,
852- ) : Promise < void > {
853- const serializedConfig = configJSON (
854- config ,
855- options . adminKey ,
856- options . schemaId ,
857- options . pushMetrics ,
858- options . bundledModuleInfos ,
859- ) ;
860- const fetch = deploymentFetch ( ctx , {
861- deploymentUrl : options . url ,
862- adminKey : options . adminKey ,
863- } ) ;
864- try {
865- if ( config . nodeDependencies . length > 0 ) {
866- changeSpinner (
867- "Installing external packages and deploying source code..." ,
868- ) ;
869- } else {
870- changeSpinner ( "Analyzing and deploying source code..." ) ;
871- }
872- await fetch ( "/api/push_config" , {
873- body : await brotli ( JSON . stringify ( serializedConfig ) , {
874- params : {
875- [ zlib . constants . BROTLI_PARAM_MODE ] : zlib . constants . BROTLI_MODE_TEXT ,
876- [ zlib . constants . BROTLI_PARAM_QUALITY ] : 4 ,
877- } ,
878- } ) ,
879- method : "POST" ,
880- headers : {
881- "Content-Type" : "application/json" ,
882- "Content-Encoding" : "br" ,
883- } ,
884- } ) ;
885- } catch ( error : unknown ) {
886- await handlePushConfigError (
887- ctx ,
888- error ,
889- "Error: Unable to push deployment config to " + options . url ,
890- options . deploymentName ,
891- {
892- adminKey : options . adminKey ,
893- deploymentUrl : options . url ,
894- deploymentNotice : "" ,
895- } ,
896- ) ;
897- }
898- }
899-
900- type Files = { source : string ; filename : string } [ ] ;
901-
902- export type CodegenResponse =
903- | {
904- success : true ;
905- files : Files ;
906- }
907- | {
908- success : false ;
909- error : string ;
910- } ;
911-
912800function renderModule ( module : {
913801 path : string ;
914802 sourceMapSize : number ;
0 commit comments