import { ProtoFab } from './models/ProtoFab' ; import { ConfigTypes } from './constants' ; export interface PluginArgs { [ arg_name ] : any ; } export interface BuildConfig { [ plugin_name ] : PluginArgs ; } export type FabSettings = { [ var_name ] : string | boolean | string [ ] ; } ; export type DeployConfig = { 'cf-workers' ? : ConfigTypes . CFWorkers ; 'aws-lambda-edge' ? : ConfigTypes . AwsLambda ; 'aws-s3' ? : ConfigTypes . AwsS3 ; } ; export type DeployProviders = keyof DeployConfig ; export interface FabConfig { plugins : BuildConfig ; settings ? : { [ env_name ] : FabSettings ; } ; deploy ? : DeployConfig ; } export interface PluginMetadataContent { [ metadata_name ] : any ; } export interface PluginMetadata { [ plugin_name ] : PluginMetadataContent ; } export type LoadedPlugin = { plugin_name : string ; plugin_args : PluginArgs ; builder : FabBuildStep | undefined ; runtime : string | undefined ; } ; export type RuntimePlugin = { plugin_args : PluginArgs ; runtime : string ; } ; export type FabBuildStep < T extends PluginArgs = PluginArgs , U extends PluginMetadata = PluginMetadata > = ( args : T , proto_fab : ProtoFab < U > , config_path : string , skip_cache ? : boolean ) => Promise < void | RuntimePlugin [ ] > ; export type FabResponderMutableContext = { [ key ] : any ; } ; export type Cookies = { [ key ] : string ; } ; export type FabResponderArgs = { request : Request ; settings : FabSettings ; url : URL ; context : FabResponderMutableContext ; cookies : Cookies ; } ; export type FabRequestResponder = ( context : FabResponderArgs ) => Promise < undefined | Request | Response | Directive > ; export type MatchParams = { [ match_name ] : string ; } ; export type FabRequestResponderWithParams = ( contextWithParams : FabResponderArgs & { params : MatchParams ; } ) => ReturnType < FabRequestResponder > ; export type ResponseInterceptor = ( response : Response ) => Promise < Response > ; export type Directive = { interceptResponse ? : ResponseInterceptor ; replaceRequest ? : Request ; } ; export type FabFilesObject = { [ k ] : string ; } ; export type FabFiles = Map < string , Buffer > ; export type FabFileMetadata = { [ filename ] : { content_type : string ; content_length : number ; } ; } ; export type FabMetadata = { file_metadata : FabFileMetadata ; plugin_metadata : PluginMetadata ; } ; export type FabCacheValue = string | number | ArrayBuffer | ReadableStream ; export type FabCache = { set : ( key : string , value : FabCacheValue , ttl_seconds ? : number ) => Promise < void > ; setJSON : ( key : string , value : any , ttl_seconds ? : number ) => Promise < void > ; get : ( key : string ) => Promise < string | undefined > ; getJSON : ( key : string ) => Promise < any | undefined > ; getNumber : ( key : string ) => Promise < number | undefined > ; getArrayBuffer : ( key : string ) => Promise < ArrayBuffer | undefined > ; getStream : ( key : string ) => Promise < ReadableStream | undefined > ; } ; export type FABServerContext = { bundle_id : string ; cache ? : FabCache ; } ; export type ServerConstructor = ( filename : string , args : ServerArgs ) => ServerType ; export interface ServerType { serve ( runtimeType , watch , proxyWs ) : Promise < void > ; } export type ServerArgs = { port : string ; cert : string | undefined ; key : string | undefined ; env : string | undefined ; config : string ; } ; export enum SandboxType { v8isolate , nodeVm } export type FabSpecRender = ( request : Request , settings : FabSettings ) => Promise < Request | Response > ; export type FabSpecMetadata = { production_settings : FabSettings ; fab_version : string ; } ; export type FabSpecExports = { render : FabSpecRender ; metadata : FabSpecMetadata ; initialize : ( server_context : FABServerContext ) => void ; } ; export type FetchApi = ( url : string | Request , init ? : RequestInit ) => Promise < Response > ; export type FabServerDeployer < T extends ConfigTypes . Union > = ( fab_path : string , working_dir : string , config : T , env_overrides : FabSettings , assets_url : string ) => Promise < string | string [ ] > ; export type FabAssetsDeployer < T extends ConfigTypes . Union > = ( fab_path : string , working_dir : string , config : T ) => Promise < string > ; export type FabDeployer < T extends ConfigTypes . Union > = ( fab_path : string , working_dir : string , config : T , env_overrides : FabSettings ) => Promise < string | string [ ] > ; export type FabDeployerExports < T extends ConfigTypes . Union > = { deployServer ? : FabServerDeployer < T > ; deployAssets ? : FabAssetsDeployer < T > ; deployBoth ? : FabDeployer < T > ; } ; export type FabPackager < T extends ConfigTypes . Union > = ( fab_path : string , package_path : string , config : T , env_overrides : FabSettings , assets_url : string ) => Promise < void > ; export type FabPackagerExports < T extends ConfigTypes . Union > = { createPackage : FabPackager < T > ; } ; export interface JSON5ConfigI { data : FabConfig ; str_contents : string ; write ( file_path ) : Promise < void > ; } export type PackageFn = ( file_path : string , config : FabConfig , target : DeployProviders , output_path : string | undefined , assets_url : string , env : string | undefined ) => Promise < void > ; export type DeployFn = ( config : JSON5ConfigI , file_path : string , package_dir : string , server_host : DeployProviders | undefined , assets_host : DeployProviders | undefined , env : string | undefined , assets_only : boolean , assets_already_deployed_at : string | undefined , auto_install : boolean ) => Promise < string | string [ ] > ; export type BuildFn = ( config_path : string , config : FabConfig , skip_cache : boolean , skip_typecheck : boolean , minify : boolean ) => Promise < void > ; export type FabActionsExports = { Packager : { package : PackageFn ; } ; Deployer : { deploy : DeployFn ; } ; Builder : { build : BuildFn ; } ; } ; export type FabServerExports = { createServer : ServerConstructor ; } ;