UNPKG

5.23 kBTypeScriptView Raw
1/// <reference types="node" />
2import { ProtoFab } from './models/ProtoFab';
3import { ConfigTypes } from './constants';
4export interface PluginArgs {
5 [arg_name: string]: any;
6}
7export interface BuildConfig {
8 [plugin_name: string]: PluginArgs;
9}
10export declare type FabSettings = {
11 [var_name: string]: string | boolean;
12};
13export declare type DeployConfig = {
14 'cf-workers'?: ConfigTypes.CFWorkers;
15 'aws-lambda-edge'?: ConfigTypes.AwsLambda;
16 'aws-s3'?: ConfigTypes.AwsS3;
17};
18export declare type DeployProviders = keyof DeployConfig;
19export interface FabConfig {
20 plugins: BuildConfig;
21 settings?: {
22 [env_name: string]: FabSettings;
23 };
24 deploy?: DeployConfig;
25}
26export interface PluginMetadataContent<T extends PluginArgs = {}> {
27 args: T;
28 [metadata_name: string]: any;
29}
30export interface PluginMetadata<T extends PluginArgs = {}> {
31 [plugin_name: string]: PluginMetadataContent<T>;
32}
33export declare type FabBuildStep<T extends PluginArgs = PluginArgs, U extends PluginMetadata = PluginMetadata> = (args: T, proto_fab: ProtoFab<U>, config_path: string, skip_cache?: boolean) => Promise<void>;
34export declare type FabResponderMutableContext = {
35 [key: string]: any;
36};
37export declare type FabResponderArgs = {
38 request: Request;
39 settings: FabSettings;
40 url: URL;
41 context: FabResponderMutableContext;
42};
43export declare type FabRequestResponder = (context: FabResponderArgs) => Promise<undefined | Request | Response | Directive>;
44export declare type MatchParams = {
45 [match_name: string]: string;
46};
47export declare type FabRequestResponderWithParams = (contextWithParams: FabResponderArgs & {
48 params: MatchParams;
49}) => ReturnType<FabRequestResponder>;
50export declare type ResponseInterceptor = (response: Response) => Promise<Response>;
51export declare type Directive = {
52 interceptResponse?: ResponseInterceptor;
53 replaceRequest?: Request;
54};
55export declare type FabFilesObject = {
56 [k: string]: string;
57};
58export declare type FabFiles = Map<string, Buffer>;
59export declare type FabFileMetadata = {
60 [filename: string]: {
61 content_type: string;
62 content_length: number;
63 };
64};
65export declare type FabMetadata = {
66 file_metadata: FabFileMetadata;
67 plugin_metadata: PluginMetadata;
68};
69export declare type FABServerContext = {
70 bundle_id: string;
71};
72export declare type ServerConstructor = (filename: string, args: ServerArgs) => ServerType;
73export interface ServerType {
74 serve(runtimeType: SandboxType): Promise<void>;
75}
76export declare type ServerArgs = {
77 port: string;
78 cert: string | undefined;
79 key: string | undefined;
80 env: string | undefined;
81 config: string;
82};
83export declare enum SandboxType {
84 v8isolate = 0,
85 nodeVm = 1
86}
87export declare type FabSpecRender = (request: Request, settings: FabSettings) => Promise<Request | Response>;
88export declare type FabSpecMetadata = {
89 production_settings: FabSettings;
90 fab_version: string;
91};
92export declare type FabSpecExports = {
93 render: FabSpecRender;
94 metadata: FabSpecMetadata;
95 initialize: (server_context: FABServerContext) => void;
96};
97export declare type FetchApi = (url: string | Request, init?: RequestInit) => Promise<Response>;
98export declare type FabServerDeployer<T extends ConfigTypes.Union> = (fab_path: string, working_dir: string, config: T, env_overrides: FabSettings, assets_url: string) => Promise<string>;
99export declare type FabAssetsDeployer<T extends ConfigTypes.Union> = (fab_path: string, working_dir: string, config: T) => Promise<string>;
100export declare type FabDeployer<T extends ConfigTypes.Union> = (fab_path: string, working_dir: string, config: T, env_overrides: FabSettings) => Promise<string>;
101export declare type FabDeployerExports<T extends ConfigTypes.Union> = {
102 deployServer?: FabServerDeployer<T>;
103 deployAssets?: FabAssetsDeployer<T>;
104 deployBoth?: FabDeployer<T>;
105};
106export declare type FabPackager<T extends ConfigTypes.Union> = (fab_path: string, package_path: string, config: T, env_overrides: FabSettings, assets_url: string) => Promise<void>;
107export declare type FabPackagerExports<T extends ConfigTypes.Union> = {
108 createPackage: FabPackager<T>;
109};
110export interface JSON5ConfigI {
111 data: FabConfig;
112 str_contents: string;
113 write(file_path: string): Promise<void>;
114}
115export declare type PackageFn = (file_path: string, config: FabConfig, target: DeployProviders, output_path: string | undefined, assets_url: string, env: string | undefined) => Promise<void>;
116export declare 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>;
117export declare type BuildFn = (config_path: string, config: FabConfig, skip_cache: boolean) => Promise<void>;
118export declare type FabActionsExports = {
119 Packager: {
120 package: PackageFn;
121 };
122 Deployer: {
123 deploy: DeployFn;
124 };
125 Builder: {
126 build: BuildFn;
127 };
128};
129export declare type FabServerExports = {
130 createServer: ServerConstructor;
131};