UNPKG

3.47 kBJavaScriptView Raw
1/* @flow */
2'use strict'
3
4/* ::
5import type BmResponse from './lib/bm-response.js'
6import type BlinkMobileIdentity from '@blinkmobile/bm-identity'
7*/
8
9/* ::
10export type EnvironmentNetworkConfiguration = {
11 vpcSubnets: string[],
12 vpcSecurityGroups: string[]
13}
14
15export type BlinkMRC = {
16 server?: BlinkMRCServer
17}
18
19export type ServerCLIServiceConfig = {
20 bucket: string,
21 origin: string
22}
23
24export type BlinkMRCServer = {
25 project?: string,
26 region?: string,
27 awsProfile?: string,
28 cors?: CorsConfiguration | boolean,
29 routes?: Array<RouteConfiguration>,
30 timeout?: number,
31 service?: ServerCLIServiceConfig,
32 analytics?: {
33 key: string,
34 secret: string,
35 origin?: string
36 },
37 variables?: {
38 [id:string]: string | {
39 [id:string]: string
40 }
41 },
42 network?: {
43 [environment: string]: EnvironmentNetworkConfiguration
44 }
45}
46
47export type BmRequest = {
48 body: any,
49 headers: Headers,
50 method: string,
51 route: string,
52 url: {
53 host: string,
54 hostname: string,
55 params: { [id:string]: string },
56 pathname: string,
57 protocol: Protocol,
58 query: { [id:string]: string }
59 }
60}
61
62export type CLIFlags = {
63 provision: boolean,
64 bmServerVersion: string,
65 deploymentBucket?: string,
66 cwd: string,
67 env: string,
68 executionRole?: string,
69 filter?: string,
70 force: boolean,
71 out?: string,
72 port?: string,
73 region: string,
74 startTime?: string,
75 tail: boolean,
76 vpcSecurityGroups?: string,
77 vpcSubnets?: string,
78 analyticsCollectorToken?: string,
79 analyticsOrigin?: string
80}
81
82export type AnalyticsConfig = {
83 collectorToken: string | void,
84 origin: string | void
85}
86
87export type CLIOptions = {
88 blinkMobileIdentity: BlinkMobileIdentity
89}
90
91export type CorsConfiguration = {
92 credentials: boolean,
93 exposedHeaders: Array<string>,
94 headers: Array<string>,
95 maxAge: number,
96 origins: Array<string>
97}
98
99export type Handler = (BmRequest, BmResponse) => any
100
101export type HandlerConfiguration = {
102 handler: Handler | void,
103 params: {
104 [id:string]: string
105 }
106}
107
108export type Headers = {
109 [id:string]: string | boolean
110}
111
112export type LambdaEvent = {
113 body: any,
114 headers: Headers,
115 httpMethod: string,
116 path: string,
117 pathParameters: { [id:string]: string },
118 queryStringParameters: { [id:string]: string },
119 resource: string
120}
121
122export type MapObject = { [id:string]: any }
123
124export type ProjectConfig = {
125 load: () => Promise<BlinkMRC>,
126 update: ((BlinkMRC) => BlinkMRC) => Promise<BlinkMRC>
127}
128
129export type Protocol = 'http:' | 'https:'
130
131export type RouteConfiguration = {
132 route: string,
133 module: string,
134 timeout: number,
135 params?: {[id:string]: string}
136}
137
138export type APIEnvironmentRoute = {
139 module: string,
140 route: string
141}
142
143export type APIEnvironment = {
144 apiId: string,
145 environment: string,
146 lastDeployment: string,
147 routes: APIEnvironmentRoute[],
148 cors: Object | boolean,
149 vpcSecurityGroupIds?: string,
150 vpcSubnetIds?: string,
151 bmServerVersion?: string,
152 status?: 'Warning' | 'Error' | 'Okay' | 'Unknown'
153}
154
155export type API = {
156 id: string,
157 createdAt: string,
158 vpcSecurityGroupIds?: string,
159 vpcSubnetIds?: string,
160 links: {
161 awsAccounts: string,
162 organisations: string
163 },
164 environments?: APIEnvironment[],
165 whiteListedEmails?: string[]
166}
167
168export type AWSAccount = {
169 id: string,
170 name: string,
171 accountNumber: string,
172 tenancy: string,
173 createdAt: string,
174 apiHosting: {
175 vpcSecurityGroupIds: string,
176 vpcSubnetIds: string
177 },
178 isDefault: boolean
179}
180*/