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